mini板hid修改

删除不亮
This commit is contained in:
Irene-Maxine
2024-09-12 21:27:00 +09:00
parent 3af2a14634
commit 9f14457b75
7 changed files with 269 additions and 78 deletions

View File

@@ -43,6 +43,8 @@ class BOT035(FrameBuffer):
if 0x20 <= ord(ch) <= 0x7f:
char_index = 2 + (ord(ch)-32) * _FONT_W
return _FONT5x8_CODE[char_index : char_index + _FONT_W]
else:
raise ValueError("Cannot display characters other than ASCLL code")
def _uincode(self, ch):
'''uincode code font reading data'''
@@ -54,7 +56,7 @@ class BOT035(FrameBuffer):
elif 0xff01 <= uni <= 0xffe5 :
_address = 0x25734 + (uni - 0xff01) * 4
else:
return None, 0
raise ValueError("Cannot display characters other than GB2312 code")
buffer = bytearray(4)
flash_read(_Uincode_ADDR + _address, buffer)
font_info = buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]
@@ -138,7 +140,7 @@ class BOT035(FrameBuffer):
self._buffer[i] = self._buffer[i] | buffer[i]
def _ascall_bitmap(self, buffer, x=0):
if -_FONT_W <= x <= _LEDS_W and buffer is not None:
if -_FONT_W <= x <= _LEDS_W:
for _x in range(_FONT_W):
for _y in range(_FONT_H):
if (buffer[_x] >> _y) & 0x1:
@@ -146,7 +148,7 @@ class BOT035(FrameBuffer):
def _uincode_bitmap(self, buffer, x=0):
_buffer, width = buffer
if -width < x < _LEDS_H and _buffer is not None:
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)):
@@ -222,9 +224,9 @@ class BOT035(FrameBuffer):
return self._i2c.readfrom(_BOT035_ADDRESS, nbytes)[0]
def reset(self):
"""Reset SPK, PWM registers to default state"""
"""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')
self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_KB, bytes(9))
#self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_KB, bytes(9))
def get_brightness(self):
return self._brightness
@@ -285,11 +287,12 @@ class BOT035(FrameBuffer):
def hid_keyboard(self, special=0, general=0, release=True):
self._buf = bytearray(4)
self._buf[0] = special
if type(general) is int:
self._buf[1] = general
elif type(general) is tuple:
if type(general) in (tuple, list):
for i in range(len(general)):
if i > 2: break
self._buf[i + 1] = general[i]
else:
self._buf[1] = general
self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_KB, self._buf)
if release:
time.sleep_ms(10)
@@ -297,21 +300,15 @@ class BOT035(FrameBuffer):
def hid_keyboard_str(self, string, delay=0):
for char in str(string):
self._wreg(_BOT035_STR, ord(char))
self._wreg(_BOT035_STR, ord(char) & 0xFF)
time.sleep_ms(20 + delay)
def hid_mouse(self, keys=0, move=(0, 0), wheel=0, release=True):
self._buf = bytearray(4)
self._buf[0] = keys
self._buf[1] = move[0]
self._buf[2] = move[1]
self._buf[3] = wheel
self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_MS, self._buf)
self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_MS, bytes([keys & 0x0F, move[0] & 0xFF, move[1] & 0xFF, wheel & 0xFF]))
if release:
time.sleep_ms(10)
self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_MS, bytes(4))
"""Graph module"""
HEART=b'\x00\x0c\x1e?~\xfc~?\x1e\x0c\x00\x00'
HEART_SMALL=b'\x00\x00\x0c\x1e<x<\x1e\x0c\x00\x00\x00'

View File

@@ -1703,18 +1703,25 @@
</block>
<block type="analog_keyboard_input" m-show="micropython:esp32c2:mixgo_mini">
<value name="special">
<shadow type="special_key">
</shadow>
<block type="special_key">
</block>
</value>
<value name="general">
<shadow type="general_key">
</shadow>
<block type="general_key">
</block>
</value>
</block>
<block type="general_key_tuple" m-show="micropython:esp32c2:mixgo_mini">
<value name="general">
<block type="general_key">
</block>
</value>
</block>
<block type="analog_mouse_input" m-show="micropython:esp32c2:mixgo_mini">
<value name="key">
<shadow type="mouse_key">
</shadow>
<block type="mouse_key">
</block>
</value>
<value name="x">
<shadow type="math_number">
@@ -1737,6 +1744,7 @@
</value>
<value name="time">
<shadow type="math_number">
<field name="NUM">10</field>
</shadow>
</value>
</block>