Marquee is working now
This commit is contained in:
parent
ec0233f756
commit
6578445931
2 changed files with 19 additions and 30 deletions
|
|
@ -3,7 +3,7 @@
|
|||
from ctypes import CDLL, POINTER, c_void_p, Structure, c_uint8, c_size_t, cast, addressof
|
||||
import numpy as np
|
||||
from itertools import product
|
||||
from matelight import sendframe
|
||||
from matelight import sendframe, DISPLAY_WIDTH, DISPLAY_HEIGHT
|
||||
from terminal import printframe
|
||||
|
||||
class COLOR(Structure):
|
||||
|
|
@ -25,18 +25,25 @@ def render_text(text):
|
|||
buf = np.ctypeslib.as_array(cast(fbd.data, POINTER(c_uint8)), shape=(fbd.h, fbd.w, 4))
|
||||
# Set data pointer to NULL before freeing framebuffer struct to prevent free_framebuffer from also freeing the data
|
||||
# buffer that is now used by numpy
|
||||
bdf.console_render_buffer(fb)
|
||||
#bdf.console_render_buffer(fb)
|
||||
fbd.data = cast(c_void_p(), POINTER(COLOR))
|
||||
bdf.free_framebuffer(fb)
|
||||
return buf
|
||||
|
||||
def printframe(fb):
|
||||
h,w,_ = fb.shape
|
||||
bdf.console_render_buffer(fb.ctypes.data_as(ctypes.POINTER(ctypes.c_uint8)), w, h)
|
||||
print('\033[H\033[2J')
|
||||
bdf.console_render_buffer(fb.ctypes.data_as(POINTER(c_uint8)), w, h)
|
||||
|
||||
if __name__ == '__main__':
|
||||
fb = render_text('foobarbaz');
|
||||
sendframe(fb)
|
||||
# printframe(fb)
|
||||
|
||||
fb = render_text('\033[31;48;5;167;4;6mfoo\033[0;91mbar\033[93;106;5mbaz\033[0m\033[0;94;6m♥♥♥');
|
||||
h,w,_ = fb.shape
|
||||
for i in range(-DISPLAY_WIDTH,w+1):
|
||||
leftpad = np.zeros((DISPLAY_HEIGHT, max(-i, 0), 4), dtype=np.uint8)
|
||||
framedata = fb[:, max(0, i):min(i+DISPLAY_WIDTH, w)]
|
||||
rightpad = np.zeros((DISPLAY_HEIGHT, min(DISPLAY_WIDTH, max(0, i+DISPLAY_WIDTH-w)), 4), dtype=np.uint8)
|
||||
dice = np.concatenate((leftpad, framedata, rightpad), 1)
|
||||
sendframe(dice)
|
||||
printframe(dice)
|
||||
fb = render_text('\033[31;48;5;167;4;6mfoo\033[0;91mbar\033[93;106;5mbaz\033[0m\033[0;94;6m♥♥♥');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue