"""ILI9341 demo (fonts)."""
from time import sleep
from ili9341 import Display, color565
from machine import Pin, SPI, SoftI2C
from xglcd_font import XglcdFont
import utime
import machine
# Initialiser SoftI2C avec SDA sur GPIO 23 et SCL sur GPIO 22
i2c = SoftI2C(scl=Pin(22), sda=Pin(23))
# Configuration SPI avec les broches mises à jour
spi = SPI(1, baudrate=10000000, sck=Pin(18), mosi=Pin(12), miso=Pin(19))
# Configuration de l'affichage avec les broches mises à jour
display = Display(spi, dc=Pin(2), cs=Pin(15), rst=Pin(4))
# Charger la police
print('Fonts loading...')
espresso_dolce = XglcdFont('EspressoDolce18x24.c', 18, 24)
print('espresso_dolce loaded.')
bally = XglcdFont('Bally7x9.c', 7, 9)
print('bally loaded.')
unispace = XglcdFont('Unispace12x24.c', 12, 24)
print('unispace loaded.')
Dejavu = XglcdFont('Dejavu24x43.c', 24, 43)
print('Dejavu loaded.')
robotron = XglcdFont('Robotron13x21.c', 13, 21)
print('robotron loaded.')
print('Fonts loaded.')
# Définir les coordonnées et la largeur de la zone de texte
x_start = 0
y_start = 60
text_width = 240 # Ajustez selon la largeur de l' écran
def interfaces():
display.clear(color565(245, 245, 245))
display.fill_rectangle(80, 5, 25, 310, color565(0, 0, 0))
display.fill_rectangle(110, 5, 25, 310, color565(0, 0, 0))
display.fill_rectangle(140, 5, 25, 310, color565(228, 255, 90))
display.fill_rectangle(170, 5, 25, 310, color565(255, 255, 255))
display.fill_rectangle(200, 5, 25, 310, color565(255, 255, 255))
display.draw_text(30, 315, 'GPS Data', unispace, color565(0, 0, 0), landscape=True, background=color565(245, 245, 245))
display.draw_text(59, 315, 'Overview', bally, color565(0, 0, 0), landscape=True, background=color565(245, 245, 245))
while True :
display.draw_text(5, 32, '100%', bally, color565(0, 0, 0), landscape=True, background=color565(245, 245, 245))
display.draw_text(5, 315, '21:30', bally, color565(0, 0, 0), landscape=True, background=color565(245, 245, 245))
display.draw_text(89, 310, 'Latitude : 12 deg 17.55436\' E', bally, color565(255, 255, 255), landscape=True, background=color565(0, 0, 0))
display.draw_text(119, 310, 'Longitude : 49 deg 18.24274\' N', bally, color565(255, 255, 255), landscape=True, background=color565(0, 0, 0))
display.draw_text(149, 310, 'Altitude : 61.4', bally, color565(0, 0, 0), landscape=True, background=color565(228, 255, 90))
display.draw_text(179, 310, 'Satelites in use : 4', bally, color565(0, 0, 0), landscape=True, background=color565(255, 255, 255))
display.draw_text(209, 310, 'Horizontale Dilution of Precision : 99.99', bally, color565(0, 0, 0), landscape=True, background=color565(255, 255, 255))
def run():
print('Interface va afficher')
try:
while True:
interfaces()
utime.sleep(.1)
pass # Keep the script running
except KeyboardInterrupt:
print("\nCtrl-C pressed. Cleaning up and exiting...")
run()