I have written a function on my Arduino Nano board and I want to keep track on it's output.
Serial.println(BootSequence());
BootSequence()
is a function that gives back false until it has been completed. When I watch the Serial Monitor I get 0 most of the time but every I think 50 prints I get a charakter like "m", "n" etc. the appear in alphabetical order, after "z" I get "{" and so on, this is a "normal" behavior?
yes normal printing executes without flaws.
I cut all the return false statements in the switch case so that the function Bootsequence only consists how this code and this seems to work.
bool BootSequence(bool reset = false) {
static BootState currentState = BootState::PHASE_0;
if (reset) {
cycSwitchLedsOn(CYCLE_PHASE_0, NUM_LEDS_CYCLOTRON, CYCL_BRIGHT_MAX_0, true);
cycIncreaseBrightness(CYCLE_PHASE_1, NUM_LEDS_CYCLOTRON, CYCL_BRIGHT_MAX_0, CYCL_BRIGHT_MAX, true);
cycDecreaseBrightness(CYCLE_PHASE_2, NUM_LEDS_CYCLOTRON, CYCL_BRIGHT_MAX, true);
for (int i = 0; i < NUM_LEDS_CYCLOTRON; i++) {
cyclotron_leds[i] = CRGB::Black; // Turn off all LEDs
}
FastLedNeedsUpdate = true;
currentState = BootState::PHASE_0;
BootSequenceHelper = false;
}
switch (currentState) {
case BootState::PHASE_0:
if (cycSwitchLedsOn(CYCLE_PHASE_0, NUM_LEDS_CYCLOTRON, CYCL_BRIGHT_MAX_0)) {
currentState = BootState::PHASE_1;
}
break;
case BootState::PHASE_1:
if (cycIncreaseBrightness(CYCLE_PHASE_1, NUM_LEDS_CYCLOTRON, CYCL_BRIGHT_MAX_0, CYCL_BRIGHT_MAX)) {
currentState = BootState::PHASE_2;
}
break;
case BootState::PHASE_2:
if (cycDecreaseBrightness(CYCLE_PHASE_2, NUM_LEDS_CYCLOTRON, CYCL_BRIGHT_MAX)) {
currentState = BootState::FINISHED;
}
break;
case BootState::FINISHED:
return true;
}
return false;
}