Matrice di led con HT1632C (4)

luca 12/10/2012 20

Nel precedente tutorial, abbiamo visto come visualizzare sul display una scritta statica, codificata e memorizzata nella memoria programma di Arduino. In questo tutorial vedremo come costruire scritte dinamiche…

CODIFICA FONT

Per comporre a runtime una scritta, dobbiamo codificare i singoli caratteri, memorizzandoli nella memoria programma.

Possiamo procedere manualmente (“disegnando” ogni carattere su carta); per velocizzare l’attività ho sviluppato un programma per Windows, LetterToBinary:

Il codice sorgente (C#) del programma è disponibile in un repository GitHub; per scaricare la versione compilata fai click qui.

Usando LetterToBinary è possibile ottenere subito la codifica di un carattere e copiarla nella clipboard di Windows; ho utilizzato questo applicativo per codificare tutto il set di caratteri (font) Ai Pointe, di Ritchie Ned Hansel:

Il font è quindi memorizzato in un array all’interno della memoria programma:

DESCRITTORE FONT

Perché Arduino possa comporre una scritta utilizzando il font appena codificato, è necessario fornire due informazioni:

  • la lunghezza (= numero di byte) del singolo carattere
  • l’offset di inizio del carattere all’interno dell’array

Ho separato il font dallo sketch principale memorizzandolo in un file .h, all’interno del quale è definita una struttura FONT_INFO:

typedef struct {  
  unsigned char length;  
  unsigned int offset;
} FONT_INFO;

e un array con elementi FONT_INFO, uno per ogni carattere:

FONT_INFO aipoint_info[] = {
  {2, 0},	// !
  {5, 2},	// "
  {5, 7},	// #
  {5, 12},	// $
  {5, 17},	// %
  ...

Attraverso questo array Arduino può sapere che – ad esempio – il carattere $ ha lunghezza 5 bytes e inizia dal byte 12 dell’array aipointe_font[].

Osservando la tabella dei codici ASCII, notiamo che siamo partiti a codificare dal carattere ! Tale carattere ha valore decimale 33 ed è memorizzato all’elemento 0 dell’array aipointe_info[]: questo significa che, per sapere la posizione occupata in tale array dai vari caratteri, dovremo sottrarre al loro valore decimale il numero 33.

Nella prossima pagina vedremo come scrivere uno sketch che utilizzi il font così codificato…

Pagine: 1 2

20 Comments »

  1. Locomolo 14/10/2012 at 12:45 - Reply

    Hi Luca,

    I have a 3208 matrix display likes yours, but when i upload the arduino’s sketch all is working well but the text display is rotated 90 degres. It’ s like the leds panels aren’t wired in the same position.

    This is my 3208 led matrix:

    http://fw.hardijzer.nl/?p=148

    How can i modify your sketch to getting the correct position?

    Thanks!

    • luca 14/10/2012 at 13:12 - Reply

      Hi Luis,

      mmm it seems they rotated each matrix 90 degrees? What does it happen if you run the “static text” example (nr 3)? Could you please post a photo?
      Thanks

  2. Locomolo 14/10/2012 at 18:59 - Reply

    Hi Luca!

    Yes, each matrix is rotated 90 degrees.

    http://imageshack.us/photo/my-images/402/20121014194624.jpg/sr=1

    Thanks

    • luca 16/10/2012 at 16:23 - Reply

      Hi Luis,

      mmm I wasn’t able to find any datasheets about your display to know how they connected each matrix to the controller. I’m going to send you a demo sketch via mail to do some tests…

  3. Locomolo 16/10/2012 at 23:25 - Reply

    Hi Luca, here some info about this led matrix( datasheet…)

    http://fw.hardijzer.nl/?p=148.

    Thanks a lot, i ‘am ready for testing.

  4. Locomolo 21/10/2012 at 13:25 - Reply

    Hi luca, i upgraded my fileshack library with the images, arduino UNO running your first sketch.

    The order is, the first dot begins at the rightest matrix, at bottom right, and the last is the upperest left, always in horizontal direction form the right to the left. Similar for the four matrix.

    Check it please
    http://imageshack.us/photo/my-images/402/20121014194624.jpg/sr=1

    • luca 27/10/2012 at 09:40 - Reply

      Hi Luis,

      I’ve just sent you a demo sketch for your display, let me know how it works

  5. Toni B. 04/11/2012 at 14:45 - Reply

    Thanks vor the great help ! I Try the same Projekt but i try to make 2 led Matrix with 8x 32 Leds with 16.000 mcd each red led. I want go give any Text out of my rear from my Car XD such as the German Police .

    Great thanks from Germany !

    • luca 04/11/2012 at 22:59 - Reply

      Thanks Toni!

  6. Locomolo 15/11/2012 at 21:17 - Reply

    Hi Lucca thanks for your help, finally i found a compatible library in Github, otherwise i keep regarding your project :)

    • luca 16/11/2012 at 08:48 - Reply

      Good news, Luis!
      Could you please send me the link of your library? I’ll add it in my article…
      thanks

    • Martin 18/09/2013 at 14:16 - Reply

      Hi Luca,

      forgot to tell, yes. I’m using same matrix as Locomolo (mcu 3208 matrix clock, with atmega removed) and chars and scroll direction is rotated 90 degrees.

      Searched all over github (and the rest of the internet :)) but can’t find working solution.

      • luca 19/09/2013 at 12:46 - Reply

        Hi Martin,

        hope that Locomolo will send you the link to the library he found on Github because I can’t find it too… :(

  7. xyz 18/03/2013 at 23:03 - Reply

    Hello,

    Currently I am working on Sure Electronics 0832 Display interfacing with PIC16F1937.
    I am using SPI interface between PIC16F1937 and Display.

    I am facing problem with Scrolling Message across Led display. I made 4*7 character library. Every time i am shifting 4 columns in address for displaying next char. but it overlaps.I am starting with R-L shifting but when it goes beyond 0x00 address ,it overlaps with last addresses(0x3E).

    Can you please provide some guidelines for scrolling text. in C?

    • luca 21/03/2013 at 09:30 - Reply

      Hello! Give a look to my Arduino code (on Github): it’s in C. If you have any questions about it write me a comment!

  8. Martin 15/09/2013 at 12:53 - Reply

    hello,

    i’m also having the same problem with mcu matrix but can’t find working code on github.
    Could you point me in right direction?

    tnx, martin

    • luca 17/09/2013 at 09:07 - Reply

      Hi Martin,

      do you mean the same problem as Locomolo?

  9. Doug 12/02/2015 at 11:25 - Reply

    Hi Luca,

    Has been googling and browsing the internet to no result of getting info about manually trigger character from switches.

    Now i found your article which is the closest thing i can find related to my needs and i hope you can give me some light in the darkness.

    I just need to output automatic transmission gear position (P R N D 3 2 1 O) to 5×8 led matrix.
    The input will be +12v via automatic gear selector/switch (no clock generator or such, just a simple open/close switch).

    Could you please help me ?

    Thanks in advanced luca.

    • luca 13/02/2015 at 21:29 - Reply

      Hi Doug: how do you “know” which gear is selected? Does a single switch corrispond to a specific gear (I mean, do you have 8 switches for 8 gears)? You could monitor the status of each switch using a digital PIN of Arduino and then, with some if display the correct letter on the led matrix

Leave A Response »

Questo sito usa i cookie per poterti offrire una migliore esperienza di navigazione maggiori informazioni

Questo sito utilizza i cookie per fonire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o clicchi su "Accetta" permetti al loro utilizzo.

Chiudi