diff --git a/rack/config.scad b/rack/config.scad index 2b54809..40a4c86 100644 --- a/rack/config.scad +++ b/rack/config.scad @@ -8,13 +8,16 @@ */ include <./profiles.scad> -profile = "default"; +profileName = "micro"; +profile = getProfile(profileName); echo("Profile:", profile); +function getConfig(name) = getConfigValue(profile, name); + // Maximum width for rackmount units. Change this according your max expected enclosure width. // Changing this will directly affect the required build volume. -maxUnitWidth = getConfigValue(profile, "maxUnitWidth"); +maxUnitWidth = getConfig("maxUnitWidth"); // Maximum (recommended) unit depth. There technically isn't a max unit depth because there's no physical bound on // how far a rack unit can extrude back. This parameter basically controls the distance between the front of the front diff --git a/rack/profiles.scad b/rack/profiles.scad index e2c8fe4..600ac60 100644 --- a/rack/profiles.scad +++ b/rack/profiles.scad @@ -39,6 +39,12 @@ function _getConfigValueRaw(profile, varName) = profile[search([varName], profil function _getProfileRaw(profileName) = _profileConfigs[search([profileName], _profileConfigs)[0]][1]; function _getConfigValueOrThrowError(val) = val == undef? assert(false, "blah") 0: val; +function _getConfigValueOrDefault(val, default) = val == undef? default: val; + +function getConfigValue(profile, varName) = + _getConfigValueOrDefault( + _getConfigValueRaw(profile, varName), + _getConfigValueOrThrowError(_getConfigValueRaw(getProfile("default"), varName)) + ); -function getConfigValue(profile, varName) = _getConfigValueOrThrowError(_getConfigValueRaw(profile, varName)); function getProfile(profileName) = _getConfigValueOrThrowError(_getProfileRaw(profileName));