#Ecran ili9341 Touch
import machine, onewire, ds18x20, time, binascii
from machine import Pin, SPI, Timer
timer_0 = Timer(0)
from ili9341new import ILI9341, color565
from xpt2046 import Touch
import ESP32
from ESP32 import *
import ZonesTactiles
from ZonesTactiles import *
import random
blanc=color565(255,255,255)
noir=color565(0,0,0)
rouge=color565(255,0,0)
blue=color565(0,0,255)
vert=color565(0,255,0)
cyan = color565(0, 255, 255)
pourpre = color565(255, 0, 255)
grisF=color565(64,64,64)
grisM=color565(128,128,128)
grisC=color565(192,192,192)
temp_pièce=20.1
temp_motoconvecteur=26.7
# INIT ECRAN ili9341
power = Pin(ILI_LED_PIN, Pin.OUT)
power.value(1) # obligatoire sur certains modele
#---------------------------------------------
cs_pin=Pin(ILI_CS_PIN,Pin.OUT)
cs_pin.on()
cs_pinTouch=Pin(ILI_CS_PINTouch,Pin.OUT)
irq_pinTouch=Pin(ILI_IRQ_PINTouch,Pin.IN)
cs_pinTouch.on()
spi = SPI(2,
baudrate=40000000,
miso=Pin(ILI_MISO_PIN),
mosi=Pin(ILI_MOSI_PIN),
sck=Pin(ILI_CLK_PIN)
)
ecran = ILI9341(
spi,
cs=Pin(ILI_CS_PIN),
dc=Pin(ILI_DC_PIN),
rst=Pin(ILI_RST_PIN),
w=ILI_largeur,
h=ILI_hauteur,
r=ILI_rotation
)
# capteur tactile
#print("___FIN DES DEFINITIONS des routines--debut boucle____")
# (0x001F) # FOND BLEU
# (0x1FF8) # MAGENTA
# (0xFF07) # VERT
# (0x20FD) # ORANGE ROSE
# (0xEFBD) # FOND gris clair
import framebuf
def creer_sprite(sprite_ON,texte, color_texte, color_fond):
w =8
h =8
buf_Entree = bytearray(w * h * 2)
fb_buf_Entree = framebuf.FrameBuffer(buf_Entree, w, h, framebuf.RGB565)
fb_buf_Entree.fill(color_fond) # FOND gris clair
fb_buf_Entree.text(texte, 0, 0, color_texte) # CARACTERES
ecran.ds_sprite(fb_buf_Entree, 10, 10, w, h)
continuer = input("enter 3 pour continuer")
W = 2*w
H = 2*h
buf_X2 = bytearray(W * H * 4)
fb_buf_X2 = framebuf.FrameBuffer(buf_X2, W, H, framebuf.RGB565)
ligne_O = bytearray(w*2) # ligne O à traiter
ligne_D = bytearray(W*2) #w*4 ligne D à creer
index_D = 0
for ih in range(h): #pour la ligne ih
ligne_O[:] = buf_Entree[ih*2*w:ih*2*w + 2*w] # extraction ligne ih
index_LD = 0
for iw in range(0,2*w,2): # parcourir les w*2 codcol
ligne_D[index_LD:index_LD+2] = ligne_O[iw:iw+2]
ligne_D[index_LD+2:index_LD+4] = ligne_O[iw:iw+2]
index_LD += 4
buf_X2[index_D:index_D+2*W] = ligne_D[:]
buf_X2[index_D+2*W:index_D+4*W] = ligne_D[:]
index_D += 4*W
sprite_ON[:]=buf_X2
W=48
H=16
sprite_ON = bytearray(W*2 * H*2 * 2)
fb_sprite_ON = framebuf.FrameBuffer(sprite_ON, W, H, framebuf.RGB565)
creer_sprite(sprite_ON,"O", 0x0000, 0x001F)
ecran.ds_sprite(fb_sprite_ON, 30, 59, W, H)