Autres articles / Other articles

Gérer la communication avec le module d'affichage MAX7219

published: 20 February 2023 / updated 20 February 2023

Lire cette page en français

 

Call for collaboration

You develop montages, simple or complex with ESP32 and ESP32forth.

Share them here on this site.

ESP32forth can only develop with the active collaboration of all good will.

Your montages can help other developers.

Mounts from other developers can help.

To propose an article or a montage, click here


Transmission de signaux vers le module MAX7219

La sélection du périphérique MAX7219 s'effectue à l'aide du mot MAX7219.select.

La dé-sélection du périphérique MAX7219 s'effectue à l'aide du mot MAX7219.deselect.

\ CS select for MAX7219 
: MAX7219.select ( -- ) 
    VSPI_CS LOW digitalWrite 
  ; 
 
\ CS deselect for MAX7219 
: MAX7219.deselect ( -- ) 
    VSPI_CS HIGH digitalWrite 
  ; 

Rappel: la sélection d'un périphérique s'effectue en mettant le pin pointé par VSPI_CS au niveau bas.

Une transmission de données ne peut avoir lieu qu'après avoir sélectionné le module MAX7219, ce que fait le mot MAX7219.send:

\ send two bytes to MAX7219 thru SPI port 
: MAX7219.send ( c1 c2 -- ) 
    MAX7219.select 
    SPI.write SPI.write 
    MAX7219.deselect 
  ; 

Ce mot MAX7219.send transmet deux octets: un octet de commande, un octet de donnée.

Les commandes de contrôle du module MAX7219

\ definition of MAX7219 parameters 
4 value #NB_MAX7219     \ for 32 x 8 display size 
 
\ send a command an data to MAX7219 
: MAX7219.send.command  { data command -- }   
    #NB_MAX7219 for 
        aft  data command MAX7219.send  then 
    next 
  ; 
 
\ definition of MAX7219 commands 
$00 constant _NO-OP         \ $00 
$09 constant _DECODE-MODE   \ val: $00 for led matrix  
$0a constant _INTENSITY     \ range $00..$0f 
$0b constant _SCAN-LIMIT    \ range 0..7 
$0c constant _SHUTDOWN      \ range 0|1 
$0f constant _DISPLAY-TEST  \ range 0|1 
 
: MAX7219.normal   ( -- )  
    $01 _SHUTDOWN MAX7219.send.command 
  ; 
 
: MAX7219.shutdown ( -- )  
    $00 _SHUTDOWN MAX7219.send.command 
  ; 
 
: MAX7219.intensity  { intens -- }  ( 0|1 -- ) 
    intens _INTENSITY MAX7219.send.command 
  ; 
 
: MAX7219.decode { decod -- }    ( 0 -- )   
    decod _DECODE-MODE MAX7219.send.command 
  ; 
 
: MAX7219.scan.limit { scan -- }  ( 0..7 -- )   
    scan _SCAN-LIMIT MAX7219.send.command 
  ; 

Legal: site web personnel sans commerce / personal site without seling