add button stuff and timer stuff

This commit is contained in:
Wolfgang Hottgenroth
2016-09-08 14:05:57 +02:00
parent 7c854e7353
commit 8e08c2045e
13 changed files with 238 additions and 26 deletions

49
src/eggTimer.c Normal file
View 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;
}
}