def __init__(self): # general init self.i2c_channels = [] # 0,1 self.i2c_initialized = False self.i2cbus = None self.spi_channels = [] # 0,1 self.spi_cs = [0,0] self.serial = 0 self.bluetooth = 0 # 0:disabled,1:enabled with SW miniUART,2:enabled with HW UART self.wifi = 0 # 0:disabled,1:enabled self.audio = 0 self.i2s = 0 self.pwm = [0,0] # 0.byte:pwm0 pin, 1.byte:pwm1 pin, no more self.rtc = "" # /lib/udev/hwclock-set self.pwmo = [] for p in range(22): self.pwmo.append({"pin":0,"o":False}) try: rpitype = OS.getRPIVer() except: rpitype=[] try: po = rpitype["pins"] except: po = "0" try: bta = int(rpitype["bt"]) except: bta = 0 try: wf = int(rpitype["wlan"]) except: wf = 0 try: iram = rpitype["ram"] except: iram = "0" try: GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) self.gpioinit = True except: print("GPIO init failed") self.gpioinit = False self.pinnum = po self.internalwlan = (wf==1) self.internalbt = (bta==1) self.gpumin = 16 self.gpumax = self.gpumin if "256m" in iram.lower(): self.gpumax = 192 elif "512m" in iram.lower(): self.gpumax = 448 elif "1m" in iram.lower(): self.gpumax = 944 self.gpumem = self.gpumin
def hardwareInit(): print("Init hardware...") rpieGlobals.osinuse = misc.getosname(0) rpieGlobals.ossubtype = misc.getsupportlevel(1) pinout = "0" if rpieGlobals.osinuse == "linux": import linux_os as OS import linux_network as Network Settings.NetMan = Network.NetworkManager() if len(OS.getsounddevs()) > 0: Settings.SoundSystem["usable"] = True if rpieGlobals.ossubtype == 10: rpv = OS.getRPIVer() if rpv: pinout = rpv["pins"] misc.addLog( rpieGlobals.LOG_LEVEL_DEBUG, str(rpv["name"]) + " " + str(rpv["pins"]) + " pins") print("Load network settings...") Settings.loadnetsettings() Settings.NetMan.networkinit() print("Load GPIO settings...") if pinout != "0": Settings.loadpinout() if pinout == "40" and len(Settings.Pinout) != 41: Settings.Pinout = gpios.PINOUT40 elif pinout == "26R1" and len(Settings.Pinout) != 27: for p in range(27): Settings.Pinout.append(gpios.PINOUT40[p]) for p in range(len(gpios.PINOUT26R1_DELTA)): pi = int(gpios.PINOUT26R1_DELTA[p]["ID"]) Settings.Pinout[pi] = gpios.PINOUT26R1_DELTA[p] elif pinout == "26R2" and len(Settings.Pinout) != 27: for p in range(27): Settings.Pinout.append(gpios.PINOUT40[p]) for p in range(len(gpios.PINOUT26R2_DELTA)): pi = int(gpios.PINOUT26R2_DELTA[p]["ID"]) Settings.Pinout[pi] = gpios.PINOUT26R2_DELTA[p] perror = False try: gpios.HWPorts.readconfig() except: perror = True if perror or len(Settings.Pinout) < 26: misc.addLog(rpieGlobals.LOG_LEVEL_ERROR, "Your GPIO can not be identified!") Settings.Pinout = [] else: gpios.HWPorts.initpinstates() else: Settings.Pinout = [] return 0
def hardwareInit(): #print("Init hardware...") rpieGlobals.osinuse = misc.getosname(0) rpieGlobals.ossubtype = misc.getsupportlevel(1) pinout = "0" if rpieGlobals.osinuse == "linux": import linux_os as OS import linux_network as Network Settings.NetMan = Network.NetworkManager() if len(OS.getsounddevs()) > 0: Settings.SoundSystem["usable"] = True if rpieGlobals.ossubtype == 10: rpv = OS.getRPIVer() if rpv: pinout = rpv["pins"] Settings.loadnetsettings() Settings.NetMan.networkinit() if pinout != "0": Settings.loadpinout() if pinout == "40" and len(Settings.Pinout) != 41: Settings.Pinout = gpios.PINOUT40 elif pinout == "26R1" and len(Settings.Pinout) != 27: for p in range(27): Settings.Pinout.append(gpios.PINOUT40[p]) for p in range(len(gpios.PINOUT26R1_DELTA)): pi = int(gpios.PINOUT26R1_DELTA[p]["ID"]) Settings.Pinout[pi] = gpios.PINOUT26R1_DELTA[p] elif pinout == "26R2" and len(Settings.Pinout) != 27: for p in range(27): Settings.Pinout.append(gpios.PINOUT40[p]) for p in range(len(gpios.PINOUT26R2_DELTA)): pi = int(gpios.PINOUT26R2_DELTA[p]["ID"]) Settings.Pinout[pi] = gpios.PINOUT26R2_DELTA[p] gpios.HWPorts.readconfig() gpios.HWPorts.initpinstates() else: Settings.Pinout = [] return 0
def hardwareInit(): print("Init hardware...") rpieGlobals.osinuse = misc.getosname(0) rpieGlobals.ossubtype = misc.getsupportlevel(1) pinout = "0" if rpieGlobals.osinuse=="linux": import linux_os as OS import linux_network as Network Settings.NetMan = Network.NetworkManager() if len(OS.getsounddevs())>0: Settings.SoundSystem["usable"]=True if rpieGlobals.ossubtype == 10: # rpi rpv = OS.getRPIVer() if rpv: pinout = rpv["pins"] misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(rpv["name"])+" "+str(rpv["pins"])+" pins") elif rpieGlobals.ossubtype == 3: # opi opv = OS.getarmbianinfo() if opv: pinout = opv["pins"] misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(opv["name"])+" "+str(opv["pins"])+" pins") hwtype = rpieGlobals.ossubtype if pinout=="0": try: import lib.lib_ftdigpios as ftdigpio # check for ftdi hwtype? if ftdigpio.get_ftdi_devices(0)>0: hwtype = 19 pinout = "ftdi" except Exception as e: print(e) print("Load network settings...") Settings.loadnetsettings() Settings.NetMan.networkinit() print("Load GPIO settings...") if pinout != "0": Settings.loadpinout() try: gpios.preinit(hwtype) # create HWPorts variable except Exception as e: print("init",e) if (("40" in pinout) and (len(Settings.Pinout)<41)) or (("26" in pinout) and (len(Settings.Pinout)<27)) or (pinout=="ftdi" and len(Settings.Pinout)<1): print("Creating new pinout") try: gpios.HWPorts.createpinout(pinout) except Exception as e: print("Pinout creation error:",e) perror = False try: gpios.HWPorts.readconfig() except Exception as e: # print(e) # debug perror = True if perror or len(Settings.Pinout)<1: misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"Your GPIO can not be identified!") Settings.Pinout = [] else: gpios.HWPorts.initpinstates() else: Settings.Pinout = [] return 0
def hardwareInit(): print("Init hardware...") rpieGlobals.osinuse = misc.getosname(0) rpieGlobals.ossubtype = misc.getsupportlevel(1) pinout = "0" if rpieGlobals.osinuse=="linux": import linux_os as OS import linux_network as Network if OS.isAlreadyRunning()>1: time.sleep(1) print("\nAn RPIEasy is already running! Close that first!") sys.exit(0) Settings.NetMan = Network.NetworkManager() if len(OS.getsounddevs())>0: Settings.SoundSystem["usable"]=True if rpieGlobals.ossubtype == 10: # rpi rpv = OS.getRPIVer() if rpv: pinout = rpv["pins"] misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(rpv["name"])+" "+str(rpv["pins"])+" pins") elif rpieGlobals.ossubtype == 9: # rockpi ropv = OS.getRockPIVer() if ropv: pinout = ropv["pins"] misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(ropv["name"])+" "+str(ropv["pins"])+" pins") elif rpieGlobals.ossubtype == 3: # opi opv = OS.getarmbianinfo() if opv: pinout = opv["pins"] misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(opv["name"])+" "+str(opv["pins"])+" pins") if rpieGlobals.osinuse=="windows": print("Windows OS is not supported") import win_os as OS import win_network as Network Settings.NetMan = Network.NetworkManager() Settings.SoundSystem["usable"]=False hwtype = rpieGlobals.ossubtype if pinout=="0": try: import lib.lib_ftdigpios as ftdigpio # check for ftdi hwtype? ftdigpio.correctdependencies() if ftdigpio.get_ftdi_devices(0)>0: hwtype = 19 pinout = "ftdi" except Exception as e: print(e) print("Load network settings...") Settings.loadnetsettings() Settings.NetMan.networkinit() print("Load GPIO settings...") if pinout != "0": Settings.loadpinout() try: gpios.preinit(hwtype) # create HWPorts variable except Exception as e: print("init",e) if (("40" in pinout) and (len(Settings.Pinout)<41)) or (("26" in pinout) and (len(Settings.Pinout)!=27) and (len(Settings.Pinout)!=53) ) or (pinout=="ftdi" and len(Settings.Pinout)<1): print("Creating new pinout") try: gpios.HWPorts.createpinout(pinout) except Exception as e: print("Pinout creation error:",e) perror = False try: gpios.HWPorts.readconfig() except Exception as e: perror = True if perror or len(Settings.Pinout)<1: misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"Your GPIO can not be identified!") Settings.Pinout = [] else: gpios.HWPorts.initpinstates() else: Settings.Pinout = [] return 0