I can get a LCD using I2C to work with the built in characters, but I want to create some custom characters (to give a battery condition bar graph) and I am having difficulty. Has anybody got any experience of doing this?
Here is my code that does not work...
So it's a LCD made by Midas and it has a ST7032 controller. The standard (ASCII) charcters display, but when I try for custom characters it does not appear to work.
Looking at the code.. my first question is why are you not using the standard I2C driver for LCD and then all should work?
#define LCD_IO 10
#define LCD_I2C_Address_1 0x7C
'You may need to use SLOW or MEDIUM if your LCD is a slower device.
#define LCD_SPEED FAST
'You may need to invert these states. Dependent of LCD I2C adapter.
#define LCD_Backlight_On_State 1
#define LCD_Backlight_Off_State 0
Did you try this? As I would expect all to work out of the box.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wrote the code when the GCBasic compiler only supported HD44780 character displays (I always use the standard driver for these and I can make custom characters).
I thought this particular LCD controller (ST7032) was not supported.
Some of the setting for the display OSC, contrast and follower need to be set for this display to work, and it seems to be easier to write custom code to do this.
It is not that difficult to write the code. Clearly I'm missing something or have done something daft that is causing the custom character to not load.
I also have several other I2C devices connected to the same two wires so I prefer to have as much control over what is happening as possible.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've looked at the code in the mylcd.h file and except for delays between writes it is the same code as I am using. So I tried with the delays (50 us) and still nothing.
I'm going to give up for the moment.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the data sheet says l Character Generator RAM (CGRAM)
In the character generator RAM, the user can rewrite character patterns by program. For 5 x 8 dots, eight
character patterns can be written.
Write into DDRAM the character codes at the addresses shown as the left column of code table (refer to
appendix) to show the character patterns stored in CGRAM.
See Table 4 for the relationship between CGRAM addresses and data and display patterns. Areas that are not
used for display can be used as general data RAM.
l ICON RAM
In the ICON RAM, the user can rewrite icon pattern b
All sounds complicated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have solved the problem. Before calling the routine to load custom character(s) there needs to be a short delay (I have used 1ms - probably excessive).
So here's the routine to load a bar-graph into character(0) the size of the graph depends on the variable BAT.
It is also used to adjust the contrast of the LCD display as the battery goes down.
The voltage is detected using the ADC relative to the internal (selectable)reference of 2.048V.
It's great that you have resolved this problem. However, adding a delay may just be a workaround and may not be addressing the root cause of the problem. So help us out a bit here.
What command or code was executed immmediately prior to calling the sub? .Seeing the added delay in context may help to diagnose the root cause.
Can you post more complete code so that we can see what preceeds the call to the sub and exactly where you have added the delay?
William
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It was immediately after the initialization of the LCD (setting OSC, Power, follower etc). Probably everything has to settle before the LCD will accept any data.
I've now put the routine elsewhere as I really only need to create a new character when a detectable change in battery voltage has happened. So basically it was like this...
Intialize LCD
wait 1 ms
load custom character
without the 1 ms the character did not load.
Completely different question Can I switch on spell-checking when I'm posting here?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That makes sense. According to the Sitronix ST7032 datasheet (page 19) the instruction execution time of "Clear Display" is between .58 and 1.08 ms. So any time a "Clear Display" is issued it should be followed by a 1 or 2 ms delay, depending upon OSC speed. The same applies to "Clear Home".
Last edit: William Roth 2017-05-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can get a LCD using I2C to work with the built in characters, but I want to create some custom characters (to give a battery condition bar graph) and I am having difficulty. Has anybody got any experience of doing this?
Here is my code that does not work...
Can you attach the rest of the code to give us the context? Someone can then none have to sort the preamble.
So it's a LCD made by Midas and it has a ST7032 controller. The standard (ASCII) charcters display, but when I try for custom characters it does not appear to work.
Looking at the code.. my first question is why are you not using the standard I2C driver for LCD and then all should work?
Did you try this? As I would expect all to work out of the box.
I wrote the code when the GCBasic compiler only supported HD44780 character displays (I always use the standard driver for these and I can make custom characters).
I thought this particular LCD controller (ST7032) was not supported.
Some of the setting for the display OSC, contrast and follower need to be set for this display to work, and it seems to be easier to write custom code to do this.
It is not that difficult to write the code. Clearly I'm missing something or have done something daft that is causing the custom character to not load.
I also have several other I2C devices connected to the same two wires so I prefer to have as much control over what is happening as possible.
OK. I would open up the LCD library and take the code from there. But, this is all based on a standard approach but should work.
I've looked at the code in the mylcd.h file and except for delays between writes it is the same code as I am using. So I tried with the delays (50 us) and still nothing.
I'm going to give up for the moment.
the data sheet says l Character Generator RAM (CGRAM)
In the character generator RAM, the user can rewrite character patterns by program. For 5 x 8 dots, eight
character patterns can be written.
Write into DDRAM the character codes at the addresses shown as the left column of code table (refer to
appendix) to show the character patterns stored in CGRAM.
See Table 4 for the relationship between CGRAM addresses and data and display patterns. Areas that are not
used for display can be used as general data RAM.
l ICON RAM
In the ICON RAM, the user can rewrite icon pattern b
All sounds complicated.
Yes Stan much of the data sheet looks like it was generated from a google translation.
I have solved the problem. Before calling the routine to load custom character(s) there needs to be a short delay (I have used 1ms - probably excessive).
So here's the routine to load a bar-graph into character(0) the size of the graph depends on the variable BAT.
It is also used to adjust the contrast of the LCD display as the battery goes down.
The voltage is detected using the ADC relative to the internal (selectable)reference of 2.048V.
Hi David,
It's great that you have resolved this problem. However, adding a delay may just be a workaround and may not be addressing the root cause of the problem. So help us out a bit here.
What command or code was executed immmediately prior to calling the sub? .Seeing the added delay in context may help to diagnose the root cause.
Can you post more complete code so that we can see what preceeds the call to the sub and exactly where you have added the delay?
William
It was immediately after the initialization of the LCD (setting OSC, Power, follower etc). Probably everything has to settle before the LCD will accept any data.
I've now put the routine elsewhere as I really only need to create a new character when a detectable change in battery voltage has happened. So basically it was like this...
Intialize LCD
wait 1 ms
load custom character
without the 1 ms the character did not load.
Completely different question Can I switch on spell-checking when I'm posting here?
That makes sense. According to the Sitronix ST7032 datasheet (page 19) the instruction execution time of "Clear Display" is between .58 and 1.08 ms. So any time a "Clear Display" is issued it should be followed by a 1 or 2 ms delay, depending upon OSC speed. The same applies to "Clear Home".
Last edit: William Roth 2017-05-15