CycleRunner.cpp 466 B

1234567891011121314151617181920212223
  1. #include "include/CycleRunner.h"
  2. CycleRunner::CycleRunner(Trafficlight *sc_handle){
  3. this->handle = sc_handle;
  4. }
  5. /**
  6. * The cycleRunner uses timer0 for his cycle-time-calculation (every second)
  7. */
  8. void CycleRunner::start(void){
  9. TCCR0B |= (1<<CS02) | (1<<CS00); // prescaler 1024
  10. TCNT0 = 0; // Startvalue ->1s to overflow
  11. TIMSK0 |= (1<<TOIE0);
  12. }
  13. void CycleRunner::stop(void){
  14. TCCR0B = 0;
  15. }
  16. void CycleRunner::runCycle(void){
  17. trafficlight_runCycle(handle);
  18. }