ttt2/my_src/timer.c
Wolfgang Hottgenroth 7f54b22e6b buzzer is working
2017-06-12 17:50:08 +02:00

55 lines
892 B
C

/*
* timer.c
*
* Created on: May 31, 2017
* Author: wn
*/
#include "hmi.h"
#include "timer.h"
#include "alarm.h"
#include <PontCoopScheduler.h>
extern tDisplay display;
void startTimer() {
display.timerState = STARTED;
}
void stopTimer() {
display.timerState = IDLE;
}
void secondTick(void *handle) {
tDisplay *lDisplay = (tDisplay*) handle;
switch (lDisplay->timerState) {
case STARTED:
lDisplay->currentTime = lDisplay->targetTime;
lDisplay->overrunTime = 0;
lDisplay->timerState = RUNNING;
break;
case RUNNING:
lDisplay->currentTime -= 1;
if (lDisplay->currentTime == 0) {
enableAlarm(TIME_ALARM);
lDisplay->timerState = OVERRUN;
}
break;
case OVERRUN:
lDisplay->overrunTime += 1;
break;
case IDLE:
;
break;
default:
;
}
}
void timerInit() {
schAdd(secondTick, &display, 0, 1000);
}