From a21aea6f225bbc3dcd7a6b295bf0d9e518e02e8f Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Tue, 6 Jun 2023 16:27:48 +0200 Subject: [PATCH] Moved lib to submodule --- firmware/lib/teensy-libc | 1 + firmware/src/IndicatorLed.cpp | 101 --------------------------------- firmware/src/IndicatorLed.h | 55 ------------------ firmware/src/cmdr_keyboard.cpp | 4 +- 4 files changed, 3 insertions(+), 158 deletions(-) create mode 160000 firmware/lib/teensy-libc delete mode 100644 firmware/src/IndicatorLed.cpp delete mode 100644 firmware/src/IndicatorLed.h diff --git a/firmware/lib/teensy-libc b/firmware/lib/teensy-libc new file mode 160000 index 0000000..6a2b179 --- /dev/null +++ b/firmware/lib/teensy-libc @@ -0,0 +1 @@ +Subproject commit 6a2b179d8f624d69b41a5d30df7b46080a1deec6 diff --git a/firmware/src/IndicatorLed.cpp b/firmware/src/IndicatorLed.cpp deleted file mode 100644 index 05a40c0..0000000 --- a/firmware/src/IndicatorLed.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * ======================================================================================================= - * ------------------------------------------------------------------------------------------------------- - * ---####################-----###########-------###########-----############--############-############-- - * --######################---#############-----#############---- -- - --- - * --###### ##---##### ###-----### #####---------##-------#######------#------------- - * -- -------------- --- ----- --- ----- ---------##-------#------------#------------- - * --#####--------------------#####------####-####------#####---------##-------###########--############-- - * -- -------------------- ------ ------ --------- ------- -- -- - * --#####--------------------#####--------#####--------#####--------------------------------------------- - * -- -------------------- -------- -------- --------------------------------------------- - * --######--------------##---#####---------------------#####---------------- IndicatorLed --------------- - * --##################### ---#####---------------------#####--------------------------------------------- - * ---################### ----#####---------------------#####--------------------------------------------- - * --- ----- --------------------- --------------------------------------------- - * ------------------------------------------------------------------------------------------------------- - * ======================================================================================================= - * - * Copyright 2023 Christoffer Martinsson - * - * CMtec ERLS can be redistributed and/or modified under the terms of the GNU General - * Public License (Version 2), as published by the Free Software Foundation. - * A copy of the license can be found online at www.gnu.o urg/licenses. - * - * CMtec ERLS is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - */ - -#include "IndicatorLed.h" - -/** - * @brief Construct a new Indicator Led:: Indicator Led object - * - * @param pin Pin number for indicator LED - */ -IndicatorLed::IndicatorLed(int pin) -{ - _pin = pin; -} - -/** - * @brief Initialize indicator LED - */ -void IndicatorLed::begin() -{ - pinMode(_pin, OUTPUT); - digitalWrite(_pin, LOW); -} - -/** - * @brief Turn on indicator LED - */ -void IndicatorLed::on() -{ - led_mode = LED_ON; -} - -/** - * @brief Turn off indicator LED - */ -void IndicatorLed::off() -{ - led_mode = LED_OFF; -} - -/** - * @brief Blink indicator LED - */ -void IndicatorLed::blink() -{ - led_mode = LED_BLINK; -} - -/** - * @brief Update indicator LED. Call this function in the main loop with a 200-500 ms interval. - */ -void IndicatorLed::update() -{ - - if (led_mode == LED_BLINK && current_state == LED_OFF) - { - digitalWrite(_pin, HIGH); - current_state = LED_ON; - } - else if (led_mode == LED_BLINK && current_state == LED_ON) - { - digitalWrite(_pin, LOW); - current_state = LED_OFF; - } - else if (led_mode == LED_ON) - { - digitalWrite(_pin, HIGH); - current_state = LED_ON; - } - else - { - digitalWrite(_pin, LOW); - current_state = LED_OFF; - } -} diff --git a/firmware/src/IndicatorLed.h b/firmware/src/IndicatorLed.h deleted file mode 100644 index a25a6fc..0000000 --- a/firmware/src/IndicatorLed.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ======================================================================================================= - * ------------------------------------------------------------------------------------------------------- - * ---####################-----###########-------###########-----############--############-############-- - * --######################---#############-----#############---- -- - --- - * --###### ##---##### ###-----### #####---------##-------#######------#------------- - * -- -------------- --- ----- --- ----- ---------##-------#------------#------------- - * --#####--------------------#####------####-####------#####---------##-------###########--############-- - * -- -------------------- ------ ------ --------- ------- -- -- - * --#####--------------------#####--------#####--------#####--------------------------------------------- - * -- -------------------- -------- -------- --------------------------------------------- - * --######--------------##---#####---------------------#####---------------- IndicatorLed --------------- - * --##################### ---#####---------------------#####--------------------------------------------- - * ---################### ----#####---------------------#####--------------------------------------------- - * --- ----- --------------------- --------------------------------------------- - * ------------------------------------------------------------------------------------------------------- - * ======================================================================================================= - * - * Copyright 2023 Christoffer Martinsson - * - * CMtec ERLS can be redistributed and/or modified under the terms of the GNU General - * Public License (Version 2), as published by the Free Software Foundation. - * A copy of the license can be found online at www.gnu.o urg/licenses. - * - * CMtec ERLS is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - */ - -#ifndef INDICATORLED_H -#define INDICATORLED_H - -#include - -const int LED_OFF = 0; -const int LED_ON = 1; -const int LED_BLINK = 2; - -class IndicatorLed -{ - public: - IndicatorLed(int pin); - void begin(); - void on(); - void off(); - void blink(); - void update(); - - private: - int _pin; - int led_mode = LED_OFF; - int current_state = LED_OFF; -}; - -#endif diff --git a/firmware/src/cmdr_keyboard.cpp b/firmware/src/cmdr_keyboard.cpp index b9f3d1f..c86e571 100755 --- a/firmware/src/cmdr_keyboard.cpp +++ b/firmware/src/cmdr_keyboard.cpp @@ -6,8 +6,8 @@ * License: Please refer to LICENSE in root directory */ -#include "IndicatorLed.h" #include +#include #include const uint8_t USB_LED_CAPS_LOCK = 1; // Caps lock LED definition from HID spec @@ -287,7 +287,7 @@ void loop() } status_led.update(); - + indicator_timestamp = current_timestamp + 200; } }