Exemplo n.º 1
0
def main():
    hat_joyc0.SetLedColor(0x3232ff)

    wifiCfg.wlan_ap.active(True)
    wifiCfg.wlan_sta.active(True)
    espnow.init()
    espnow.recv_cb(receive_msg)

    timerSch.run('UpdatePosition', 10, 0x00)
    timerSch.run('UpdateBattery', 1000, 0x00)
Exemplo n.º 2
0
    def on(self):
        global espnow_callback_fn

        self.wlan.active(True)
        self.wlan.config(channel=1)
        self.wlan.config(protocol=network.MODE_LR)

        espnow.init()
        espnow.set_pmk("0123456789abcdef")
        espnow.set_recv_cb(espnow_callback_fn)
        self.add_espnow_peer(WiFi.BROADCAST_ADDR)
Exemplo n.º 3
0
def main():
  wifiCfg.wlan_ap.active(True)
  wifiCfg.wlan_sta.active(True)

  espnow.init()
  espnow.recv_cb(receive_msg)

  label0.setText(str('broadcasting'))

  timerSch.run('UpdateBattery', 1000, 0x00) 
  timerSch.run('SendDiscoveryBroadcast', 1000, 0x00)

  try:
    while True:
      pass
  except KeyboardInterrupt:
    print('Got ctrl-c')
    # Explicitly stop timers (threads) here.
    timerSch.stop('SendDiscoveryBroadcast')
Exemplo n.º 4
0
print('>> Disp init OK')


# 時刻表示スレッド起動
_thread.start_new_thread(time_count , ())
print('>> Time Count thread ON')


# ボタン検出スレッド起動
btnA.wasPressed(buttonA_wasPressed)
btnB.wasPressed(buttonB_wasPressed)
print('>> Button Check thread ON')


# ESP NOW設定
espnow.init()
print('>> ESP NOW init')


# メインループ
while True:
    update_count = utime.time() - now_power_time
    if update_count >= TIMEOUT : # 瞬間電力値の更新時刻が[TIMEOUT]秒以上前なら電力値非表示(黒文字化)
        data_mute = True
        draw_w()

    d = espnow.recv_data()
    if len(d[2]) > 0 :
        r_txt = str(d[2].strip(), 'utf-8')
        if ure.match('NPD=' , r_txt.strip()) :
            if not now_power == int(r_txt[4:]) :