add button stuff and timer stuff
This commit is contained in:
49
src/eggTimer.c
Normal file
49
src/eggTimer.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* eggTimer.c
|
||||
*
|
||||
* Created on: 08.09.2016
|
||||
* Author: dehottgw
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "eggTimer.h"
|
||||
#include "displayMuxer.h"
|
||||
#include "button.h"
|
||||
|
||||
|
||||
const uint32_t EGG_TIMER_CYCLE = 1000;
|
||||
|
||||
const uint8_t COOKING_TIME = 120;
|
||||
uint8_t restCookingTime;
|
||||
bool timerRunning;
|
||||
bool timerStarted;
|
||||
|
||||
void eggTimerInit(void *handleArg) {
|
||||
restCookingTime = COOKING_TIME;
|
||||
timerRunning = false;
|
||||
timerStarted = false;
|
||||
buttonRegister(eggTimerStart, NULL, BUTTON_START_TIMER);
|
||||
}
|
||||
|
||||
void eggTimerExec(void *handleArg) {
|
||||
if (timerRunning) {
|
||||
restCookingTime--;
|
||||
displayMuxerSetValue(restCookingTime, true, TIMER_MUX);
|
||||
if (restCookingTime == 0) {
|
||||
// activate alarm
|
||||
timerRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void eggTimerStart(void *handleArg) {
|
||||
if (! timerStarted) {
|
||||
timerRunning = true;
|
||||
timerStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user