Skip to content

Commit

Permalink
Flash LED and backlight LEDs working including blinking
Browse files Browse the repository at this point in the history
  • Loading branch information
norbert-walter committed Jan 6, 2024
1 parent f394cb0 commit ce80c21
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
25 changes: 24 additions & 1 deletion lib/obp60task/OBP60Extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CRGB backlight[NUM_BACKLIGHT_LED]; // Backlight
// Global vars
bool blinkingLED = false; // Enable / disable blinking flash LED
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

Expand Down Expand Up @@ -76,6 +77,28 @@ void togglePortPin(uint 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){
statusLED = status;
FastLED.setBrightness(255); // Brightness for flash LED
Expand All @@ -90,7 +113,7 @@ void setFlashLED(bool status){

void blinkingFlashLED(){
if(blinkingLED == true){
statusLED != statusLED;
statusLED = !statusLED;
FastLED.setBrightness(255); // Brightness for flash LED
if(statusLED == true){
fled[0] = CRGB::Red; // Flash LED on in red
Expand Down
3 changes: 3 additions & 0 deletions lib/obp60task/OBP60Extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Arduino.h>
#include "OBP60Hardware.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 <GxIO/GxIO_SPI/GxIO_SPI.h> // GxEPD lip for SPI display communikation
#include <GxIO/GxIO.h> // GxEPD lip for SPI
Expand All @@ -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 toggleBacklightLED(); // Toggle backlight LEDs

void setFlashLED(bool status); // Set flash LED
void blinkingFlashLED(); // Blinking function for flash LED
void setBlinkingLED(bool on); // Set blinking flash LED active
Expand Down
1 change: 0 additions & 1 deletion lib/obp60task/PageVoltage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ double raw = 0;
// Limits for Pb battery
if(String(batType) == "Pb" && (raw < 11.8 || raw > 14.8)){
setBlinkingLED(true);
setFlashLED(true);
}
if(String(batType) == "Pb" && (raw >= 11.8 && raw <= 14.8)){
setBlinkingLED(false);
Expand Down
2 changes: 1 addition & 1 deletion lib/obp60task/obp60task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void OBP60Task(GwApi *api){
if(String(backlight) == "Control by Key"){
if(keyboardMessage == 6){
LOG_DEBUG(GwLog::LOG,"Toggle Backlight LED");
togglePortPin(OBP_BACKLIGHT_LED);
toggleBacklightLED();
}
}
// #9 Swipe right
Expand Down

0 comments on commit ce80c21

Please sign in to comment.