;LCD SERIE utilisant un picaxe 18M2 MM 11/03/25
; Emulates basic serial operation of the popular AXE033 module;
; Supported Commands
; 0-7, 8-15 8 charactères enregistrés en CGRAM
; 0- 252 caractères de la table ASCII de l'afficheur + les caractères accentués de 0 à 7
; 253, X non utilisé ici
; 254, X LCD command, X can be 0 to 255
; 255, X Si l'adaptateur est câblé pour lire les broches C.0 ; C.1 ; C.2
; Ex; X= %00000010 le port C.1 passe à 1 (5v)
; LCD data pins are on B.0 to B.7
#picaxe 18M2
#no_data
symbol baud1 = N2400_16
symbol baud2 = N9600_16
symbol RX = C.5 ; serial receive pin
symbol enable = C.6 ; LCD enable
symbol rs = C.7 ; LCD RS
symbol choix =pinC.2
;initialise LCD
gosub LCD_init ; initialise LCD
; Le programme principal tourne à 16MHz
if choix=0 then main2
main1:
serin RX,baud1,b1 ; attente byte suivant
; NB keep character mode test as first item in this list to optimise speed
if b1 < 253 then ' c'est un caractère à écrire
pinsB = b1 ; output the data
pulsout enable,1 ; pulse the enable pin to send data.
goto main1 ; quickly loop back to top
else if b1 = 254 then ' c'est une commande à exécuter
low rs ; rs en mode commande
serin RX,baud1,b1 ; attente du byte de commande
pinsB = b1 ; output the data
pulsout enable,1 ; validation
high rs ; repositionnement mode donn?es
goto main1 ; quickly loop back to top
else if b1 = 253 then ' c'est un message pr?enregistr? (else if en commentaire pour 255)
serin RX,baud1,b1 ; wait for the next byte
goto main1 ; back to top
else ; doit être 255 'reste 255:commande des ports sorties non utiliés
serin RX,baud1,b1 ; wait for the next byte
pinsC = b1 & %00000011 | %10000000 'Port utilisables: C.0 ; C.1
goto main1 ; back to top ;
endif
main2:
serin RX,baud2,b1 ; wait for the next byte
; NB keep character mode test as first item in this list to optimise speed
if b1 < 253 then ' c'est un caractère à écrire
pinsB = b1 ; output the data
pulsout enable,1 ; pulse the enable pin to send data.
goto main2 ; quickly loop back to top
else if b1 = 254 then ' c'est une commande à exécuter
low rs ; rs en mode commande
serin RX,baud2,b1 ; attente du byte de commande
pinsB = b1 ; output the data
pulsout enable,1 ; validation
high rs ; repositionnement mode donn?es
goto main2 ; quickly loop back to top
else if b1 = 253 then ' c'est un message pr?enregistr? (else if en commentaire pour 255)
serin RX,baud2,b1 ; wait for the next byte
goto main2 ; back to top
else ; doit être 255 'reste 255:commande des ports sorties non utiliés
serin RX,baud2,b1 ; wait for the next byte
pinsC = b1 & %00000011 | %10000000 'Port utilisables: C.0 ; C.1
goto main2 ; back to top ; 'RS (C.2) reste ? 1
end if
'**********************************************************************
; power on LCD initialisation sub routine
LCD_init:
dirsC = %10111110 ; PortC en sortie sauf C.6 et C.0
dirsB = %11111111 ; PortB all outputs
; Standard LCD Module Initialisation
pause 15 ; Wait 15ms for LCD to reset.
pinsB = %00110000 ; 8 bit, 2 line
pulsout enable,1 ; Send data by pulsing enable
pause 5 ; Wait 5 ms
pulsout enable,1 ; Send data 48 again
pulsout enable,1 ; Send data 48 again
setfreq m16 ; on passe à 16MHz
pinsB = %00111000 ; LCD - 8 bit, 2 line, 5x8
pulsout enable,1
pinsB = %00000001 ; Clear Display
pulsout enable,1
pause 8 ; 8 = 2ms at 16MHz
pinsB = %00000010 ; return home
pulsout enable,1
pinsB = %00000110 ; Entry mode
pulsout enable,1
pause 1
pinsB = %00001100 ; Display on, no cursor, no blink
pulsout enable,1
gosub cardef 'sub définition caractères utilisateur
high rs ; Leave in character mode
return
'***********************************************************************
cardef:
'Les caractères sont dessinés dans une matrice 8 lignes x 5 colonnes
'La dernière ligne est normalement réservée au curseur.
'définition é en caractère utilisateur n°1
pinsB=1*8|$40 'Utilisateur, definition table car 1
low rs
pulsout enable,1
high rs:pause 10
pinsB=%00010 ;$2
pulsout enable,1
pinsB=%00100 ;$4
pulsout enable,1
pinsB=%01110 ;$E
pulsout enable,1
pinsB=%10001 ;$11
pulsout enable,1
pinsB=%11111 ;$1F
pulsout enable,1
pinsB=%10000 ;$10
pulsout enable,1
pinsB=%01110 ;$1E
pulsout enable,1
pinsB=%00000 ;$0
pulsout enable,1
'définition è en caractère utilisateur n°2
pinsB=2*8|$40 'Utilisateur, definition table car 2
low rs
pulsout enable,1
high rs:pause 10
pinsB=%01000 ;$10
pulsout enable,1
pinsB=%00100 ;$4
pulsout enable,1
pinsB=%01110 ;$E
pulsout enable,1
pinsB=%10001 ;$11
pulsout enable,1
pinsB=%11111 ;$1F
pulsout enable,1
pinsB=%10000 ;$10
pulsout enable,1
pinsB=%01110 ;$1E
pulsout enable,1
pinsB=%00000
pulsout enable,1
'définition ê en caractère utilisateur n°3
pinsB=3*8|$40 'Utilisateur, definition table car 3
low rs
pulsout enable,1
high rs:pause 10
pinsB=%00100 ;$4 4
pulsout enable,1
pinsB=%01010 ;$A 10 ;
pulsout enable,1
pinsB=%01110 ;$1E 30
pulsout enable,1
pinsB=%10001 ;$11 17
pulsout enable,1
pinsB=%11111 ;$1F 31
pulsout enable,1
pinsB=%10000 ;$10 16
pulsout enable,1
pinsB=%01110 ;$E 14
pulsout enable,1
pinsB=%00000 ;$0 0
pulsout enable,1
'd?finition à en caractère utilisateur n°4
pinsB=4*8|$40 'Utilisateur, definition table car 4
low rs
pulsout enable,1
high rs:pause 10
pinsB=%01000 ;$10 16
pulsout enable,1
pinsB=%00100 ;$4 4
pulsout enable,1
pinsB=%01110 ;$1E 30
pulsout enable,1
pinsB=%00001 ;$1 1
pulsout enable,1
pinsB=%01111 ;$F 15
pulsout enable,1
pinsB=%10001 ;$11 17
pulsout enable,1
pinsB=%01111 ;$F 15
pulsout enable,1
pinsB=%00000 ;$0
pulsout enable,1
'd?finition ç en caractère utilisateur n°5
pinsB=5*8|$40 'Utilisateur, definition table car 5
low rs
pulsout enable,1
high rs:pause 10
pinsB=%00000 ;$0
pulsout enable,1
pinsB=%01110 ;$1E 30
pulsout enable,1
pinsB=%10000 ;$10 16
pulsout enable,1
pinsB=%10000 ;$10 16
pulsout enable,1
pinsB=%10001 ;$11 17
pulsout enable,1
pinsB=%01110 ;$F 15
pulsout enable,1
pinsB=%00100 ;$4 4
pulsout enable,1
pinsB=%01100 ;$C 12
pulsout enable,1
'définition ù en caractère utilisateur n°6
pinsB=6*8|$40 'Utilisateur, definition table car 6
low rs
pulsout enable,1
high rs:pause 10
pinsB=%01000 ;8
pulsout enable,1
pinsB=%00100 ;4
pulsout enable,1
pinsB=%10001 ;17
pulsout enable,1
pinsB=%10001 ;17
pulsout enable,1
pinsB=%10001 ;17
pulsout enable,1
pinsB=%10011 ;19
pulsout enable,1
pinsB=%01101 ;13
pulsout enable,1
pinsB=%00000
pulsout enable,1
'définition ü en caractère utilisateur n°7
pinsB=7*8|$40 'Utilisateur, definition table car 7
low rs
pulsout enable,1
high rs:pause 10
pinsB=%01010 ;10
pulsout enable,1
pinsB=%00000 ;0
pulsout enable,1
pinsB=%10001 ;17
pulsout enable,1
pinsB=%10001 ;17
pulsout enable,1
pinsB=%10001 ;17
pulsout enable,1
pinsB=%10011 ;19
pulsout enable,1
pinsB=%01101 ;13
pulsout enable,1
pinsB=%00000 ;0
pulsout enable,1
'définition ë en caractère utilisateur n°8
pinsB=8*8|$40 'Utilisateur, definition table car 8
low rs
pulsout enable,1
high rs:pause 10
pinsB=%01010 ;10
pulsout enable,1
pinsB=%0000 ;0
pulsout enable,1
pinsB=%01110 ;15
pulsout enable,1
pinsB=%10001 ;17
pulsout enable,1
pinsB=%11111 ;31
pulsout enable,1
pinsB=%10000 ;16
pulsout enable,1
pinsB=%01110 ;15
pulsout enable,1
pinsB=%00000 ;0
pulsout enable,1
return