OSDN Git Service

Added IPC interfaces for display task.
authorShinichiro Nakamura <shinta.main.jp@gmail.com>
Sat, 21 Jul 2012 03:46:02 +0000 (12:46 +0900)
committerShinichiro Nakamura <shinta.main.jp@gmail.com>
Sat, 21 Jul 2012 03:46:02 +0000 (12:46 +0900)
firm/sample/simple_mp3_player/os/Makefile
firm/sample/simple_mp3_player/os/ipc_display.c [new file with mode: 0644]
firm/sample/simple_mp3_player/os/ipc_display.h [new file with mode: 0644]
firm/sample/simple_mp3_player/os/ipc_graph.sh
firm/sample/simple_mp3_player/os/task_command.c
firm/sample/simple_mp3_player/os/task_display.c
firm/sample/simple_mp3_player/os/task_display.h
firm/sample/simple_mp3_player/os/task_menu.c

index 063a055..3381e11 100644 (file)
@@ -29,7 +29,7 @@ OBJS += spi.o spreg.o
 
 # Tasks
 OBJS += task_audio.o ipc_audio.o
-OBJS += task_display.o
+OBJS += task_display.o ipc_display.o
 OBJS += task_fileio.o
 OBJS += task_menu.o
 OBJS += task_input.o
diff --git a/firm/sample/simple_mp3_player/os/ipc_display.c b/firm/sample/simple_mp3_player/os/ipc_display.c
new file mode 100644 (file)
index 0000000..4e697db
--- /dev/null
@@ -0,0 +1,86 @@
+
+#include "kozos.h"
+#include "ipc_display.h"
+#include "lib.h"
+
+void ipc_display_led_write(int target, int state)
+{
+  char *p;
+  p = kz_kmalloc(2);
+  p[0] = state ? DISPLAY_CMD_LED_ON : DISPLAY_CMD_LED_OFF;
+  p[1] = '0' + target;
+  kz_send(MSGBOX_ID_DISPLAY, 2, p);
+}
+
+void ipc_display_led_toggle(int target)
+{
+  char *p;
+  p = kz_kmalloc(2);
+  p[0] = DISPLAY_CMD_LED_TOGGLE;
+  p[1] = '0' + target;
+  kz_send(MSGBOX_ID_DISPLAY, 2, p);
+}
+
+void ipc_display_clear(void)
+{
+  char *p;
+  p = kz_kmalloc(1);
+  p[0] = DISPLAY_CMD_LCD_CLEAR;
+  kz_send(MSGBOX_ID_DISPLAY, 1, p);
+}
+
+void ipc_display_draw_box(int x1, int y1, int x2, int y2, int on)
+{
+  char *p;
+  p = kz_kmalloc(6);
+  p[0] = DISPLAY_CMD_LCD_DRAW_BOX;
+  p[1] = x1;
+  p[2] = y1;
+  p[3] = x2;
+  p[4] = y2;
+  p[5] = !on;
+  kz_send(MSGBOX_ID_DISPLAY, 6, p);
+}
+
+void ipc_display_draw_logo(int x, int y, int size)
+{
+  char *p;
+  p = kz_kmalloc(4);
+  p[0] = DISPLAY_CMD_LCD_DRAW_LOGO;
+  p[1] = x;
+  p[2] = y;
+  p[3] = size;
+  kz_send(MSGBOX_ID_DISPLAY, 4, p);
+}
+
+void ipc_display_draw_text(int x, int y, char *str)
+{
+  char *p;
+  int len;
+  len = strlen(str);
+  p = kz_kmalloc(3 + len + 1);
+  p[0] = DISPLAY_CMD_LCD_DRAW_TEXT;
+  p[1] = x;
+  p[2] = y;
+  memcpy(&p[3], str, len);
+  p[3 + len] = '\0';
+  kz_send(MSGBOX_ID_DISPLAY, 3 + len + 1, p);
+}
+
+void ipc_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);
+}
+
diff --git a/firm/sample/simple_mp3_player/os/ipc_display.h b/firm/sample/simple_mp3_player/os/ipc_display.h
new file mode 100644 (file)
index 0000000..5f1a7c0
--- /dev/null
@@ -0,0 +1,25 @@
+
+#ifndef IPC_DISPLAY_H
+#define IPC_DISPLAY_H
+
+#define DISPLAY_CMD_LCD_CLEAR       'c' /* LCD\e$B$N>C5n\e(B */
+#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 */
+
+void ipc_display_led_write(int target, int state);
+void ipc_display_led_toggle(int target);
+void ipc_display_clear(void);
+void ipc_display_draw_box(int x1, int y1, int x2, int y2, int on);
+void ipc_display_draw_logo(int x, int y, int size);
+void ipc_display_draw_text(int x, int y, char *str);
+void ipc_display_draw_progressbar(
+        int x1, int y1, int x2, int y2,
+        int min, int max, int value);
+
+#endif
+
index 67c092b..f3f9593 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# KOZOS IPC Call Graph Visualization Tool (Version 0.0.1)
+# KOZOS IPC Relationship Visualization Tool (Version 0.0.1)
 # Copyright(C) 2012 Shinichiro Nakamura (CuBeatSystems)
 #
 
@@ -47,8 +47,8 @@ grep kz_recv $TARGET_RECVTASK | \
 #
 # バナー
 #
-echo "// Generated by KOZOS IPC Call Graph Visualization Tool " >> $DOTFILE
-echo "// Copyright(C) 2012 Shinichiro Nakamura (CuBeatSystems)" >> $DOTFILE
+echo "// Generated by KOZOS IPC Relationship Visualization Tool" >> $DOTFILE
+echo "// Copyright(C) 2012 Shinichiro Nakamura (CuBeatSystems) " >> $DOTFILE
 echo "" >> $DOTFILE
 
 #
index b4d8df3..c97a563 100644 (file)
@@ -3,7 +3,7 @@
 #include "kozos.h"
 #include "lib.h"
 #include "driver_console.h"
-#include "task_display.h"
+#include "ipc_display.h"
 
 int task_command(int argc, char *argv[])
 {
@@ -27,13 +27,13 @@ int task_command(int argc, char *argv[])
       console_write(p + 4); /* echo¤Ë³¤¯Ê¸»úÎó¤ò½ÐÎϤ¹¤ë */
       console_write("\n");
     } else if (!strncmp(p, "led1", 4)) {
-      display_led_toggle(0);
+      ipc_display_led_toggle(0);
     } else if (!strncmp(p, "led2", 4)) {
-      display_led_toggle(1);
+      ipc_display_led_toggle(1);
     } else if (!strncmp(p, "ledg", 4)) {
-      display_led_toggle(2);
+      ipc_display_led_toggle(2);
     } else if (!strncmp(p, "ledr", 4)) {
-      display_led_toggle(3);
+      ipc_display_led_toggle(3);
     } else {
       console_write("unknown.\n");
     }
index 761bbc9..6c807e7 100644 (file)
 
 #include "task_display.h"
+#include "ipc_display.h"
 #include "sg12232c.h"
 #include "kozos.h"
 #include "lib.h"
 #include "led.h"
 
-#define DISPLAY_CMD_LCD_CLEAR       'c' /* LCD\e$B$N>C5n\e(B */
-#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 */
-
-void display_led_write(int target, int state)
-{
-  char *p;
-  p = kz_kmalloc(2);
-  p[0] = state ? DISPLAY_CMD_LED_ON : DISPLAY_CMD_LED_OFF;
-  p[1] = '0' + target;
-  kz_send(MSGBOX_ID_DISPLAY, 2, p);
-}
-
-void display_led_toggle(int target)
-{
-  char *p;
-  p = kz_kmalloc(2);
-  p[0] = DISPLAY_CMD_LED_TOGGLE;
-  p[1] = '0' + target;
-  kz_send(MSGBOX_ID_DISPLAY, 2, p);
-}
-
-void display_clear(void)
-{
-  char *p;
-  p = kz_kmalloc(1);
-  p[0] = DISPLAY_CMD_LCD_CLEAR;
-  kz_send(MSGBOX_ID_DISPLAY, 1, p);
-}
-
-void display_draw_box(int x1, int y1, int x2, int y2, int on)
-{
-  char *p;
-  p = kz_kmalloc(6);
-  p[0] = DISPLAY_CMD_LCD_DRAW_BOX;
-  p[1] = x1;
-  p[2] = y1;
-  p[3] = x2;
-  p[4] = y2;
-  p[5] = !on;
-  kz_send(MSGBOX_ID_DISPLAY, 6, p);
-}
-
-void display_draw_logo(int x, int y, int size)
-{
-  char *p;
-  p = kz_kmalloc(4);
-  p[0] = DISPLAY_CMD_LCD_DRAW_LOGO;
-  p[1] = x;
-  p[2] = y;
-  p[3] = size;
-  kz_send(MSGBOX_ID_DISPLAY, 4, p);
-}
-
-void display_draw_text(int x, int y, char *str)
-{
-  char *p;
-  int len;
-  len = strlen(str);
-  p = kz_kmalloc(3 + len + 1);
-  p[0] = DISPLAY_CMD_LCD_DRAW_TEXT;
-  p[1] = x;
-  p[2] = y;
-  memcpy(&p[3], str, len);
-  p[3 + len] = '\0';
-  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[] = {
index f6f17e2..dce11b3 100644 (file)
@@ -2,16 +2,6 @@
 #ifndef DISPLAY_H
 #define DISPLAY_H
 
-void display_led_write(int target, int state);
-void display_led_toggle(int target);
-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[]);
 
 #endif
index 9a4f8cc..c10434f 100644 (file)
@@ -2,7 +2,7 @@
 #include "lib.h"
 #include "kozos.h"
 #include "task_menu.h"
-#include "task_display.h"
+#include "ipc_display.h"
 
 #define MENU_CMD_FILENAME   'F'
 #define MENU_CMD_LOCATION   'L'
 
 #define LED_LEFT() \
     do { \
-      display_led_write(1, 0); \
-      display_led_toggle(0); \
+      ipc_display_led_write(1, 0); \
+      ipc_display_led_toggle(0); \
     } while (0)
 
 #define LED_RIGHT() \
     do { \
-      display_led_write(0, 0); \
-      display_led_toggle(1); \
+      ipc_display_led_write(0, 0); \
+      ipc_display_led_toggle(1); \
     } while (0)
 
 #define LED_GREEN() \
     do { \
-      display_led_toggle(2); \
+      ipc_display_led_toggle(2); \
     } while (0)
 
 #define LED_RED() \
     do { \
-      display_led_toggle(3); \
+      ipc_display_led_toggle(3); \
     } while (0)
 
 #define DISP_VOLUME(N) \
-    display_draw_progressbar(107, 3, 118, 7, VOL_MIN, VOL_MAX, N)
+    ipc_display_draw_progressbar(107, 3, 118, 7, VOL_MIN, VOL_MAX, N)
 
 #define DISP_LOCATION(N) \
-    display_draw_progressbar(24, 13, 83, 17, 0, 100, N)
+    ipc_display_draw_progressbar(24, 13, 83, 17, 0, 100, N)
 
 static int _volume = VOL_DEF;
 static int _control = 0;
@@ -120,7 +120,7 @@ static int menu_cmdproc(char *p)
   int cmd = p[0];
   switch (cmd) {
   case MENU_CMD_FILENAME:
-    display_draw_text(24, 3, &p[1]);
+    ipc_display_draw_text(24, 3, &p[1]);
     break;
   case MENU_CMD_LOCATION:
     DISP_LOCATION(p[1]);
@@ -208,9 +208,9 @@ static int menu_cmdproc(char *p)
 
 int task_menu(int argc, char *argv[])
 {
-  display_clear();
-  display_draw_box(0, 0, 121, 31, 1);
-  display_draw_logo(2, 2, 0);
+  ipc_display_clear();
+  ipc_display_draw_box(0, 0, 121, 31, 1);
+  ipc_display_draw_logo(2, 2, 0);
   DISP_VOLUME(_volume);
 
   while (1) {