Skip to content
Snippets Groups Projects
Commit b0caff73 authored by michael.divia's avatar michael.divia
Browse files

Christmas function + update rapport

parent 55cfca67
Branches
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ from machine import Pin
from neopixel import NeoPixel
import utime
nb_line = 16
nb_line = 8
nb_row = 8
gpio_neopixel = 0
......@@ -259,3 +259,104 @@ def afficher_texte(text, color, speed):
for i in range(nb_row):
printColumn(step + i, i, text)
utime.sleep(speed)
def christmas():
color = 0x3
prime1=439
prime2=17005013
masque_blanc= 0x0f0f0f # setup LEDs intensity
masque_rouge=0x0f0000
masque_bleu=0x00000f
period = .01
# Balles glissantes
for r in range(100):
color = (color * prime1) % prime2
# horizontale et verticale
if color&4 == 4:
for i in range(8):
temp = (4-int(abs(4.5-i))+1)
temp = max(3-2*int(temp/2),0)
for j in range(temp,8-temp):
if (color&3 == 0):
diagonal=min(int((i+j)),7)
elif (color&3 == 1):
matrix.set_led(i,j, color&masque_blanc)
elif (color&3 == 2):
matrix.set_led(7-i,j, color&masque_blanc)
else:
matrix.set_led(j,7-i, color&masque_blanc)
utime.sleep(period)
# Diagonale
else:
for k in range(2,9):
for i in range(k+1):
if (4.5-(k-i))**2+(4.5-i)**2 < 5**2:
if (color&3 == 0):
matrix.set_led((k-i),(i), color&masque_blanc)
elif (color&3 == 1):
matrix.set_led((i),(k-i), color&masque_blanc)
elif (color&3 == 2):
matrix.set_led((7-(k-i)),(i), color&masque_blanc)
else:
matrix.set_led((i),7-(k-i), color&masque_blanc)
utime.sleep(period)
# Clear the matrix
matrix.clear(0)
# Couleurs clignote
period = .5
for r in range(20):
color = (color * prime1) % prime2
for i in range(8):
for j in range(8):
matrix.set_led(j,i,color*(i+1)*(j+11) & masque_blanc)
utime.sleep(period)
matrix.clear(0)
utime.sleep(period/10)
# Bleu aléatoire
period = .05
for r in range(20):
color = (color * prime1) % prime2
for i in range(8):
for j in range(8):
matrix.set_led(j,i,color*(i+1)*(j+11) >> 4 & masque_bleu)
utime.sleep(period)
# Couleurs aleatoire
period = .05
for r in range(10):
color = (color * prime1) % prime2
for i in range(8):
for j in range(8):
matrix.set_led(j,i,color*(i+1)*(j+11) & masque_blanc)
utime.sleep(period)
# Rouge aléatoire
period = .05
for r in range(10):
color = (color * prime1) % prime2
for i in range(8):
for j in range(8):
matrix.set_led(j,i,color*(i+1)*(j+11) & masque_rouge)
utime.sleep(period)
# Lignes
period = .05
for r in range(10):
color = (color * prime1) % prime2
for i in range(8):
matrix.set_led(color%8,i,color*(i+1)*(j+11) & masque_blanc)
utime.sleep(period)
matrix.clear(0)
for i in range(8):
matrix.set_led(i,color%8,color*(i+1)*(j+11) & masque_blanc)
utime.sleep(period)
matrix.clear(0)
\ No newline at end of file
from hl3 import *
import time
afficher_texte("Hello world!", color.ORANGE, 0.1)
while True:
christmas()
......@@ -42,7 +42,11 @@ J'ai ensuite pris du temps afin de souder des pin à la matrice de LED afin de f
## Mardi, 18 Juin 2024
J'ai commencé par créer `hl3.py` afin d'avoir un fichier librairie avec toutes les fonctions que nous allons implémentées. Je me suis ensuite attelé à la finalisation de la fonction `matrix`. J'ai aussi profité d'implémenter toute les couleurs que nous devions implémentées d'après la documentation. J'ai ensuite enchaîné avec l'ajout de la fonction `set_line`,`set_column`, `set_led`, `get_led` puis, avec l'aide de Gaspard, nous avons implémenter la fonction `afficher_texte`.
J'ai commencé par créer `hl3.py` afin d'avoir un fichier librairie avec toutes les fonctions que nous allons implémentées. Je me suis ensuite attelé à la finalisation de la fonction `matrix`.
J'ai aussi profité d'implémenter toute les couleurs que nous devions implémentées d'après la documentation. J'ai ensuite enchaîné avec l'ajout de la fonction `set_line`,`set_column`, `set_led`, `get_led` puis, avec l'aide de Gaspard, nous avons implémenter le début de la fonction `afficher_texte`.
J'ai ensuite créer un fonction de démo `christmas` afin de démontré le bon fonctionnement des LEDs. Cette fonction est une ré-implémentation de la fonction de M. Gluck que vous pouvez trouver [ici](https://gitedu.hesge.ch/cores/projects/hepialight2/hepialight2-examples/-/blob/02261b68aad94dd52c6b35fdb83ed1d54028061b/peripherals/display/christmas_ball.py).
# Creators
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment