![]() |
|
|||||||
| Embedded Systems and Microcontrollers Discussion forum for projects and working with embedded systems and microcontrollers (FPGAs, PICs, AVRs). Get help with hardware issues and embedded programming. |
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I'm going to be using a Hantronix LCD in a project and this requires sending each column of pixels one at a time. I was planning on using a lookup table to send each letter or word. However this is my first time using lookup tables so I'm hoping someone can provide a suggestion. This code is simplified and was designed to help me learn lookups. Basically this code should read the hex code for the letter 'H'. After loading each byte the code jumps to a section which will actually send it to the LCD and then continue the loop. Once it has read all the data it should loop back to 'Start' (at least in this test version)
Code:
Start movwf tt,0
movlw low(H_CHAR)
addwf tt,0,0
movwf TBLPTRL,0
movlw high(H_CHAR)
movwf TBLPTRU,0
lpl tblrd *+
movlw .153
CPFSLT TABLAT
GOTO Start
GOTO Send
Send movf TABLAT,0,0
movwf PORTA
GOTO lpl
H_CHAR db 0x00,0xfe
db 0x10,0x10
db 0xfe,0x99
Select All
What is a good way so determine when I have read all the data in the 'H_CHAR' table (in this example)? The 0x99 is not part of the actual data being sent to the LCD screen. After reading the last 0xFE and jumping to 'Send', when it returns to the 'lpl' loop the code should somehow be able to figure out/know that all the data was read. This table is only 5 bytes, but some may be more and some may be less so it would help to have a single way of detecting this. Any help would be greatly appreciated. The application note for the LCD I'll be using can be found here and on the last few pages it give a sample code, albeit the code is in 8051 assembly which I'm not familiar with. |
|
#2
|
||||
|
||||
|
I did a display similar to this a few years ago. Character bit patterns were handled as simple uniform sized bitmaps, so all you need do is know the character size and the character code you want and you can compute an offset into an array.
I did spend much time on this and while I had a nice library of functions, I've abandoned that effort after finding simple black & white displays are not substantially cheaper then color displays. I now just use the color ones and the excellent, free graphics object library from Microchip.
__________________
“Freedom is never more than one generation away from extinction. We didn’t pass it to our children in the bloodstream. It must be fought for, protected, and handed on for them to do the same, or one day we will spend our sunset years telling our children and our children’s children what it was once like in the United States where men were free.” |
|
#3
|
|||
|
|||
|
On Microchips website the graphics library is listed as only working with PIC24/dsPIC and PIC32, while I'm using the PIC18F46K22. I already have this chip and the Hantronix screen so I'd rather stick with them since they are sufficient for what I'm doing and I already have them in hand.
I'm not sure exactly what you mean by using sized bitmaps along with any array to display character on the Hantronix screen. This is the first time I'm using an LCD screen so maybe I'm missing something. Do you have an resources that you could point me to that will explain how to use your way, or the way I was trying to do it, for the type of application I'm working on. Every time I try to Google table lookups they are about changing programming memory or the user has a special code at the end of the table they can check for; which I can't do for the reasons already stated. Is there a function for returning the size or element count of a lookup table? |
|
#5
|
||||
|
||||
|
I make fonts from bitmaps of the same size placed into an array and padded out do each character starts on an even byte field. I used this structure for fonts:
Code:
typedef struct
{
rom char FirstFont; // first ASCII symbol defined
rom char LastFont; // last ASCII symbol defined
rom char DefaultFont; // If nothing available...
rom char FontWidth; // font width in pixels
rom char FontHeight; // font height in pixels
rom char BytesPerCharacter; // bytecount for a single character
rom char *Bitmap; // first byte of ROM bitmap
} font;
Select All
Code:
rom char Font5x7bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Space 32
0x00, 0x00, 0x4F, 0x00, 0x00, 0x00, // ! 33
0x00, 0x07, 0x00, 0x07, 0x00, 0x00, // " 34
...
...
0x00, 0x01, 0x02, 0x04, 0x00, 0x00, // ` 96
0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00 // (box) 97
};
rom font _Font5x7 =
{
32, // first ASCII symbol defined
97, // last ASCII symbol defined
97, // If nothing available...
6, // font width in pixels
8, // font height in pixels
6, // 6 bytes in each character definition
Font5x7bits
};
Select All
I do have one of the last projects I did and I've included it in case you wish to reverse engineer some of it.
__________________
“Freedom is never more than one generation away from extinction. We didn’t pass it to our children in the bloodstream. It must be fought for, protected, and handed on for them to do the same, or one day we will spend our sunset years telling our children and our children’s children what it was once like in the United States where men were free.” |
|
#6
|
|||
|
|||
|
I have always used the same number of bytes for each character.
|
|
| Tags |
| display, lcd, lookup, lookup table, suggestion, tablat, table |
Related Site Pages
|
||||
| Section | Title | |||
| Worksheet | Microcontroller principles | |||
| Worksheet | Digital display circuits | |||
| Textbook | SPICE models : Diodes And Rectifiers | |||
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PIC Random Lookup Table | mark squared | Embedded Systems and Microcontrollers | 4 | 10-22-2010 04:34 AM |
| Problems with program counter and lookup table | wannaBinventor | Embedded Systems and Microcontrollers | 3 | 08-21-2010 10:21 PM |
| C lookup table help | blackmamba | Embedded Systems and Microcontrollers | 6 | 12-07-2009 05:40 PM |
| LCD Display - Can't show characters | BillGeek | Embedded Systems and Microcontrollers | 12 | 10-27-2009 01:33 PM |
| The Seven Segment Display | zhhgw | Homework Help | 8 | 01-13-2008 04:55 AM |
| Thread Tools | |
| Display Modes | |
|
|