CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

getting started with LCD!!!!! help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
TheBeginner



Joined: 10 Apr 2007
Posts: 18

View user's profile Send private message

getting started with LCD!!!!! help
PostPosted: Sat Apr 14, 2007 2:54 pm     Reply with quote

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!!! Wink
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

View user's profile Send private message

PostPosted: Sat Apr 14, 2007 4:08 pm     Reply with quote

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








PostPosted: Wed Apr 18, 2007 11:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Apr 20, 2007 4:51 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 21, 2007 6:44 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 21, 2007 6:45 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 21, 2007 6:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 21, 2007 7:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Apr 22, 2007 3:09 am     Reply with quote

thank you so much man;you're so helpful!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group