OSDN Git Service

Added progress bar drawing feature.
authorShinichiro Nakamura <shinta.main.jp@gmail.com>
Sun, 15 Jul 2012 20:06:22 +0000 (05:06 +0900)
committerShinichiro Nakamura <shinta.main.jp@gmail.com>
Sun, 15 Jul 2012 20:06:22 +0000 (05:06 +0900)
firm/sample/sample1/os/task_display.c
firm/sample/sample1/os/task_display.h

index b6b4186..fdbe703 100644 (file)
@@ -8,6 +8,7 @@
 #define DISPLAY_CMD_LCD_DRAW_BOX    'b' /* BOX\e$BIA2h%3%^%s%I\e(B */
 #define DISPLAY_CMD_LCD_DRAW_LOGO   'l' /* LOGO\e$BIA2h%3%^%s%I\e(B */
 #define DISPLAY_CMD_LCD_DRAW_TEXT   't' /* TEXT\e$BIA2h%3%^%s%I\e(B */
+#define DISPLAY_CMD_LCD_DRAW_PBAR   'p' /* PBAR\e$BIA2h%3%^%s%I\e(B */
 #define DISPLAY_CMD_LED_ON          '1' /* LED\e$B$NE@Et\e(B */
 #define DISPLAY_CMD_LED_OFF         '0' /* LED\e$B$N>CEt\e(B */
 #define DISPLAY_CMD_LED_TOGGLE      'a' /* LED\e$B$N%H%0%k\e(B */
@@ -76,6 +77,23 @@ void display_draw_text(int x, int y, char *str)
   kz_send(MSGBOX_ID_DISPLAY, 3 + len + 1, p);
 }
 
+void display_draw_progressbar(
+        int x1, int y1, int x2, int y2,
+        int min, int max, int value)
+{
+  char *p;
+  p = kz_kmalloc(8);
+  p[0] = DISPLAY_CMD_LCD_DRAW_PBAR;
+  p[1] = x1;
+  p[2] = y1;
+  p[3] = x2;
+  p[4] = y2;
+  p[5] = min;
+  p[6] = max;
+  p[7] = value;
+  kz_send(MSGBOX_ID_DISPLAY, 8, p);
+}
+
 static void draw_logo(const int ofsx, const int ofsy, const int size)
 {
   static const uint8 logo_40x32[] = {
@@ -212,6 +230,10 @@ static int display_cmdproc(char *p)
   case DISPLAY_CMD_LCD_DRAW_TEXT:
     sg12232c_draw_string(p[1], p[2], &p[3], 0);
     break;
+  case DISPLAY_CMD_LCD_DRAW_PBAR:
+    sg12232c_draw_progressbar(
+            p[1], p[2], p[3], p[4], p[5], p[6], p[7], 0);
+    break;
   case DISPLAY_CMD_LED_ON:
     led_write(p[1] - '0', LedOn);
     break;
index ea30cb5..c5b827e 100644 (file)
@@ -7,6 +7,9 @@ void display_clear(void);
 void display_draw_box(int x1, int y1, int x2, int y2, int on);
 void display_draw_logo(int x, int y, int size);
 void display_draw_text(int x, int y, char *str);
+void display_draw_progressbar(
+        int x1, int y1, int x2, int y2,
+        int min, int max, int value);
 
 int task_display(int argc, char *argv[]);