[ESP32+MicroPython]快速接入blinker-Arduino中文社区 - Powered by Discuz! Archiver

coloz 发表于 2019-8-5 05:10

[ESP32+MicroPython]快速接入blinker





#!/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)

button1 = BlinkerButton('btn-abc')
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)

    button1.icon('icon_1')
    button1.color('#FFFFFF')
    button1.text('Your button name or describe')
    button1.print(state)

    global pinValue
   
    pinValue = 1 - pinValue
    p2.value(pinValue)

def data_callback(data):
    global counter
   
    BLINKER_LOG('Blinker readString: ', data)
    counter += 1
    number1.print(counter)

button1.attach(button1_callback)
Blinker.attachData(data_callback)

if __name__ == '__main__':

    while True:
      Blinker.run()

jliwme 发表于 2020-3-17 14:58

from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber 出错,memoryerror:memory allocation failed,allocation个136bytes,怎么破?

魅力舞兵 发表于 2019-8-5 15:09

快速接入blinker    www.tdszx.comwww.jyhxjm.comwww.gztpcj.com

xujianhua66 发表于 2020-8-6 12:57

请问大神:我用的mincropython IDE是uPyCcaft,不知道如何安装blinker-mpy-master 库。查遍网络,找不到一篇文章讲解,请教大神指导

xujianhua66 发表于 2020-8-6 12:58

也用thonny IDE,但还是无法安装blinker-mpy-master库
页: [1]
查看完整版本: [ESP32+MicroPython]快速接入blinker