Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import machine
- import neopixel
- import time
- import framebuf as fb
- NR_PIXEL_WIDTH = const(8)
- NR_PIXEL_HEIGHT = const(8)
- buf_array = bytearray(NR_PIXEL_WIDTH * NR_PIXEL_HEIGHT * 3)
- p1 = machine.Pin(13,machine.Pin.OUT)
- fbuf = fb.FrameBuffer(buf_array, NR_PIXEL_WIDTH, NR_PIXEL_HEIGHT, fb.RGB888)
- @micropython.viper
- def zickzack_rgb24(fbuf):
- buf = ptr8(fbuf)
- for y in range(0, NR_PIXEL_HEIGHT, 2):
- offset_s = NR_PIXEL_WIDTH * y * 3
- offset_e = offset_s + 3 * (NR_PIXEL_WIDTH - 1)
- # print("{} - {}".format(offset_s, offset_e))
- for x in range(0, NR_PIXEL_WIDTH//2):
- tmp = buf[offset_e - x * 3]
- buf[offset_e - x * 3] = buf[offset_s + x * 3]
- buf[offset_s + x * 3] = tmp
- tmp = buf[offset_e - x * 3 +1]
- buf[offset_e-x * 3 + 1] = buf[offset_s + x * 3 +1]
- buf[offset_s+x * 3 + 1] = tmp
- tmp = buf[offset_e - x * 3 +2]
- buf[offset_e - x * 3 + 2] = buf[offset_s + x * 3 + 2]
- buf[offset_s+x * 3 + 2] = tmp
- def write_neo(text):
- fbuf.fill(0)
- for c in text:
- fbuf.text(c, 0, 0, 10)
- zickzack_rgb24(buf_array)
- neopixel.neopixel_write(p1, buf_array, 1)
- time.sleep(1)
- fbuf.fill(0)
- write_neo("HALLO")
Add Comment
Please, Sign In to add comment