minor bugfixes

Status LED
Joystick Pin
This commit is contained in:
Alexander Richter 2023-08-16 13:31:44 +02:00
parent a62ebed7e5
commit f45a9c0276
2 changed files with 6 additions and 9 deletions

View File

@ -172,7 +172,7 @@ Encoder Encoder1(31,33); //A,B Pin
//#define JOYSTICK //Support of an Rotating Knob that was build in my Machine. It encodes 32 Positions with 5 Pins in Binary. This will generate 32 Pins in LinuxCNC Hal. //#define JOYSTICK //Support of an Rotating Knob that was build in my Machine. It encodes 32 Positions with 5 Pins in Binary. This will generate 32 Pins in LinuxCNC Hal.
#ifdef JOYSTICK #ifdef JOYSTICK
const int JoySticks = 1; // Number of potentiometers connected const int JoySticks = 1; // Number of potentiometers connected
const int JoyStickPins[JoySticks*2] = {A0, A1}; // Analog input pins for the potentiometers const int JoyStickPins[JoySticks*2] = {0, 1}; // Analog input pins for the potentiometers
const int middleValue = 512; // Middle value of the potentiometer const int middleValue = 512; // Middle value of the potentiometer
const int deadband = 20; // Deadband range around the middleValue const int deadband = 20; // Deadband range around the middleValue
const float scalingFactor = 0.01; // Scaling factor to control the impact of distanceFromMiddle const float scalingFactor = 0.01; // Scaling factor to control the impact of distanceFromMiddle
@ -601,18 +601,15 @@ void StatLedErr(int offtime, int ontime){
if(DLEDSTATUSLED == 1){ if(DLEDSTATUSLED == 1){
controlDLED(StatLedPin, 1);} controlDLED(StatLedPin, 1);}
#endif #endif
#ifndef DLED if(DLEDSTATUSLED == 0){digitalWrite(StatLedPin, HIGH);}
digitalWrite(StatLedPin, HIGH);
#endif
} }
if (newMillis - oldmillis >= offtime+ontime){{ if (newMillis - oldmillis >= offtime+ontime){{
#ifdef DLED #ifdef DLED
if(DLEDSTATUSLED == 1){ if(DLEDSTATUSLED == 1){
controlDLED(StatLedPin, 0);} controlDLED(StatLedPin, 0);}
#endif #endif
#ifndef DLED if(DLEDSTATUSLED == 0){digitalWrite(StatLedPin, LOW);}
digitalWrite(StatLedPin, LOW);
#endif
oldmillis = newMillis; oldmillis = newMillis;
} }

View File

@ -209,7 +209,7 @@ for port in range(AInputs):
# setup Latching Poti halpins # setup Latching Poti halpins
for Poti in range(LPoti): for Poti in range(LPoti):
if SetLPotiValue[port]== 0: if SetLPotiValue[Poti]== 0:
for Pin in range(LPotiLatches[Poti][1]): for Pin in range(LPotiLatches[Poti][1]):
c.newpin("lpoti.{}.{}" .format(LPotiLatches[Poti][0],Pin), hal.HAL_BIT, hal.HAL_OUT) c.newpin("lpoti.{}.{}" .format(LPotiLatches[Poti][0],Pin), hal.HAL_BIT, hal.HAL_OUT)
else: else:
@ -217,7 +217,7 @@ for Poti in range(LPoti):
# setup Absolute Encoder Knob halpins # setup Absolute Encoder Knob halpins
if BinSelKnob: if BinSelKnob:
if SetBinSelKnobValue == 0: if SetBinSelKnobValue[0] == 0:
for port in range(BinSelKnobPos): for port in range(BinSelKnobPos):
c.newpin("binselknob.0.{}".format(port), hal.HAL_BIT, hal.HAL_OUT) c.newpin("binselknob.0.{}".format(port), hal.HAL_BIT, hal.HAL_OUT)
else : else :