31 |
31 |
32 #ifdef HAVE_SDL_SDL_H |
32 #ifdef HAVE_SDL_SDL_H |
33 |
33 |
34 // HD44780U Commands |
34 // HD44780U Commands |
35 |
35 |
36 #define SLCD_CLEAR 0x01 |
36 //#define SLCD_CLEAR 0x01 |
37 #define SLCD_HOME 0x02 |
37 //#define SLCD_HOME 0x02 |
38 #define SLCD_ENTRY 0x04 |
38 //#define SLCD_ENTRY 0x04 |
39 #define SLCD_CTRL 0x08 |
39 //#define SLCD_CTRL 0x08 |
40 #define SLCD_CDSHIFT 0x10 |
40 //#define SLCD_CDSHIFT 0x10 |
41 #define SLCD_FUNC 0x20 |
41 //#define SLCD_FUNC 0x20 |
42 #define SLCD_CGRAM 0x40 |
42 //#define SLCD_CGRAM 0x40 |
43 #define SLCD_DGRAM 0x80 |
43 //#define SLCD_DGRAM 0x80 |
44 |
44 |
45 // // Bits in the entry register |
45 // // Bits in the entry register |
46 // |
46 // |
47 // #define LCD_ENTRY_SH 0x01 |
47 // #define LCD_ENTRY_SH 0x01 |
48 // #define LCD_ENTRY_ID 0x02 |
48 // #define LCD_ENTRY_ID 0x02 |
49 // |
49 |
50 // // Bits in the control register |
50 // Bits in the control register |
51 // |
51 #define SLCD_BLINK_CTRL 0x01 |
52 // #define LCD_BLINK_CTRL 0x01 |
52 #define SLCD_CURSOR_CTRL 0x02 |
53 // #define LCD_CURSOR_CTRL 0x02 |
53 #define SLCD_DISPLAY_CTRL 0x04 |
54 // #define LCD_DISPLAY_CTRL 0x04 |
|
55 |
54 |
56 |
55 |
57 struct slcdDataStruct |
56 struct slcdDataStruct |
58 { |
57 { |
59 int x; /* Start x pixels */ |
58 int x; /* Start x pixels */ |
63 int cols; /* Width in characters */ |
62 int cols; /* Width in characters */ |
64 int rows; /* Height in characters */ |
63 int rows; /* Height in characters */ |
65 int cx; /* Cursor x position */ |
64 int cx; /* Cursor x position */ |
66 int cy; /* Cursor y position */ |
65 int cy; /* Cursor y position */ |
67 Uint8 cgram[8][8]; /* Characters in CGRAM */ |
66 Uint8 cgram[8][8]; /* Characters in CGRAM */ |
|
67 int control; /* Control register */ |
68 }; |
68 }; |
69 struct slcdDataStruct *slcds [MAX_SLCDS] ; |
69 struct slcdDataStruct *slcds [MAX_SLCDS] ; |
70 |
70 |
71 |
71 |
72 /* Low level */ |
|
73 |
|
74 void sendDataCmd (struct slcdDataStruct *slcd, unsigned char data) |
|
75 { |
|
76 } |
|
77 |
|
78 |
|
79 void putCommand (struct slcdDataStruct *slcd, unsigned char command) |
|
80 { |
|
81 } |
|
82 |
|
83 |
72 |
84 |
73 |
85 void slcdHome(int fd) |
74 void slcdHome(int fd) |
86 { |
75 { |
87 struct slcdDataStruct *lcd = slcds [fd]; |
76 struct slcdDataStruct *lcd = slcds [fd]; |
88 |
77 |
89 lcd->cx = lcd->cy = 0; |
78 lcd->cx = lcd->cy = 0; |
|
79 SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL); |
90 } |
80 } |
91 |
81 |
92 |
82 |
93 |
83 |
94 void slcdClear(int fd) |
84 void slcdClear(int fd) |
95 { |
85 { |
96 struct slcdDataStruct *lcd = slcds [fd]; |
86 struct slcdDataStruct *lcd = slcds [fd]; |
|
87 int i; |
97 |
88 |
98 lcd->cx = lcd->cy = 0; |
89 lcd->cx = lcd->cy = 0; |
|
90 for (i = 0; i < (lcd->cols * lcd->rows); i++) |
|
91 slcdPutchar(fd, ' '); |
|
92 lcd->cx = lcd->cy = 0; |
|
93 SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL); |
99 } |
94 } |
100 |
95 |
101 |
96 |
102 |
97 |
103 void slcdDisplay(int fd, int state) |
98 void slcdDisplay(int fd, int state) |
104 { |
99 { |
|
100 struct slcdDataStruct *lcd = slcds [fd]; |
|
101 |
|
102 if (state) |
|
103 lcd->control |= SLCD_DISPLAY_CTRL; |
|
104 else |
|
105 lcd->control &= ~SLCD_DISPLAY_CTRL; |
105 } |
106 } |
106 |
107 |
107 |
108 |
108 |
109 |
109 void slcdCursor(int fd, int state) |
110 void slcdCursor(int fd, int state) |
110 { |
111 { |
|
112 struct slcdDataStruct *lcd = slcds [fd]; |
|
113 |
|
114 if (state) |
|
115 lcd->control |= SLCD_CURSOR_CTRL; |
|
116 else |
|
117 lcd->control &= ~SLCD_CURSOR_CTRL; |
|
118 SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL); |
111 } |
119 } |
112 |
120 |
113 |
121 |
114 |
122 |
115 void slcdCursorBlink(int fd, int state) |
123 void slcdCursorBlink(int fd, int state) |
116 { |
124 { |
117 } |
125 struct slcdDataStruct *lcd = slcds [fd]; |
118 |
126 |
119 |
127 if (state) |
120 |
128 lcd->control |= SLCD_BLINK_CTRL; |
121 void slcdSendCommand(int fd, Uint8 command) |
129 else |
122 { |
130 lcd->control &= ~SLCD_BLINK_CTRL; |
|
131 SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL); |
123 } |
132 } |
124 |
133 |
125 |
134 |
126 |
135 |
127 void slcdPosition(int fd, int x, int y) |
136 void slcdPosition(int fd, int x, int y) |