HD61830 + 18F452


 
How it works - last update: 8 mar 2006
Firmware - last update: 20 feb 2006
 
 

 

Download source code: glcd.zip

NOTE 1: Next update after march 10.

NOTE 2: It seems to work fine for any image size and any image start position (alignment), but there are some other tests to perform. If you find bugs, I would appreciate your feedback.

NOTE 3: Still need to solve the 6x8 font bug...

--------------------------------------

Previous version (18 february 2006): glcd_18_feb.zip

NOTE 1: I expect to update this file after march 10. (done by 20 feb :-)

NOTE 2: The lcd_puts is working fine: you can plot text (while in graph mode) with 3 different fonts: 8x8, 8x8bold and 8x16. Font 6x8 is not working yet. lcd.c file contains most of the changes.

NOTE 3: You can start plotting text anywhere in the screen. There is no more that limitation to start plotting at a "multiple of 8" x_position.

NOTE 4: When plotting images, you can start at any xy_position. Any image size is supported. Attention: it is not working properly for any combination of xy_position and image size, so I recommed you plot images with sizes and start position "multiple of 8".

NOTE 4: In attention of your suggestions, in the next update, I will implement a demonstration mode, so you will see all the graphical capabilities implemented.

--------------------------------------

Previous version (30 january 2006): glcd_30_jan.zip

NOTE 1: The lcd_puts is working partially: there is a problem in lines 376 to 390 of the lcd.c file (This part of the code is responsible for misaligned pixels in the end of a char string while in graph mode).

I started this files based on Sébastien Jeffroy stuff - thank you for your help!

 

 

How it works

  • Firmware - See comments in the code.
  • Negative supply for the LCD module  - I'm running a 555 and a "Cockcroft-Walton" voltage multiplier (see figure in the right-down corner of this file - inverter configuration). I'm using a 12vcd power supply, so the output of the voltage multiplier produces a more than sufficient voltage to drive the lcd (needs a R1/R2 divider, or a trimpot). There is no inductor. Only a 555, four 1N4148s and four small capacitors and RC for 555 driving.
  • Electrical connections - In order to match your current hardware, you can change the electrical connections in fun.c, starting around line 65. Below is the part of the code which assigns the ports to the hardware. The keyboard is matrix organized as follow: RB3, 4 and 5 are outputs and RB6 and 7 are inputs. The keys are connected between each output and each input, i.e., we have 6 keys connected to 5 port bits. (see the last few lines below - in red color - to understand how the keys are assigned). Remember to include high value resistors between the input pins and the ground, to avoid erratic shots.

#define L_RED    RA0       // Led red   (A0) - used as a flag while writting the code
#define L_GREEN  RA1     // Led green (A1) - same function as above

// The next 5 lines will be removed from the code. I forgot to remove it. Please ignore it.

#define KBO_A    RB3       // Keyboard scan out line 0
#define KBO_B    RB4       // Keyboard scan out line 1
#define KBO_C    RB5       // Keyboard scan out line 2
#define KBI_A    RB6       // Keyboard scan in  line 0
#define KBI_B    RB7       // Keyboard scan in  line 1

// connect your LCD module here:

#define LCD_CS_B RC0   // LCD CS borrow
#define LCD_RS   RE0     // LCD reset
#define LCD_RW   RE1    // LCD Read(1)/write(0)
#define LCD_EN   RE2     // LCD enable
#define BUS      PORTD   // General purpose I/O data bus (used by the LCD too)
#define BUS_DIR  TRISD  // General purpose I/O data bus direction register.
#define BUS_IN   0xFF      // BUS as in - used by the LCD, but it is intended to be
#define BUS_OUT  0x00    // shared with future hardware too.

#define KB_OUT_A RB3     // Keyboard scan out line 0
#define KB_OUT_B RB4     // Keyboard scan out line 1
#define KB_OUT_C RB5     //  Keyboard scan out line 2
#define KB_IN_A  RB6       // Keyboard scan in  line 0
#define KB_IN_B  RB7       // Keyboard scan in  line 1

// keyboard decoding follow these rules:

#define K_RIGHT (KB_OUT_A && KB_IN_A)
#define K_UP    (KB_OUT_A && KB_IN_B)
#define K_DOWN  (KB_OUT_B && KB_IN_A)
#define K_LEFT  (KB_OUT_B && KB_IN_B)
#define K_ENTER (KB_OUT_C && KB_IN_A)
#define K_CLR   (KB_OUT_C && KB_IN_B)

 

 

Related links

  • HD61830 datasheet [PDF] - This is THE datasheet to understand the instruction set of the LCD controller
  • LM238 datasheet [PDF] - 240x128 pixels. Although this is a short document, there is nothing more to know about this LCD module. The datasheet above is the source of information which complements it.
  • Bresenham's line algorithm: Undersand it

 

<< back to main page