POV

De Wiki Fab Lab Onl'Fait
Révision datée du 1 février 2024 à 13:39 par Paddy (discussion | contributions) (Ajout lien convertisseur lettre et image vers digit)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à la navigation Aller à la recherche

POV ou Persistence Of Vision ou Persistence rétinienne en anglais.


Le but de ce projet est de réutiliser le montage réalisé pour l'atelier "Ombres colorées" (une bande de 33 leds avec un micro-bit) pour en faire un affichage à LED utilisant la persistance rétinienne.


Quelques sources et projets utilisés (ou pas) pour réaliser le projet.

version pour PIC et 8 LEDS: http://nononux.free.fr/index.php?page=elec-brico-pic-pov

version pour arduino nano: https://www.instructables.com/Arduino-Based-POV-Display-Stick-JolliPOV-Stick/

create a font from one of your computer’s TrueType fonts that’s easily scalable to any size of LED matrix: http://www.georgegardner.info/arduino/easy-font-creation-for-led-matrix-from-truetype-system-fonts.html

circuit python painter (adafruit): https://learn.adafruit.com/circuitpython-painter/software

How to Make an Arduino POV (Persistence of Vision) Display: http://www.techydiy.org/arduino-pov-display/ & https://www.youtube.com/watch?v=JVoKobgGwBk

RGBike POV - Open Project: https://www.instructables.com/RGBike-POV-Open-project/

DIY LED POV Display: https://ai.thestempedia.com/project/diy-led-pov-display/

generating character or image byte arrays for dot matrix style OLED: https://github.com/stefangordon/dotmatrixtool


Première version du code, pas complétement fonctionnel mais c'est un début ;-) <syntaxhighlight lang="python"> from microbit import * import neopixel from random import randint

  1. Setup the Neopixel strip on pin0 with a length of 30 pixels

np = neopixel.NeoPixel(pin0, 30) couleur_set=[(0,0,0),(60,0,0),(0,60,0),(60,60,0),(0,0,100),(30,30,30)] compte=0 taille=1 maxled=8 couleurpix=0

phrase = [ 0b11111111111111111111111111111100, 0b11111111111111111111111111111100, 0b11111100000000000000000000000000, 0b00001111110000000000000000000000, 0b00000000111111000000000000000000, 0b00000000000011111100000000000000, 0b00000000000000001111110000000000, 0b00000000000000000000111111000000, 0b00000000000000000000001111111100, 0b11111111111111111111111111111100, 0b11111111111111111111111111111100, 0b00000000000000000000000000000000, 0b00000000000000000000000000000000, 0b00000000111111111111110000000000, 0b00000000111111111111110000000000, 0b00000011111100000011111100000000, 0b00001111110000000000111111000000, 0b00111111000000000000001111110000, 0b11111100000000000000000011111100, 0b11111100000000000000000011111100, 0b11111100000000000000000011111100, 0b11111100000000000000000011111100, 0b11111100000000000000000011111100, 0b11111100000000000000000011111100, 0b00111111000000000000001111110000, 0b00001111110000000000111111000000, 0b00000011111100000011111100000000, 0b00000000111111111111110000000000, 0b00000000111111111111110000000000, 0b00000000000000000000000000000000]

def wheel(pos):

  #Input a value 0 to 255 to get a color value.
  #The colours are a transition r - g - b - back to r.
   if pos < 0 or pos > 255:
       return (0, 0, 0)
   if pos < 85:
       return (255 - pos * 3, pos * 3, 0)
   if pos < 170:
       pos -= 85
       return (0, 255 - pos * 3, pos * 3)
   pos -= 170
   return (pos * 3, 0, 255 - pos * 3)

def rainbow_cycle(wait):

  for j in range(255):
      for i in range(30):
           rc_index = (i * 256 // 30) + j
           np[i] = wheel(rc_index & 255)
           np.write()
           sleep(wait)
     

while True:

   #Iterate over each LED in the strip
   if button_a.is_pressed() and button_b.is_pressed():
       rainbow_cycle(5)
   elif button_a.is_pressed():
       compte=(compte+1)%len(couleur_set)
   elif button_b.is_pressed():
       taille=(taille+1)%maxled
   for i in phrase: 
       for pixel_id in range(29,-1,-1):
   
           # Assign the current LED a random red, green and blue value between 0 and 60
           bit= (i >> pixel_id) & 1
           np[pixel_id] = couleur_set[bit]        #np[pixel_id-taille] = (int(phrase[i,pixel_id])*128, int(phrase[i,pixel_id])*128, int(phrase[i,pixel_id])*128))
           print(bit)
       # Display the current pixel data on the Neopixel strip
       np.show()
       sleep(0.003)
       if button_a.is_pressed() and button_b.is_pressed():
           rainbow_cycle(5)

</syntaxhighlight>