adding a feature, which lets you define values to Latching Potis
this is to make it easyer to implement a spindle and feed speed override in my case. Instead of hustle to convert Pins to values in LinuxCNC Hal the component now does it itself. So only the output hast to be linked to the signal of LinuxCNC. To be tested...
This commit is contained in:
parent
422f12ce24
commit
3a5eee4e77
17
arduino.py
17
arduino.py
@ -77,6 +77,13 @@ LPoti = 0 #number of LPotis, Set LPoti = 0 to disable
|
|||||||
LPotiLatches = [[2,9], #Poti is connected to Pin 2 (A1) and has 9 positions
|
LPotiLatches = [[2,9], #Poti is connected to Pin 2 (A1) and has 9 positions
|
||||||
[3,4]] #Poti is connected to Pin 3 (A2) and has 4 positions
|
[3,4]] #Poti is connected to Pin 3 (A2) and has 4 positions
|
||||||
|
|
||||||
|
#Do you want the Latching Potis to control override Settings in LinuxCNC? This function lets you define values for each Position.
|
||||||
|
SetLPotiValue = [1,1]
|
||||||
|
LPotiValues = [[40, 50,60,70,80,90,100,110,120],
|
||||||
|
[0.001,0.01,0.1,1]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Set if you have an binary encoded Selector Switch and how many positions it has (only one supported, as i don't think they are very common and propably nobody uses these anyway)
|
# Set if you have an binary encoded Selector Switch and how many positions it has (only one supported, as i don't think they are very common and propably nobody uses these anyway)
|
||||||
# Set BinSelKnob = 0 to disable
|
# Set BinSelKnob = 0 to disable
|
||||||
BinSelKnob = 0 #1 enable
|
BinSelKnob = 0 #1 enable
|
||||||
@ -166,8 +173,11 @@ 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:
|
||||||
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:
|
||||||
|
c.newpin("LPoti.{}.{}" .format(LPotiLatches[Poti][0],"out"), hal.HAL_FLOAT, hal.HAL_OUT)
|
||||||
|
|
||||||
# setup Absolute Encoder Knob halpins
|
# setup Absolute Encoder Knob halpins
|
||||||
if BinSelKnob:
|
if BinSelKnob:
|
||||||
@ -294,9 +304,8 @@ while True:
|
|||||||
|
|
||||||
elif cmd == "L":
|
elif cmd == "L":
|
||||||
firstcom = 1
|
firstcom = 1
|
||||||
|
|
||||||
for Poti in range(LPoti):
|
for Poti in range(LPoti):
|
||||||
if LPotiLatches[Poti][0] == io:
|
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
|
||||||
@ -305,6 +314,10 @@ while True:
|
|||||||
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:
|
||||||
|
c["LPoti.{}.{}" .format(io,"out")] = LPotiValues[Poti][io]
|
||||||
|
|
||||||
|
|
||||||
elif cmd == "K":
|
elif cmd == "K":
|
||||||
firstcom = 1
|
firstcom = 1
|
||||||
for port in range(BinSelKnobPos):
|
for port in range(BinSelKnobPos):
|
||||||
|
Loading…
Reference in New Issue
Block a user