This commit is contained in:
2025-11-08 22:35:54 +01:00
parent 55426b5f2d
commit f300ce2386

13
main.c
View File

@ -38,7 +38,7 @@ typedef enum _Mode
/** Global flags */ /** Global flags */
volatile bool bLedEnabled = true; volatile bool bLedEnabled = true;
volatile bool bBtnLongPressed = false; volatile bool bBtnPressed = false;
volatile eMode eModeCurrent = ANIMATION_BLINK; volatile eMode eModeCurrent = ANIMATION_BLINK;
// Forward declarations // Forward declarations
@ -65,19 +65,18 @@ int main(void)
VPORTA.DIR &= ~BUTTON_PIN_MASK; // Input VPORTA.DIR &= ~BUTTON_PIN_MASK; // Input
PORTA.PIN0CTRL = PORT_PULLUPEN_bm; // Pull-up enabled PORTA.PIN0CTRL = PORT_PULLUPEN_bm; // Pull-up enabled
// Ensure all LEDs off at startup leds_off(); // Ensure all LEDs off at startup
leds_off();
battery_level_indicator(); // TODO: Implement battery_level_indicator(); // TODO: Implement
bool bLedEnabledOld = bLedEnabled; bool bLedEnabledOld = bLedEnabled;
eModeCurrent = ANIMATION_BLINK; eModeCurrent = ANIMATION_BLINK; // Set the mode to start with
while (true) while (true)
{ {
bBtnLongPressed = handleSwitch(); // Check switch state bBtnPressed = handleSwitch(); // Check switch state
// Light LEDs while button is pressed // Light LEDs while button is pressed
if (bBtnLongPressed) if (bBtnPressed)
{ {
leds_on(); leds_on();
} }
@ -115,7 +114,7 @@ int main(void)
} }
else else
{ {
if (bLedEnabled && !bBtnLongPressed) if (bLedEnabled && !bBtnPressed)
{ {
switch (eModeCurrent) switch (eModeCurrent)
{ {