Beispiel #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)
Beispiel #2
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')
    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
espnow.recv_cb(recv_cb)


def buttonA_wasPressed():
  global txt, NPD, counter, POWER, stop_flag
  if stop_flag == True:
    counter = 600
    stop_flag = False
  pass
btnA.wasPressed(buttonA_wasPressed)


wifiCfg.screenShow()
wifiCfg.autoConnect(lcdShow = True)
setScreenColor(0x000000)
lcd.font(lcd.FONT_DejaVu40)