Skip to content

Commit

Permalink
Prevent EEPROM corruption by holding UP & DOWN on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
LolloDev5123 committed Jan 14, 2024
1 parent e3ce284 commit 1b57bd5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ void Main(void) {
#endif

BootMode = BOOT_GetMode();

// wait for user to release all butts before moving on
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) ||
KEYBOARD_Poll() != KEY_INVALID ||
BootMode != BOOT_MODE_NORMAL)
{ // keys are pressed
UI_DisplayReleaseKeys();
BACKLIGHT_TurnOn();
i = 0;
while (i < 50) // 500ms
{
i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0;
SYSTEM_DelayMs(10);
}
gKeyReading0 = KEY_INVALID;
gKeyReading1 = KEY_INVALID;
gDebounceCounter = 0;
}

if (gEeprom.POWER_ON_PASSWORD < 1000000) {
bIsInLockScreen = true;
UI_DisplayLock();
Expand Down
12 changes: 12 additions & 0 deletions ui/welcome.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
#include "../version.h"
#include <string.h>

void UI_DisplayReleaseKeys(void)
{
memset(gStatusLine, 0, sizeof(gStatusLine));
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));

UI_PrintString("RELEASE", 0, 127, 1, 10, true);
UI_PrintString("ALL KEYS", 0, 127, 3, 10, true);

ST7565_BlitStatusLine(); // blank status line
ST7565_BlitFullScreen();
}

void UI_DisplayWelcome(void) {
memset(gStatusLine, 0, sizeof(gStatusLine));
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
Expand Down
1 change: 1 addition & 0 deletions ui/welcome.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void UI_DisplayInfo(void);
void UI_DisplayVersion(void);
void UI_DisplayVersionFM(void);
void UI_Matoz(void);
void UI_DisplayReleaseKeys(void);

#endif

0 comments on commit 1b57bd5

Please sign in to comment.