59 lines
844 B
C
59 lines
844 B
C
#include <stdint.h>
|
|
#include <util/delay.h>
|
|
#include <ssd1306xled.h>
|
|
#include "power.h"
|
|
#include "buttons.h"
|
|
#include "screen/counter.h"
|
|
|
|
|
|
// Forward declarations
|
|
uint8_t handleGlobalInput();
|
|
void handleCurrentScreen();
|
|
|
|
|
|
|
|
int main()
|
|
{
|
|
// Delay is required on power-on for the SSD1306 to initialize,
|
|
_delay_ms(40);
|
|
ssd1306_init();
|
|
|
|
buttons_init();
|
|
|
|
while (1)
|
|
{
|
|
checkPower();
|
|
if (!handleGlobalInput())
|
|
{
|
|
if (powerState == On)
|
|
{
|
|
handleCurrentScreen();
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
uint8_t handleGlobalInput()
|
|
{
|
|
if (button_is_released_short(&buttonOption))
|
|
{
|
|
// Toggle power
|
|
if (powerState == On)
|
|
setPowerState(ManualOff);
|
|
else if (powerState == ManualOff)
|
|
setPowerState(On);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
void handleCurrentScreen()
|
|
{
|
|
handleCounterScreen();
|
|
} |