Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for o in range(len(options)):
webserver.addSelector_Item(options[o],options[o],(str(options[o])==str(choice1)),False)
webserver.addSelector_Foot()
webserver.addFormNote("For RPI use 'raspi-config' tool: 5- Interfacing Options-P6 Serial- (Kernel logging disabled + serial port hardware enabled) before enable this plugin")
webserver.addFormNumericBox("Baudrate","p201_spd",self.taskdevicepluginconfig[1],50,4000000)
webserver.addFormNote("Generic values: 9600, 19200, 38400, 57600, 115200")
choice2 = self.taskdevicepluginconfig[2]
options = ["5","6","7","8"]
optionvalues = [rpiSerial.FIVEBITS,rpiSerial.SIXBITS,rpiSerial.SEVENBITS,rpiSerial.EIGHTBITS]
webserver.addFormSelector("Bytesize","p201_bsize",len(optionvalues),options,optionvalues,None,int(choice2))
webserver.addFormNote("Most common setting is 8")
choice3 = self.taskdevicepluginconfig[3]
options = ["None","Even","Odd","Mark","Space"]
optionvalues = [rpiSerial.PARITY_NONE,rpiSerial.PARITY_EVEN,rpiSerial.PARITY_ODD,rpiSerial.PARITY_MARK,rpiSerial.PARITY_SPACE]
webserver.addHtml("Parity:")
webserver.addSelector_Head("p201_par",False)
for o in range(len(options)):
webserver.addSelector_Item(options[o],optionvalues[o],(str(optionvalues[o])==str(choice3)),False)
webserver.addSelector_Foot()
webserver.addFormNote("Most common setting is None")
choice4 = self.taskdevicepluginconfig[4]
options = ["1","2"]
optionvalues = [rpiSerial.STOPBITS_ONE,rpiSerial.STOPBITS_TWO]
webserver.addFormSelector("Stopbits","p201_sbit",len(optionvalues),options,optionvalues,None,float(choice4))
webserver.addFormNote("Most common setting is 1")
webserver.addFormNumericBox("Expected max packet size","p201_pkt",self.taskdevicepluginconfig[5],1,4096) # Linux serial buffer is fixed max 4096 bytes
webserver.addUnit("byte")
choice6 = self.taskdevicepluginconfig[6]
options = ["Hex values","String"]
optionvalues = [0,1]
webserver.addFormSelector("Data format","p201_fmt",len(optionvalues),options,optionvalues,None,int(choice6))
else:
for d in range(len(options)):
webserver.addSelector_Item(options[d],options[d],(choice1==options[d]),False)
webserver.addSelector_Foot()
choice2 = int(float(self.taskdevicepluginconfig[1])) # store i2c address
options = ["0x3c","0x3d"]
optionvalues = [0x3c,0x3d]
webserver.addFormSelector("Address","p023_adr",len(options),options,optionvalues,None,choice2)
webserver.addFormNote("Enable <a href="pinout">I2C bus</a> first, than <a href="i2cscanner">search for the used address</a>!")
choice3 = int(float(self.taskdevicepluginconfig[2])) # store rotation state
options = ["Normal","Rotate by 90","Rotate by 180","Rotate by 270"]
optionvalues = [0,1,2,3]
webserver.addFormSelector("Mode","p023_rotate",len(optionvalues),options,optionvalues,None,choice3)
options = ["Default","128x64","128x128","128x32","96x96","96x64","64x48","64x32"]
choice4 = self.taskdevicepluginconfig[3] # store resolution
webserver.addHtml("Resolution:")
webserver.addSelector_Head("p023_res",False)
for d in range(len(options)):
webserver.addSelector_Item(options[d],options[d],(choice4==options[d]),False)
webserver.addSelector_Foot()
choice5 = int(float(self.taskdevicepluginconfig[4])) # store line count
webserver.addHtml("Number of lines:")
webserver.addSelector_Head("p023_linecount",False)
for l in range(1,self.P23_Nlines+1):
webserver.addSelector_Item(str(l),l,(l==choice5),False)
webserver.addSelector_Foot()
webserver.addFormNumericBox("Try to display # characters per row","p023_charperl",self.taskdevicepluginconfig[5],1,32)
webserver.addFormNote("Leave it '1' if you do not care")
webserver.addFormCheckBox("Clear only used lines","p023_partialclear",self.taskdevicepluginconfig[6])
if choice5 > 0 and choice5<9:
lc = choice5
else:
def webform_load(self): # create html page for settings
choice1 = str(self.taskdevicepluginconfig[0]) # store display type
import luma.oled.device
options = luma.oled.device.__all__
webserver.addHtml("Display type:")
webserver.addSelector_Head("p023_type",True)
for d in range(len(options)):
webserver.addSelector_Item(options[d],options[d],(choice1==options[d]),False)
webserver.addSelector_Foot()
choice2 = int(float(self.taskdevicepluginconfig[1])) # store i2c address
options = ["0x3c","0x3d"]
optionvalues = [0x3c,0x3d]
webserver.addFormSelector("Address","p023_adr",len(options),options,optionvalues,None,choice2)
webserver.addFormNote("Enable <a href="pinout">I2C bus</a> first, than <a href="i2cscanner">search for the used address</a>!")
choice3 = int(float(self.taskdevicepluginconfig[2])) # store rotation state
options = ["Normal","Rotate by 90","Rotate by 180","Rotate by 270"]
optionvalues = [0,1,2,3]
webserver.addFormSelector("Mode","p023_rotate",len(optionvalues),options,optionvalues,None,choice3)
options = ["Default","128x64","128x128","128x32","96x96","96x64","64x48","64x32"]
choice4 = self.taskdevicepluginconfig[3] # store resolution
webserver.addHtml("Resolution:")
webserver.addSelector_Head("p023_res",False)
def webform_load(self):
choosendev = self.taskdevicepluginconfig[0]
choosenrel = self.taskdevicepluginconfig[1]
try:
relaynum = vusb.usbrelay.getrelaynum()
except:
relaynum = 0
try:
relayids = vusb.usbrelay.getcompatibledevlist()
except:
relayids = []
if relaynum>0 and len(relayids)>0:
webserver.addHtml("Device ID:")
webserver.addSelector_Head("p501_relayname",True)
for i in range(len(relayids)):
webserver.addSelector_Item(relayids[i][2],relayids[i][2],(relayids[i][2]==choosendev),False)
webserver.addSelector_Foot()
webserver.addHtml("Relay number on device:")
webserver.addSelector_Head("p501_relaynum",True)
for r in range(1,relaynum+1):
webserver.addSelector_Item(r,r,(r==int(choosenrel)),False)
webserver.addSelector_Foot()
return True
webserver.addFormNote("Enable <a href="pinout">I2C bus</a> first, than <a href="i2cscanner">search for the used address</a>!")
choice3 = int(float(self.taskdevicepluginconfig[2])) # store rotation state
options = ["Normal","Rotate by 90","Rotate by 180","Rotate by 270"]
optionvalues = [0,1,2,3]
webserver.addFormSelector("Mode","p023_rotate",len(optionvalues),options,optionvalues,None,choice3)
options = ["Default","128x64","128x128","128x32","96x96","96x64","64x48","64x32"]
choice4 = self.taskdevicepluginconfig[3] # store resolution
webserver.addHtml("Resolution:")
webserver.addSelector_Head("p023_res",False)
for d in range(len(options)):
webserver.addSelector_Item(options[d],options[d],(choice4==options[d]),False)
webserver.addSelector_Foot()
choice5 = int(float(self.taskdevicepluginconfig[4])) # store line count
webserver.addHtml("Number of lines:")
webserver.addSelector_Head("p023_linecount",False)
for l in range(1,self.P23_Nlines+1):
webserver.addSelector_Item(str(l),l,(l==choice5),False)
webserver.addSelector_Foot()
webserver.addFormNumericBox("Try to display # characters per row","p023_charperl",self.taskdevicepluginconfig[5],1,32)
webserver.addFormNote("Leave it '1' if you do not care")
webserver.addFormCheckBox("Clear only used lines","p023_partialclear",self.taskdevicepluginconfig[6])
if choice5 > 0 and choice5<9:
lc = choice5
else:
lc = self.P23_Nlines
for l in range(lc):
try:
linestr = self.lines[l]
except:
linestr = ""
webserver.addFormTextBox("Line"+str(l+1),"p023_template"+str(l),linestr,128)
def webform_load(self):
choice1 = self.taskdevicepluginconfig[0]
options = rpiSerial.serial_portlist()
if len(options)>0:
webserver.addHtml("Serial Device:")
webserver.addSelector_Head("p201_addr",False)
for o in range(len(options)):
webserver.addSelector_Item(options[o],options[o],(str(options[o])==str(choice1)),False)
webserver.addSelector_Foot()
webserver.addFormNote("For RPI use 'raspi-config' tool: 5- Interfacing Options-P6 Serial- (Kernel logging disabled + serial port hardware enabled) before enable this plugin")
webserver.addFormNumericBox("Baudrate","p201_spd",self.taskdevicepluginconfig[1],50,4000000)
webserver.addFormNote("Generic values: 9600, 19200, 38400, 57600, 115200")
choice2 = self.taskdevicepluginconfig[2]
options = ["5","6","7","8"]
optionvalues = [rpiSerial.FIVEBITS,rpiSerial.SIXBITS,rpiSerial.SEVENBITS,rpiSerial.EIGHTBITS]
webserver.addFormSelector("Bytesize","p201_bsize",len(optionvalues),options,optionvalues,None,int(choice2))
webserver.addFormNote("Most common setting is 8")
choice3 = self.taskdevicepluginconfig[3]
options = ["None","Even","Odd","Mark","Space"]
optionvalues = [rpiSerial.PARITY_NONE,rpiSerial.PARITY_EVEN,rpiSerial.PARITY_ODD,rpiSerial.PARITY_MARK,rpiSerial.PARITY_SPACE]
webserver.addHtml("Parity:")
webserver.addSelector_Head("p201_par",False)
relaynum = vusb.usbrelay.getrelaynum()
except:
relaynum = 0
try:
relayids = vusb.usbrelay.getcompatibledevlist()
except:
relayids = []
if relaynum>0 and len(relayids)>0:
webserver.addHtml("Device ID:")
webserver.addSelector_Head("p501_relayname",True)
for i in range(len(relayids)):
webserver.addSelector_Item(relayids[i][2],relayids[i][2],(relayids[i][2]==choosendev),False)
webserver.addSelector_Foot()
webserver.addHtml("Relay number on device:")
webserver.addSelector_Head("p501_relaynum",True)
for r in range(1,relaynum+1):
webserver.addSelector_Item(r,r,(r==int(choosenrel)),False)
webserver.addSelector_Foot()
return True
def webform_load(self): # create html page for settings
choice1 = str(self.taskdevicepluginconfig[0]) # store display type
import luma.oled.device
options = luma.oled.device.__all__
webserver.addHtml("Display type:")
webserver.addSelector_Head("p036_type",True)
for d in range(len(options)):
webserver.addSelector_Item(options[d],options[d],(choice1==options[d]),False)
webserver.addSelector_Foot()
choice2 = int(float(self.taskdevicepluginconfig[1])) # store i2c address
options = ["0x3c","0x3d"]
optionvalues = [0x3c,0x3d]
webserver.addFormSelector("Address","p036_adr",len(options),options,optionvalues,None,choice2)
webserver.addFormNote("Enable <a href="pinout">I2C bus</a> first, than <a href="i2cscanner">search for the used address</a>!")
choice3 = int(float(self.taskdevicepluginconfig[2])) # store rotation state
options = ["Normal","Rotate by 180"]
optionvalues = [0,2]
webserver.addFormSelector("Mode","p036_rotate",len(optionvalues),options,optionvalues,None,choice3)
options = ["Default","128x64","128x128","128x32","96x96","96x64","64x48","64x32"]
choice4 = self.taskdevicepluginconfig[3] # store resolution
webserver.addHtml("Resolution:")
webserver.addSelector_Head("p036_res",False)
def webform_load(self): # create html page for settings
choice1 = str(self.taskdevicepluginconfig[0]) # store display type
options = ["PCF8574","MCP23008","MCP23017","MCP23017/B"]
webserver.addHtml("I2C chip type:")
webserver.addSelector_Head("p012_type",True)
for d in range(len(options)):
webserver.addSelector_Item(options[d],options[d],(choice1==options[d]),False)
webserver.addSelector_Foot()
choice2 = int(float(self.taskdevicepluginconfig[1])) # store i2c address
optionvalues = []
for i in range(0x20,0x28):
optionvalues.append(i)
for i in range(0x38,0x40):
optionvalues.append(i)
options = []
for i in range(len(optionvalues)):
options.append(str(hex(optionvalues[i])))
webserver.addFormSelector("Address","p012_adr",len(options),options,optionvalues,None,choice2)
webserver.addFormNote("Enable <a href="pinout">I2C bus</a> first, than <a href="i2cscanner">search for the used address</a>!")
def webform_load(self):
choice1 = self.taskdevicepluginconfig[0]
options = self.find_dsb_devices()
if len(options)>0:
webserver.addHtml("Device Address:")
webserver.addSelector_Head("p004_addr",True)
for o in range(len(options)):
webserver.addSelector_Item(options[o],options[o],(str(options[o])==str(choice1)),False)
webserver.addSelector_Foot()
webserver.addFormNote("You have to setup one pin (at least) for <b>1WIRE</b> type at <a href="pinout">pinout settings page</a> before use!")
return True