1 #include "task_display.h"
7 #define DISPLAY_CMD_LCD_CLEAR 'c' /* LCD
\e$B$N>C5n
\e(B */
8 #define DISPLAY_CMD_LCD_DRAW_BOX 'b' /* BOX
\e$BIA2h%3%^%s%I
\e(B */
9 #define DISPLAY_CMD_LCD_DRAW_LOGO 'l' /* LOGO
\e$BIA2h%3%^%s%I
\e(B */
10 #define DISPLAY_CMD_LCD_DRAW_TEXT 't' /* TEXT
\e$BIA2h%3%^%s%I
\e(B */
11 #define DISPLAY_CMD_LCD_DRAW_PBAR 'p' /* PBAR
\e$BIA2h%3%^%s%I
\e(B */
12 #define DISPLAY_CMD_LED_ON '1' /* LED
\e$B$NE@Et
\e(B */
13 #define DISPLAY_CMD_LED_OFF '0' /* LED
\e$B$N>CEt
\e(B */
14 #define DISPLAY_CMD_LED_TOGGLE 'a' /* LED
\e$B$N%H%0%k
\e(B */
16 void display_led_write(int target, int state)
20 p[0] = state ? DISPLAY_CMD_LED_ON : DISPLAY_CMD_LED_OFF;
22 kz_send(MSGBOX_ID_DISPLAY, 2, p);
25 void display_led_toggle(int target)
29 p[0] = DISPLAY_CMD_LED_TOGGLE;
31 kz_send(MSGBOX_ID_DISPLAY, 2, p);
34 void display_clear(void)
38 p[0] = DISPLAY_CMD_LCD_CLEAR;
39 kz_send(MSGBOX_ID_DISPLAY, 1, p);
42 void display_draw_box(int x1, int y1, int x2, int y2, int on)
46 p[0] = DISPLAY_CMD_LCD_DRAW_BOX;
52 kz_send(MSGBOX_ID_DISPLAY, 6, p);
55 void display_draw_logo(int x, int y, int size)
59 p[0] = DISPLAY_CMD_LCD_DRAW_LOGO;
63 kz_send(MSGBOX_ID_DISPLAY, 4, p);
66 void display_draw_text(int x, int y, char *str)
71 p = kz_kmalloc(3 + len + 1);
72 p[0] = DISPLAY_CMD_LCD_DRAW_TEXT;
75 memcpy(&p[3], str, len);
77 kz_send(MSGBOX_ID_DISPLAY, 3 + len + 1, p);
80 void display_draw_progressbar(
81 int x1, int y1, int x2, int y2,
82 int min, int max, int value)
86 p[0] = DISPLAY_CMD_LCD_DRAW_PBAR;
94 kz_send(MSGBOX_ID_DISPLAY, 8, p);
97 static void draw_logo(const int ofsx, const int ofsy, const int size)
99 static const uint8 logo_40x32[] = {
100 0x00,0x00,0x00,0x00,0x00,
101 0x00,0x00,0x00,0x00,0x00,
102 0x00,0x1f,0xfc,0x00,0x00,
103 0x00,0x1f,0xff,0xc0,0x00,
104 0x00,0x1f,0xff,0xf0,0x00,
105 0x00,0x0f,0x7f,0xfc,0x00,
106 0x00,0x0f,0x7f,0xff,0x00,
107 0x00,0x0f,0x7f,0xff,0xc0,
108 0x00,0x0f,0x7f,0xff,0xe0,
109 0x00,0x07,0x3f,0xff,0xf0,
110 0x00,0x07,0x9f,0xff,0xfc,
111 0x00,0x07,0xc1,0xff,0xfe,
112 0x3f,0xff,0xff,0xff,0xff,
113 0x3f,0xff,0xff,0xff,0xff,
114 0x1f,0xff,0xff,0xff,0xff,
115 0x1f,0xff,0xff,0xff,0xff,
116 0x1f,0xff,0xfc,0xff,0xff,
117 0x1f,0xff,0xf0,0x3f,0xff,
118 0x1f,0xff,0xf0,0x07,0xff,
119 0x1f,0xff,0xe0,0x41,0xff,
120 0x0f,0xff,0xe0,0x21,0xff,
121 0x0f,0xff,0xe2,0x13,0xff,
122 0x07,0xff,0xf1,0x07,0xff,
123 0x07,0xff,0xf8,0x8f,0xff,
124 0x03,0xff,0xf8,0x1f,0xff,
125 0x03,0xff,0xfc,0x3f,0xff,
126 0x01,0xff,0xfc,0x7f,0xff,
127 0x00,0xff,0xfe,0xff,0xff,
128 0x00,0xff,0xff,0xff,0xff,
129 0x00,0x7f,0xff,0xff,0xff,
130 0x00,0x3f,0xff,0xff,0xff,
131 0x00,0x1f,0xff,0xff,0xff,
133 static const uint8 logo_30x24[] = {
159 static const uint8 logo_20x16[] = {
181 for (y = 0; y < 16; y++) {
182 for (x = 0; x < 20; x++) {
184 c = logo_20x16[(y * 3) + (x / 8)];
186 int pix = (c & (1 << (7 - (x % 8)))) ? 1 : 0;
187 sg12232c_set_pixel(ofsx + x, ofsy + y, pix);
192 for (y = 0; y < 24; y++) {
193 for (x = 0; x < 30; x++) {
195 c = logo_30x24[(y * 4) + (x / 8)];
197 int pix = (c & (1 << (7 - (x % 8)))) ? 1 : 0;
198 sg12232c_set_pixel(ofsx + x, ofsy + y, pix);
203 for (y = 0; y < 32; y++) {
204 for (x = 0; x < 40; x++) {
206 c = logo_40x32[(y * 5) + (x / 8)];
208 int pix = (c & (1 << (7 - (x % 8)))) ? 1 : 0;
209 sg12232c_set_pixel(ofsx + x, ofsy + y, pix);
216 /*
\e$B%9%l%C%I$+$i$NMW5a$r=hM}$9$k
\e(B */
217 static int display_cmdproc(char *p)
221 case DISPLAY_CMD_LCD_CLEAR:
224 case DISPLAY_CMD_LCD_DRAW_BOX:
225 sg12232c_draw_box(p[1], p[2], p[3], p[4], p[5]);
227 case DISPLAY_CMD_LCD_DRAW_LOGO:
228 draw_logo(p[1], p[2], p[3]);
230 case DISPLAY_CMD_LCD_DRAW_TEXT:
231 sg12232c_draw_string(p[1], p[2], &p[3], 0);
233 case DISPLAY_CMD_LCD_DRAW_PBAR:
234 sg12232c_draw_progressbar(
235 p[1], p[2], p[3], p[4], p[5], p[6], p[7], 0);
237 case DISPLAY_CMD_LED_ON:
238 led_write(p[1] - '0', LedOn);
240 case DISPLAY_CMD_LED_OFF:
241 led_write(p[1] - '0', LedOff);
243 case DISPLAY_CMD_LED_TOGGLE:
244 led_toggle(p[1] - '0');
254 int task_display(int argc, char *argv[])
260 kz_recv(MSGBOX_ID_DISPLAY, &size, &p);