{
RS_ON();
write_command(c);
- DELAY_US(40);
+ DELAY_US(46);
}
void lcd_puts(char *str)
}
}
+void lcd_font_init(FontSet *fs)
+{
+ int i, j;
+ for (i = 0; i < LCD_FONT_CHARS; i++) {
+ for (j = 0; j < LCD_FONT_HEIGHT; j++) {
+ fs->fontlist[i].data[j] = 0x00;
+ }
+ }
+}
+
+void lcd_font_set_pixel(
+ FontSet *fs, UserFont index,
+ const int x, const int y, const int on)
+{
+ if (LCD_FONT_WIDTH <= x) {
+ return;
+ }
+ if (LCD_FONT_HEIGHT <= y) {
+ return;
+ }
+ if (on) {
+ fs->fontlist[(int)index].data[y] |=
+ (1 << (LCD_FONT_WIDTH - x - 1));
+ } else {
+ fs->fontlist[(int)index].data[y] &=
+ ~(1 << (LCD_FONT_WIDTH - x - 1));
+ }
+}
+
+void lcd_font_setup_single(FontSet *fs, UserFont index)
+{
+ uint8_t addr = 0;
+ int i = (int)index, j;
+ for (j = 0; j < LCD_FONT_HEIGHT; j++) {
+ RS_OFF();
+ write_command(0x40 | (addr & 0x3f));
+ DELAY_US(40);
+
+ RS_ON();
+ write_command(fs->fontlist[i].data[j]);
+ DELAY_US(46);
+
+ addr++;
+ }
+}
+
+void lcd_font_setup_all(FontSet *fs)
+{
+ uint8_t addr = 0;
+ int i, j;
+ for (i = 0; i < LCD_FONT_CHARS; i++) {
+ for (j = 0; j < LCD_FONT_HEIGHT; j++) {
+ RS_OFF();
+ write_command(0x40 | (addr & 0x3f));
+ DELAY_US(40);
+
+ RS_ON();
+ write_command(fs->fontlist[i].data[j]);
+ DELAY_US(46);
+
+ addr++;
+ }
+ }
+}
+
Right
} Direction;
+typedef enum {
+ UserFont1,
+ UserFont2,
+ UserFont3,
+ UserFont4,
+ UserFont5,
+ UserFont6,
+ UserFont7,
+ UserFont8
+} UserFont;
+
+#define LCD_FONT_WIDTH (5)
+#define LCD_FONT_HEIGHT (8)
+#define LCD_FONT_CHARS (8)
+
+typedef struct {
+ unsigned char data[LCD_FONT_HEIGHT];
+} Font;
+
+typedef struct {
+ Font fontlist[LCD_FONT_CHARS];
+} FontSet;
+
void lcd_init(void);
void lcd_clear(void);
void lcd_cursor_at_home(void);
void lcd_goto(uint8_t x, uint8_t y);
void lcd_putc(char c);
void lcd_puts(char *str);
+void lcd_font_init(FontSet *fs);
+void lcd_font_set_pixel(
+ FontSet *fs, UserFont index,
+ const int x, const int y, const int on);
+void lcd_font_setup_single(FontSet *fs, UserFont index);
+void lcd_font_setup_all(FontSet *fs);
#endif