Пример #1
0
def setup():
    webiopi.debug("Basic script - Setup")
    # Setup GPIOs
    GPIO.setFunction(LED_GREEN, GPIO.OUT)
    GPIO.digitalWrite(LED_GREEN, GPIO.LOW)

    webiopi.debug("Set Green LED as ON OFF")

    # # # X Axis
    # GPIO.setFunction(STEPPER_STEP_PIN_X, GPIO.OUT)
    # GPIO.setFunction(STEPPER_DIR_PIN_X, GPIO.OUT)
    # GPIO.setFunction(ENDSTOP_PIN_X, GPIO.IN)
    # #
    # # # Y Axis
    # GPIO.setFunction(STEPPER_STEP_PIN_Y, GPIO.OUT)
    # GPIO.setFunction(STEPPER_DIR_PIN_Y, GPIO.OUT)
    # GPIO.setFunction(ENDSTOP_PIN_Y, GPIO.IN)
    # #
    # # # Z Axis
    # GPIO.setFunction(STEPPER_STEP_PIN_Z, GPIO.OUT)
    # GPIO.setFunction(STEPPER_DIR_PIN_Z, GPIO.OUT)
    # GPIO.setFunction(ENDSTOP_PIN_Z, GPIO.IN)

    logging_config.debug_disable()

    do_line("x5.0 y5.0 z5.0")
    do_line("x0.0 y0.0 z0.0")
    print("Tested XYZ Motion +5mm and Back")
Пример #2
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(M1_A, GPIO.IN)
    GPIO.setFunction(M1_B, GPIO.IN)
    GPIO.setFunction(M2_A, GPIO.IN)
    GPIO.setFunction(M2_B, GPIO.IN)
Пример #3
0
def setup():
    webiopi.debug("setting up in script")
    GPIO.setFunction(17, GPIO.OUT)
    GPIO.setFunction(22, GPIO.OUT)
    pygame.mixer.init(44100, -16, 1, 1024)
    if AMBIANCE:
        startAmbiance()
Пример #4
0
def Load41(val):
    global brake_free
    f = open(path + filename41, "r")
    brake_free = int(f.read())
    f.close()
    webiopi.debug(brake_free)
    return "%d" % (brake_free)
Пример #5
0
def ChangeVoltageLevel(strLevel):
    webiopi.debug("ChangeVoltageLevel( %s )" % (strLevel))
    global g_fRatio
    g_fRatio = int(strLevel) * 0.05
    # ratio = level * 0.05 : level=10 -> ratio=0.5 -> InputVoltage=2.5[V](When VM=5[V]).
    webiopi.debug("Ratio : %f" % (g_fRatio))
    ChangeDriveMode(g_strMode)
Пример #6
0
def setup():
    webiopi.debug("setup")

    GPIO.setFunction(leftMotorDrivePWM1, GPIO.PWM)
    GPIO.setFunction(leftMotorDrivePWM2, GPIO.PWM)
    GPIO.setFunction(rightMotorDrivePWM1, GPIO.PWM)
    GPIO.setFunction(rightMotorDrivePWM2, GPIO.PWM)
Пример #7
0
def stop():
    webiopi.debug("stop")

    GPIO.pwmWrite(leftMotorDrivePWM1, GPIO.LOW)
    GPIO.pwmWrite(leftMotorDrivePWM2, GPIO.LOW)
    GPIO.pwmWrite(rightMotorDrivePWM1, GPIO.LOW)
    GPIO.pwmWrite(rightMotorDrivePWM2, GPIO.LOW)
Пример #8
0
def turnRight():
    webiopi.debug("turnRight")

    GPIO.pwmWrite(leftMotorDrivePWM1, GPIO.HIGH)
    GPIO.pwmWrite(leftMotorDrivePWM2, GPIO.LOW)
    GPIO.pwmWrite(rightMotorDrivePWM1, GPIO.LOW)
    GPIO.pwmWrite(rightMotorDrivePWM2, GPIO.HIGH)
Пример #9
0
def reverse():
    webiopi.debug("reverse")

    GPIO.pwmWrite(leftMotorDrivePWM1, GPIO.HIGH)
    GPIO.pwmWrite(leftMotorDrivePWM2, GPIO.LOW)
    GPIO.pwmWrite(rightMotorDrivePWM1, GPIO.HIGH)
    GPIO.pwmWrite(rightMotorDrivePWM2, GPIO.LOW)
Пример #10
0
def setup():
    webiopi.debug("Blink script - Setup")
    # Setup GPIOs
    GPIO.setFunction(LED0, GPIO.PWM)
    # GPIO.setFunction(LED1, GPIO.OUT)

    GPIO.pwmWrite(LED0, 0.5)  # set to 50% ratio
Пример #11
0
def runAlarm():
    alarm_time_file = '/home/pi/py/webcontrol/files/alarm_time.txt'
    try:
        fin_time = open(alarm_time_file, 'r')
        alarm_time = fin_time.read()
        fin_time.close()
    except IOError:
        webiopi.debug("Cannot find file: " + alarm_time_file)
        webiopi.debug("file read error")

    alarm_flag_file = '/home/pi/py/webcontrol/files/alarm_flag.txt'
    try:
        fin_flag = open(alarm_flag_file, 'r')
        alarm_flag = fin_flag.read()
        fin_flag.close()
    except IOError:
        webiopi.debug("Cannot find file: " + alarm_flag_file)
        webiopi.debug("file read error")

    fmt = "%I:%M:%S"
    t = time.localtime()
    current_time = time.strftime(fmt, t)

    if (current_time[0:5] == alarm_time[0:5]
            and alarm_flag[0:8] == "ALARM_ON"):
        webiopi.debug("Alarm Start!!! " + alarm_time_file[0:5])
        minifigure_control.jong_strike()
        minifigure_control.book_strike()
        minifigure_control.jing_strike()
        sleep(1)
    sleep(0.1)
Пример #12
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(LED1, GPIO.IN)
    GPIO.setFunction(LsrPin, GPIO.IN)
    GPIO.setFunction(Buzz, GPIO.IN)
    os.system("sudo service motion stop")
Пример #13
0
def setup():
    try:
        global refreshTimeInterval
        refreshTimeInterval = 0

    except Exception as Err:
        webiopi.debug('%s' % Err)
Пример #14
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(SWITCH, GPIO.IN)
    GPIO.setFunction(SERVO, GPIO.IN)
    GPIO.setFunction(LED0, GPIO.IN)
    GPIO.setFunction(LED1, GPIO.IN)
Пример #15
0
def setup():
    webiopi.debug("Loading config")
    global config
    try:
        config = ConfigFile('GardenPyConfig.pyc').load()
    except (IOError, UnicodeDecodeError):
        config = RootConfig()
Пример #16
0
def setup():
    webiopi.debug("Blink script - Setup")
    # Setup GPIOs

    GPIO.setFunction(LED0, GPIO.OUT)
    GPIO.setFunction(RELAY1, GPIO.OUT)
    GPIO.setFunction(RELAY2, GPIO.OUT)
Пример #17
0
def loop():

    webiopi.debug("Loop")
    # Toggle LED each 1 second
    value = not GPIO.digitalRead(LED_GREEN)
    GPIO.digitalWrite(LED_GREEN, value)
    webiopi.sleep(1)
def Relaythread(pin,status,sec,delay):
  relay = relay1
  #Select relay object and set logic pin
  if int(pin) <= 8:
    relay = relay1
    inPin = int(pin)-1
  elif int(pin) <= 16:
    relay = relay2
    inPin = int(pin)-9 
  elif int(pin) <= 24:
    relay = relay3
    inPin = int(pin)-17 
  else:
    webiopi.debug(tempList[0] + " is not a valid command")
    return "ERROR - " + tempList[0] + " is not a valid command"
    
  #Handle delay in needed
  if (str(delay) != "0"):
    webiopi.sleep(float(delay))
    
  #Write desired status
  webiopi.debug("Writing to pin " + str(inPin))
  relay.digitalWrite(inPin, status)
  
  #If interval needed then wait and toggle
  if (str(sec) != "0"):
    webiopi.sleep(float(sec))
    if (status == ON):
      relay.digitalWrite(inPin, OFF)
    else:
      relay.digitalWrite(inPin, ON)
Пример #19
0
def setup():
    webiopi.debug("Script with macros - Setup")
    # Setup GPIOs
    GPIO.setFunction(RED, GPIO.PWM)
    GPIO.setFunction(GREEN, GPIO.PWM)
    GPIO.setFunction(BLUE, GPIO.PWM)
    GPIO.setup(SWITCH, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Пример #20
0
def setup():
    webiopi.debug("Script with macros - Setup")
    # Setup GPIOs
    GPIO.setFunction(17, GPIO.OUT)
    GPIO.setFunction(0, GPIO.OUT)

    GPIO.output(17, GPIO.HIGH)
Пример #21
0
def destroy():
    webiopi.debug("Basic script - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(SWITCH, GPIO.IN)
    GPIO.setFunction(SERVO, GPIO.IN)
    GPIO.setFunction(LED0, GPIO.IN)
    GPIO.setFunction(LED1, GPIO.IN)
Пример #22
0
def measureWU(api_key, index, lat, lon):
    # get WeatherUnderground data
    try:
        webiopi.debug("Starting WU measure")
        url = "http://api.wunderground.com/api/" + api_key + "/conditions/q/" + lat + "," + lon + ".json"
        r = requests.get(url, timeout=2)
        data = r.json()
        dat = data["current_observation"]
        try:
            temp = str(round(dat["temp_c"], 1))
        except:
            temp = "U"
        #hr = str(round(dat["relative_humidity"], 1))
        match = re.search('([\d\.]+)%', dat["relative_humidity"])
        if match:
            hr = match.group(1)
        else:
            hr = "U"
        match = re.search('([\d\.]+)', dat["precip_1hr_metric"])
        if match:
            rain = match.group(1)
        else:
            rain = "U"
        #match = re.search('([\d\.]+)%', dat["clouds"]["all"])
        clouds = "0"
    except:
        temp = "U"
        hr = "U"
        clouds = "U"
        rain = "U"
        webiopi.info("! WU request error ! %s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
    finally:
        values = [temp, hr, clouds, rain]
        webiopi.debug("WU values = %s" % values)
        return values[index]
Пример #23
0
def measureDHT(DHTtype, gpio, index):
    try:
        script = os.path.join(eziopi_dir, "scripts/adafruit_dht")
        tries = 5
        for i in range(tries):
            val = str(subprocess.check_output([script, DHTtype, str(gpio)]))
            match = re.search('Temp.+\s([\d\.]+)\s.+Hum.+\s([\d\.]+)\s%', val)
            if match:
                temp, hr = match.group(1), match.group(2)
                webiopi.debug("DHT22 measure %s: temp=%s hr=%s" % (str(i+1), temp, hr))
                break
            else:
                # Erreur mesure gpioDHT22
                if i == tries-1:
                    temp = "U"
                    hr = "U"
                    webiopi.info("! DHT22 error after %s tries ! - stop trying" % str(i+1))
                else:
                    time.sleep(2)
    except:
        temp = "U"
        hr = "U"
        webiopi.exception("! DHT22 error ! %s" % sys.exc_info()[1])
    finally:
        values = [temp, hr]
        return values[index]
Пример #24
0
 def turn_on_pc(self):
     try:
         webiopi.debug(self.address)
         resp = requests.get(self.address+  "/pc_on")
     except:
         webiopi.debug("connection error with turn_on_pc")
         return 0
Пример #25
0
def ResetTempRange():
    webiopi.debug("Reset All Temp Range Macro...")
    global tShopHigh
    global tShopLo
    global tGpuHigh
    global tGpuLow
    global tCpuHigh
    global tCpuLow
    fahrenheit = t.getFahrenheit()
    GPUfahrenheit = float(get_gpu_temp())
    CPUfahrenheit = float(get_cpu_temp())
    tShopHigh = fahrenheit
    tShopLow = fahrenheit
    tGpuHigh = GPUfahrenheit
    tGpuLow = GPUfahrenheit
    tCpuHigh = CPUfahrenheit
    tCpuLow = CPUfahrenheit
    # LCD Background Cyan
    GPIO.pwmWrite(RED, 1.0)
    GPIO.pwmWrite(GREEN, 0.0)
    GPIO.pwmWrite(BLUE, 0.0)
    # Display current temperature on LCD display
    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    lcd.lcd_string("Temp Ranges Reset")
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    lcd.lcd_string("( HTTP Request )")
Пример #26
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(IC1A, GPIO.IN)
    GPIO.setFunction(IC1B, GPIO.IN)
    GPIO.setFunction(IC2A, GPIO.IN)
    GPIO.setFunction(IC2B, GPIO.IN)
Пример #27
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(IC1A, GPIO.IN)
    GPIO.setFunction(IC1B, GPIO.IN)
    GPIO.setFunction(IC2A, GPIO.IN)
    GPIO.setFunction(IC2B, GPIO.IN)
Пример #28
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(RED, GPIO.IN)
    GPIO.setFunction(GREEN, GPIO.IN)
    GPIO.setFunction(BLUE, GPIO.IN)
    GPIO.setFunction(SWITCH, GPIO.IN)
Пример #29
0
def setup():
    GPIO.setFunction(TRANS_PIN_BCM_NO, GPIO.OUT)
    try:
        webiopi.debug("RemotePi Started")

    except Exception as Err:
        webiopi.debug('%s' % Err)
Пример #30
0
def CoilCtrl(out):
    webiopi.debug("Coil : " + str(out))

    GPIO.output(17, GPIO.HIGH)
    
    if out == 'on':
        buff = [0x01, 0x06, 0x01, 0xf4, 0xff, 0x00]
        crc = CalcCrcFast(buff, len(buff))
        buff = buff + crc

        webiopi.debug(bytes(buff))
        size = ser.write(bytes(buff))
        webiopi.debug(size)
    else:
        buff = [0x01, 0x06, 0x01, 0xf4, 0x00, 0xff]
        crc = CalcCrcFast(buff, len(buff))
        buff = buff + crc

        webiopi.debug(bytes(buff))
        size = ser.write(bytes(buff))
        webiopi.debug(size)

    x = 0.0; 
    y = 1.0; 
    z = 0.0;  

    for i in range(0, 1500) :
        z += math.sin(y) * math.sin(y)
        y = y - 0.001
        x = x + 0.001
    GPIO.output(17, GPIO.LOW)
    
    return 'OK' 
Пример #31
0
def forward():
    webiopi.debug("forward")

    GPIO.pwmWrite(leftMotorDrivePWM1, GPIO.LOW)
    GPIO.pwmWrite(leftMotorDrivePWM2, GPIO.HIGH)
    GPIO.pwmWrite(rightMotorDrivePWM1, GPIO.LOW)
    GPIO.pwmWrite(rightMotorDrivePWM2, GPIO.HIGH)
Пример #32
0
def loop():
    webiopi.debug("Looptest script - Loop") #optional, can be omitted
    if BLINKING:
        print("B-L-I-N-K") 
        webiopi.sleep(BLINKPERIOD)        
        print("---------") 
    webiopi.sleep(BLINKPERIOD)        
Пример #33
0
def main12(val):
    global range12
    range12 = []
    f = open(path + filename21, "r")
    mini21 = int(f.read())
    f.close()
    f = open(path + filename22, "r")
    maxi21 = int(f.read())
    f.close()
    f = open(path + filename23, "r")
    x21 = int(f.read())
    f.close()
    f = open(path + filename24, "r")
    y21 = int(f.read())
    f.close()

    a21 = y21 - mini21
    b21 = maxi21 - y21
    c21 = float(a21 / x21)
    d21 = float(b21 / (200 - x21))
    e21 = int(maxi21 - d21 * 200)

    for i in range(0, 201):
        if i <= x21:
            range12.append(int(c21 * i + mini21))
        else:
            range12.append(int(d21 * i + e21))

    webiopi.debug(range12)
Пример #34
0
def updatedb():
    values = ':'.join(map(str, sensors))
    webiopi.debug("Updating db with: %s" % values)
    # update rrdtool db
    subprocess.check_output(
        ["rrdtool update /home/pi/clarice/clarice.rrd N:" + values],
        shell=True)
Пример #35
0
 def update(self):
     self.status = GPIO.digitalRead(self.inputBCM)
     webiopi.debug('Switch read as {0} now and {1} last'.format(self.status, self.lastStatus))
     if (self.status != self.lastStatus && not self.status):
         self.lightSet.toggle()
     self.lastStatus = self.status
     self.lightSet.update()
Пример #36
0
def setup():
    webiopi.debug("Blink script - Setup")
    # Setup GPIOs
    GPIO.setFunction(LED0, GPIO.PWM)
    # GPIO.setFunction(LED1, GPIO.OUT)

    GPIO.pwmWrite(LED0, 0.5)      # set to 50% ratio
Пример #37
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(M1_A, GPIO.IN)
    GPIO.setFunction(M1_B, GPIO.IN)
    GPIO.setFunction(M2_A, GPIO.IN)
    GPIO.setFunction(M2_B, GPIO.IN)
Пример #38
0
def setSchedule(newSchedule):
    global schedule
    global currentShow
    global showStartTime
    global fadeOutShow

    del schedule[:]
    programs = newSchedule.split(";")

    for p in programs:
        parts = p.split(":");
        newShow = Show()
        newShow.program = urllib.parse.unquote(parts[0])
        newShow.length = int(parts[1])
        webiopi.debug("adding show '" + newShow.program + "' for " + str(newShow.length) + " seconds");
        schedule.append(newShow)

        # append a fadeOut for every program... fadeIn is added by the loop above 
        schedule.append(fadeOutShow)

    currentShow = -1
    showStartTime = int(time.time())

    # send fade out to end the current thing smoothly
    serial.writeString('push fadeout')
    serial.writeString("\r")

    return 1 
Пример #39
0
def loop():
    global schedule
    global currentShow
    global showStartTime

    #webiopi.debug("loop... schedule count: " + str(len(schedule)))
    if len(schedule) > 0:
        #webiopi.debug("running schedule")
        currentTime = int(time.time())
        if (currentShow == -1) or ((currentTime - showStartTime) > schedule[currentShow].length):
            # currentShow == -1 means we're starting a schedule for the first time... give time to fade out of previous
            if (currentShow == -1):
                time.sleep(2)
            
            currentShow += 1

            if (currentShow >= len(schedule)):
                currentShow = 0

            showStartTime = currentTime
            webiopi.debug("next show: " + schedule[currentShow].program + " for " + str(schedule[currentShow].length) + " seconds");

            if (schedule[currentShow].program != 'fadeout'):
                serial.writeString("program ")
            else:
                serial.writeString("push ")

            serial.writeString(schedule[currentShow].program)
            if (schedule[currentShow].program != 'fadeout'):
                serial.writeString(" fadein")
            serial.writeString("\r")

    webiopi.sleep(1)
Пример #40
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # GPIO関数のリセット(入力にセットすることで行う)
    GPIO.setFunction(PWM1, GPIO.IN)
    GPIO.setFunction(PWM2, GPIO.IN)
    GPIO.setFunction(PWM3, GPIO.IN)
    GPIO.setFunction(PWM4, GPIO.IN)
Пример #41
0
def checkProg(gpio, rank=None):
    try:
        if rank is None:
            id = str(gpio) + '-' + "deact"
            job = sched.get_job(id)
            #webiopi.debug("job: %s" % job)
            return job
        else:
            jobs = []
            # Get main job
            id = str(gpio) + '-' + rank
            job = sched.get_job(id)
            if job:
                jobs.append(job)
            # Get sons job
            for job in sched.get_jobs():
                result = re.match(id + "\-.+$", job.id)
                if result:
                    # LOGIC if job.id match str(gpio) + '-' + rank + '-' *
                    webiopi.debug("job: %s" % job)
                    #if job.args[2] == gpio and job.args[1] == rank:
                    jobs.append(job)
            #webiopi.debug("jobs: %s" % jobs)
            if jobs:
                return jobs
    except:
        webiopi.exception("! error checking prog ! %s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
Пример #42
0
def setup():
    webiopi.debug("Script with macros - Setup")
    # Setup GPIOs
    GPIO.setFunction(RED, GPIO.PWM)
    GPIO.setFunction(GREEN, GPIO.PWM)
    GPIO.setFunction(BLUE, GPIO.PWM)
    GPIO.setup(SWITCH, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Пример #43
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(RED, GPIO.IN)
    GPIO.setFunction(GREEN, GPIO.IN)
    GPIO.setFunction(BLUE, GPIO.IN)
    GPIO.setFunction(SWITCH, GPIO.IN)
Пример #44
0
def setup():
    webiopi.debug("Script with macros - Setup")
    # Setup GPIOs
    GPIO.setFunction(LED1, GPIO.OUT)
    GPIO.setFunction(PIR_PIN, GPIO.IN)
    GPIO.setFunction(Buzz, GPIO.OUT)
    os.system("sudo service motion start")
Пример #45
0
def destroy():
    webiopi.debug("Basic script - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(SWITCH, GPIO.IN)
    GPIO.setFunction(SERVO, GPIO.IN)
    GPIO.setFunction(LED0, GPIO.IN)
    GPIO.setFunction(LED1, GPIO.IN)
Пример #46
0
 def update(self):
     self.isOn = true
     for light in self.lightSet:
         if not GPIO.digitalRead(light):
             webiopi.debug('Light {0} is off'.format(light))
             self.isOn = false
             break
     webiopi.debug('Light set is on set as {0}'.format(self.isOn))
def setup():
    """ Called when webiopi starts """
    webiopi.debug(PROJECT_NAME + " - Setup")

    #Setup GPIO
    GPIO.setFunction(BUTTON, GPIO.IN)
    GPIO.setFunction(POWER, GPIO.OUT)
    GPIO.digitalWrite(POWER, True)
Пример #48
0
def MoveForward(active):
        webiopi.debug("GetButtonNo. is " + active)
        if active == 1:
                FunMoveMotor(forward,1)
        if active == 2:
                FunMoveMotor(turnLeft,1)
        if active == 5:
                FunMoveMotor(stop,0.5)
Пример #49
0
 def __init__(self,address):
     self.address = str(address)
     try:
         resp = requests.get(self.address)
         if resp.status_code != 200:
             webiopi.debug("can't get status from api")
     except:
         webiopi.debug("connection error at init")
Пример #50
0
def Pause():
    webiopi.debug("一時停止")
    GPIO.output(ini_position1, False)
    GPIO.output(ini_position2, False)
    GPIO.output(RUN1, False)
    GPIO.output(RUN2, False)
    GPIO.output(Relay, False)
    webiopi.sleep(1)
def togglePower(pin=POWER):
    """ toggle the power state"""
    if checkPowerState(pin):
        GPIO.digitalWrite(pin, False)
        webiopi.debug(PROJECT_NAME + " - Power Off")
    else:
        GPIO.digitalWrite(pin, True)
        webiopi.debug(PROJECT_NAME + " - Power On")
Пример #52
0
def Do():
    webiopi.debug("実行中")
    GPIO.output(ini_position1, False)
    GPIO.output(ini_position2, False)
    GPIO.output(RUN1, True)
    GPIO.output(RUN2, True)
    GPIO.output(Relay, True)
    webiopi.sleep(1)
Пример #53
0
def End():
    webiopi.debug("終了しました")
    GPIO.output(ini_position1, True)
    GPIO.output(ini_position2, True)
    GPIO.output(RUN1, False)
    GPIO.output(RUN2, False)
    GPIO.output(Relay, False)
    webiopi.sleep(1)
Пример #54
0
def setup():
    webiopi.debug("Script with macros - Setup")
    # GPIOのセットアップ
    GPIO.setFunction(PWM1, GPIO.PWM)
    GPIO.setFunction(PWM2, GPIO.PWM)
    # 初期のデューティー比を0%に(静止状態)
    GPIO.pwmWrite(PWM1, 0)
    GPIO.pwmWrite(PWM2, 0)
Пример #55
0
def setup():
    GPIO.setFunction(TRANS_PIN_BCM_NO, GPIO.OUT)
    try:
        webiopi.debug("RemotePi Started")


    except Exception as Err:
        webiopi.debug('%s' % Err)
Пример #56
0
def destroy():
    webiopi.debug("Script with macros - Destroy")
    # Reset GPIO functions
    GPIO.setFunction(SWITCH, GPIO.IN)
    GPIO.setFunction(SERVO, GPIO.IN)
    GPIO.setFunction(LED0, GPIO.IN)
    GPIO.setFunction(LED1, GPIO.IN)
    gpio0 = webiopi.deviceInstance("gpio0")
    gpio0.digitalWrite(0, 1)
Пример #57
0
def sendData(moduleId, data, retry=3):
    try:
        for n in range(0, retry):
            rtc = rfsendData(moduleId, data)
            webiopi.debug('[%d] SendData : %s' % (n, rtc))
            time.sleep(1)

    except Exception as err:
        webiopi.debug('%s' % err)