build(boards): xpython板卡执行 npm run build:prod
This commit is contained in:
@@ -161,6 +161,8 @@ class FrameBuffer_Base(FrameBuffer):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self._buffer = buf
|
||||
self._way = 1
|
||||
self._speed = 100
|
||||
|
||||
def show(self):
|
||||
print("External inheritance is required to override this method")
|
||||
@@ -304,6 +306,16 @@ class FrameBuffer_Ascall(FrameBuffer_Base):
|
||||
"""Font selection or externally defined font code"""
|
||||
self._font = Font_Ascall(font)
|
||||
|
||||
def uin_font(self, font_address=0x3A0000):
|
||||
"""Uincode encoding font code"""
|
||||
self._ufont = Font_Uincode(font_address)
|
||||
|
||||
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 bitmap(self, buffer, x=0, y=0):
|
||||
"""Graphic model display(buffer,(width,height))"""
|
||||
buffer_info, (width, height) = buffer
|
||||
@@ -314,6 +326,45 @@ class FrameBuffer_Ascall(FrameBuffer_Base):
|
||||
if (buffer_info[char_x] >> char_y) & 0x1:
|
||||
self.pixel(x + char_x, y + char_y, 1, sync=False) if height <= self.height else self.pixel(y + char_y, self.height - (x + char_x), 1, sync=False)
|
||||
|
||||
def _uincode_scroll(self, buffer, space):
|
||||
"""Scroll to display uincode encoded characters"""
|
||||
_len = 0
|
||||
for buf in buffer:
|
||||
_len = _len + space + (buf[1][1] if self._way <= 1 else buf[1][0])
|
||||
for i in range(_len - space + (self.width if self._way <= 1 else self.height)):
|
||||
_step = (self.width - 1 if self._way <= 1 else self.height) - i
|
||||
self.fill(0, sync=False)
|
||||
for buf in buffer:
|
||||
_buf, (width, height) = buf
|
||||
_xx = (self.width - width) // 2
|
||||
_yy = (self.width - height) // 2
|
||||
if -width < _step < self.width or -height < _step < self.height :
|
||||
for _y in range(height):
|
||||
for _x in range(width):
|
||||
if _buf[_y * ((width + 7) // 8) + _x // 8] & (0x80 >> (_x & 7)):
|
||||
if self._way == 0:
|
||||
self.pixel(self.width - (_x + _xx) - 2, self.height - (_step + _y), 1, sync=False)
|
||||
elif self._way == 1:
|
||||
self.pixel(_xx + _x + 1, _step + _y, 1, sync=False)
|
||||
elif self._way == 2:
|
||||
self.pixel(_y +_yy, self.height - (_step + _x), 1, sync=False)
|
||||
elif self._way == 3:
|
||||
self.pixel(self.width - (_y +_yy) - 1, (_step + _x), 1, sync=False)
|
||||
_step = _step + space + (height if self._way <= 1 else width)
|
||||
self.show()
|
||||
time.sleep_ms(self._speed)
|
||||
|
||||
def _gb2312_scroll(self, data, space):
|
||||
"""Determine if the uincode is encoded"""
|
||||
for char in data:
|
||||
if ord(char) >= 0xFF:
|
||||
font_buffer = []
|
||||
for c in data:
|
||||
_buffer = self._ufont.chardata(c)
|
||||
font_buffer.append(_buffer)
|
||||
self._uincode_scroll(font_buffer, space)
|
||||
return True
|
||||
|
||||
def shows(self, data, space=0, center=True, sync=True):
|
||||
"""Display character"""
|
||||
if data is not None:
|
||||
@@ -322,11 +373,12 @@ class FrameBuffer_Ascall(FrameBuffer_Base):
|
||||
self.set_buffer(data, sync)
|
||||
else:
|
||||
data=str(data)
|
||||
x = (self.width - len(data) * (self._font.font_width + space) + space) // 2 if center else 0
|
||||
for char in data:
|
||||
self.bitmap(self._font.chardata(char), x)
|
||||
x = self._font.font_width + x + space
|
||||
if sync: self.show()
|
||||
if not self._gb2312_scroll(data, space):
|
||||
x = (self.width - len(data) * (self._font.font_width + space) + space) // 2 if center else 0
|
||||
for char in data:
|
||||
self.bitmap(self._font.chardata(char), x)
|
||||
x = self._font.font_width + x + space
|
||||
if sync: self.show()
|
||||
|
||||
def frame(self, data, delay=500):
|
||||
"""Display one frame per character"""
|
||||
@@ -339,26 +391,34 @@ class FrameBuffer_Ascall(FrameBuffer_Base):
|
||||
time.sleep_ms(delay)
|
||||
else:
|
||||
data=str(data)
|
||||
x=(self.width - self._font.font_width) // 2
|
||||
for char in data:
|
||||
self.fill(0, sync=False)
|
||||
self.bitmap(self._font.chardata(char), x)
|
||||
self.show()
|
||||
if ord(char) >= 0xFF:
|
||||
_way = self._way
|
||||
self._way = 1
|
||||
self._uincode_scroll([self._ufont.chardata(char)], 0)
|
||||
self._way = _way
|
||||
else:
|
||||
self.bitmap(self._font.chardata(char), (self.width - self._font.font_width) // 2 )
|
||||
self.show()
|
||||
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)
|
||||
str_len = len(data) * (self._font.font_width + space) - space
|
||||
for i in range(str_len + self.width + 1):
|
||||
x = -i + self.width
|
||||
self.fill(0, sync=False)
|
||||
for char in data:
|
||||
self.bitmap(self._font.chardata(char),x)
|
||||
x = self._font.font_width + x + space
|
||||
self.show()
|
||||
time.sleep_ms(speed)
|
||||
if not self._gb2312_scroll(data, space):
|
||||
str_len = len(data) * (self._font.font_width + space) - space
|
||||
for i in range(str_len + self.width + 1):
|
||||
x = -i + self.width
|
||||
self.fill(0, sync=False)
|
||||
for char in data:
|
||||
self.bitmap(self._font.chardata(char),x)
|
||||
x = self._font.font_width + x + space
|
||||
self.show()
|
||||
time.sleep_ms(self._speed)
|
||||
|
||||
class FrameBuffer_Uincode(FrameBuffer_Base):
|
||||
'''FrameBuffer for Uincode'''
|
||||
|
||||
Reference in New Issue
Block a user