コード例 #1
0
ファイル: _P215_MCP342x.py プロジェクト: enesbcs/rpieasy
 def webform_load(self):  # create html page for settings
     options = [
         'MCP3422', 'MCP3423', 'MCP3424', 'MCP3426', 'MCP3427', 'MCP3428'
     ]
     webserver.addHtml("<tr><td>Type:<td>")
     webserver.addSelector_Head("plugin_215_type", False)
     for o in range(len(options)):
         webserver.addSelector_Item(
             str(options[o]), str(options[o]),
             (str(options[o]) == str(self.taskdevicepluginconfig[0])),
             False)
     webserver.addSelector_Foot()
     choice2 = self.taskdevicepluginconfig[1]
     options = [
         "0x68", "0x69", "0x6A", "0x6B", "0x6C", "0x6D", "0x6E", "0x6F"
     ]
     optionvalues = [0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F]
     webserver.addFormSelector("Address", "plugin_215_addr",
                               len(optionvalues), options, optionvalues,
                               None, int(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]
     options = ["2/3", "1", "2", "4", "8", "16"]
     optionvalues = [(2 / 3), 1, 2, 4, 8, 16]
     webserver.addFormSelector("Gain", "plugin_215_gain", len(optionvalues),
                               options, optionvalues, None, float(choice3))
     choice4 = self.taskdevicepluginconfig[3]
     options = ["CH1", "CH2", "CH3", "CH4"]
     optionvalues = [0, 1, 2, 3]
     webserver.addFormSelector("Channel", "plugin_215_apin", 4, options,
                               optionvalues, None, int(choice4))
     return True
コード例 #2
0
ファイル: _P508_Temper.py プロジェクト: markbirss/rpieasy
 def webform_load(self):
     choice1 = self.taskdevicepluginconfig[0]
     try:
         options = utemper.get_select_list()
     except:
         options = []
     if len(options) > 0:
         webserver.addHtml("<tr><td>Device:<td>")
         webserver.addSelector_Head("p508_addr", True)
         for o in range(len(options)):
             webserver.addSelector_Item(
                 str(options[o][1]) + " " + str(options[o][2]), int(o + 1),
                 (str(o + 1) == str(choice1)), False)
         webserver.addSelector_Foot()
         choice2 = self.taskdevicepluginconfig[1]
         options = [
             "Internal temp", "External temp", "Internal temp+humidity",
             "External temp+humidity"
         ]
         optionvalues = [0, 1, 2, 3]
         webserver.addFormSelector("Sensor type", "p508_type",
                                   len(optionvalues), options, optionvalues,
                                   None, choice2)
     webserver.addFormNote(
         "Without root rights you will not see any Temper device!")
     return True
コード例 #3
0
 def webform_load(self):
     if Settings.SoundSystem["usable"] == False:
         webserver.addHtml(
             "<tr><td><td><font color='red'>The sound system can not be used!</font>"
         )
     else:
         if len(self.languages) < 1:
             try:
                 self.languages = gtts.lang.tts_langs()
             except Exception as e:
                 misc.addLog(rpieGlobals.LOG_LEVEL_ERROR, str(e))
         options = []
         optionvalues = []
         if len(self.languages) > 0:
             for l in self.languages:
                 options.append(l + " " + self.languages[l])
                 optionvalues.append(l)
         webserver.addHtml("<tr><td>Language:<td>")
         webserver.addSelector_Head("p521_lang", False)
         for o in range(len(options)):
             try:
                 webserver.addSelector_Item(
                     options[o], optionvalues[o],
                     (str(optionvalues[o]) == str(self.lang)), False)
             except Exception as e:
                 print(e)
         webserver.addSelector_Foot()
         webserver.addFormNote(
             "Either taskvalueset or say command can be used to speak text."
         )
     return True
コード例 #4
0
ファイル: _P082_GPS.py プロジェクト: markbirss/rpieasy
 def webform_load(self):
     choice1 = self.taskdevicepluginconfig[0]
     options = rpiSerial.serial_portlist()
     if len(options) > 0:
         webserver.addHtml("<tr><td>Serial Device:<td>")
         webserver.addSelector_Head("p082_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"
         )
     else:
         webserver.addFormNote("No serial ports found")
     webserver.addHtml("<tr><td>Fix:<td>")
     time.sleep(2)  #wait to get reply
     webserver.addHtml(str(self.validloc))
     if self.initialized and self.validloc != 0:
         webserver.addHtml("<tr><td>Satellites in use:<td>")
         webserver.addHtml(self.GPSDAT["numSat"])
         webserver.addHtml("<tr><td>HDOP:<td>")
         webserver.addHtml(self.GPSDAT["horDil"])
         webserver.addHtml("<tr><td>UTC Time:<td>")
         gpstime = self.GPSDAT["fixTime"][0:2] + ":" + self.GPSDAT[
             "fixTime"][2:4] + ":" + self.GPSDAT["fixTime"][4:6]
         webserver.addHtml(self.GPSDATE["year"] + "-" +
                           self.GPSDATE["mon"] + "-" + self.GPSDATE["day"] +
                           " " + gpstime)
     return True
コード例 #5
0
ファイル: _P514_Dallas_USB.py プロジェクト: yanhuizen/rpieasy
    def webform_load(self):
        choice0 = self.taskdevicepluginconfig[0]
        options0 = self.serial_portlist()
        if len(options0) > 0:
            webserver.addHtml("<tr><td>Serial Device:<td>")
            webserver.addSelector_Head("p514_addr", False)
            for o in range(len(options0)):
                webserver.addSelector_Item(options0[o], options0[o],
                                           (str(options0[o]) == str(choice0)),
                                           False)
            webserver.addSelector_Foot()

            choice1 = self.taskdevicepluginconfig[1]
            options1 = self.find_dsb_devices()
            if len(options1) > 0:
                webserver.addHtml("<tr><td>Device Address:<td>")
                webserver.addSelector_Head("p514_id", True)
                for o in range(len(options1)):
                    webserver.addSelector_Item(
                        options1[o], options1[o],
                        (str(options1[o]) == str(choice1)), False)
                webserver.addSelector_Foot()
            else:
                webserver.addFormNote("No DS18B20 found on bus!")
        else:
            webserver.addFormNote("No serial port found!")
        webserver.addFormNote(
            "You have to connect the Ds18B20 through an USB-Serial adapter!")
        return True
コード例 #6
0
ファイル: _P501_USBRelay.py プロジェクト: happytm/rpieasy
    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("<tr><td>Device ID:<td>")
            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("<tr><td>Relay number on device:<td>")
            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
コード例 #7
0
 def webform_load(self):
  webserver.addFormNote("IP and Port parameter is not used!")
  try:
   choice1 = self.port
   options = rpiSerial.serial_portlist()
   if len(options)>0:
    webserver.addHtml("<tr><td>Serial Device:<td>")
    webserver.addSelector_Head("ser_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","ser_spd",self.baud,50,4000000)
    webserver.addFormNote("Generic values: 9600, 19200, 38400, 57600, 115200")
#    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")
    webserver.addFormNote("Detected gateway MAC address "+str(self.mac))
    options = []
    optionvalues = []
    for i in range(1,14):
       options.append(str(i))
       optionvalues.append(i)
    webserver.addFormSelector("Wifi channel","wchannel",len(options),options,optionvalues,None,self.wchan)
    webserver.addFormNote("Set the same wifi channel at all nodes!")
    webserver.addWideButton("espnow","ESPNow endpoint management","")
   else:
    webserver.addFormNote("No serial ports found")

  except Exception as e:
   misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"ESPNow GW init error: "+str(e))
  return True
コード例 #8
0
ファイル: _P038_NeoPixel.py プロジェクト: czosnekltd/rpieasy
 def webform_load(self):  # create html page for settings
     choice = self.taskdevicepin[0]
     webserver.addRowLabel("GPIO")
     webserver.addSelector_Head("p038_pin", False)
     if len(Settings.Pinout) > 0:
         webserver.addSelector_Item(Settings.Pinout[0]["name"][0], -1,
                                    (str(choice) == -1), False, "")
     for x in range(len(Settings.Pinout)):
         if Settings.Pinout[x][
                 "altfunc"] == 0 and Settings.Pinout[x]["canchange"] > 0:
             oname = Settings.Pinout[x]["name"][0]
             if "PWM" in oname:
                 if Settings.Pinout[x]["canchange"] == 1:
                     onum = 0
                     try:
                         onum = int(Settings.Pinout[x]["startupstate"])
                         if onum < 1:
                             onum = 0
                     except:
                         pass
                     oname += " (" + Settings.PinStates[onum] + ")"
                 webserver.addSelector_Item(
                     oname, Settings.Pinout[x]["BCM"],
                     (str(choice) == str(Settings.Pinout[x]["BCM"])), False,
                     "")
     webserver.addSelector_Foot()
     webserver.addFormNote(
         "Only PWM-able pins can be used! WARNING: internal audio, I2S and other PWM functions might interfere with NeoPixel, so <a href='pinout'>disable them at the Hardware page</a>"
     )
     webserver.addFormNumericBox("Led Count", "p038_leds",
                                 self.taskdevicepluginconfig[0], 1, 2700)
     webserver.addFormNumericBox("Initial brightness", "p038_bright",
                                 self.taskdevicepluginconfig[1], 0, 255)
     return True
コード例 #9
0
 def webform_load(self): # create html page for settings
  global analogpins,realanalog,rpiok
  if realanalog:
   self.taskdevicepluginconfig[0] = 0
   webserver.addHtml("<tr><td>Analog input pin:<td>")
   webserver.addSelector_Head("p002_ain",False)
   for d in range(len(analogpins)):
    webserver.addSelector_Item(analogpins[d][1],analogpins[d][0],(self.taskdevicepluginconfig[1]==analogpins[d][0]),False)
   webserver.addSelector_Foot()
  elif rpiok:
   webserver.addFormNote("Pin1 is A, Pin2 is B, for wiring, see <a href='https://github.com/simonmonk/pi_analog'>https://github.com/simonmonk/pi_analog</a>")
   choice0 = self.taskdevicepluginconfig[0]
   options = ["Analog","Resistance","Thermistor"]
   optionvalues = [0,1,2]
   webserver.addFormSelector("Result Type","p002_type",len(options),options,optionvalues,None,choice0)
   webserver.addFormFloatNumberBox("C1 capacitor", "p002_c1", self.taskdevicepluginconfig[1], 0, 1000000.0)
   webserver.addUnit("uF")
   webserver.addFormNumericBox("R1 resistor","p002_r1",self.taskdevicepluginconfig[2])
   webserver.addUnit("Ohm")
   webserver.addFormFloatNumberBox("Vt voltage (digital HIGH level)", "p002_vt", self.taskdevicepluginconfig[3], 0, 3.3)
   webserver.addUnit("V")
   webserver.addFormNote("Settings below are only valid for thermistor type!")
   webserver.addFormNumericBox("Thermistor resistance","p002_tr",self.taskdevicepluginconfig[4])
   webserver.addUnit("Ohm")
   webserver.addFormNumericBox("Thermistor Beta","p002_tb",self.taskdevicepluginconfig[5])
  return True
コード例 #10
0
ファイル: _P205_EPD.py プロジェクト: NAzT/rpieasy
    def webform_load(self):  # create html page for settings
        choice1 = str(self.taskdevicepluginconfig[0])  # store display type
        options = [
            '1.54" (200x200)', '1.54"B (200x200)', '1.54"C (150x150)',
            '2.13" (250x122)', '2.13"B (212x104)', '2.7" (264x176)',
            '2.7"B (264x176)', '2.9" (296x128)', '2.9"B (296x128)',
            '4.2" (400x300)', '4.2"B (400x300)', '7.5" (800x480)',
            '7.5"B (800x480)'
        ]
        optionvalues = [
            "154", "154b", "154c", "213", "213b", "270", "270b", "290", "290b",
            "420", "420b", "750", "750b"
        ]
        webserver.addHtml("<tr><td>Display type:<td>")
        webserver.addSelector_Head("p205_type", False)
        for d in range(len(options)):
            webserver.addSelector_Item(options[d], optionvalues[d],
                                       (str(choice1) == str(optionvalues[d])),
                                       False)
        webserver.addSelector_Foot()
        webserver.addFormNote("Enable <a href='pinout'>SPI-0</a> first!")
        webserver.addFormNote(
            "Hardware connection (OLED => Raspberry Pi)<br>VCC->3.3V, GND->GND, SDI->MOSI, SCLK->SCLK, CS-> GPIO8/CE0, D/C->GPIO25 (out), RES->GPIO17 (out), BUSY->GPIO24 (in)"
        )

        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", "p205_rotate", len(optionvalues),
                                  options, optionvalues, None, choice3)

        choice5 = int(float(
            self.taskdevicepluginconfig[4]))  # store line count
        webserver.addHtml("<tr><td>Number of lines:<td>")
        webserver.addSelector_Head("p205_linecount", False)
        for l in range(1, self.P205_Nlines + 1):
            webserver.addSelector_Item(str(l), l, (l == choice5), False)
        webserver.addSelector_Foot()
        webserver.addFormNumericBox("Try to display # characters per row",
                                    "p205_charperl",
                                    self.taskdevicepluginconfig[5], 1, 32)
        webserver.addFormNote("Leave it '1' if you do not care")
        webserver.addFormCheckBox("Clear only used lines", "p205_partialclear",
                                  self.taskdevicepluginconfig[6])
        if choice5 > 0 and choice5 < 9:
            lc = choice5
        else:
            lc = self.P205_Nlines
        for l in range(lc):
            try:
                linestr = self.lines[l]
            except:
                linestr = ""
            webserver.addFormTextBox("Line" + str(l + 1),
                                     "p205_template" + str(l), linestr, 128)

        return True
コード例 #11
0
    def webform_load(self):
        misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG_DEV, "Webform Loading")
        choice1 = self.taskdevicepluginconfig[0]
        try:
            options = rpiSerial.serial_portlist()
        except:
            options = []
        if len(options) > 0:
            webserver.addHtml("<tr><td>Serial Device:<td>")
            webserver.addSelector_Head("p082_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(
                "If using GPIO UART on the RaspberryPi, use 'sudo raspi-config' at the terminal: Select P3- Interface Options, then P6- Serial Port. /n Say NO to Login Shell, then YES to Serial Port, then reboot."
            )
        else:
            webserver.addFormNote("No serial or USB ports found")
        webserver.addFormCheckBox("Enable time decoding", "p082_time",
                                  self.taskdevicepluginconfig[1])

        webserver.addHtml("<tr><td>Fix:<td>")
        time.sleep(2)  # wait to get reply
        webserver.addHtml(str(self.validloc))

        if self.initialized and self.validloc != 0:
            try:
                webserver.addHtml("<tr><td>Satellites in use:<td>")
                webserver.addHtml(self.GPSDAT["numSat"])
                webserver.addHtml("<tr><td>HDOP:<td>")
                webserver.addHtml(self.GPSDAT["horDil"])
            except:
                misc.addLog(
                    rpieGlobals.LOG_LEVEL_ERROR,
                    f"webserver GNSS info failed, initialized {self.initialized}, validloc {self.validloc}"
                )
                pass
            webserver.addHtml("<tr><td>UTC Time:<td>")
            notime = True
            try:
                webserver.addHtml(f"{str(self.gnssdate)} {str(self.gnsstime)}")
                notime = False
            except:
                pass
            if notime:  #fallback
                try:
                    gpstime = self.GPSDAT["fixTime"][0:2] + ":" + self.GPSDAT[
                        "fixTime"][2:4] + ":" + self.GPSDAT["fixTime"][4:6]
                    webserver.addHtml(self.GPSDATE["year"] + "-" +
                                      self.GPSDATE["mon"] + "-" +
                                      self.GPSDATE["day"] + " " + gpstime)
                except:
                    pass

        return True
コード例 #12
0
ファイル: _P509_EvDev.py プロジェクト: yiit/rpieasy
 def webform_load(self):
  choice1 = self.taskdevicepluginconfig[0]
  options = self.get_evdevs()
  if len(options)>0:
   webserver.addHtml("<tr><td>EvDev Device:<td>")
   webserver.addSelector_Head("p509_addr",False)
   for o in range(len(options)):
    webserver.addSelector_Item(options[o],options[o],(str(options[o])==str(choice1)),False)
   webserver.addSelector_Foot()
  else:
   webserver.addFormNote("/dev/input/event* not found")
  return True
コード例 #13
0
ファイル: _P012_LCD.py プロジェクト: yanhuizen/rpieasy
 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
コード例 #14
0
ファイル: _P004_Dallas.py プロジェクト: happytm/rpieasy
 def webform_load(self):
     choice1 = self.taskdevicepluginconfig[0]
     options = self.find_dsb_devices()
     if len(options) > 0:
         webserver.addHtml("<tr><td>Device Address:<td>")
         webserver.addSelector_Head("p004_addr", True)
         for o in range(len(options)):
             webserver.addSelector_Item(options[o], options[o],
                                        (str(options[0]) == 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
コード例 #15
0
ファイル: _P206_PZEM016.py プロジェクト: greg2001/rpieasy
    def webform_load(self):  # create html page for settings
        choice1 = self.taskdevicepluginconfig[0]
        options = rpiSerial.serial_portlist()
        if len(options) > 0:
            webserver.addHtml("<tr><td>Serial Device:<td>")
            webserver.addSelector_Head("p206_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("Address of the USB-RS485 converter")
        else:
            webserver.addFormNote("No serial ports found")
        webserver.addFormNumericBox("Slave address", "p206_saddr",
                                    self.taskdevicepluginconfig[1], 1, 247)

        webserver.addFormNote(
            "Default address is 1. Use 'pzemaddress,[currentaddress],[newaddress]' command to change it"
        )
        if self.taskname == "":
            choice1 = 0
            choice2 = 1
            choice3 = 3
            choice4 = 5
        else:
            choice1 = self.taskdevicepluginconfig[2]
            choice2 = self.taskdevicepluginconfig[3]
            choice3 = self.taskdevicepluginconfig[4]
            choice4 = self.taskdevicepluginconfig[5]
        options = ["None", "Volt", "Amper", "Watt", "Wh", "Hz", "PwrFact"]
        optionvalues = [-1, 0, 1, 3, 5, 7, 8]
        webserver.addFormSelector("Indicator1", "plugin_206_ind0",
                                  len(options), options, optionvalues, None,
                                  choice1)
        webserver.addFormSelector("Indicator2", "plugin_206_ind1",
                                  len(options), options, optionvalues, None,
                                  choice2)
        webserver.addFormSelector("Indicator3", "plugin_206_ind2",
                                  len(options), options, optionvalues, None,
                                  choice3)
        webserver.addFormSelector("Indicator4", "plugin_206_ind3",
                                  len(options), options, optionvalues, None,
                                  choice4)
        return True
コード例 #16
0
ファイル: _P511_RunOSCmd.py プロジェクト: enesbcs/rpieasy
    def webform_load(self):
        cmd1 = str(self.taskdevicepluginconfig[0])
        if '"' in cmd1 or "'" in cmd1:
            cmd1 = urllib.parse.quote(cmd1)
        cmd2 = str(self.taskdevicepluginconfig[1])
        if '"' in cmd2 or "'" in cmd2:
            cmd2 = urllib.parse.quote(cmd2)
        webserver.addFormTextBox("Command 0", "plugin_511_cmd0", cmd1, 512)
        webserver.addFormTextBox("Command 1", "plugin_511_cmd1", cmd2, 512)
        webserver.addFormNote(
            "Specify OS commands that has to be executed at the speficied state (0/1)"
        )
        webserver.addFormCheckBox("Use threading to run in background",
                                  "plugin_511_th",
                                  self.taskdevicepluginconfig[2])
        webserver.addFormCheckBox("Enable parsing command line before execute",
                                  "plugin_511_parse",
                                  self.taskdevicepluginconfig[3])

        options2 = ["None"]
        optionvalues2 = ["_"]
        for t in range(0, len(Settings.Tasks)):
            if (Settings.Tasks[t] and (type(Settings.Tasks[t])
                                       is not bool)) and (t != self.taskindex):
                for v in range(0, Settings.Tasks[t].valuecount):
                    options2.append("T" + str(t + 1) + "-" + str(v + 1) +
                                    " / " + str(Settings.Tasks[t].taskname) +
                                    "-" + str(Settings.Tasks[t].valuenames[v]))
                    optionvalues2.append(str(t) + "_" + str(v))
        webserver.addHtml("<tr><td>Trigger variable:<td>")
        webserver.addSelector_Head("p511_trigger", False)
        ddata = str(self.taskdevicepluginconfig[4])
        for o in range(len(options2)):
            webserver.addSelector_Item(options2[o], optionvalues2[o],
                                       (str(optionvalues2[o]) == str(ddata)),
                                       False)
        webserver.addSelector_Foot()
        webserver.addFormNumericBox("Trigger Low value", "p511_low",
                                    self.taskdevicepluginconfig[5], -65535,
                                    65535)
        webserver.addFormNumericBox("Trigger High value", "p511_high",
                                    self.taskdevicepluginconfig[6], -65535,
                                    65535)
        return True
コード例 #17
0
ファイル: _N007_Jami.py プロジェクト: markbirss/rpieasy
 def webform_load(self):  # create html page for settings
     #  webserver.addFormTextBox("Server","server",self.server,128)
     #  webserver.addFormNumericBox("Port","port",self.port,1,65535)
     choice1 = self.connectionmode
     options = [
         "Direct DBUS session (no root)", "UDP JamiBridge (any user)"
     ]
     optionvalues = [0, 1]
     webserver.addFormSelector("Connection mode", "connmode",
                               len(optionvalues), options, optionvalues,
                               None, choice1)
     webserver.addFormNote(
         "Download and install Jami from <a href='https://jami.net/download/'>https://jami.net/download/</a>. Set up an account by its GUI, after that it can be monitored by RPIEasy."
     )
     webserver.addFormNote(
         "Direct session can only be used if RPIEasy started with the same user as the Jami application!"
     )
     webserver.addFormNote(
         "JamiBridge can be used, IF the external jamibridge.py started with the same user as the Jami application! RPIEasy can be started as root in this case. The jamibridge.py can be found in the same directory as RPIEasy.py, the sample desktop entry can be found at rpieasy/lib/dringctrl/jamibridge.desktop. Please consult your distribution manual for autostarting application with your GUI."
     )
     if self.initialized:
         try:
             status = (self.jami.initialized and self.jami.operational)
             webserver.addHtml("<tr><td>Connected to Jami daemon<td>" +
                               str(status) + "</tr>")
             webserver.addHtml("<tr><td>Account in use<td>" +
                               str(self.jami.account) + "</tr>")
             cl = self.jami.getContactList()
             if len(cl) > 0:
                 webserver.addHtml("<tr><td>Addressee:<td>")
                 webserver.addSelector_Head("destination", False)
                 for i in range(len(cl)):
                     webserver.addSelector_Item(cl[i], cl[i],
                                                (cl[i] == self.dest), False)
                 webserver.addSelector_Foot()
         except Exception as e:
             webserver.addHtml("<tr><td>Status<td>" + str(e) + "</tr>")
     webserver.addHtml(
         "<TR><TD>Body:<TD><textarea name='body' rows='5' cols='80' size=255 wrap='off'>"
     )
     webserver.addHtml(str(self.body))
     webserver.addHtml("</textarea>")
     return True
コード例 #18
0
ファイル: _P201_GenSerial.py プロジェクト: happytm/rpieasy
 def webform_load(self):
  choice1 = self.taskdevicepluginconfig[0]
  options = rpiSerial.serial_portlist()
  if len(options)>0:
   webserver.addHtml("<tr><td>Serial Device:<td>")
   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("<tr><td>Parity:<td>")
   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:
   webserver.addFormNote("No serial ports found")
  return True
コード例 #19
0
 def webform_load(self):  # create html page for settings
     try:
         options2 = ["None"]
         optionvalues2 = ["_"]
         for t in range(0, len(Settings.Tasks)):
             if (Settings.Tasks[t]
                     and (type(Settings.Tasks[t]) is not bool)):
                 for v in range(0, Settings.Tasks[t].valuecount):
                     options2.append("T" + str(t + 1) + "-" + str(v + 1) +
                                     " / " +
                                     str(Settings.Tasks[t].taskname) + "-" +
                                     str(Settings.Tasks[t].valuenames[v]))
                     optionvalues2.append(str(t) + "_" + str(v))
         webserver.addFormNumericBox("Number of relays", "p216_relays",
                                     self.taskdevicepluginconfig[0], 1, 8)
         webserver.addFormNote(
             "Basic fake Tasmota HTTP command API for Android apps: Tasmota Remota, Tasmota Control, HomeSwitch"
         )
         webserver.addFormNote(
             "Select tasks below which you need to access from Android app. Only On/Off supported!"
         )
         for r in range(8):
             webserver.addFormSubHeader("Relay " + str(r + 1))
             webserver.addHtml("<tr><td>Controlled task:<td>")
             ddata = self.datas[r][0]
             webserver.addSelector_Head("p216_tv_" + str(r), False)
             for o in range(len(options2)):
                 webserver.addSelector_Item(
                     options2[o], optionvalues2[o],
                     (str(optionvalues2[o]) == str(ddata)), False)
             webserver.addSelector_Foot()
             webserver.addFormTextBox("Relay friendly name",
                                      "p216_tvn_" + str(r),
                                      self.datas[r][1], 64)
     except Exception as e:
         return False
     return True
コード例 #20
0
ファイル: _P035_IRTX.py プロジェクト: yanhuizen/rpieasy
 def webform_load(self):
     try:
         choice1 = self.taskdevicepluginconfig[0]
         options = find_lirc_devices()
         if len(options) > 0:
             webserver.addHtml("<tr><td>LIRC device<td>")
             webserver.addSelector_Head("p035_dev", False)
             for o in range(len(options)):
                 webserver.addSelector_Item(
                     options[o], options[o],
                     (str(options[o]) == str(choice1)), False)
             webserver.addSelector_Foot()
         else:
             webserver.addFormNote("/dev/lirc* not found")
             return False
         webserver.addFormNote(
             "Select a transceiver LIRC device (lirc-tx)! Do not forget to set the Data pin to IR-PWM or IR-TX <a href='pinout'>at pinout settings</a>!"
         )
         webserver.addFormNote(
             "According to documentation, only GPIO18 or GPIO12 is supported as IR-PWM!"
         )
     except Exception as e:
         print(e)
     return True
コード例 #21
0
ファイル: _P208_FPM.py プロジェクト: markbirss/rpieasy
 def webform_load(self): # create html page for settings
  choice1 = self.taskdevicepluginconfig[0]
  options = rpiSerial.serial_portlist()
  if len(options)>0:
   webserver.addHtml("<tr><td>Serial Device:<td>")
   webserver.addSelector_Head("p208_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("Address of the FPM serial port")
  else:
   webserver.addFormNote("No serial ports found")
  options = ["None", "Valid", "Position","SHA2"]
  optionvalues = [0, 1, 2,3]
  webserver.addFormSelector("Indicator1","plugin_208_ind0",len(options),options,optionvalues,None,self.taskdevicepluginconfig[1])
  webserver.addFormSelector("Indicator2","plugin_208_ind1",len(options),options,optionvalues,None,self.taskdevicepluginconfig[2])
  webserver.addFormSelector("Indicator3","plugin_208_ind2",len(options),options,optionvalues,None,self.taskdevicepluginconfig[3])
  if self.enabled and self.initialized:
   try:
    webserver.addFormNote("Stored fingerprints: "+ str(self.fp.getTemplateCount())+"/"+str(self.fp.getStorageCapacity()))
   except:
    pass
  webserver.addHtml("<tr><td><a href='/finger'>Management page</a>")
  return True
コード例 #22
0
    def webform_load(self):
        choice1 = self.taskdevicepluginconfig[0]
        options = rpiSerial.serial_portlist()
        webserver.addFormNote(
            "For RPI use 'raspi-config' tool: 5- Interfacing Options-P6 Serial- (Kernel logging disabled + serial port hardware enabled) before enable this plugin"
        )
        if len(options) > 0:
            webserver.addHtml("<tr><td>Serial Device:<td>")
            webserver.addSelector_Head("p049_addr", False)
            for o in range(len(options)):
                webserver.addSelector_Item(options[o], options[o],
                                           (str(options[o]) == str(choice1)),
                                           False)
            webserver.addSelector_Foot()

            choice2 = self.taskdevicepluginconfig[1]
            options = ["Enabled (Normal)", "Disabled"]
            optionvalues = [0, 1]
            webserver.addFormSelector("Auto Base Calibration", "p049_abc",
                                      len(optionvalues), options, optionvalues,
                                      None, int(choice2))
        else:
            webserver.addFormNote("No serial ports found")
        return True
コード例 #23
0
ファイル: _P016_IR.py プロジェクト: yanhuizen/rpieasy
 def webform_load(self):
     try:
         choice1 = self.taskdevicepluginconfig[0]
         options = find_lirc_devices()
         if len(options) > 0:
             webserver.addHtml("<tr><td>LIRC device<td>")
             webserver.addSelector_Head("p016_dev", False)
             for o in range(len(options)):
                 webserver.addSelector_Item(
                     options[o], options[o],
                     (str(options[o]) == str(choice1)), False)
             webserver.addSelector_Foot()
         else:
             webserver.addFormNote("/dev/lirc* not found")
             return False
         webserver.addFormNote(
             "Select a receiver LIRC device (lirc-rx)! Do not forget to set the Data pin to IR-RX <a href='pinout'>at pinout settings</a>!"
         )
     except Exception as e:
         print(e)
     try:
         supprot = get_ir_supported_protocols()
         enprot = get_ir_enabled_protocols()
         webserver.addRowLabel("Enabled protocols")
         for s in range(len(supprot)):
             webserver.addHtml(
                 "<label class='container' style='height:30px'>" +
                 supprot[s] + " <input type='checkbox' id='")
             webserver.addHtml("_" + supprot[s] + "' name='_" + supprot[s] +
                               "'")
             if (supprot[s] in enprot):
                 webserver.addHtml(" checked")
             webserver.addHtml("><span class='checkmark'></span></label>")
     except Exception as e:
         print(e)
     return True
コード例 #24
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
コード例 #25
0
ファイル: _P023_OLED.py プロジェクト: yiit/rpieasy
 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("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("<tr><td>Resolution:<td>")
  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("<tr><td>Number of lines:<td>")
  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)

  return True
コード例 #26
0
ファイル: _P053_PMSx003.py プロジェクト: enesbcs/rpieasy
 def webform_load(self):
     choice1 = self.taskdevicepluginconfig[0]
     options = rpiSerial.serial_portlist()
     if len(options) > 0:
         webserver.addHtml("<tr><td>Serial Device:<td>")
         webserver.addSelector_Head("p053_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"
         )
     else:
         webserver.addFormNote("No serial ports found")
     sensortypes = [
         "PMSx003", "PMS3003", "PMS5003S", "PMS5003ST", "PMS5003T",
         "SDS01x", "SDS198", "HPMA115S0", "HPMA115C0", "SPS30", "MCU680"
     ]
     webserver.addHtml("<tr><td>Sensor type:<td>")
     webserver.addSelector_Head("p053_sensor", False)
     for o in range(len(sensortypes)):
         webserver.addSelector_Item(
             sensortypes[o], sensortypes[o],
             (str(sensortypes[o]) == str(self.taskdevicepluginconfig[5])),
             False)
     webserver.addSelector_Foot()
     options = [
         "None", "PM01", "PM25", "PM04", "PM10", "PM100", "Temperature",
         "Relative humidity"
     ]
     optionvalues = [
         "None", "pm01", "pm25", "pm04", "pm10", "pm100", "temp", "rhum"
     ]
     for os in range(1, 5):
         webserver.addHtml("<tr><td>Value" + str(os) + ":<td>")
         webserver.addSelector_Head("p053_ind" + str(os), False)
         for o in range(len(options)):
             webserver.addSelector_Item(options[o], optionvalues[o], (str(
                 optionvalues[o]) == str(self.taskdevicepluginconfig[os])),
                                        False)
         webserver.addSelector_Foot()
     return True
コード例 #27
0
ファイル: _P212_Dash.py プロジェクト: markbirss/rpieasy
    def webform_load(self):  # create html page for settings
        webserver.addFormCheckBox("Use standard HTML head", "p212_head",
                                  self.taskdevicepluginconfig[2])
        try:
            sp = Settings.AdvSettings["startpage"]
        except:
            sp = "/"
        webserver.addFormCheckBox("Set as startpage", "p212_start",
                                  (sp == "/dash"))
        webserver.addHtml("<tr><td>Columns:<td>")
        webserver.addSelector_Head("p212_cols", False)
        for o in range(7):
            webserver.addSelector_Item(
                str(o), o, (str(o) == str(self.taskdevicepluginconfig[0])),
                False)
        webserver.addSelector_Foot()

        webserver.addHtml("<tr><td>Rows:<td>")
        webserver.addSelector_Head("p212_rows", False)
        for o in range(16):
            webserver.addSelector_Item(
                str(o), o, (str(o) == str(self.taskdevicepluginconfig[1])),
                False)
        webserver.addSelector_Foot()

        if int(self.taskdevicepluginconfig[0]) > 0 and int(
                self.taskdevicepluginconfig[1]) > 0:
            if self.enabled:
                webserver.addHtml(
                    "<tr><td>Dashboard address:</td><td><a href='dash'>/dash</a></td></tr>"
                )
            options1 = [
                "None", "Text", "Binary input", "Switch output", "Meter",
                "Gauge", "Slider output", "Select output"
            ]
            optionvalues1 = [-1, 0, 1, 2, 3, 4, 5, 6]
            options2 = ["None"]
            optionvalues2 = ["_"]
            for t in range(0, len(Settings.Tasks)):
                if (Settings.Tasks[t]
                        and (type(Settings.Tasks[t]) is not bool)):
                    for v in range(0, Settings.Tasks[t].valuecount):
                        options2.append("T" + str(t + 1) + "-" + str(v + 1) +
                                        " / " +
                                        str(Settings.Tasks[t].taskname) + "-" +
                                        str(Settings.Tasks[t].valuenames[v]))
                        optionvalues2.append(str(t) + "_" + str(v))

            for r in range(int(self.taskdevicepluginconfig[1])):
                for c in range(int(self.taskdevicepluginconfig[0])):
                    offs = (r * int(self.taskdevicepluginconfig[0])) + c
                    try:
                        adata = self.celldata[offs]
                    except:
                        adata = {}
                    dtype = -1
                    if "type" in adata:
                        dtype = int(adata["type"])
                    webserver.addHtml("<tr><td><b>Cell" + str(offs) + " (y" +
                                      str(r) + "x" + str(c) + ")</b><td>")

                    dname = ""
                    if "name" in adata:
                        dname = str(adata["name"])
                    webserver.addFormTextBox("Name overwrite",
                                             "p212_names_" + str(offs), dname,
                                             64)

                    webserver.addFormSelector("Type", "p212_type_" + str(offs),
                                              len(options1), options1,
                                              optionvalues1, None, dtype)
                    webserver.addHtml("<tr><td>Data source:<td>")
                    ddata = "_"
                    if "data" in adata:
                        ddata = str(adata["data"])
                    webserver.addSelector_Head("p212_data_" + str(offs), False)
                    for o in range(len(options2)):
                        webserver.addSelector_Item(
                            options2[o], optionvalues2[o],
                            (str(optionvalues2[o]) == str(ddata)), False)
                    webserver.addSelector_Foot()

                    if dtype in (0, 4):
                        try:
                            udata = str(adata["unit"])
                        except:
                            udata = ""
                        webserver.addFormTextBox("Unit",
                                                 "p212_unit_" + str(offs),
                                                 udata, 16)
                    if dtype in (3, 4, 5):
                        try:
                            umin = float(adata["min"])
                        except:
                            umin = 0
                        try:
                            umax = float(adata["max"])
                        except:
                            umax = 100
                        webserver.addFormFloatNumberBox(
                            "Min value", "p212_min_" + str(offs), umin,
                            -65535.0, 65535.0)
                        webserver.addFormFloatNumberBox(
                            "Max value", "p212_max_" + str(offs), umax,
                            -65535.0, 65535.0)
                    elif dtype == 6:
                        try:
                            uon = str(adata["optionnames"])
                        except:
                            uon = ""
                        try:
                            uopt = str(adata["options"])
                        except:
                            uopt = ""
                        webserver.addFormTextBox(
                            "Option name list",
                            "p212_optionnames_" + str(offs), uon, 1024)
                        webserver.addFormTextBox("Option value list",
                                                 "p212_options_" + str(offs),
                                                 uopt, 1024)
                        webserver.addFormNote(
                            "Input comma separated values for selector boxes!")
        return True
コード例 #28
0
ファイル: _C020_LoraDirect.py プロジェクト: jabastien/rpieasy
    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