diff --git a/boards/default_src/micropython_esp32c2/origin/build/Mixgo_Mini-v1.23.0.bin b/boards/default_src/micropython_esp32c2/origin/build/Mixgo_Mini-v1.23.0.bin index 4a0440bb..2720099a 100644 Binary files a/boards/default_src/micropython_esp32c2/origin/build/Mixgo_Mini-v1.23.0.bin and b/boards/default_src/micropython_esp32c2/origin/build/Mixgo_Mini-v1.23.0.bin differ diff --git a/boards/default_src/micropython_esp32c2/origin/build/Mixgo_Mini_lib-v1.23.0.bin b/boards/default_src/micropython_esp32c2/origin/build/Mixgo_Mini_lib-v1.23.0.bin index 4c2c7dc5..d53e96c6 100644 Binary files a/boards/default_src/micropython_esp32c2/origin/build/Mixgo_Mini_lib-v1.23.0.bin and b/boards/default_src/micropython_esp32c2/origin/build/Mixgo_Mini_lib-v1.23.0.bin differ diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py index c1fa7d24..e4d819ab 100644 --- a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py @@ -228,6 +228,7 @@ class BOT035(FrameBuffer): """Reset SPK, PWM, HID registers to default state""" self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_SPK, b'\x0A\x00\x00\x00\x20\x4E\x64\x64') if self._version: self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_KB, bytes(9)) + def get_brightness(self): return self._brightness diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/mixgo_mini.py b/boards/default_src/micropython_esp32c2/origin/build/lib/mixgo_mini.py index 07c41616..f0808a4c 100644 --- a/boards/default_src/micropython_esp32c2/origin/build/lib/mixgo_mini.py +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/mixgo_mini.py @@ -164,6 +164,7 @@ class LED: def setcolor(self, index, color): self._col[index-1] = color + self.setbrightness(index, 100) def getcolor(self, index): return self._col[index-1] diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/radio.py b/boards/default_src/micropython_esp32c2/origin/build/lib/radio.py index be318509..e1114536 100644 --- a/boards/default_src/micropython_esp32c2/origin/build/lib/radio.py +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/radio.py @@ -1,94 +1,94 @@ -""" -Radio-ESP-NOW(ESP32-C2) - -Micropython library for the Radio-ESP-NOW(ESP32-C2) -======================================================= -@dahanzimin From the Mixly Team -""" - -import espnow -from ubinascii import hexlify,unhexlify -import network - -class ESPNow(espnow.ESPNow): - def __init__(self,channel=1,txpower=20): - super().__init__() - self.active(True) - self._channel = channel - self._txpower = txpower - self._nic = network.WLAN(network.STA_IF) - self._nic.active(True) - self._nic.config(channel=self._channel,txpower=self._txpower) - - def send(self,peer,msg): - '''Send data after error reporting and effective processing''' - try: - _peer=unhexlify(peer) - return super().send(_peer, str(msg)) - except OSError as err: - if len(err.args) < 2: - raise err - if err.args[1] == 'ESP_ERR_ESPNOW_NOT_INIT': - raise OSError("Radio(ESPNOW) is not activated, unable to transmit data") - elif err.args[1] == 'ESP_ERR_ESPNOW_IF': - self._nic.active(True) - elif err.args[1] == 'ESP_ERR_ESPNOW_NOT_FOUND': - self.add_peer(_peer) - return super().send(_peer, str(msg)) - elif err.args[1] == 'ESP_ERR_ESPNOW_NO_MEM': - raise OSError("internal ESP-NOW buffers are full") - elif err.args[1] == 'ESP_ERR_ESPNOW_ARG': - raise OSError("invalid argument") - else: - raise err - - def recv(self): - '''Receive data''' - if self.any(): - host, msg = super().recv() - return hexlify(host).decode(),msg.decode() - else : - return None,None - - def set_channel(self,channel=None,txpower=None): - self._channel = self._channel if channel is None else channel - self._nic.config(channel=self._channel, txpower=self._txpower if txpower is None else txpower) - - def _cb_handle(self, ee): - '''Callback processing conversion''' - host, msg = super().recv() - if self._on_handle: - if isinstance(self._on_handle, list): - for func in self._on_handle: - cmd = func.__name__.rfind('__') - if cmd != -1: - cmd=func.__name__[cmd+2:] - if cmd == str(msg.decode()): - func(hexlify(host).decode(), msg.decode()) - else: - func(hexlify(host).decode(), msg.decode()) - else: - self._on_handle(hexlify(host).decode(), msg.decode()) - - def recv_cb(self, recv_cbs): - '''Receive callback''' - self._on_handle = recv_cbs - if recv_cbs: - self.irq(self._cb_handle) - - def info(self): - '''Get the paired Mac and rssi''' - _info=[] - for i in self.peers_table: - _info.append((hexlify(i).decode(),self.peers_table[i][0])) - return _info - - @property - def mac(self): - '''Get mac address''' - return hexlify(self._nic.config('mac')).decode() - - @property - def channel(self): - '''Get mac address''' - return self._nic.config('channel') +""" +Radio-ESP-NOW(ESP32-C2) + +Micropython library for the Radio-ESP-NOW(ESP32-C2) +======================================================= +@dahanzimin From the Mixly Team +""" + +import espnow +from ubinascii import hexlify,unhexlify +import network + +class ESPNow(espnow.ESPNow): + def __init__(self,channel=1,txpower=20): + super().__init__() + self.active(True) + self._channel = channel + self._txpower = txpower + self._nic = network.WLAN(network.STA_IF) + self._nic.active(True) + self._nic.config(channel=self._channel,txpower=self._txpower) + + def send(self,peer,msg): + '''Send data after error reporting and effective processing''' + try: + _peer=unhexlify(peer) + return super().send(_peer, str(msg)) + except OSError as err: + if len(err.args) < 2: + raise err + if err.args[1] == 'ESP_ERR_ESPNOW_NOT_INIT': + raise OSError("Radio(ESPNOW) is not activated, unable to transmit data") + elif err.args[1] == 'ESP_ERR_ESPNOW_IF': + self._nic.active(True) + elif err.args[1] == 'ESP_ERR_ESPNOW_NOT_FOUND': + self.add_peer(_peer) + return super().send(_peer, str(msg)) + elif err.args[1] == 'ESP_ERR_ESPNOW_NO_MEM': + raise OSError("internal ESP-NOW buffers are full") + elif err.args[1] == 'ESP_ERR_ESPNOW_ARG': + raise OSError("invalid argument") + else: + raise err + + def recv(self): + '''Receive data''' + if self.any(): + host, msg = super().recv() + return hexlify(host).decode(),msg.decode() + else : + return None,None + + def set_channel(self,channel=None,txpower=None): + self._channel = self._channel if channel is None else channel + self._nic.config(channel=self._channel, txpower=self._txpower if txpower is None else txpower) + + def _cb_handle(self, ee): + '''Callback processing conversion''' + host, msg = super().recv() + if self._on_handle: + if isinstance(self._on_handle, list): + for func in self._on_handle: + cmd = func.__name__.rfind('__') + if cmd != -1: + cmd=func.__name__[cmd+2:] + if cmd == str(msg.decode()): + func(hexlify(host).decode(), msg.decode()) + else: + func(hexlify(host).decode(), msg.decode()) + else: + self._on_handle(hexlify(host).decode(), msg.decode()) + + def recv_cb(self, recv_cbs): + '''Receive callback''' + self._on_handle = recv_cbs + if recv_cbs: + self.irq(self._cb_handle) + + def info(self): + '''Get the paired Mac and rssi''' + _info=[] + for i in self.peers_table: + _info.append((hexlify(i).decode(),self.peers_table[i][0])) + return _info + + @property + def mac(self): + '''Get mac address''' + return hexlify(self._nic.config('mac')).decode() + + @property + def channel(self): + '''Get mac address''' + return self._nic.config('channel') diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/ws2812x.py b/boards/default_src/micropython_esp32c2/origin/build/lib/ws2812x.py index 90f2eca5..d338460a 100644 --- a/boards/default_src/micropython_esp32c2/origin/build/lib/ws2812x.py +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/ws2812x.py @@ -37,9 +37,8 @@ class NeoPixel: def write(self): self.pin.init(self.pin.OUT, value=0) - sleep_us(40) - bitstream(self.pin, 0, self.timing, bytes(3)+self.rgb_buf) - sleep_us(40) + bitstream(self.pin, 0, self.timing, bytes(3) + self.rgb_buf) + sleep_us(150) self.pin.init(self.pin.IN) def color_chase(self,R, G, B, wait):