from microbit import * import music # 2.04.2021 # -- COMMUNICATION - cannot be changed pit= bytearray(1) pit[0] = 1 spd = 8 def ispis(tekst): dd = len(tekst) if dd < 31: salji(tekst) else: salji(tekst[0:30] + "+") salji(tekst[30:dd]) def salji(tekst): global spd duz = len(tekst) buf = bytearray(duz) for n in range(0, duz): bb = ord(tekst[n : n + 1]) buf[n] = bb try: i2c.write(0x11, buf) sleep(duz * spd) except OSError: print("er: send") # -- COMMUNICATION --- end def trazi(): global pit try: pit = i2c.read(0x11,1) except OSError: print("er: seek") # -- def rest(): global pit ispis("RST") while True: trazi() if pit[0] == 5: break sleep(20) # -- def begin(): ispis("CLS") ispis("START;2;1;2") ispis("G A M E;3;3") sleep(1000) ispis("CLS") # -- rest() begin() ispis("BIT;1;255;153;189;231;231;189;153;255") ispis("BIT;9;60;66;165;165;129;189;102;219") # player ispis("BIT;8;60;66;165;129;189;66;231;24") # player anima map ispis("OBJ;1;1;0;3;6") ispis("OBJ;1;1;8;0;5;1") ispis("FX;1") ispis("POZ;5;2") ispis("ANI;1") ispis("KOL;1") ispis("GRV;1") while True: if button_a.is_pressed(): ispis("BUT;-;X;1") if button_b.is_pressed(): ispis("BUT;+;X;1")