DLED Stability Issue Bugfix

This commit is contained in:
Alexander Richter 2023-08-15 18:33:10 +02:00
parent 7dc5950b6a
commit b89c15434e
2 changed files with 30 additions and 15 deletions

View File

@ -196,7 +196,7 @@ const float scalingFactor = 0.01; // Scaling factor to control the impact of d
#ifdef STATUSLED #ifdef STATUSLED
const int StatLedPin = 13; //Pin for Status LED const int StatLedPin = 13; //Pin for Status LED
const int StatLedErrDel[] = {1000,10}; //Blink Timing for Status LED Error (no connection) const int StatLedErrDel[] = {1000,10}; //Blink Timing for Status LED Error (no connection)
const int DLEDSTATUSLED = 1; //set to 1 to use Digital LED instead. set StatLedPin to the according LED number in the chain. const int DLEDSTATUSLED = 0; //set to 1 to use Digital LED instead. set StatLedPin to the according LED number in the chain.
#endif #endif
@ -221,7 +221,7 @@ If you want the LED to be off just define {0,0,0}, .
If you use STATUSLED, it will also take the colors of your definition here. If you use STATUSLED, it will also take the colors of your definition here.
*/ */
#define DLED //#define DLED
#ifdef DLED #ifdef DLED
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
@ -465,7 +465,7 @@ void loop() {
#endif #endif
#ifdef DLED #ifdef DLED
updateDLEDs(); //read Encoders & send data //updateDLEDs(); //read Encoders & send data
#endif #endif
} }
@ -475,6 +475,7 @@ void updateDLEDs(){
for(int i = 0; i< DLEDcount; i++){ for(int i = 0; i< DLEDcount; i++){
controlDLED(i, DLEDstate[i]); controlDLED(i, DLEDstate[i]);
//update all DLEDs regulary //update all DLEDs regulary
} }
@ -579,12 +580,17 @@ void comalive(){
StatLedErr(500,200); StatLedErr(500,200);
} }
else{ else{
#ifdef DLED
controlDLED(StatLedPin, 1); if(DLEDSTATUSLED == 1){
#endif #ifdef DLED
#ifndef DLED controlDLED(StatLedPin, 1);
digitalWrite(StatLedPin, HIGH); #endif
#endif }
else{
digitalWrite(StatLedPin, HIGH);
}
} }
#endif #endif
} }
@ -831,8 +837,15 @@ void commandReceived(char cmd, uint16_t io, uint16_t value){
#ifdef DLED #ifdef DLED
if(cmd == 'D'){ if(cmd == 'D'){
DLEDstate[io] = value; DLEDstate[io] = value;
controlDLED(io,value); updateDLEDs();
//controlDLED(io,value);
lastcom=millis(); lastcom=millis();
#ifdef debug
Serial.print("DLED:");
Serial.print(io);
Serial.print(" State:");
Serial.println(DLEDstate[io]);
#endif
} }
#endif #endif

View File

@ -309,15 +309,17 @@ def managageOutputs():
if (Debug):print ("Sending:{}".format(command.encode())) if (Debug):print ("Sending:{}".format(command.encode()))
olddOutStates[port]= State olddOutStates[port]= State
for port in range(DLEDcount): for dled in range(DLEDcount):
State = int(c["dled.{}".format(port)]) State = int(c["dled.{}".format(dled)])
if oldDLEDStates[port] != State: #check if states have changed if oldDLEDStates[dled] != State: #check if states have changed
Sig = 'D' Sig = 'D'
Pin = int(port) Pin = dled
command = "{}{}:{}\n".format(Sig,Pin,State) command = "{}{}:{}\n".format(Sig,Pin,State)
arduino.write(command.encode()) arduino.write(command.encode())
oldDLEDStates[port] = State
if (Debug):print ("Sending:{}".format(command.encode())) if (Debug):print ("Sending:{}".format(command.encode()))
oldDLEDStates[dled] = State
while True: while True: