couple of tiny stuff & spelling Errors
This commit is contained in:
Alexander Richter 2023-03-28 20:01:00 +02:00
parent fa04530a67
commit 81bc5a03c7
4 changed files with 10 additions and 9 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
.vscode
.vscode/arduino.json .vscode/arduino.json

View File

@ -64,19 +64,19 @@
int sInPinmap[] = {32,33,34,35,36}; int sInPinmap[] = {32,33,34,35,36};
#endif #endif
//#define OUTPUTS //Use Arduino IO's as Outputs. Define how many Outputs you want in total and then which Pins you want to be Outputs. #define OUTPUTS //Use Arduino IO's as Outputs. Define how many Outputs you want in total and then which Pins you want to be Outputs.
#ifdef OUTPUTS #ifdef OUTPUTS
const int Outputs = 9; //number of outputs const int Outputs = 9; //number of outputs
int OutPinmap[] = {10,9,8,7,6,5,4,3,2,21}; int OutPinmap[] = {10,9,8,7,6,5,4,3,2,21};
#endif #endif
//#define PWMOUTPUTS //Use Arduino PWM Capable IO's as PWM Outputs. Define how many PWM Outputs you want in total and then which Pins you want to be PWM Outputs. #define PWMOUTPUTS //Use Arduino PWM Capable IO's as PWM Outputs. Define how many PWM Outputs you want in total and then which Pins you want to be PWM Outputs.
#ifdef PWMOUTPUTS #ifdef PWMOUTPUTS
const int PwmOutputs = 2; //number of outputs const int PwmOutputs = 2; //number of outputs
int PwmOutPinmap[] = {12,11}; int PwmOutPinmap[] = {12,11};
#endif #endif
//#define AINPUTS //Use Arduino ADC's as Analog Inputs. Define how many Analog Inputs you want in total and then which Pins you want to be Analog Inputs. #define AINPUTS //Use Arduino ADC's as Analog Inputs. Define how many Analog Inputs you want in total and then which Pins you want to be Analog Inputs.
//Note that Analog Pin numbering is different to the Print on the PCB. //Note that Analog Pin numbering is different to the Print on the PCB.
#ifdef AINPUTS #ifdef AINPUTS
const int AInputs = 1; const int AInputs = 1;
@ -109,7 +109,7 @@
int margin = 20; //giving it some margin so Numbers dont jitter, make this number smaller if your knob has more than 50 Positions int margin = 20; //giving it some margin so Numbers dont jitter, make this number smaller if your knob has more than 50 Positions
#endif #endif
//#define ABSENCODER //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 ABSENCODER //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 ABSENCODER #ifdef ABSENCODER
const int AbsEncPins[] = {27,28,31,29,30}; //1,2,4,8,16 const int AbsEncPins[] = {27,28,31,29,30}; //1,2,4,8,16
#endif #endif
@ -492,8 +492,8 @@ void readsInputs(){
sInState[i] = digitalRead(sInPinmap[i]); sInState[i] = digitalRead(sInPinmap[i]);
if (sInState[i] != soldInState[i] && millis()- lastsInputDebounce[i] > debounceDelay){ if (sInState[i] != soldInState[i] && millis()- lastsInputDebounce[i] > debounceDelay){
// Button state has changed and debounce delay has passed // Button state has changed and debounce delay has passed
soldInState[i] = sInState[i];
if (sInState[i] == LOW) { if (sInState[i] == LOW || soldInState[i]== -1) { // Stuff after || is only there to send States at Startup
// Button has been pressed // Button has been pressed
togglesinputs[i] = !togglesinputs[i]; // Toggle the LED state togglesinputs[i] = !togglesinputs[i]; // Toggle the LED state
@ -504,6 +504,7 @@ void readsInputs(){
sendData('I',sInPinmap[i],togglesinputs[i]); // Turn the LED off sendData('I',sInPinmap[i],togglesinputs[i]); // Turn the LED off
} }
} }
soldInState[i] = sInState[i];
lastsInputDebounce[i] = millis(); lastsInputDebounce[i] = millis();
} }
} }

View File

@ -84,7 +84,7 @@ AbsKnobPos = 32
DLEDcount = 8 DLEDcount = 8
Debug = 1 Debug = 0
######## End of Config! ######## ######## End of Config! ########
olddOutStates= [0]*Outputs olddOutStates= [0]*Outputs
oldPwmOutStates=[0]*PwmOutputs oldPwmOutStates=[0]*PwmOutputs
@ -100,7 +100,7 @@ InPinmap += sInPinmap
# setup Input halpins # setup Input halpins
for port in range(Inputs): for port in range(Inputs):
c.newpin("dIn.{}".format(InPinmap[port]), hal.HAL_BIT, hal.HAL_OUT) c.newpin("dIn.{}".format(InPinmap[port]), hal.HAL_BIT, hal.HAL_OUT)
c.newparam("dIn.{}-invert".format(InPinmap[port]), hal.HAL_BIT, hal.HAL_OUT) c.newparam("dIn.{}-invert".format(InPinmap[port]), hal.HAL_BIT, hal.HAL_RW)
# setup Output halpins # setup Output halpins
for port in range(Outputs): for port in range(Outputs):

View File