def __init__(self): self.auth = auth self.ssid = ssid self.pswd = pswd BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.begin(auth, ssid, pswd) self.button1 = BlinkerButton('btn-of9') self.button2 = BlinkerButton('btn-a1x') #开窗帘 self.button3 = BlinkerButton('btn-qni') #关窗帘 self.button4 = BlinkerButton('btn-5gx') #1号继电器 self.number1 = BlinkerNumber('num-abc') self.number2 = BlinkerNumber('num-kf5') #发送温度 self.number3 = BlinkerNumber('num-50b') #发送湿度 self.slider1 = BlinkerSlider("ran-jhb") self.slider2 = BlinkerSlider("ran-bqm") self.counter = 0 self.pinValue = 0 self.p2 = p2 self.p5 = p5 self.value5 = 0 self.pwm = pwm self.pwm.freq(38000) self.pwm.duty(1) self.pwm2 = pwm2 self.pwm2.freq(38000) self.pwm2.duty(1) self.p2.value(self.pinValue)
def data_callback(data): global counter BLINKER_LOG('Blinker readString: ', data) counter += 1 number1.print(counter) Blinker.push("msg")
def data_callback(data): global counter BLINKER_LOG('Blinker readString: ', data) counter += 1 number1.print(counter) Blinker.wechat("title", "state", "msg")
def data_callback(data): global counter BLINKER_LOG('Blinker readString: ', data) counter += 1 number1.print(counter) BLINKER_LOG("Blinker AQI: ", Blinker.aqi())
def run(self): self.button1.attach(self.button1_callback) Blinker.attachData(self.data_callback) Blinker.attachHeartbeat(self.heartbeat_callback) self.button2.attach(self.button2_callback) self.button3.attach(self.button3_callback) self.button4.attach(self.button4_callback) self.slider1.attach(self.slider1_callback) self.slider2.attach(self.slider2_callback) while True: value = get_value() try: Blinker.run() except OSError: pass
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerMiot from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.miType( 'BLINKER_MIOT_LIGHT' ) # BLINKER_MIOT_LIGHT 灯, BLINKER_MIOT_OUTLET 插座, BLINKER_MIOT_MULTI_OUTLET 多口插座, BLINKER_MIOT_SENSOR 传感器 Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 wsState = 'on' wsMode = BLINKER_CMD_COMMON def miotPowerState(state): ''' ''' BLINKER_LOG('need set power state: ', state) wsState = state and 'on' or 'off' BlinkerMiot.powerState(wsState)
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerDuerOS from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.duerType('BLINKER_DUEROS_OUTLET') Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 oState = 'on' def duerPowerState(state): ''' ''' BLINKER_LOG('need set power state: ', state) BlinkerDuerOS.powerState(state) BlinkerDuerOS.print()
#!/usr/bin/env python # -*- coding: utf-8 -*- from machine import Pin from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerAliGenie from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' ssid = 'Your WiFi network SSID or name' pswd = 'Your WiFi network WPA password or WEP key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.aliType('BLINKER_ALIGENIE_LIGHT') Blinker.begin(auth, ssid, pswd) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 pinValue = 0 wsState = 'on' wsMode = BLINKER_CMD_COMMON p2 = Pin(2, Pin.OUT) p2.value(pinValue)
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerMiot from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.miType('BLINKER_MIOT_OUTLET') Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 oState = 'on' def miotPowerState(state): ''' ''' global oState BLINKER_LOG('need set power state: ', state) oState = state
#!/usr/bin/env python # -*- coding: utf-8 -*- from machine import Pin from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' ssid = 'Your WiFi network SSID or name' pswd = 'Your WiFi network WPA password or WEP key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.begin(auth, ssid, pswd) slider1 = BlinkerSlider("SliderKey") def slider1_callback(value): """ """ BLINKER_LOG('Slider read: ', value) def data_callback(data): BLINKER_LOG('Blinker readString: ', data) slider1.color('#FFFFFF') slider1.print(random.randint(0, 255))
#!/usr/bin/env python # -*- coding: utf-8 -*- from machine import Pin from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerDuerOS from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' ssid = 'Your WiFi network SSID or name' pswd = 'Your WiFi network WPA password or WEP key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.duerType('BLINKER_DUEROS_LIGHT') Blinker.begin(auth, ssid, pswd) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 pinValue = 0 wsState = 'on' wsMode = BLINKER_CMD_COMMON p2 = Pin(2, Pin.OUT) p2.value(pinValue)
def run(): while True: Blinker.run()
#!/usr/bin/env python # -*- coding: utf-8 -*- from machine import Pin from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber from Blinker.BlinkerDebug import * auth = '7f185ddddb90' ssid = '62-5-202' pswd = 'anys888888' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.begin(auth, ssid, pswd) button1 = BlinkerButton('btn-sps') number1 = BlinkerNumber('num-abc') counter = 0 pinValue = 0 p2 = Pin(2, Pin.OUT) p2.value(pinValue) def button1_callback(state): ''' ''' BLINKER_LOG('get button state: ', state)
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerMIOT from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.miotType('BLINKER_MIOT_SENSOR') Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 def miotQuery(queryCode): ''' ''' BLINKER_LOG('MIOT Query codes: ', queryCode) if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER: BLINKER_LOG('MIOT Query All') BlinkerMIOT.temp(20) BlinkerMIOT.humi(20) BlinkerMIOT.pm25(20)
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerAliGenie from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.aliType('BLINKER_ALIGENIE_MULTI_OUTLET') Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 wsState = ['off', 'off', 'off', 'off', 'off'] def aligeniePowerState(state, num): ''' ''' BLINKER_LOG("need set outlet: ", num, ", power state: ", state) global wsState wsState[num] = state if num == 0 and state == 'false': for i in len(wsState):
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerAliGenie from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.aliType('BLINKER_ALIGENIE_SENSOR') Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 def aligenieQuery(queryCode): ''' ''' BLINKER_LOG('AliGenie Query codes: ', queryCode) if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER : BLINKER_LOG('AliGenie Query All') BlinkerAliGenie.temp(20) BlinkerAliGenie.humi(20) BlinkerAliGenie.pm25(20) BlinkerAliGenie.print()