int main(void) { configure_teensy(); configure_LEDs(); configure_usb(); int16_t lastcmd = '\0', cmd = '\0'; while (1) { wait_for_usb_connection(); while (1) { cmd = usb_serial_getchar(); if(is_valid_control_key(cmd)) { if(cmd == '+') adjust_speed(-10); // Speed up == less time. else if(cmd == '-') adjust_speed(10); } if( is_valid_cmd(cmd) ) { lastcmd = cmd; } if(lastcmd == 'k') knight_rider(); else if(lastcmd == 's') step(); else if(lastcmd == 'f') follow(); else if(lastcmd == '0') nop(); else demo(); } } }
void Led24::update(){ int now = millis(); if (now - _time > _currentMode.pulseDelay){ _time = now; switch (_currentMode.name){ case MODE_STEP_LEFT_TO_RIGHT : slow_step_left_to_right(); break; case MODE_PULSE_ALL : quick_pulse(); break; case MODE_KNIGHT_RIDER : knight_rider(); break; case MODE_TOGGLE_EVEN_ODD : every_other_one(); break; case MODE_OUT_FROM_CENTER : out_from_center(); break; } if (_autoMode == true){ _sequence_count++; if (_sequence_count == _currentMode.repeatCount){ _index = _sequence_count = 0; if (++_modeIndex == NUM_ANIMATIONS) _modeIndex = 0; _currentMode = ANIMATIONS[_modeIndex]; // tell the outside world the animation mode has changed // String m = "MODE"; m += _modeIndex+1; Serial.println(m); } } } }