From 83a77bc54449e9ed609049271c0cda4eee0cd434 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 22 Nov 2016 09:31:47 +0100 Subject: [PATCH 1/3] BootAnimation shall not be a LED effect Having the boot animation as a LED effect, making it function as an "off" state, while a novel idea, is confusing. For this reason, make it just a simple function we can call from the Sketch's `setup()` method. Signed-off-by: Gergely Nagy --- examples/KeyboardioFirmware/KeyboardioFirmware.ino | 4 ++-- src/{LED-BootAnimation.cpp => BootAnimation.cpp} | 9 +++------ src/BootAnimation.h | 3 +++ src/LED-BootAnimation.h | 10 ---------- 4 files changed, 8 insertions(+), 18 deletions(-) rename src/{LED-BootAnimation.cpp => BootAnimation.cpp} (79%) create mode 100644 src/BootAnimation.h delete mode 100644 src/LED-BootAnimation.h diff --git a/examples/KeyboardioFirmware/KeyboardioFirmware.ino b/examples/KeyboardioFirmware/KeyboardioFirmware.ino index 9f342368..a138e08d 100644 --- a/examples/KeyboardioFirmware/KeyboardioFirmware.ino +++ b/examples/KeyboardioFirmware/KeyboardioFirmware.ino @@ -7,7 +7,7 @@ #include "KeyboardioFirmware.h" #include "generated/keymaps.h" -#include "LED-BootAnimation.h" +#include "BootAnimation.h" #include "LED-SolidColor.h" #include "LED-Numlock.h" #include "LED-BreatheEffect.h" @@ -23,7 +23,6 @@ uint8_t temporary_keymap = 0; const Key keymaps[][ROWS][COLS] PROGMEM = { KEYMAP_LIST }; -static LEDBootAnimation bootAnimation; static LEDSolidColor solidRed (100, 0, 0); static LEDSolidColor solidOrange (100, 30, 0); static LEDSolidColor solidYellow (90, 70, 0); @@ -41,6 +40,7 @@ static LEDNumlock numLockEffect (NUMPAD_KEYMAP); void setup() { Keyboardio.setup(KEYMAPS); + bootAnimation(); } diff --git a/src/LED-BootAnimation.cpp b/src/BootAnimation.cpp similarity index 79% rename from src/LED-BootAnimation.cpp rename to src/BootAnimation.cpp index 728c4eb1..3c865e55 100644 --- a/src/LED-BootAnimation.cpp +++ b/src/BootAnimation.cpp @@ -1,4 +1,5 @@ -#include "LED-BootAnimation.h" +#include "BootAnimation.h" +#include "KeyboardConfig.h" static void type_letter(uint8_t letter) { @@ -10,12 +11,8 @@ type_letter(uint8_t letter) { delay(10); } -LEDBootAnimation::LEDBootAnimation (void) { - LEDControl.mode_add (this); -} - void -LEDBootAnimation::setup (void) { +bootAnimation (void) { LEDControl.set_all_leds_to(0, 0, 0); type_letter(LED_K); diff --git a/src/BootAnimation.h b/src/BootAnimation.h new file mode 100644 index 00000000..f8b49cac --- /dev/null +++ b/src/BootAnimation.h @@ -0,0 +1,3 @@ +#pragma once + +void bootAnimation(void); diff --git a/src/LED-BootAnimation.h b/src/LED-BootAnimation.h deleted file mode 100644 index dcd4f616..00000000 --- a/src/LED-BootAnimation.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "LEDControl.h" - -class LEDBootAnimation : LEDMode { - public: - LEDBootAnimation (void); - - virtual void setup (void) final; -}; From e077ff68bc7cdbb908ea2c974daae6830cabaa72 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 22 Nov 2016 09:35:03 +0100 Subject: [PATCH 2/3] LED-Off: A new "effect" that simply turns LEDs off With the BootAnimation not functioning as a LED effect anymore, ship a dedicated off effect. Signed-off-by: Gergely Nagy --- examples/KeyboardioFirmware/KeyboardioFirmware.ino | 2 ++ src/LED-Off.h | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/LED-Off.h diff --git a/examples/KeyboardioFirmware/KeyboardioFirmware.ino b/examples/KeyboardioFirmware/KeyboardioFirmware.ino index a138e08d..9c0247d0 100644 --- a/examples/KeyboardioFirmware/KeyboardioFirmware.ino +++ b/examples/KeyboardioFirmware/KeyboardioFirmware.ino @@ -8,6 +8,7 @@ #include "generated/keymaps.h" #include "BootAnimation.h" +#include "LED-Off.h" #include "LED-SolidColor.h" #include "LED-Numlock.h" #include "LED-BreatheEffect.h" @@ -23,6 +24,7 @@ uint8_t temporary_keymap = 0; const Key keymaps[][ROWS][COLS] PROGMEM = { KEYMAP_LIST }; +static LEDOff LEDSOff; static LEDSolidColor solidRed (100, 0, 0); static LEDSolidColor solidOrange (100, 30, 0); static LEDSolidColor solidYellow (90, 70, 0); diff --git a/src/LED-Off.h b/src/LED-Off.h new file mode 100644 index 00000000..daae9150 --- /dev/null +++ b/src/LED-Off.h @@ -0,0 +1,8 @@ +#pragma once + +#include "LEDControl.h" + +class LEDOff : LEDMode { + public: + LEDOff (void) { LEDControl.mode_add (this); }; +}; From eb3ad072b57976864d6b99edec2ef6dbd05f6622 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 23 Nov 2016 10:04:26 +0100 Subject: [PATCH 3/3] BootAnimation: Only display the animation once Save the seen state in EEPROM, so that the boot animation is displayed only on first boot, and not every time the keyboard boots, or is plugged in. This way, we still have a nice welcome animation on first boot, but it won't become an annoying delay every time the keyboard boots. Signed-off-by: Gergely Nagy --- src/BootAnimation.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/BootAnimation.cpp b/src/BootAnimation.cpp index 3c865e55..d5f973b7 100644 --- a/src/BootAnimation.cpp +++ b/src/BootAnimation.cpp @@ -1,5 +1,8 @@ #include "BootAnimation.h" #include "KeyboardConfig.h" +#include "EEPROM.h" + +#define EEPROM_BOOT_ANIMATION_LOCATION 1 static void type_letter(uint8_t letter) { @@ -13,6 +16,9 @@ type_letter(uint8_t letter) { void bootAnimation (void) { + if (EEPROM.read (EEPROM_BOOT_ANIMATION_LOCATION)) + return; + LEDControl.set_all_leds_to(0, 0, 0); type_letter(LED_K); @@ -29,4 +35,6 @@ bootAnimation (void) { type_letter(LED_0); type_letter(LED_PERIOD); type_letter(LED_9); + + EEPROM.update (EEPROM_BOOT_ANIMATION_LOCATION, 1); }