build(boards): xpython板卡执行 npm run build:prod

This commit is contained in:
王立帮
2025-09-13 23:03:29 +08:00
parent 167c6e9e30
commit b4256d9764
72 changed files with 1906 additions and 3306 deletions

View File

@@ -1,83 +0,0 @@
{
"ble_central": {
"__require__": [
"time",
"gc",
"bluetooth",
"micropython",
"ubinascii",
"ble_advertising"
],
"__file__": true,
"__size__": 7378,
"__name__": "ble_central.py"
},
"mini_bot": {
"__require__": [
"time",
"math",
"esp",
"micropython",
"framebuf"
],
"__file__": true,
"__size__": 14852,
"__name__": "mini_bot.py"
},
"mini_go": {
"__require__": [
"time",
"gc",
"math",
"tm1931",
"machine"
],
"__file__": true,
"__size__": 8481,
"__name__": "mini_go.py"
},
"mini_gx": {
"__require__": [
"gc",
"machine",
"rc522",
"ci130x"
],
"__file__": true,
"__size__": 736,
"__name__": "mini_gx.py"
},
"mixgo_mini": {
"__require__": [
"time",
"gc",
"esp32",
"machine",
"musicx",
"ws2812x",
"sc7a20",
"ap3216c",
"mini_bot"
],
"__file__": true,
"__size__": 4920,
"__name__": "mixgo_mini.py"
},
"musicx": {
"__require__": [
"time"
],
"__file__": true,
"__size__": 3545,
"__name__": "musicx.py"
},
"ws2812x": {
"__require__": [
"time",
"machine"
],
"__file__": true,
"__size__": 1979,
"__name__": "ws2812x.py"
}
}

View File

@@ -31,7 +31,9 @@ _Uincode_ADDR = const(0x3A0000)
class BOT035(FrameBuffer):
def __init__(self, i2c_bus, brightness=0.8):
self._i2c= i2c_bus
self._i2c = i2c_bus
self._way = 2
self._speed = 100
self._buffer = bytearray(12)
self._brightness = brightness
self._touchs = [self.touch(0), self.touch(1)]
@@ -51,7 +53,7 @@ class BOT035(FrameBuffer):
def _uincode(self, ch):
'''uincode code font reading data'''
uni = ord(ch)
if 0x20 <= uni <= 0x2642 :
if 0x20 <= uni <= 0x2642 :
_address = 0x28 + (uni - 0x20) * 4
elif 0x3001 <= uni <= 0x9fa0 :
_address = 0x98b4 + (uni - 0x3001) * 4
@@ -62,11 +64,11 @@ class BOT035(FrameBuffer):
buffer = bytearray(4)
flash_read(_Uincode_ADDR + _address, buffer)
font_info = buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]
font_address = font_info & 0X3FFFFFF
font_address = font_info & 0x3FFFFFF
font_width = font_info >> 26
buffer = bytearray( 12 * (font_width // 8 + 1))
flash_read(_Uincode_ADDR + font_address, buffer)
return buffer, font_width
buffer = bytearray(12 * (font_width // 8 + 1))
flash_read(_Uincode_ADDR + font_address, buffer)
return buffer, font_width, 12
def shift(self, x, y, rotate=False):
"""Shift pixels by x and y"""
@@ -141,20 +143,58 @@ class BOT035(FrameBuffer):
for i in range(len(buffer)):
self._buffer[i] = self._buffer[i] | buffer[i]
def _ascall_bitmap(self, buffer, x=0):
if -_FONT_W <= x <= _LEDS_W:
for _x in range(_FONT_W):
for _y in range(_FONT_H):
if (buffer[_x] >> _y) & 0x1:
self.pixel(x + _x, _y, 1)
def _ascall_bitmap(self, data, x=0 ,space=0):
for char in data:
buf = self._chardata(char)
if -_FONT_W <= x <= _LEDS_W:
for _x in range(_FONT_W):
for _y in range(_FONT_H):
if (buf[_x] >> _y) & 0x1:
self.pixel(x + _x, _y, 1)
x = _FONT_W + x + space
self.show()
def _uincode_bitmap(self, buffer, x=0):
_buffer, width = buffer
if -width < x < _LEDS_H:
for _y in range(12):
for _x in range(width):
if _buffer[_y * ((width + 7) // 8) + _x // 8] & (0x80 >> (_x & 7)):
self.pixel(_y, _LEDS_H - (x + _x), 1)
def _uincode_scroll(self, buffer, space):
_len = 0
for buf in buffer:
_len = _len + space + (buf[2] if self._way <= 1 else buf[1])
for i in range(_len - space + (_LEDS_W if self._way <= 1 else _LEDS_H)):
_step = (_LEDS_W - 1 if self._way <= 1 else _LEDS_H) - i
self.fill(0)
for buf in buffer:
_buf, width, high = buf
_xx = (_LEDS_W - width) // 2
if -high < _step < _LEDS_W:
for _y in range(12):
for _x in range(width):
if _buf[_y * ((width + 7) // 8) + _x // 8] & (0x80 >> (_x & 7)):
if self._way == 0:
self.pixel( _LEDS_W - (_xx + _x) - 2, _LEDS_H - (_step + _y), 1)
elif self._way == 1:
self.pixel(_xx + _x + 1, _step + _y, 1)
elif self._way == 2:
self.pixel(_y, _LEDS_H - (_step + _x), 1)
elif self._way == 3:
self.pixel(_LEDS_W - _y - 1, (_step + _x), 1)
_step = _step + space + (high if self._way <= 1 else width)
self.show()
time.sleep_ms(self._speed)
def _gb2312_scroll(self, data, space):
for char in data:
if ord(char) >= 0xFF:
font_buffer = []
for c in data:
_buffer = self._uincode(c)
font_buffer.append(_buffer)
self._uincode_scroll(font_buffer, space)
return True
def scroll_way(self, way=1, speed=None):
"""0,1竖2,3横"""
self._way = way % 4
if speed is not None:
self._speed = speed
def shows(self, data, space=1, center=True):
"""Display character"""
@@ -165,11 +205,9 @@ class BOT035(FrameBuffer):
self.show()
else:
data = str(data)
x = (_LEDS_W - len(data) * (_FONT_W + space) + space) // 2 if center else 0
for char in data:
self._ascall_bitmap(self._chardata(char), x)
x = _FONT_W + x + space
self.show()
if not self._gb2312_scroll(data, space):
x = (_LEDS_W - len(data) * (_FONT_W + space) + space) // 2 if center else 0
self._ascall_bitmap(data, x)
def frame(self, data, delay=500):
"""Display one frame per character"""
@@ -177,44 +215,28 @@ class BOT035(FrameBuffer):
data = str(data)
for char in data:
self.fill(0)
self._ascall_bitmap(self._chardata(char), (_LEDS_W - _FONT_W) // 2)
self.show()
if ord(char) >= 0xFF:
_way = self._way
self._way = 1
self._uincode_scroll([self._uincode(char)], 0)
self._way = _way
else:
self._ascall_bitmap([char], (_LEDS_W - _FONT_W) // 2)
time.sleep_ms(delay)
def scroll(self, data, space=0, speed=100):
def scroll(self, data, space=0, speed=None):
"""Scrolling characters"""
if speed is not None:
self._speed = speed
if data is not None:
data = str(data)
uincode = False
for char in data:
if ord(char) >= 0xff:
uincode =True
break
if uincode:
font_buffer = []
str_len = 0
for c in data:
_buffer = self._uincode(c)
font_buffer.append(_buffer)
str_len = str_len + _buffer[1] + space
for i in range(str_len + _LEDS_H - space):
x = _LEDS_H - i
self.fill(0)
for buffer in font_buffer:
self._uincode_bitmap(buffer, x)
x = buffer[1] + x + space
self.show()
time.sleep_ms(speed)
else:
if not self._gb2312_scroll(data, space):
str_len = len(data) * (_FONT_W + space) - space
for i in range(str_len + _LEDS_W + 1):
x = _LEDS_W -i
x = _LEDS_W - i
self.fill(0)
for char in data:
self._ascall_bitmap(self._chardata(char), x)
x = _FONT_W + x + space
self.show()
time.sleep_ms(speed)
self._ascall_bitmap(data, x)
time.sleep_ms(self._speed)
def pointern(self, x=_LEDS_W // 2, y=_LEDS_H // 2, l=_LEDS_H // 2, angle=0):
radian = math.radians(angle)

View File

@@ -1,27 +1,81 @@
{
"board": {
"MixGo MINI": "micropython:esp32c2:mixgo_mini",
"ESP32C2 Generic(2M)": "micropython:esp32c2:generic_2M"
"MixGo MINI": {
"key": "micropython:esp32c2:mixgo_mini",
"config": [
{
"key": "BurnSpeed",
"label": "Burn Speed",
"messageId": "MICROPYTHON_CONFIG_MESSAGE_BURN_SPEED",
"options": [
{
"key": "460800",
"label": "460800"
},
{
"key": "115200",
"label": "115200"
},
{
"key": "230400",
"label": "230400"
},
{
"key": "921600",
"label": "921600"
}
]
}
]
},
"ESP32C2 Generic(4M)": {
"key": "micropython:esp32c2:generic_4M",
"config": [
{
"key": "BurnSpeed",
"label": "Burn Speed",
"messageId": "MICROPYTHON_CONFIG_MESSAGE_BURN_SPEED",
"options": [
{
"key": "460800",
"label": "460800"
},
{
"key": "115200",
"label": "115200"
},
{
"key": "230400",
"label": "230400"
},
{
"key": "921600",
"label": "921600"
}
]
}
]
}
},
"language": "MicroPython",
"burn": {
"type": "command",
"portSelect": "all",
"micropython:esp32c2:mixgo_mini": {
"command": "\"{esptool}\" --chip esp32c2 --port {com} --baud 115200 --after=no_reset_stub erase_flash && \"{esptool}\" --chip esp32c2 --port {com} --baud 460800 --after=no_reset_stub write_flash 0x0 \"{indexPath}/build/Mixgo_Mini_lib-v1.25.0.bin\" 0X3A0000 \"{indexPath}/../micropython/build/HZK12.bin\"",
"command": "\"{esptool}\" --chip esp32c2 --port {com} --baud {baudrate} --after=no_reset_stub write_flash -e 0x0 \"{indexPath}/build/Mixgo_Mini_lib-v1.25.0.bin\" 0X3A0000 \"{indexPath}/../micropython/build/HZK12.bin\"",
"special": [
{
"name": "Firmware For General Application",
"command": "\"{esptool}\" --chip esp32c2 --port {com} --baud 115200 --after=no_reset_stub erase_flash && \"{esptool}\" --chip esp32c2 --port {com} --baud 460800 --after=no_reset_stub write_flash 0x0 \"{indexPath}/build/Mixgo_Mini_lib-v1.25.0.bin\" 0X3A0000 \"{indexPath}/../micropython/build/HZK12.bin\""
"command": "\"{esptool}\" --chip esp32c2 --port {com} --baud {baudrate} --after=no_reset_stub write_flash -e 0x0 \"{indexPath}/build/Mixgo_Mini_lib-v1.25.0.bin\" 0X3A0000 \"{indexPath}/../micropython/build/HZK12.bin\""
},
{
"name": "Firmware Optimize For V2.x Board",
"command": "\"{esptool}\" --chip esp32c2 --port {com} --baud 115200 --after=no_reset_stub erase_flash && \"{esptool}\" --chip esp32c2 --port {com} --baud 460800 --after=no_reset_stub write_flash 0x0 \"{indexPath}/build/Mixgo_Mini_v2_lib-v1.25.0.bin\" 0X3A0000 \"{indexPath}/../micropython/build/HZK12.bin\""
"command": "\"{esptool}\" --chip esp32c2 --port {com} --baud {baudrate} --after=no_reset_stub write_flash -e 0x0 \"{indexPath}/build/Mixgo_Mini_v2_lib-v1.25.0.bin\" 0X3A0000 \"{indexPath}/../micropython/build/HZK12.bin\""
}
]
},
"micropython:esp32c2:generic_2M": {
"command": "\"{esptool}\" --chip esp32c2 --port {com} --baud 460800 erase_flash && \"{esptool}\" --chip esp32c2 --port {com} --baud 460800 write_flash 0x0 \"{indexPath}/build/Mixgo_Mini-v1.23.0-26mhz.bin\" "
"command": "\"{esptool}\" --chip esp32c2 --port {com} --baud {baudrate} write_flash -e 0x0 \"{indexPath}/build/Generic_C2_lib-v1.25.0.bin\""
}
},
"upload": {
@@ -133,11 +187,11 @@
}
]
},
"micropython:esp32c2:generic_2M": {
"micropython:esp32c2:generic_4M": {
"binFile": [
{
"offset": "0x0000",
"path": "./build/Mixgo_Mini-v1.23.0-26mhz.bin"
"path": "./build/Generic_C2_lib-v1.25.0.bin"
}
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long