]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
disp: control screen almost finalized
authorMartin Zidek <zidekm1@gmail.com>
Thu, 16 Apr 2009 16:05:11 +0000 (18:05 +0200)
committerMartin Zidek <zidekm1@gmail.com>
Thu, 16 Apr 2009 16:05:11 +0000 (18:05 +0200)
src/disp-4dgl/ctrl.4dg

index f899968ecbeabd61a61935cdb82bd7f58c105fc9..b2e5522b341878450d07e34bf5a768c2eb7b2e77 100644 (file)
@@ -13,9 +13,9 @@
 #constant BT_CMU_INIT 5\r
 #constant BT_START 6\r
 #constant BT_COLOR 7\r
-#constant BT_FOROTA 8\r
 #constant BT_INIT 9\r
 #constant BT_END 10\r
+#constant BT_RESTART 11\r
 \r
 #constant X_OFFSET 0\r
 #constant Y_OFFSET 4\r
 #constant MSG_CMU_INIT 156\r
 #constant MSG_START_ACT 157\r
 #constant MSG_COLOR 158\r
-#constant MSG_FOROTA 159\r
 #constant MSG_INIT 160\r
 #constant MSG_STATUS_REQ 161\r
+#constant MSG_RESTART 162\r
+\r
+#constant COLOR_RED 1\r
+#constant COLOR_GREEN 0\r
 \r
 var msg_buff[MSG_BUFF_LEN];\r
 var bt_y[20];\r
 var bt_x[20];\r
 var out_buff[3];\r
 var msg_len;\r
+var current_color;\r
+var button_color;\r
 \r
 func send_msg()\r
     var idx;\r
@@ -108,35 +113,46 @@ func act_start()
     send_msg();\r
 endfunc\r
 \r
-func act_color(var col)\r
+func act_init()\r
     out_buff[0]:=MSG_START;\r
-    out_buff[1]:=MSG_COLOR;\r
-    out_buff[3]:=MSG_TERM_LF;\r
-    msg_len:=4;\r
+    out_buff[1]:=MSG_INIT;\r
+    out_buff[2]:=MSG_TERM_LF;\r
+    msg_len:=3;\r
     send_msg();\r
 endfunc\r
 \r
-func act_forota()\r
+func act_status()\r
     out_buff[0]:=MSG_START;\r
-    out_buff[1]:=MSG_FOROTA;\r
+    out_buff[1]:=MSG_STATUS_REQ;\r
     out_buff[2]:=MSG_TERM_LF;\r
     msg_len:=3;\r
     send_msg();\r
 endfunc\r
 \r
-func act_init()\r
+func act_restart()\r
     out_buff[0]:=MSG_START;\r
-    out_buff[1]:=MSG_INIT;\r
+    out_buff[1]:=MSG_RESTART;\r
     out_buff[2]:=MSG_TERM_LF;\r
     msg_len:=3;\r
     send_msg();\r
 endfunc\r
 \r
-func act_status()\r
+func act_color()\r
+    if(current_color==COLOR_RED)\r
+        current_color := COLOR_GREEN;\r
+        button_color := GREEN;\r
+    else\r
+        if(current_color==COLOR_GREEN)\r
+            current_color := COLOR_RED;\r
+            button_color := RED;\r
+        endif\r
+    endif\r
+\r
     out_buff[0]:=MSG_START;\r
-    out_buff[1]:=MSG_STATUS_REQ;\r
-    out_buff[2]:=MSG_TERM_LF;\r
-    msg_len:=3;\r
+    out_buff[1]:=MSG_COLOR;\r
+    out_buff[2]:=current_color;\r
+    out_buff[3]:=MSG_TERM_LF;\r
+    msg_len:=4;\r
     send_msg();\r
 endfunc\r
 \r
@@ -145,11 +161,11 @@ func lift_calib_bt(var state)
 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, "PSH_IN");\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_PUSHER_IN], BLUE, YELLOW, FONT2, 2, 2, "PSH IN");\r
 endfunc\r
 \r
 func pusher_out_bt(var state)\r
-    gfx_Button(state, bt_x[BT_PUSHER_OUT], bt_y[BT_PUSHER_IN], BLUE, YELLOW, FONT2, 2, 2, "PSH_OUT");\r
+    gfx_Button(state, bt_x[BT_PUSHER_OUT], bt_y[BT_PUSHER_IN], BLUE, YELLOW, FONT2, 2, 2, "PSH OUT");\r
 endfunc\r
 \r
 func lift_up_bt(var state)\r
@@ -165,15 +181,15 @@ func cmu_init_bt(var state)
 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
+    gfx_Button(state, X_OFFSET, bt_y[BT_START], ORANGE, WHITE, 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
+    gfx_Button(state, X_OFFSET, bt_y[BT_COLOR], button_color, YELLOW, FONT2, 2, 2, "     COLOR    ");\r
 endfunc\r
 \r
 func restart_bt(var state)\r
-    gfx_Button(state, X_OFFSET, bt_y[BT_FOROTA], GRAY, YELLOW, FONT2, 2, 2, "    RESTART   ");\r
+    gfx_Button(state, X_OFFSET, bt_y[BT_RESTART], GRAY, YELLOW, FONT2, 2, 2, "    RESTART   ");\r
 endfunc\r
 \r
 func init_bt(var state)\r
@@ -212,7 +228,7 @@ func draw_control()
     bt_y[BT_COLOR]:=gfx_Get(3)+4;\r
     color_bt(UP);\r
 \r
-    bt_y[BT_FOROTA]:=gfx_Get(3)+4;\r
+    bt_y[BT_RESTART]:=gfx_Get(3)+4;\r
     restart_bt(UP);\r
     \r
     bt_y[BT_INIT]:=gfx_Get(3)+4;\r
@@ -258,6 +274,12 @@ var col, state, x, y;
             if((y > bt_y[BT_START])&&(y<bt_y[BT_COLOR]))\r
                 start_bt(DOWN);\r
             endif            \r
+            if((y > bt_y[BT_COLOR])&&(y<bt_y[BT_RESTART]))\r
+                color_bt(DOWN);\r
+            endif            \r
+            if((y > bt_y[BT_RESTART])&&(y<bt_y[BT_INIT]))\r
+                restart_bt(DOWN);\r
+            endif            \r
             if((y > bt_y[BT_INIT])&&(y<bt_y[BT_END]))\r
                 init_bt(DOWN);\r
             endif            \r
@@ -303,6 +325,14 @@ var col, state, x, y;
                 start_bt(UP);\r
                 act_start();\r
             endif       \r
+            if((y > bt_y[BT_COLOR])&&(y<bt_y[BT_RESTART]))\r
+                act_color();\r
+                color_bt(UP);                \r
+            endif       \r
+            if((y > bt_y[BT_RESTART])&&(y<bt_y[BT_INIT]))\r
+                restart_bt(UP);\r
+                act_restart();\r
+            endif       \r
             if((y > bt_y[BT_INIT])&&(y<bt_y[BT_END]))\r
                 init_bt(UP);\r
                 act_init();\r
@@ -325,6 +355,8 @@ func main()
     touch_Set(TOUCH_ENABLE); // enable TS\r
     touch_Set(TOUCH_REGIONDEFAULT); // reset touch area to fullscreen\r
     \r
+    current_color:=COLOR_GREEN;\r
+    button_color:=GREEN;\r
     draw_control();\r
     repeat // the main application loop\r
        touchscreen();\r
@@ -334,3 +366,4 @@ func main()
     forever\r
 endfunc\r
 \r
+\r