]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
disp: first version of app for robot control
authorMartin Zidek <zidekm1@gmail.com>
Tue, 14 Apr 2009 18:11:57 +0000 (20:11 +0200)
committerMartin Zidek <zidekm1@gmail.com>
Tue, 14 Apr 2009 18:11:57 +0000 (20:11 +0200)
src/disp-4dgl/ctrl.4dg [new file with mode: 0644]

diff --git a/src/disp-4dgl/ctrl.4dg b/src/disp-4dgl/ctrl.4dg
new file mode 100644 (file)
index 0000000..26b24f3
--- /dev/null
@@ -0,0 +1,170 @@
+#platform "uOLED-32028-PMD3T"
+
+#inherit "4DGL_16bitColours.fnc"
+//#inherit "4DGL-System.fnc"
+\r
+#constant MSG_BUFF_LEN 10\r
+\r
+#constant BT_LIFT_CALIB 0\r
+#constant BT_PUSHER_IN 1\r
+#constant BT_PUSHER_OUT 2\r
+#constant BT_LIFT_UP 3\r
+#constant BT_LIFT_DOWN 4\r
+#constant BT_CMU_INIT 5\r
+#constant BT_START 6\r
+#constant BT_COLOR 7\r
+#constant BT_FOROTA 8\r
+\r
+#constant X_OFFSET 30\r
+#constant Y_OFFSET 4\r
+\r
+var msg_buff[MSG_BUFF_LEN];\r
+var bt_y[20];\r
+var bt_x[20];\r
+\r
+func lift_calib_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_LIFT_CALIB], BLUE, YELLOW, FONT2, 2, 2, " LIFT CAL ");\r
+endfunc\r
+\r
+func pusher_in_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_PUSHER_IN], BLUE, YELLOW, FONT2, 2, 2, " PUSHER IN");\r
+endfunc\r
+\r
+func pusher_out_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_PUSHER_OUT], BLUE, YELLOW, FONT2, 2, 2, "PUSHER OUT");\r
+endfunc\r
+\r
+func lift_up_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_LIFT_UP], BLUE, YELLOW, FONT2, 2, 2, " LIFT UP  ");\r
+endfunc\r
+\r
+func lift_down_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_LIFT_DOWN], BLUE, YELLOW, FONT2, 2, 2, " LIFT DOWN");\r
+endfunc\r
+\r
+func cmu_init_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_CMU_INIT], BLUE, YELLOW, FONT2, 2, 2, " CMU INIT ");\r
+endfunc\r
+\r
+func start_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_START], BLUE, YELLOW, FONT2, 2, 2, " !!START!!");\r
+endfunc\r
+\r
+func color_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_COLOR], GREEN, YELLOW, FONT2, 2, 2, "   COLOR  ");\r
+endfunc\r
+\r
+func forota_bt(var state)\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_FOROTA], GRAY, YELLOW, FONT2, 2, 2, "  FOROTA  ");\r
+endfunc\r
+\r
+func draw_control()\r
+    bt_y[BT_LIFT_CALIB]:=Y_OFFSET;\r
+    lift_calib_bt(UP);\r
+    \r
+    bt_y[BT_PUSHER_IN]:=gfx_Get(3)+4;\r
+    pusher_in_bt(UP);\r
+    \r
+    bt_y[BT_PUSHER_OUT]:=gfx_Get(3)+4;\r
+    pusher_out_bt(UP);\r
+    \r
+    bt_y[BT_LIFT_UP]:=gfx_Get(3)+4;\r
+    lift_up_bt(UP);\r
+    \r
+    bt_y[BT_LIFT_DOWN]:=gfx_Get(3)+4;\r
+    lift_down_bt(UP);\r
+    \r
+    bt_y[BT_CMU_INIT]:=gfx_Get(3)+4;\r
+    cmu_init_bt(UP);\r
+\r
+    bt_y[BT_START]:=gfx_Get(3)+4;\r
+    start_bt(UP);\r
+    \r
+    bt_y[BT_COLOR]:=gfx_Get(3)+4;\r
+    color_bt(UP);\r
+\r
+    bt_y[BT_FOROTA]:=gfx_Get(3)+4;\r
+    forota_bt(UP);\r
+endfunc\r
+\r
+func touchscreen()\r
+var col, state, x, y;\r
+    state := touch_Get(TOUCH_STATUS);               // get touchscreen status\r
+        \r
+        if(state == NOTOUCH)\r
+            return;\r
+        endif\r
+        //-----------------------------------------------------------------------------------------\r
+        if(state == TOUCH_PRESS)                        // if there's a press\r
+            x := touch_Get(TOUCH_GETX);                          \r
+            y := touch_Get(TOUCH_GETY);\r
+            \r
+            if((y > bt_y[BT_LIFT_CALIB])&&(y<bt_y[BT_PUSHER_IN]))\r
+                lift_calib_bt(DOWN);\r
+            endif            \r
+            if((y > bt_y[BT_PUSHER_IN])&&(y<bt_y[BT_PUSHER_OUT]))\r
+                pusher_in_bt(DOWN);\r
+            endif            \r
+            if((y > bt_y[BT_PUSHER_OUT])&&(y<bt_y[BT_LIFT_UP]))\r
+                pusher_out_bt(DOWN);\r
+            endif            \r
+            if((y > bt_y[BT_LIFT_UP])&&(y<bt_y[BT_LIFT_DOWN]))\r
+                lift_up_bt(DOWN);\r
+            endif            \r
+            if((y > bt_y[BT_LIFT_DOWN])&&(y<bt_y[BT_CMU_INIT]))\r
+                lift_down_bt(DOWN);\r
+            endif            \r
+            if((y > bt_y[BT_CMU_INIT])&&(y<bt_y[BT_START]))\r
+                cmu_init_bt(DOWN);\r
+            endif            \r
+            if((y > bt_y[BT_START])&&(y<bt_y[BT_COLOR]))\r
+                start_bt(DOWN);\r
+            endif            \r
+\r
+        endif\r
+        if(state == TOUCH_RELEASE)                        // if there's a press\r
+            x := touch_Get(TOUCH_GETX);                          \r
+            y := touch_Get(TOUCH_GETY);\r
+            if((y > bt_y[BT_LIFT_CALIB])&&(y<bt_y[BT_PUSHER_IN]))\r
+                lift_calib_bt(UP);\r
+            endif            \r
+            if((y > bt_y[BT_PUSHER_IN])&&(y<bt_y[BT_PUSHER_OUT]))\r
+                pusher_in_bt(UP);\r
+            endif            \r
+            if((y > bt_y[BT_PUSHER_OUT])&&(y<bt_y[BT_LIFT_UP]))\r
+                pusher_out_bt(UP);\r
+            endif            \r
+            if((y > bt_y[BT_LIFT_UP])&&(y<bt_y[BT_LIFT_DOWN]))\r
+                lift_up_bt(UP);\r
+            endif            \r
+            if((y > bt_y[BT_LIFT_DOWN])&&(y<bt_y[BT_CMU_INIT]))\r
+                lift_down_bt(UP);\r
+            endif            \r
+            if((y > bt_y[BT_CMU_INIT])&&(y<bt_y[BT_START]))\r
+                cmu_init_bt(UP);\r
+            endif            \r
+            if((y > bt_y[BT_START])&&(y<bt_y[BT_COLOR]))\r
+                start_bt(UP);\r
+            endif       \r
+        endif\r
+endfunc\r
+\r
+func get_msg()\r
+\r
+endfunc\r
+
+func main()\r
+    setbaud(6); // 9600 baud\r
+    com_Init(msg_buff, MSG_BUFF_LEN, ':');\r
+\r
+    touch_Set(TOUCH_ENABLE); // enable TS\r
+    touch_Set(TOUCH_REGIONDEFAULT); // reset touch area to fullscreen\r
+    \r
+    draw_control();\r
+    repeat // the main application loop\r
+       touchscreen();\r
+        if(com_Full()==1)\r
+            get_msg();\r
+        endif\r
+    forever\r
+endfunc\r