changed Format of Hal Pins to LinuxCNC standard

This commit is contained in:
Alexander Richter 2023-07-23 17:32:58 +02:00
parent 14122bca26
commit b6dcb2350a

View File

@ -159,43 +159,43 @@ 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_RW) 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):
c.newpin("dOut.{}".format(OutPinmap[port]), hal.HAL_BIT, hal.HAL_IN) c.newpin("dout.{}".format(OutPinmap[port]), hal.HAL_BIT, hal.HAL_IN)
olddOutStates[port] = 0 olddOutStates[port] = 0
# setup Pwm Output halpins # setup Pwm Output halpins
for port in range(PwmOutputs): for port in range(PwmOutputs):
c.newpin("PwmOut.{}".format(PwmOutPinmap[port]), hal.HAL_FLOAT, hal.HAL_IN) c.newpin("pwmout.{}".format(PwmOutPinmap[port]), hal.HAL_FLOAT, hal.HAL_IN)
oldPwmOutStates[port] = 255 oldPwmOutStates[port] = 255
# setup Analog Input halpins # setup Analog Input halpins
for port in range(AInputs): for port in range(AInputs):
c.newpin("aIn.{}".format(AInPinmap[port]), hal.HAL_FLOAT, hal.HAL_OUT) c.newpin("ain.{}".format(AInPinmap[port]), hal.HAL_FLOAT, hal.HAL_OUT)
# setup Latching Poti halpins # setup Latching Poti halpins
for Poti in range(LPoti): for Poti in range(LPoti):
if SetLPotiValue[port]== 0: if SetLPotiValue[port]== 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:
c.newpin("LPoti.{}.{}" .format(LPotiLatches[Poti][0],"out"), hal.HAL_S32, hal.HAL_OUT) c.newpin("lpoti.{}.{}" .format(LPotiLatches[Poti][0],"out"), hal.HAL_S32, hal.HAL_OUT)
# setup Absolute Encoder Knob halpins # setup Absolute Encoder Knob halpins
if BinSelKnob: if BinSelKnob:
if SetBinSelKnobValue == 0: if SetBinSelKnobValue == 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 :
c.newpin("BinSelKnob.{}.{}" .format("0","out"), hal.HAL_S32, hal.HAL_OUT) c.newpin("binselknob.{}.{}" .format("0","out"), hal.HAL_S32, hal.HAL_OUT)
# setup Digital LED halpins # setup Digital LED halpins
if DLEDcount > 0: if DLEDcount > 0:
for port in range(DLEDcount): for port in range(DLEDcount):
c.newpin("DLED.{}".format(port), hal.HAL_BIT, hal.HAL_IN) c.newpin("dled.{}".format(port), hal.HAL_BIT, hal.HAL_IN)
oldDLEDStates[port] = 0 oldDLEDStates[port] = 0
# setup MatrixKeyboard halpins # setup MatrixKeyboard halpins
if Keypad > 0: if Keypad > 0:
@ -203,7 +203,7 @@ if Keypad > 0:
if Destination[port] == 0 & LinuxKeyboardInput: if Destination[port] == 0 & LinuxKeyboardInput:
pass #if destination is set to Linux, don't register a Hal Pin for this key. pass #if destination is set to Linux, don't register a Hal Pin for this key.
else: else:
c.newpin("Keypad.{}".format(Chars[port]), hal.HAL_BIT, hal.HAL_IN) c.newpin("keypad.{}".format(Chars[port]), hal.HAL_BIT, hal.HAL_IN)
c.ready() c.ready()
#setup Serial connection #setup Serial connection
@ -241,7 +241,7 @@ def extract_nbr(input_str):
def managageOutputs(): def managageOutputs():
for port in range(PwmOutputs): for port in range(PwmOutputs):
State = int(c["PwmOut.{}".format(PwmOutPinmap[port])]) State = int(c["pwmout.{}".format(PwmOutPinmap[port])])
if oldPwmOutStates[port] != State: #check if states have changed if oldPwmOutStates[port] != State: #check if states have changed
Sig = 'P' Sig = 'P'
Pin = int(PwmOutPinmap[port]) Pin = int(PwmOutPinmap[port])
@ -251,7 +251,7 @@ def managageOutputs():
oldPwmOutStates[port]= State oldPwmOutStates[port]= State
for port in range(Outputs): for port in range(Outputs):
State = int(c["dOut.{}".format(OutPinmap[port])]) State = int(c["dout.{}".format(OutPinmap[port])])
if olddOutStates[port] != State: #check if states have changed if olddOutStates[port] != State: #check if states have changed
Sig = 'O' Sig = 'O'
Pin = int(OutPinmap[port]) Pin = int(OutPinmap[port])
@ -261,7 +261,7 @@ def managageOutputs():
olddOutStates[port]= State olddOutStates[port]= State
for port in range(DLEDcount): for port in range(DLEDcount):
State = int(c["DLED.{}".format(port)]) State = int(c["dled.{}".format(port)])
if oldDLEDStates[port] != State: #check if states have changed if oldDLEDStates[port] != State: #check if states have changed
Sig = 'D' Sig = 'D'
Pin = int(port) Pin = int(port)
@ -295,20 +295,20 @@ while True:
if cmd == "I": if cmd == "I":
firstcom = 1 firstcom = 1
if value == 1: if value == 1:
c["dIn.{}".format(io)] = 1 c["din.{}".format(io)] = 1
c["dIn.{}-invert".format(io)] = 0 c["din.{}-invert".format(io)] = 0
if(Debug):print("dIn{}:{}".format(io,1)) if(Debug):print("din{}:{}".format(io,1))
if value == 0: if value == 0:
c["dIn.{}".format(io)] = 0 c["din.{}".format(io)] = 0
c["dIn.{}-invert".format(io)] = 1 c["din.{}-invert".format(io)] = 1
if(Debug):print("dIn{}:{}".format(io,0)) if(Debug):print("din{}:{}".format(io,0))
else:pass else:pass
elif cmd == "A": elif cmd == "A":
firstcom = 1 firstcom = 1
c["aIn.{}".format(io)] = value c["ain.{}".format(io)] = value
if (Debug):print("aIn.{}:{}".format(io,value)) if (Debug):print("ain.{}:{}".format(io,value))
elif cmd == "L": elif cmd == "L":
firstcom = 1 firstcom = 1
@ -316,28 +316,28 @@ while True:
if LPotiLatches[Poti][0] == io and SetLPotiValue[Poti] == 0: if LPotiLatches[Poti][0] == io and SetLPotiValue[Poti] == 0:
for Pin in range(LPotiLatches[Poti][1]): for Pin in range(LPotiLatches[Poti][1]):
if Pin == value: if Pin == value:
c["LPoti.{}.{}" .format(io,Pin)] = 1 c["lpoti.{}.{}" .format(io,Pin)] = 1
if(Debug):print("LPoti.{}.{} =1".format(io,Pin)) if(Debug):print("lpoti.{}.{} =1".format(io,Pin))
else: else:
c["LPoti.{}.{}" .format(io,Pin)] = 0 c["lpoti.{}.{}" .format(io,Pin)] = 0
if(Debug):print("LPoti.{}.{} =0".format(io,Pin)) if(Debug):print("lpoti.{}.{} =0".format(io,Pin))
if LPotiLatches[Poti][0] == io and SetLPotiValue[Poti] == 1: if LPotiLatches[Poti][0] == io and SetLPotiValue[Poti] == 1:
c["LPoti.{}.{}" .format(io,"out")] = LPotiValues[Poti][value] c["lpoti.{}.{}" .format(io,"out")] = LPotiValues[Poti][value]
if(Debug):print("LPoti.{}.{} = 0".format("out",LPotiValues[Poti][value])) if(Debug):print("lpoti.{}.{} = 0".format("out",LPotiValues[Poti][value]))
elif cmd == "K": elif cmd == "K":
firstcom = 1 firstcom = 1
if SetBinSelKnobValue == 0: if SetBinSelKnobValue == 0:
for port in range(BinSelKnobPos): for port in range(BinSelKnobPos):
if port == value: if port == value:
c["BinSelKnob.{}".format(port)] = 1 c["binselknob.{}".format(port)] = 1
if(Debug):print("BinSelKnob.{}:{}".format(port,1)) if(Debug):print("binselknob.{}:{}".format(port,1))
else: else:
c["BinSelKnob.{}".format(port)] = 0 c["binselknob.{}".format(port)] = 0
if(Debug):print("BinSelKnob.{}:{}".format(port,0)) if(Debug):print("binselknob.{}:{}".format(port,0))
else: else:
c["BinSelKnob.{}.{}" .format(0,"out")] = BinSelKnobvalues[value] c["binselknob.{}.{}" .format(0,"out")] = BinSelKnobvalues[value]
elif cmd == "M": elif cmd == "M":
@ -347,12 +347,12 @@ while True:
subprocess.call(["xdotool", "key", Chars[io]]) subprocess.call(["xdotool", "key", Chars[io]])
if(Debug):print("Emulating Keypress{}".format(Chars[io])) if(Debug):print("Emulating Keypress{}".format(Chars[io]))
else: else:
c["Keypad.{}".format(Chars[io])] = 1 c["keypad.{}".format(Chars[io])] = 1
if(Debug):print("Keypad{}:{}".format(Chars[io],1)) if(Debug):print("keypad{}:{}".format(Chars[io],1))
if value == 0 & Destination[io] == 0: if value == 0 & Destination[io] == 0:
c["Keypad.{}".format(Chars[io])] = 0 c["keypad.{}".format(Chars[io])] = 0
if(Debug):print("Keypad{}:{}".format(Chars[io],0)) if(Debug):print("keypad{}:{}".format(Chars[io],0))