i have these two objects declared globally, at the beginning of the setup routine the configuration for the device is loaded, is there any way i can disable to objects? so if i didnt want those hardware resources to be consumed could how would i globally shut this off. or is there a way to load my configuration globally and then if it is disabled just never initialize it ?
like
if (FAN0_ENABLED) {
FanController fan0(GPIO_FAN_TACH0 , SENSOR_THRESHOLD, GPIO_FAN_PWM0);
}
if (FAN1_ENABLED) {
FanController fan1(GPIO_FAN_TACH1, SENSOR_THRESHOLD, GPIO_FAN_PWM1);
}
or would it matter if i declared these globally and then just never called begin()?
in this case if i exit the void setup does the object still exist? so i can call on it by the name i set using new, until the system is restarted?
nah because then they would be excluded form the program entirely. i may have not been entirely clear, this code runs on a sub processor and that processor receives a json config file for the hardware that is attached and then reconfigures the inputs and outputs to match the hard ware that is attached based on user input, therefore some people may have a button attached where the fan is declared and that would function differently than the button.
the reconfiguration only happens once in the cycle at the time of system start up. so if i can create the object based on the config and then use it until the object is shut off, then that will suffice. this hardware will not be power cycled that often in its use case.
i thought about this but the way i understand this if you don't define it as declared at compile time then the program doesn't include it at all i need the ability encoded in the firmware, but based on the users use case they may not want it like that or even on that pin. i am trying to open options to the user without having 900 firmware versions or without creating an external tool that will create random firmware based on use case.