summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile36
-rw-r--r--Model01-Firmware.ino41
2 files changed, 70 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 585ccba..ac11fb3 100644
--- a/Makefile
+++ b/Makefile
@@ -12,12 +12,40 @@ PACKAGE_DIR ?= $(HOME)/.arduino15
endif
-INSTALLED_ENV=$(shell ls -dt $(PACKAGE_DIR)/packages/keyboardio/hardware/avr/* 2>/dev/null |head -n 1)
+ARDUINO_INSTALLED_ENV=$(shell ls -dt $(PACKAGE_DIR)/packages/keyboardio/hardware/avr/* 2>/dev/null |head -n 1)
+MANUALLY_INSTALLED_ENV=$(shell ls -dt $(SKETCHBOOK_DIR)/hardware/keyboardio/avr 2>/dev/null |head -n 1)
+
+
+
+ifneq ("$(wildcard $(ARDUINO_INSTALLED_ENV)/boards.txt)","")
+
+ifneq ("$(wildcard $(MANUALLY_INSTALLED_ENV)/boards.txt)","")
+
+$(info ***************************************************************************)
+$(info It appears that you have installed two copies of Kaleidoscope. One copy was)
+$(info installed using Arduino's "Board Manager", while the other was installed by)
+$(info hand, probably using "git".)
+$(info )
+$(info This will likely cause some trouble as you try to build keyboard firmware)
+$(info using Kaleidoscope. You may want to remove either: )
+$(info )
+$(info $(PACKAGE_DIR)/packages/keyboardio/ which was installed using Arduino)
+$(info )
+$(info or)
+$(info )
+$(info $(SKETCHBOOK_DIR)/hardware/keyboardio/ which was installed by hand.)
+$(info )
+$(info ***************************************************************************)
+$(info )
+
+endif
-ifneq ("$(wildcard $(INSTALLED_ENV)/boards.txt)","")
-BOARD_HARDWARE_PATH = $(INSTALLED_ENV)
+BOARD_HARDWARE_PATH = $(ARDUINO_INSTALLED_ENV)
KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= build-tools/makefiles/
-KALEIDOSCOPE_BUILDER_DIR ?= $(INSTALLED_ENV)/libraries/Kaleidoscope/bin/
+KALEIDOSCOPE_BUILDER_DIR ?= $(ARDUINO_INSTALLED_ENV)/libraries/Kaleidoscope/bin/
+
+
+
endif
diff --git a/Model01-Firmware.ino b/Model01-Firmware.ino
index e00e535..1549174 100644
--- a/Model01-Firmware.ino
+++ b/Model01-Firmware.ino
@@ -56,6 +56,9 @@
// Support for Keyboardio's internal keyboard testing mode
#include "Kaleidoscope-Model01-TestMode.h"
+// Support for host power management (suspend & wakeup)
+#include "Kaleidoscope-HostPowerManagement.h"
+
/** This 'enum' is a list of all the macros used by the Model 01's firmware
* The names aren't particularly important. What is important is that each
@@ -153,7 +156,7 @@ KEYMAPS(
M(MACRO_VERSION_INFO), ___, Key_Keypad7, Key_Keypad8, Key_Keypad9, Key_KeypadSubtract, ___,
___, ___, Key_Keypad4, Key_Keypad5, Key_Keypad6, Key_KeypadAdd, ___,
- ___, Key_Keypad1, Key_Keypad2, Key_Keypad3, Key_Equals, Key_Quote,
+ ___, Key_Keypad1, Key_Keypad2, Key_Keypad3, Key_Equals, ___,
___, ___, Key_Keypad0, Key_KeypadDot, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter,
___, ___, ___, ___,
___),
@@ -249,7 +252,32 @@ static kaleidoscope::LEDSolidColor solidBlue(0, 70, 130);
static kaleidoscope::LEDSolidColor solidIndigo(0, 0, 170);
static kaleidoscope::LEDSolidColor solidViolet(130, 0, 120);
+/** toggleLedsOnSuspendResume toggles the LEDs off when the host goes to sleep,
+ * and turns them back on when it wakes up.
+ */
+void toggleLedsOnSuspendResume(kaleidoscope::HostPowerManagement::Event event) {
+ switch (event) {
+ case kaleidoscope::HostPowerManagement::Suspend:
+ LEDControl.paused = true;
+ LEDControl.set_all_leds_to({0, 0, 0});
+ LEDControl.syncLeds();
+ break;
+ case kaleidoscope::HostPowerManagement::Resume:
+ LEDControl.paused = false;
+ LEDControl.refreshAll();
+ break;
+ case kaleidoscope::HostPowerManagement::Sleep:
+ break;
+ }
+}
+/** hostPowerManagementEventHandler dispatches power management events (suspend,
+ * resume, and sleep) to other functions that perform action based on these
+ * events.
+ */
+void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event event) {
+ toggleLedsOnSuspendResume(event);
+}
/** The 'setup' function is one of the two standard Arduino sketch functions.
* It's called when your keyboard first powers up. This is where you set up
@@ -309,7 +337,11 @@ void setup() {
&Macros,
// The MouseKeys plugin lets you add keys to your keymap which move the mouse.
- &MouseKeys
+ &MouseKeys,
+
+ // The HostPowerManagement plugin enables waking up the host from suspend,
+ // and allows us to turn LEDs off when it goes to sleep.
+ &HostPowerManagement
);
// While we hope to improve this in the future, the NumPad plugin
@@ -317,7 +349,7 @@ void setup() {
NumPad.numPadLayer = NUMPAD;
// We configure the AlphaSquare effect to use RED letters
- AlphaSquare.color = { 255, 0, 0 };
+ AlphaSquare.color = CRGB(255, 0, 0);
// We set the brightness of the rainbow effects to 150 (on a scale of 0-255)
// This draws more than 500mA, but looks much nicer than a dimmer effect
@@ -329,6 +361,9 @@ void setup() {
// see https://github.com/keyboardio/Kaleidoscope-LED-Stalker
StalkerEffect.variant = STALKER(BlazingTrail);
+ // We want the keyboard to be able to wake the host up from suspend.
+ HostPowerManagement.enableWakeup();
+
// We want to make sure that the firmware starts with LED effects off
// This avoids over-taxing devices that don't have a lot of power to share
// with USB devices