Ejemplo n.º 1
0
 def webform_load(self):  # create html page for settings
     ownpin = -1
     try:
         if self.mcp:
             if self.mcp.externalintsetted > -1:
                 ownpin = int(self.mcp.extinta)
         else:
             ownpin = ""
     except Exception as e:
         ownpin = -1
     webserver.addFormPinSelect("MCP interrupt", "taskdevicepin0", ownpin)
     webserver.addFormNote(
         "Add one RPI input pin to handle input changes immediately - not needed for interval input reading and output using only"
     )
     webserver.addFormNumericBox("Port", "p009_pnum",
                                 self.taskdevicepluginconfig[0], 0, 128)
     webserver.addFormNote("First extender 1-16, Second 17-32...")
     choice2 = self.taskdevicepluginconfig[1]
     options = ["Input", "Input-Pullup", "Output"]
     optionvalues = [0, 1, 2]
     webserver.addFormSelector("Type", "p009_ptype", len(optionvalues),
                               options, optionvalues, None, int(choice2))
     choice3 = self.taskdevicepluginconfig[2]
     options = ["MCP23017", "MCP23008"]
     optionvalues = [0, 1]
     webserver.addFormSelector("Chip", "p009_chip", len(optionvalues),
                               options, optionvalues, None, int(choice3))
     return True
Ejemplo n.º 2
0
 def webform_load(self): # create html page for settings
  choice1 = self.taskdevicepluginconfig[0]
  options = ["0x68","0x69"]
  optionvalues = [0x68,0x69]
  webserver.addFormSelector("I2C address","p045_address",len(optionvalues),options,optionvalues,None,int(choice1))
  webserver.addFormNote("Enable <a href='pinout'>I2C bus</a> first, than <a href='i2cscanner'>search for the used address</a>!")
  webserver.addFormPinSelect("Interrupt pin","p045_int_pin",self.taskdevicepin[0])
  webserver.addFormNote("Set an Input-PULLUP pin to INT pin and connect it for fastest results. (optional)")
  choice2 = int(self.taskdevicepluginconfig[1])
  options = ["Movement detection","Acceleration X","Acceleration Y","Acceleration Z","G-force X","G-force Y","G-force Z"]
  optionvalues = [0,4,5,6,7,8,9]
  webserver.addFormSelector("Type","p045_function",len(optionvalues),options,optionvalues,None,choice2)
  if choice2==0:
   webserver.addHtml("<TR><TD><TD>The thresholdvalues (-65535 to 65535, except 0) can be used to set a threshold for one or more<br>")
   webserver.addHtml("axis. The axis will trigger when the range for that axis exceeds the threshold<br>")
   webserver.addHtml("value. A value of 0 disables movement detection for that axis.")
   webserver.addFormNumericBox("Detection threshold X", "p045_threshold_x", self.taskdevicepluginconfig[2], -65535, 65535)
   webserver.addFormNumericBox("Detection threshold Y", "p045_threshold_y", self.taskdevicepluginconfig[3], -65535, 65535)
   webserver.addFormNumericBox("Detection threshold Z", "p045_threshold_z", self.taskdevicepluginconfig[4], -65535, 65535)
   webserver.addFormNumericBox("Min movement time", "p045_threshold_window", self.taskdevicepluginconfig[6], 0, 120)
   webserver.addUnit("s")
  else: # pos
   choice5 = int(self.taskdevicepluginconfig[7])
   options = ["Nothing","Acceleration X","Acceleration Y","Acceleration Z","G-force X","G-force Y","G-force Z"]
   optionvalues = [0,4,5,6,7,8,9]
   webserver.addFormSelector("Type","p045_function2",len(optionvalues),options,optionvalues,None,choice5)
   choice6 = int(self.taskdevicepluginconfig[8])
   webserver.addFormSelector("Type","p045_function3",len(optionvalues),options,optionvalues,None,choice6)
  if self.enabled and self.initialized:
   try:
    webserver.addFormNote("Accel x:"+str(self.mpu.ax)+", y:"+str(self.mpu.ay)+", z:"+str(self.mpu.az))
    webserver.addFormNote("Gyro x:"+str(self.mpu.gx)+", y:"+str(self.mpu.gy)+", z:"+str(self.mpu.gz))
   except:
    pass
  return True
Ejemplo n.º 3
0
 def webform_load(self):  # create html page for settings
     webserver.addFormNote(
         "I2C address is fixed 0x24! You can check it at <a href='i2cscanner'>i2cscan</a> page."
     )
     webserver.addFormPinSelect("Reset pin (optional)", "taskdevicepin3",
                                self.taskdevicepin[0])
     webserver.addFormNote(
         "Set to an Output pin connected to PN532 reset pin or None!")
     return True
Ejemplo n.º 4
0
 def webform_load(self):  # create html page for settings
     webserver.addFormPinSelect("Reset pin (required)", "taskdevicepin1",
                                self.taskdevicepin[0])
     webserver.addFormNote(
         "Set to an Output pin connected to RC522 reset pin!")
     webserver.addFormPinSelect("IRQ pin (required)", "taskdevicepin2",
                                self.taskdevicepin[1])
     webserver.addFormNote(
         "Set to an Input-Pullup pin connected to RC522 IRQ pin!")
     return True
Ejemplo n.º 5
0
 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("<tr><td>Display type:<td>")
  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("<tr><td>Resolution:<td>")
  webserver.addSelector_Head("p036_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("<tr><td>Lines per Frame:<td>")
  webserver.addSelector_Head("p036_linecount",False)
  for l in range(1,5):
   webserver.addSelector_Item(str(l),l,(l==choice5),False)
  webserver.addSelector_Foot()

  choice6 = int(float(self.taskdevicepluginconfig[5])) # transition speed
  options =      ["Very Slow","Slow","Fast","Very Fast","Instant"]
  optionvalues = [1,2,4,8,32]
  webserver.addFormSelector("Scroll","p036_scroll",len(optionvalues),options,optionvalues,None,choice6)

  for l in range(self.P36_Nlines):
   try:
    linestr = self.lines[l]
   except:
    linestr = ""
   webserver.addFormTextBox("Line"+str(l+1),"p036_template"+str(l),linestr,128)

  choice7 = int(float(self.taskdevicepluginconfig[6])) # contrast
  options = ["Low","Medium","High"]
  optionvalues = [self.P36_CONTRAST_LOW, self.P36_CONTRAST_MED, self.P36_CONTRAST_HIGH]
  webserver.addFormSelector("Contrast","p036_contrast",len(optionvalues),options,optionvalues,None,choice7)
  webserver.addFormNumericBox("Try to display # characters per row","p036_charperl",self.taskdevicepluginconfig[7],1,32)
  webserver.addFormNote("Leave it '1' if you do not care")
  webserver.addFormPinSelect("Display button", "p036_button", self.taskdevicepin[0])
  return True
Ejemplo n.º 6
0
 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("<tr><td>I2C chip type:<td>")
  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>!")

  choice3 = self.taskdevicepluginconfig[2] # store resolution
  webserver.addHtml("<tr><td>Resolution:<td>")
  webserver.addSelector_Head("p012_res",False)
  options = ["16x2","20x4"]
  for d in range(len(options)):
   webserver.addSelector_Item(options[d],options[d],(choice3==options[d]),False)
  webserver.addSelector_Foot()

  choice4 = int(float(self.taskdevicepluginconfig[3])) # store linewrap state
  options =      ["Auto","None"]
  optionvalues = [1,0]
  webserver.addFormSelector("Linebreak","p012_break",len(optionvalues),options,optionvalues,None,choice4)

  choice5 = int(float(self.taskdevicepluginconfig[4])) # store backlight state
  options =      ["Enabled","Disabled"]
  optionvalues = [1,0]
  webserver.addFormSelector("Backlight","p012_blight",len(optionvalues),options,optionvalues,None,choice5)

  if "x2" in str(self.taskdevicepluginconfig[2]):
   lc = 2
  else:
   lc = 4
  for l in range(lc):
   try:
    linestr = self.lines[l]
   except:
    linestr = ""
   webserver.addFormTextBox("Line"+str(l+1),"p012_template"+str(l),linestr,128)
  webserver.addFormPinSelect("Display button","taskdevicepin0",self.taskdevicepin[0])
  return True
Ejemplo n.º 7
0
 def webform_load(self):  # create html page for settings
     webserver.addFormNote(
         "I2C address is fixed 0x39! You can check it at <a href='i2cscanner'>i2cscan</a> page."
     )
     webserver.addFormPinSelect("Interrupt pin", "p064_int_pin",
                                self.taskdevicepin[0])
     webserver.addFormNote(
         "Set an Input for using interrupt pin or none if you want to scan gestures continously!"
     )
     choice1 = self.taskdevicepluginconfig[0]
     options = ["Gesture/Dimmer", "Proximity+Light/Dual"]
     optionvalues = [0, 1]
     webserver.addFormSelector("Type", "p064_type", 2, options,
                               optionvalues, None, choice1)
     return True
Ejemplo n.º 8
0
 def webform_load(self): # create html page for settings
  try:
   if self.pcf.externalintsetted:
    self.taskdevicepin[0]=self.pcf.extinta
  except Exception as e:
   pass
  webserver.addFormPinSelect("PCF interrupt","taskdevicepin0",self.taskdevicepin[0])
  webserver.addFormNote("Add one RPI INPUT-PULLUP pin to handle input changes immediately - not needed for interval input reading and output using")
  webserver.addFormNumericBox("Port","p019_pnum",self.taskdevicepluginconfig[0],1,128)
  webserver.addFormNote("First extender 1-8 (0x20), Second 9-16 (0x21)...")
  choice2 = self.taskdevicepluginconfig[1]
  options = ["Input","Output"]
  optionvalues = [0,2]
  webserver.addFormSelector("Type","p019_ptype",len(optionvalues),options,optionvalues,None,int(choice2))
  return True
Ejemplo n.º 9
0
 def webform_load(self):  # create html page for settings
     webserver.addFormPinSelect("MPR interrupt", "taskdevicepin0",
                                self.taskdevicepin[0])
     webserver.addFormNote(
         "Add one RPI INPUT-PULLUP pin to handle input changes immediately - not needed for interval input reading and output using"
     )
     choice1 = self.taskdevicepluginconfig[0]
     options = ["0x5a", "0x5b", "0x5c", "0x5d"]
     optionvalues = [0x5a, 0x5b, 0x5c, 0x5d]
     webserver.addFormSelector("I2C address", "p062_addr",
                               len(optionvalues), options, optionvalues,
                               None, int(choice1))
     webserver.addFormNote(
         "Enable <a href='pinout'>I2C bus</a> first, than <a href='i2cscanner'>search for the used address</a>!"
     )
     webserver.addFormCheckBox("ScanCode", "scancode",
                               self.taskdevicepluginconfig[1])
     return True
Ejemplo n.º 10
0
    def webform_load(self):
        if len(self.colpins) < 1:
            self.colpins = self.DEF_COL_PINS
        if len(self.rowpins) < 1:
            self.rowpins = self.DEF_ROW_PINS
        if len(self.keypad) < 1 or self.kptype == 0:
            self.keypad = self.KEYPAD16
            self.kptype = 16

        optionvalues = [16, 12]
        options = ["4x4", "3x4"]
        webserver.addFormSelector("Type", "p524_type", len(options), options,
                                  optionvalues, None, self.kptype)
        webserver.addFormNote(
            "Setup Row pins as Input-PullDown, Column pins as Output at <a href='pinout'>Pinout page</a>"
        )

        webserver.addFormPinSelect("Row1 pin", "row1pin", self.rowpins[0])
        webserver.addFormPinSelect("Row2 pin", "row2pin", self.rowpins[1])
        webserver.addFormPinSelect("Row3 pin", "row3pin", self.rowpins[2])
        webserver.addFormPinSelect("Row4 pin", "row4pin", self.rowpins[3])
        webserver.addFormPinSelect("Col1 pin", "col1pin", self.colpins[0])
        webserver.addFormPinSelect("Col2 pin", "col2pin", self.colpins[1])
        webserver.addFormPinSelect("Col3 pin", "col3pin", self.colpins[2])
        try:
            cp = self.colpins[3]
        except:
            cp = -1
        webserver.addFormPinSelect("Col4 pin", "col4pin", cp)
        webserver.addFormNote("Col4 only used on 4x4 type!")
        return True
Ejemplo n.º 11
0
    def webform_load(self):
        webserver.addFormNote("IP and Port parameter is not used!")
        webserver.addFormNote("SX127x hardware supported by pyLoRa library")
        webserver.addHtml(
            "<p>Example sender sketches could be find <a href='https://github.com/enesbcs/EasyLora'>here</a>."
        )
        try:
            webserver.addTableSeparator("Hardware settings", 2, 3)
            options = ["PyLora (SX127x)", "Sx1262"]
            optionvalues = [1276, 1262]
            webserver.addFormSelector("LoRa chip type", "loratype",
                                      len(optionvalues), options, optionvalues,
                                      None, self.rtype)
            if self.rtype == 1276:
                try:
                    if BOARD.SPI_BUS:
                        pass
                except:
                    self.rtype = 1262
            if self.rtype == 1276:
                if BOARD.SPI_BUS == 0:
                    webserver.addHtml(
                        "<tr><td>SPI0 selected<td><i>(MOSI=GPIO10, MISO=GPIO9, SCK=GPIO11, NSS=GPIO8)</i>"
                    )
                    spiok = False
                    import gpios
                    if gpios.HWPorts.is_spi_usable(BOARD.SPI_BUS):
                        if gpios.HWPorts.is_spi_enabled(BOARD.SPI_BUS):
                            webserver.addHtml(" - <b>SPI0 enabled</b>")
                            spiok = True
                    if spiok == False:
                        webserver.addHtml(
                            "<tr><td><td>Enable SPI0 first at hardware <a href='pinout'>pinout page</a>!"
                        )
                else:
                    webserver.addHtml(
                        "<tr><td><td>You have modified BOARD constants, so you are an expert!"
                    )
                webserver.addHtml("<tr><td>DIO0 (IRQ)<td>GPIO" +
                                  str(BOARD.DIO0))
                webserver.addHtml("<tr><td>DIO1<td>GPIO" + str(BOARD.DIO1))
                webserver.addHtml("<tr><td>DIO2<td>GPIO" + str(BOARD.DIO2))
                webserver.addHtml("<tr><td>DIO3<td>GPIO" + str(BOARD.DIO3))
                webserver.addHtml("<tr><td>RST<td>GPIO" + str(BOARD.RST))
            elif self.rtype == 1262:
                try:
                    import gpios
                    options1, options2 = gpios.HWPorts.getspilist()
                except Exception as e:
                    options1 = []
                    options2 = []
                webserver.addHtml("<tr><td>SPI line:<td>")
                webserver.addSelector_Head("spi", False)
                for d in range(len(options1)):
                    try:
                        webserver.addSelector_Item("SPI" + str(options1[d]),
                                                   options1[d],
                                                   (self.spi == options1[d]),
                                                   False)
                    except:
                        pass
                webserver.addSelector_Foot()
                webserver.addHtml("<tr><td>SPI device num:<td>")
                webserver.addSelector_Head("spidnum", False)
                for d in range(len(options2)):
                    try:
                        webserver.addSelector_Item(
                            "CE" + str(options2[d]), options2[d],
                            (self.spidnum == options2[d]), False)
                    except:
                        pass
                webserver.addSelector_Foot()
                webserver.addFormPinSelect("DIO1 pin", "dio1", self.dio1)
                webserver.addFormPinSelect("RESET pin", "rst", self.rst)
                webserver.addFormPinSelect("BUSY pin", "busy", self.busy)

            webserver.addTableSeparator("LoRa settings", 2, 3)
            webserver.addFormFloatNumberBox("Frequency", "freq", self.freq,
                                            433, 928)
            webserver.addUnit("Mhz")
            if self.lora is not None:
                try:
                    afreq = self.lora.get_freq()
                except:
                    afreq = "UNINITIALIZED"
                webserver.addFormNote("Current frequency: " + str(afreq) +
                                      " Mhz")
            webserver.addFormNote(
                "Please check local regulations for your selected frequency!")

            options = ["10%", "1%", "0.1%"]
            optionvalues = [10, 100, 1000]
            webserver.addFormSelector("Duty cycle", "duty", len(optionvalues),
                                      options, optionvalues, None, self.duty)
            webserver.addFormNote(
                "Please check your local Duty cycle regulations for your selected frequency!"
            )

            webserver.addFormNumericBox("Spreading factor", "spreading",
                                        self.sf, 6, 12)
            options = [
                "7.8", "10.4", "15.6", "20.8", "31.25", "41.7", "62.5", "125",
                "250", "500"
            ]
            if self.rtype == 1276:
                optionvalues = [
                    BW.BW7_8, BW.BW10_4, BW.BW15_6, BW.BW20_8, BW.BW31_25,
                    BW.BW41_7, BW.BW62_5, BW.BW125, BW.BW250, BW.BW500
                ]
            else:
                optionvalues = [
                    7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500
                ]
            webserver.addFormSelector("Bandwidth", "bw", len(optionvalues),
                                      options, optionvalues, None, self.bw)
            webserver.addUnit("khz")

            options = ["CR4/5", "CR4/6", "CR4/7", "CR4/8"]
            if self.rtype == 1276:
                optionvalues = [
                    CODING_RATE.CR4_5, CODING_RATE.CR4_6, CODING_RATE.CR4_7,
                    CODING_RATE.CR4_8
                ]
            else:
                optionvalues = [5, 6, 7, 8]
            webserver.addFormSelector("Coding rate", "coding",
                                      len(optionvalues), options, optionvalues,
                                      None, self.coding)

            webserver.addFormNumericBox("Sync Word", "sync", self.sync, 0, 255)
            webserver.addHtml("( 0x" + format(self.sync, '02x') + " )")
            webserver.addFormNote(
                "Default 0x12, LoRaWAN is 0x34. Nodes can only communicate each other if uses same sync word!"
            )

            webserver.addFormCheckBox("Enable Sending", "sender",
                                      self.enablesend)
            webserver.addFormNumericBox("Default destination node index",
                                        "defaultnode", self.defaultunit, 0,
                                        255)
            webserver.addFormNote("Default node index for data sending")
        except Exception as e:
            misc.addLog(rpieGlobals.LOG_LEVEL_ERROR, str(e))
        return True