Esempio n. 1
0
def recv_cb(_):
    global color, addr, data, message, left, right
    addr, _, data = espnow.recv_data(encoder='str')
    message = json.loads(data)
    set_dirction()
    set_led()

    pass
Esempio n. 2
0
def recv_cb(_):
  global send_flag,sender_address,receive_data
  sender_address, _, receive_data = espnow.recv_data(encoder='str')
  if receive_data == 'on':
    rgb.setColorAll(0x33cc00)
  if receive_data == 'off':
    rgb.setColorAll(0x000000)
  label0.setText(str(receive_data))

  pass
Esempio n. 3
0
def receive_msg(_):
  global addr, data, paired
  addr, _, data = espnow.recv_data(encoder='byte')

  if paired == False:
    paired = True
    label0.setText(str('connected'))
    print('paired')
    pass
  else:
    #TODO: control actual motors to move Rover
    set_speed(data[0], data[1], data[2])

    pass
Esempio n. 4
0
def receive_msg(_):
    global addr, data, paired
    addr, _, data = espnow.recv_data(encoder='str')
    label4.setText(str(data))

    if paired == False:
        #TODO: check if is this a mac address?
        espnow.add_peer(str(data), id=1)
        espnow.send(id=1, data=str('connected'))
        paired = True
        label4.setText(str('paired'))
        pass
    else:
        pass
def recv_cb(_):
  global txt,NPD,counter,POWER,stop_flag
  _, _, txt = espnow.recv_data(encoder='str')
  if txt.count('NPD=') > 0:
    NPD = txt.replace('NPD=', '')
    POWER = float(NPD)
    if POWER > 3000:
      setScreenColor(0xff0000)
      lcd.print(((NPD + 'W   ')), 0, 25, 0xff0000)
      axp.setLcdBrightness(100)
    elif POWER >= 0:
      setScreenColor(0x000000)
      lcd.print(((NPD + 'W   ')), 0, 25, 0xffffff)
      axp.setLcdBrightness(50)
    else:
      setScreenColor(0x000000)
      lcd.print(((NPD + 'W   ')), 0, 25, 0x3366ff)
      axp.setLcdBrightness(60)

  pass
Esempio n. 6
0
# ボタン検出スレッド起動
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:]) :
                now_power = int(r_txt[4:])
                data_mute = False
                now_power_time = utime.time()
                draw_w()
                print(str(now_power) + ' W')

    gc.collect()
    utime.sleep(0.1)