Moved lib to submodule

This commit is contained in:
Christoffer Martinsson 2023-06-06 16:27:48 +02:00
parent cfcf804b82
commit a21aea6f22
4 changed files with 3 additions and 158 deletions

@ -0,0 +1 @@
Subproject commit 6a2b179d8f624d69b41a5d30df7b46080a1deec6

View File

@ -1,101 +0,0 @@
/*
* =======================================================================================================
* -------------------------------------------------------------------------------------------------------
* ---####################-----###########-------###########-----############--############-############--
* --######################---#############-----#############---- -- - ---
* --###### ##---##### ###-----### #####---------##-------#######------#-------------
* -- -------------- --- ----- --- ----- ---------##-------#------------#-------------
* --#####--------------------#####------####-####------#####---------##-------###########--############--
* -- -------------------- ------ ------ --------- ------- -- --
* --#####--------------------#####--------#####--------#####---------------------------------------------
* -- -------------------- -------- -------- ---------------------------------------------
* --######--------------##---#####---------------------#####---------------- IndicatorLed ---------------
* --##################### ---#####---------------------#####---------------------------------------------
* ---################### ----#####---------------------#####---------------------------------------------
* --- ----- --------------------- ---------------------------------------------
* -------------------------------------------------------------------------------------------------------
* =======================================================================================================
*
* Copyright 2023 Christoffer Martinsson <cm@cmtec.se>
*
* 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;
}
}

View File

@ -1,55 +0,0 @@
/*
* =======================================================================================================
* -------------------------------------------------------------------------------------------------------
* ---####################-----###########-------###########-----############--############-############--
* --######################---#############-----#############---- -- - ---
* --###### ##---##### ###-----### #####---------##-------#######------#-------------
* -- -------------- --- ----- --- ----- ---------##-------#------------#-------------
* --#####--------------------#####------####-####------#####---------##-------###########--############--
* -- -------------------- ------ ------ --------- ------- -- --
* --#####--------------------#####--------#####--------#####---------------------------------------------
* -- -------------------- -------- -------- ---------------------------------------------
* --######--------------##---#####---------------------#####---------------- IndicatorLed ---------------
* --##################### ---#####---------------------#####---------------------------------------------
* ---################### ----#####---------------------#####---------------------------------------------
* --- ----- --------------------- ---------------------------------------------
* -------------------------------------------------------------------------------------------------------
* =======================================================================================================
*
* Copyright 2023 Christoffer Martinsson <cm@cmtec.se>
*
* 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 <Arduino.h>
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

View File

@ -6,8 +6,8 @@
* License: Please refer to LICENSE in root directory * License: Please refer to LICENSE in root directory
*/ */
#include "IndicatorLed.h"
#include <Arduino.h> #include <Arduino.h>
#include <IndicatorLed.h>
#include <Keypad.h> #include <Keypad.h>
const uint8_t USB_LED_CAPS_LOCK = 1; // Caps lock LED definition from HID spec const uint8_t USB_LED_CAPS_LOCK = 1; // Caps lock LED definition from HID spec
@ -287,7 +287,7 @@ void loop()
} }
status_led.update(); status_led.update();
indicator_timestamp = current_timestamp + 200; indicator_timestamp = current_timestamp + 200;
} }
} }