Created
March 21, 2019 21:36
-
-
Save TannerQuigley/cb4cfd2e0ff99ccbcf2f4c6db1351ac2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import radio | |
import random | |
from microbit import display, Image, button_a, sleep, uart | |
flash = [Image().invert()*(i/9) for i in range(9, -1, -1)] | |
radio.on() | |
uart.init(115200) | |
def get_serial_number(type=hex): | |
NRF_FICR_BASE = 0x10000000 | |
DEVICEID_INDEX = 25 # deviceid[1] | |
@micropython.asm_thumb | |
def reg_read(r0): | |
ldr(r0, [r0, 0]) | |
return type(reg_read(NRF_FICR_BASE + (DEVICEID_INDEX*4))) | |
serial_num = get_serial_number() | |
while True: | |
# incoming = "54:11:1234:number:321" | |
# incoming = "hello>4:11:" + serial_num + ":keyvalue:321" | |
incoming = radio.receive() | |
if incoming != None: | |
display.show(flash, delay=100, wait=False) | |
print(str(incoming)) | |
sleep(1000) | |
else : | |
display.show(Image.SAD) | |
# msg = uart.read() | |
#msg_str = str(msg_bytes, 'UTF-8') | |
# test = sys.stdn.read() | |
if uart.any(): | |
display.show(flash, delay=100, wait=False) | |
sleep(1000) | |
else: | |
display.show(Image.SAD) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment