"""
Interface: microbit
Nom du projet: Nouveau projet
Description: %253Cspan%2520class=%2522tooltip-title%2522%253ENouveau%2520projet%253C/span%253E%253Cspan%2520class=%2522tooltip-author%2522%253EAnonyme%253C/span%253E%253Cspan%2520class=%2522tooltip-description%2522%253E%253C/span%253E
Toolbox: vittascience
Mode: blocks

Blocks: <xml xmlns="https://developers.google.com/blockly/xml"><block type="on_start" id="G[=T#8yqB70`NFgYq}GP" deletable="false" x="137" y="-13"><comment pinned="true" h="51" w="231">Carte Ordi-ELEVE</comment><statement name="DO"><block type="communication_radioConfig" id="/5N[$d!~PxzMVL_=j49p"><value name="CANAL"><shadow type="math_number" id="yORs_;dnXGZ#xuxOE6,O"><field name="NUM">63</field></shadow></value><value name="POWER"><shadow type="math_number" id="$QinoL1^u;#udE:OxW[J"><field name="NUM">6</field></shadow></value><value name="LEN"><shadow type="math_number" id="8.{j}`9Og=riB=$U=e2]"><field name="NUM">32</field></shadow></value><value name="GROUP"><shadow type="math_number" id="UO=`w9_a=!6;#2TYPfDI"><field name="NUM">0</field></shadow></value></block></statement></block><block type="forever" id="o[WN]+eeF.OUxGch67@8" x="887" y="12"><statement name="DO"><block type="io_onButtonPressed" id="Qxj{DHJ{T?yO0U3pzmF9"><field name="BUTTON">a</field><field name="STATE">is_</field><statement name="DO"><block type="communication_radioSendNumber" id="t1MsHq4%.@[okk`y`_.i"><value name="N"><shadow type="math_number" id="-wJ+~6_RX5X$At-Nqhf$"><field name="NUM">20</field></shadow></value><next><block type="io_pause" id="YUu!KDD#^B!V^1i9#9=B"><field name="UNIT">MILLI</field><value name="TIME"><shadow type="math_number" id="usUV9Z~$2h1+EPC6GBwN"><field name="NUM">500</field></shadow></value><next><block type="show_icon" id="yt/V?`yWsXv|nD9+3`t*"><field name="ICON">YES</field><next><block type="io_pause" id="1e=)14WX=t$}-O%WCV+c"><field name="UNIT">MILLI</field><value name="TIME"><shadow type="math_number" id="]V2;x:^nv|{bW]3W1MIM"><field name="NUM">1000</field></shadow></value><next><block type="clear" id="=eH?Uco}A__E7jl0?:W-"></block></next></block></next></block></next></block></next></block></statement><next><block type="io_onButtonPressed" id="Udn=$i%@u7tx(Y`vV?e{"><field name="BUTTON">b</field><field name="STATE">is_</field><statement name="DO"><block type="show_string" id="}8Pol:]66AK)*FejTKcS"><mutation speed="false"></mutation><value name="TEXT"><shadow type="math_number" id="/=SYfuAX7CHa5{9|RVX."><field name="NUM">20</field></shadow></value></block></statement></block></next></block></statement></block></xml>

Projet généré par Vittascience.
Ce fichier contient le code textuel ainsi que le code blocs. Il peut être importé de nouveau
sur l'interface http://vittascience.com/microbit

"""

from microbit import *
import radio
import utime

def radio_send(data):
  type = None
  if isinstance(data, int):
    type = "int:"
  elif isinstance(data, float):
    type = "float:"
  elif isinstance(data, bool):
    data = int(data)
    type = "bool:"
  if type is not None:
    radio.send("&&&" + type + str(data) + "&&&")
  else:
    raise ValueError("Unable to send number: '" + str(data) + "'")

radio.on()

radio.config(channel = 63, power = 6, length = 32, group=0)

# Carte Ordi-ELEVE

while True:
  if button_a.is_pressed():
    radio_send(20)
    utime.sleep_ms(500)
    display.show(Image.YES)
    utime.sleep_ms(1000)
    display.clear()
  if button_b.is_pressed():
    display.scroll(20, delay=150, wait=True)
