Flash LED and backlight LEDs working including blinking
This commit is contained in:
parent
f394cb0e43
commit
ce80c21264
|
@ -39,6 +39,7 @@ CRGB backlight[NUM_BACKLIGHT_LED]; // Backlight
|
||||||
// Global vars
|
// Global vars
|
||||||
bool blinkingLED = false; // Enable / disable blinking flash LED
|
bool blinkingLED = false; // Enable / disable blinking flash LED
|
||||||
bool statusLED = false; // Actual status of flash LED on/off
|
bool statusLED = false; // Actual status of flash LED on/off
|
||||||
|
bool statusBacklightLED = false;// Actual status of flash LED on/off
|
||||||
|
|
||||||
int uvDuration = 0; // Under voltage duration in n x 100ms
|
int uvDuration = 0; // Under voltage duration in n x 100ms
|
||||||
|
|
||||||
|
@ -76,6 +77,28 @@ void togglePortPin(uint pin){
|
||||||
digitalWrite(pin, !digitalRead(pin));
|
digitalWrite(pin, !digitalRead(pin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toggleBacklightLED(){
|
||||||
|
statusBacklightLED = !statusBacklightLED;
|
||||||
|
FastLED.setBrightness(255); // Brightness for flash LED
|
||||||
|
if(statusBacklightLED == true){
|
||||||
|
backlight[0] = CRGB::White; // Backlight LEDs on
|
||||||
|
backlight[1] = CRGB::White;
|
||||||
|
backlight[2] = CRGB::White;
|
||||||
|
backlight[3] = CRGB::White;
|
||||||
|
backlight[4] = CRGB::White;
|
||||||
|
backlight[5] = CRGB::White;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
backlight[0] = CRGB::Black; // Backlight LEDs off
|
||||||
|
backlight[1] = CRGB::Black;
|
||||||
|
backlight[2] = CRGB::Black;
|
||||||
|
backlight[3] = CRGB::Black;
|
||||||
|
backlight[4] = CRGB::Black;
|
||||||
|
backlight[5] = CRGB::Black;
|
||||||
|
}
|
||||||
|
FastLED.show();
|
||||||
|
}
|
||||||
|
|
||||||
void setFlashLED(bool status){
|
void setFlashLED(bool status){
|
||||||
statusLED = status;
|
statusLED = status;
|
||||||
FastLED.setBrightness(255); // Brightness for flash LED
|
FastLED.setBrightness(255); // Brightness for flash LED
|
||||||
|
@ -90,7 +113,7 @@ void setFlashLED(bool status){
|
||||||
|
|
||||||
void blinkingFlashLED(){
|
void blinkingFlashLED(){
|
||||||
if(blinkingLED == true){
|
if(blinkingLED == true){
|
||||||
statusLED != statusLED;
|
statusLED = !statusLED;
|
||||||
FastLED.setBrightness(255); // Brightness for flash LED
|
FastLED.setBrightness(255); // Brightness for flash LED
|
||||||
if(statusLED == true){
|
if(statusLED == true){
|
||||||
fled[0] = CRGB::Red; // Flash LED on in red
|
fled[0] = CRGB::Red; // Flash LED on in red
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "OBP60Hardware.h"
|
#include "OBP60Hardware.h"
|
||||||
#include <MCP23017.h>
|
#include <MCP23017.h>
|
||||||
|
#include <FastLED.h> // Driver for WS2812 RGB LED
|
||||||
#include <GxGDEW042T2/GxGDEW042T2.h> // 4.2" Waveshare S/W 300 x 400 pixel
|
#include <GxGDEW042T2/GxGDEW042T2.h> // 4.2" Waveshare S/W 300 x 400 pixel
|
||||||
#include <GxIO/GxIO_SPI/GxIO_SPI.h> // GxEPD lip for SPI display communikation
|
#include <GxIO/GxIO_SPI/GxIO_SPI.h> // GxEPD lip for SPI display communikation
|
||||||
#include <GxIO/GxIO.h> // GxEPD lip for SPI
|
#include <GxIO/GxIO.h> // GxEPD lip for SPI
|
||||||
|
@ -30,6 +31,8 @@ void setPortPin(uint pin, bool value); // Set port pin for extension po
|
||||||
|
|
||||||
void togglePortPin(uint pin); // Toggle extension port pin
|
void togglePortPin(uint pin); // Toggle extension port pin
|
||||||
|
|
||||||
|
void toggleBacklightLED(); // Toggle backlight LEDs
|
||||||
|
|
||||||
void setFlashLED(bool status); // Set flash LED
|
void setFlashLED(bool status); // Set flash LED
|
||||||
void blinkingFlashLED(); // Blinking function for flash LED
|
void blinkingFlashLED(); // Blinking function for flash LED
|
||||||
void setBlinkingLED(bool on); // Set blinking flash LED active
|
void setBlinkingLED(bool on); // Set blinking flash LED active
|
||||||
|
|
|
@ -95,7 +95,6 @@ public:
|
||||||
// Limits for Pb battery
|
// Limits for Pb battery
|
||||||
if(String(batType) == "Pb" && (raw < 11.8 || raw > 14.8)){
|
if(String(batType) == "Pb" && (raw < 11.8 || raw > 14.8)){
|
||||||
setBlinkingLED(true);
|
setBlinkingLED(true);
|
||||||
setFlashLED(true);
|
|
||||||
}
|
}
|
||||||
if(String(batType) == "Pb" && (raw >= 11.8 && raw <= 14.8)){
|
if(String(batType) == "Pb" && (raw >= 11.8 && raw <= 14.8)){
|
||||||
setBlinkingLED(false);
|
setBlinkingLED(false);
|
||||||
|
|
|
@ -417,7 +417,7 @@ void OBP60Task(GwApi *api){
|
||||||
if(String(backlight) == "Control by Key"){
|
if(String(backlight) == "Control by Key"){
|
||||||
if(keyboardMessage == 6){
|
if(keyboardMessage == 6){
|
||||||
LOG_DEBUG(GwLog::LOG,"Toggle Backlight LED");
|
LOG_DEBUG(GwLog::LOG,"Toggle Backlight LED");
|
||||||
togglePortPin(OBP_BACKLIGHT_LED);
|
toggleBacklightLED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #9 Swipe right
|
// #9 Swipe right
|
||||||
|
|
Loading…
Reference in New Issue