bool Move() //set movement speed. { //8=normal (will set default in Tuning.h) int actspeed= ILeftSpeed * MAX_DUTY / 16; WritePWM(LeftDrive,PERIOD,actspeed); actspeed=IRightSpeed * MAX_DUTY / 16; }
void Led::StopStrobe() { isStrobing = false; strobe_times_remain = 0; isOn = strobe_isOn_before; WritePWM(); }
void Led::Loop() { CalculateFade(); CalculateStrobe(); CalculateFadeOnOff(); WritePWM(); }
void Led::SetBrightness(uint8_t brightness) { if (IsFading()) StopFade(); brightness = constrain(brightness, 0, 255); this->brightness = brightness; WritePWM(); }
void Led::TurnOff() { fadeOnOff_current_brightness = 0; fadeOnOff_time_remain = 0; if (IsStrobing()) { strobe_isOn_before = false; StopStrobe(); } else { isOn = false; WritePWM(); } }
////////////////////////////////////////////////////////////////////////////////// /// name: main /// params: none /// return: int /// desc: calls the initialization of variables/hardware, and contains /// the main loop with all active functionality int main(void) { // initialize ports for buttons and LED, PWM receiving, and PWM writing intialization(); while ( ! NULL ) { // read in button value (push on, push off) readbutton(); // read incoming PWM signal for arm extension ReadPWM(PWM_IN_1); // read incoming PWM signal for arm extension // ReadPWM(PWM_IN_2); // set the motor state based on PWM frequency InterpretPWM(); // write to the motor depending on current state WritePWM(); } }