View previous topic :: View next topic |
Author |
Message |
TheBeginner
Joined: 10 Apr 2007 Posts: 18
|
getting started with LCD!!!!! help |
Posted: Sat Apr 14, 2007 2:54 pm |
|
|
hi everyone,i've done my first part of the project which is data acquisition and some math operation and i wanna thank each one who helped me there spicially PCM programmer!!!
1-i would like to know how can i use the visual c# to create windows using the CCS compiler and the pic18f8722
2-how can i start with LCD ( i have to display a graph and a table of values)
3-can anyone show me an exemple (an easy one please )
thanks a lot and best regards |
|
|
GoodEmbed'
Joined: 14 Apr 2007 Posts: 11
|
|
Posted: Sat Apr 14, 2007 4:08 pm |
|
|
Different graphic LCDs use different control protocols.
If you're using a 128x64 pixel cheapo one using one of the standard interfaces, then I can give you code to drive it and simple examples.
Getting to grips with new LCDs can be quite frustrating. Especially if you want to draw graphs!
Actually, I have just made an oscilloscope using a PIC so I have graph code to hand if it'll help. (In C, not C# unfortunately for you)
Basically, I've made some high level and some low-level functions to help with graphics.
One such function is lcd_print_byte(int value, int x, int y); which as you can guess sets 8 pixels (one byte) to the suppplied value at the given xy location. |
|
|
Guest
|
|
Posted: Wed Apr 18, 2007 11:45 am |
|
|
yeah man i think that it's gonna help me,please could you give it to me,every thing can help me to strat with LCD
bset regards |
|
|
TheBeginner
Joined: 10 Apr 2007 Posts: 18
|
|
Posted: Fri Apr 20, 2007 4:51 am |
|
|
GoodEmbed' wrote: | Different graphic LCDs use different control protocols.
If you're using a 128x64 pixel cheapo one using one of the standard interfaces, then I can give you code to drive it and simple examples.
Getting to grips with new LCDs can be quite frustrating. Especially if you want to draw graphs!
Actually, I have just made an oscilloscope using a PIC so I have graph code to hand if it'll help. (In C, not C# unfortunately for you)
Basically, I've made some high level and some low-level functions to help with graphics.
One such function is lcd_print_byte(int value, int x, int y); which as you can guess sets 8 pixels (one byte) to the suppplied value at the given xy location. |
please could you give me the graph code to have an overview ???
thanks |
|
|
GoodEmbed'
Joined: 14 Apr 2007 Posts: 11
|
|
Posted: Sat Apr 21, 2007 6:44 pm |
|
|
The Driver
I had to upload the file rather than post it using [code] tags as for some reasons the code was getting messed up.
Last edited by GoodEmbed' on Sat Apr 21, 2007 7:21 pm; edited 2 times in total |
|
|
GoodEmbed'
Joined: 14 Apr 2007 Posts: 11
|
|
Posted: Sat Apr 21, 2007 6:45 pm |
|
|
ignore, originally needed two posts to get all code in.
Last edited by GoodEmbed' on Sat Apr 21, 2007 7:19 pm; edited 1 time in total |
|
|
GoodEmbed'
Joined: 14 Apr 2007 Posts: 11
|
|
Posted: Sat Apr 21, 2007 6:53 pm |
|
|
OK - the above two posts give the LCD driver.
Here's a quick example that shows how to use the functions
To draw a single byte on page 4, 20 columns along: (pixels are grouped together in 8's for byte access. Pages go from 1-16 using this 'high level' function.
Code: | lcd_print_byte(0b1111111,4,20); |
To draw a horizontal line accross a whole page, two pixels wide:
Code: |
lcd_set_page(0); //could be any 0-15 (NOT 1-16) when using the lower level functions
lcd_send_instruction(LCD_GOTO_TOP); //this resets the address pointer to 0
for(i=0;i<64;i++){
lcd_send_byte(0b00011000);
} |
Pages are arranged like this:
Bytes are a vertical stripe, LSB at the bottom. address counter rages from 0-63, right to left. The actual pages are 0-7 for each side and two 'chip select' lines. So you could write the same thing to both sides at the same time. |
|
|
GoodEmbed'
Joined: 14 Apr 2007 Posts: 11
|
|
Posted: Sat Apr 21, 2007 7:03 pm |
|
|
Here's the code that uses the above driver to draw a graph:
Note that this is not very nice or clean code!!
Finished code working:
The Code (Note: you will need to scroll down to the plot() function. Also - ignore any code to do with triggering as this is code specifically for my project.
Basically the code works its way though the array deducing which byte on the LCD it needs to write to.
What makes this code so confusing is that it also 'joins the dots' on the graph.
You'll notice some random bit manipulation. It's like this. Imagine you want to draw the value '138' on a display that has only 64 pixels vertically.
138 is 10001010 in binary. There are 8 rows, so we look at the 3 most significant (because 2^3 = 8) bits to see which page to use this would be '100' (page 4) which you would get by doing a (>> 5). Then we use the next three bits to see which pixel to use. The 2 LSBs are ignored because the display res is too low. |
|
|
TheBeginner
Joined: 10 Apr 2007 Posts: 18
|
|
Posted: Sun Apr 22, 2007 3:09 am |
|
|
thank you so much man;you're so helpful!!!! |
|
|
|