Go Down

Topic: Enhanced LiquidCrystal (Read 15 times) previous topic - next topic

jrraines

"writing 80 characters to the screen then 80 blanks and looping through that 20 times. The results are:
4 data pins 727 milliseconds
8 data pins 644 milliseconds"
so (80+80)*20 = 3200 characters in less than 3/4 of a second. your bar graph is one line long so either 20 or 40 characters. Lets say you have 40 chars. 727 *40/3200 =  9 milliseconds. Probably the rest of your code will be the limiting factor.

in the benchmark I print 80 character long strings. If you use a for loop and call once per character, of course it will go slower because of all the loop and call overhead. If you need maximum speed you might create an array of strings of different lengths for the different bar lengths.

mowcius

Yeah it was the other code. After having a play around it is much faster now :)

Mowcius

jrraines

other thoughts about bar graphs that may be obvious:

if you're using an array of strings they should follow the pattern "x    ", "xx   ","xxx  ",.. so that trailing spaces overwrite what was left over from last time. If you use the for loop and single character print you want to do the same thing--print spaces over the old bar.  Using clear takes 2 milliseconds and then you have to reconstruct the whole screen.

A program that does bar graphs is likely to want to divide somewhere and if you can work it out so that >> will do, that is a LOT faster. so putting a short label on the line and having 16 or 32 segments in the bar may have a big payoff in speed.

mowcius

Yes, I will be sticking a bargraph in my media player project. It has an rMP3 and a 40x4 LCD showing lyrics, time, track etc. I will have a bargraph for the volume and for the track length (probably) but they don't need to be very fast...

Mowcius

brtech

I'm probably overthinking this.  I had thought that the display had something like a 200Hz refresh cycle, but that appears to be the refresh of one row, not the whole display.  The datasheet I'm looking at shows a 64hz frame rate.  at 64 Hz, I only need to get the bar graph into the LCD in 15 ms more or less, which clearly works without the RW.  I don't really want to use the RW, because I want to use the pin for something else :)

Go Up