get ram and others tests to see how fast can I update the screen
authorEduardo <[email protected]>
Sun, 10 Dec 2023 21:59:34 +0000 (22:59 +0100)
committerEduardo <[email protected]>
Sun, 10 Dec 2023 21:59:34 +0000 (22:59 +0100)
main.py

diff --git a/main.py b/main.py
index c6a9bd6888d79d2adcd89422f886f8010eb8e1ee..09719267f4f6b9ce9a1fea334b68db140f2b1453 100644 (file)
--- a/main.py
+++ b/main.py
@@ -1,10 +1,9 @@
 from machine import Pin, Timer, SPI
-from libs.neopixel import (
-    Neopixel,
-)  # https://github.com/blaz-r/pi_pico_neopixel/wiki/Library-methods-documentation # type: ignore
-from libs.ili9341 import Display
-from uasyncio import sleep_ms
-from utils import df
+from libs.neopixel import Neopixel # https://github.com/blaz-r/pi_pico_neopixel/wiki/Library-methods-documentation
+from libs.ili9341 import Display, color565
+from libs.xglcd_font import XglcdFont
+from time import sleep_us, ticks_cpu, ticks_us, ticks_diff
+from utils import df, free
 
 # region SPI SCREEN
 
@@ -29,11 +28,18 @@ spi = SPI(
     sck=Pin(TFT_CLK_PIN),
 )
 display = Display(spi, dc=Pin(TFT_DC_PIN), cs=Pin(TFT_CS_PIN), rst=Pin(TFT_RST_PIN))
-display.clear()
+display.clear(hlines=80)
+display.fill_rectangle(0, 0, 240, 320, -1)
 
 # display.draw_image('ili9341/images/kururin_anim/kururin1.raw', 0, 0)
 # display.draw_image('ili9341/images/RaspberryPiWB128x128.raw', 0, 0, 128, 128)
 
+# arcadepix = XglcdFont('fonts/ArcadePix9x11.c', 9, 11)
+# print('Fonts loaded.')
+
+# def print_clock(time):
+#     display.draw_text(10, 10, 'Arcade Pix 9x11', arcadepix, color565(255, 0, 0), -1)
+
 # endregion
 # region RGB PIXEL
 
@@ -56,8 +62,8 @@ def move_rgb(_):
 # endregion
 # region main program
 
-print(df())
-display.fill_rectangle(0, 0, 239, 319, -1)
+print("Disk: " + df())
+print("RAM: " + free())
 
 # makes the rgb led rotate colors
 rgb_timer = Timer(period=50, mode=Timer.PERIODIC, callback=move_rgb)
@@ -66,6 +72,7 @@ y = 0
 right = False
 bottom = False
 while True:
+    timer = ticks_us()
     if x + 128 > 239:
         right = True
     elif x == 0:
@@ -84,7 +91,12 @@ while True:
     else:
         y += 1
         
-    display.draw_image("ili9341/images/RaspberryPiWB128x128.raw", x, y, 128, 128)
-    sleep_ms(10)
+    # display.draw_image("ili9341/images/RaspberryPiWB128x128.raw", x, y, 128, 128)
+    
+    # print_clock(0)
+    timer = ticks_us()
+    timer_dif = 333 - ticks_diff(ticks_us(), timer)
+    if timer_dif > 0:
+        sleep_us(timer_dif)
 
 # endregion