From 95a35bb1c9a01241e8978a762128b8ad0c408160 Mon Sep 17 00:00:00 2001 From: Alexander Richter Date: Tue, 5 Sep 2023 13:38:42 +0200 Subject: [PATCH] updated py file --- arduino-connector.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arduino-connector.py b/arduino-connector.py index 4cd4733..e381e8c 100644 --- a/arduino-connector.py +++ b/arduino-connector.py @@ -76,7 +76,10 @@ AInPinmap = [1] #Potentiometer connected to Pin 1 (A0) # Set how many Latching Analog Inputs you have programmed in Arduino and how many latches there are, you can set as many as your Arduino has Analog pins. List the connected pins below. -LPoti = 0 #number of LPotis, Set LPoti = 0 to disable +SetLPotiValue = [1,2] #0 OFF - creates Pin for each Position + #1 S32 - Whole Number between -2147483648 to 2147483647 + #2 FLOAT - 32 bit floating point value + LPotiLatches = [[1,9], #Poti is connected to Pin 1 (A1) and has 9 positions [2,4]] #Poti is connected to Pin 2 (A2) and has 4 positions @@ -206,14 +209,15 @@ for port in range(PwmOutputs): # setup Analog Input halpins for port in range(AInputs): c.newpin("ain.{}".format(AInPinmap[port]), hal.HAL_FLOAT, hal.HAL_OUT) - # setup Latching Poti halpins for Poti in range(LPoti): - if SetLPotiValue[Poti]== 0: + if SetLPotiValue[Poti] == 0: for Pin in range(LPotiLatches[Poti][1]): - 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_S32, hal.HAL_OUT) + c.newpin("LPoti.{}.{}" .format(LPotiLatches[Poti][0],Pin), hal.HAL_BIT, hal.HAL_OUT) + if SetLPotiValue[Poti] == 1: + c.newpin("LPoti.{}.{}" .format(LPotiLatches[Poti][0],"out"), hal.HAL_S32, hal.HAL_OUT) + if SetLPotiValue[Poti] == 2: + c.newpin("LPoti.{}.{}" .format(LPotiLatches[Poti][0],"out"), hal.HAL_FLOAT, hal.HAL_OUT) # setup Absolute Encoder Knob halpins if BinSelKnob: