Custom character by the master program ?

zorgloub

Member
Hi Everybody,

Is it possible to create, on the fly, new custom graphic characters (CGRAM) by the master program?

I try this code but it does not work:


Code:
'Custom Graphic Character in CG6

Serout Display,Baud,(254,70) 'Addressing CGRAM CG 6 (CG Address + 64)
Serout Display,Baud,($10,$1B,$11,$11,$11,$11,$11,$1F)  'Data for Battery Level 0 in CGRAM6
Serout Display,Baud,(254,128)  'Reinit Address DDRAM

' Call CG6
Serout Display,Baud,(254,136)  'Line1 Col9
Serout Display,Baud,("CG6= ",6)  'CG6 ---- > NOTHING !!!
Thanks
 

hippy

Technical Support
Staff member
It should be possible. The "Set CGRAM character" command is %01xxx000 where 'x' is the CGRAM character number (0-7).

For CGRAM character 6 (%110) that command would be %01110000 which is $70.

Your "254,70" should probably be "254,$70".
 

zorgloub

Member
Hi Hippy,
Thanks for your reactivity !

Indeed, it is necessary to declare this value in Hexa ... and it works!

So, the default addresses in the CGRAM are 0 to 7.
Is it possible to use addresses 8 to 15 instead?
I seem to have read something about it.
Uses either 0 to 7; or 8 to 15.
I am wrong ?




Thanks again.
 
Last edited:

hippy

Technical Support
Staff member
Indeed, it is necessary to declare this value in Hexa
It's not necessary to specify the number in hexadecimal. You could have used any of the following -

%01110000
$70
112
"p"

It's not so much how the number is represented but that it has the correct value.

In this case it does seem it was simply forgetting the $ which indicates it as a hexadecimal value.

I would recommend using either binary or hexadecimal though because it allows easier checking that the value used is what it would be expected to be, and also avoids errors in converting to decimal or back again.
 

zorgloub

Member
Yes of course.
I wanted to say that the 70 of my initial code had to be preceded by "$" but I could also write this value in decimal or in binary% as you say.

Is it then possible to place the custom characters at addresses 8 to 15 of the CGRAM (instead of addresses 0 to 7)?

Thank you.
 

AllyCat

Senior Member
Hi,

Yes, I believe that bit3 of the CGRAM address is simply ignored. So you can write/read them as characters 8 - 15, but the same characters will also appear at addresses 0 - 7.

Cheers, Alan.
 

hippy

Technical Support
Staff member
Is it then possible to place the custom characters at addresses 8 to 15 of the CGRAM (instead of addresses 0 to 7)?
No. The CGRAM character programmed must be character 0 through 7.

There are only three bits used to specify which character in the "Set CGRAM character" command; %01xxx000, so it has to be 0 through 7.

If you display characters 8 through 15, they will also display whatever characters 0 through 7 are.

It is technically possible to notionally program CGRAM 8 through 15 by forcing the bit 3 to be ignored as AllyCat says, but you are actually still programming CGRAM 0 through 7 -

Code:
b0 = 8 ; CGRAM char 8
b1 = b0 * 8 | $40
SerOut ... ( 254, b1 )
SerOut ... ( $1F, $11, $11, $11, $11, $11, $11, $1F )
If you however used "b1 = b0 * 8 + $40" ( PLUS rather than OR ) that would not work.

You could use "b1 = b0 & 7 * 8 + $40" which would work but it's not really worth all the fuss when one can just program 0 through 7.
 
Last edited:

zorgloub

Member
Hi Hippy,

If I look at the LCD display datasheets, the Set CGRAM Address command is % 01xxxxxx
So the address CG1 would be % 01000001 ... but it does not work with the AXE134 interface !
Your proposal, which works: % 01xxx000, gives so for CG1 the address: % 01001000. (with RS and RW = 0)
How to explain this difference of information?
Does yours work but does not match the LCD display datasheets! ??

Exemple OK (With Hippy Address Mode):

Code:
#Picaxe 08M2

Symbol Display = C.2
Symbol Baud = N2400_4

#no_data
#SIMSPEED 150
#Terminal 4800


Pause 2000 'Stabilize Serial Display
Serout Display, Baud,(254,1) : Pause 30 'Clear display 'Cmd1


'Creation Graphic Charactere

'GG0
Serout Display,Baud,(254,$40) ' %01 [B]000[/B] 000 for CG0
Serout Display,Baud,($0E,$1B,$11,$11,$11,$11,$11,$1F)' : Battery Level 0 in CG0
Serout Display,Baud,(254,128)' : Reinit Address DDRAM
'GG1
Serout Display,Baud,(254,$48) ' %01 [B]001[/B] 000 for CG1
Serout Display,Baud,($0E,$1B,$11,$11,$11,$11,$1F,$1F)' : Battery Level 1 in CG1
Serout Display,Baud,(254,128)' : Reinit Address DDRAM
'GG2
Serout Display,Baud,(254,$50) ' %01 [B]010[/B] 000 for CG2
Serout Display,Baud,($0E,$1B,$11,$11,$11,$1F,$1F,$1F)' : Battery Level 2 in CG2
Serout Display,Baud,(254,128)' : Reinit Address DDRAM
'GG3
Serout Display,Baud,(254,$58) ' %01 [B]011[/B] 000 for CG3
Serout Display,Baud,($0E,$1B,$11,$11,$1F,$1F,$1F,$1F)' : Battery Level 3 in CG3
Serout Display,Baud,(254,128)' : Reinit Address DDRAM
'GG4
Serout Display,Baud,(254,$60) ' %01 [B]100[/B] 000 for CG4
Serout Display,Baud,($0E,$1B,$11,$1F,$1F,$1F,$1F,$1F)' : Battery Level 4 in CG4
Serout Display,Baud,(254,128)' : Reinit Address DDRAM
'GG5
Serout Display,Baud,(254,$68) ' 01 [B]101[/B] 000 for CG5
Serout Display,Baud,($0E,$1B,$1F,$1F,$1F,$1F,$1F,$1F)' : Battery Level 5 in CG5
Serout Display,Baud,(254,128)' : Reinit Address DDRAM
'GG6
Serout Display,Baud,(254,$70) ' 01 [B]110[/B] 000 for CG6
Serout Display,Baud,($0E,$1F,$1F,$1F,$1F,$1F,$1F,$1F)' : Battery Level 6 in CG6
Serout Display,Baud,(254,128)' : Reinit Address DDRAM
'GG7
Serout Display,Baud,(254,$78) ' 01 [B]111[/B] 000 for CG7
Serout Display,Baud,($01,$1B,$00,$04,$01,$12,$0C,$00)' : Smile in CG7
Serout Display,Baud,(254,128)' : Reinit Address DDRAM


Serout Display,Baud,(254,128)'L1 C1
Serout Display,Baud,("CG 0/7 =",0,1,2,3,4,5,6,7)

Serout Display,Baud,(254,192)'L2 C2
Serout Display,Baud,("CG 8/15=",8,9,10,11,12,13,14,15)
 

Attachments

Last edited:
Top