]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
disp: working app switching
authorMartin Zidek <zidekm1@gmail.com>
Sat, 18 Apr 2009 15:45:42 +0000 (17:45 +0200)
committerMartin Zidek <zidekm1@gmail.com>
Sat, 18 Apr 2009 15:45:42 +0000 (17:45 +0200)
src/disp-4dgl/control_screen.4dg
src/disp-4dgl/status_screen.4dg

index b2e5522b341878450d07e34bf5a768c2eb7b2e77..c0c8239943cab321aeaa0d3eaf6a150a830e635f 100644 (file)
 #constant MSG_START_ACT 157\r
 #constant MSG_COLOR 158\r
 #constant MSG_INIT 160\r
-#constant MSG_STATUS_REQ 161\r
+#constant MSG_STATUS_REQ 183\r
 #constant MSG_RESTART 162\r
+#constant MSG_SWITCH_TO_CONTROL_DONE 186\r
 \r
 #constant COLOR_RED 1\r
 #constant COLOR_GREEN 0\r
 \r
 var msg_buff[MSG_BUFF_LEN];\r
+var msg_rcvd[MSG_BUFF_LEN];\r
 var bt_y[20];\r
 var bt_x[20];\r
-var out_buff[3];\r
+var out_buff[4];\r
 var msg_len;\r
 var current_color;\r
 var button_color;\r
@@ -54,7 +56,6 @@ func send_msg()
         serout(out_buff[idx]);\r
         idx++;\r
     until(idx==msg_len)\r
-\r
 endfunc\r
 \r
 func act_lift_calib()\r
@@ -151,7 +152,7 @@ func act_color()
     out_buff[0]:=MSG_START;\r
     out_buff[1]:=MSG_COLOR;\r
     out_buff[2]:=current_color;\r
-    out_buff[3]:=MSG_TERM_LF;\r
+    out_buff[3]:=10;\r
     msg_len:=4;\r
     send_msg();\r
 endfunc\r
@@ -344,14 +345,54 @@ var col, state, x, y;
         endif\r
 endfunc\r
 \r
+func load_status()\r
+    file_Run("STATUS.4XE",0);\r
+endfunc\r
+\r
+func process_msg()\r
+    if(msg_rcvd[0]==200)\r
+        load_status();\r
+    endif\r
+endfunc\r
+\r
 func get_msg()\r
+    var in, idx, bad, msg_len;\r
+\r
+    idx:=0;\r
+    bad:=0;    \r
+    in:=serin();\r
+    \r
+    repeat\r
+        in:=serin();\r
+        if(in!=-1)\r
+            msg_rcvd[idx] := in;\r
+            idx++;\r
+        else\r
+            break;\r
+        endif\r
+    forever\r
+\r
+    msg_len := idx;\r
+    com_Init(msg_buff, MSG_BUFF_LEN, ':');\r
 \r
+    process_msg();\r
+    return 0; \r
 endfunc\r
 
 func main()\r
-    setbaud(6); // 9600 baud\r
+    var idx;\r
+    setbaud(4); // 9600 baud\r
     com_Init(msg_buff, MSG_BUFF_LEN, ':');\r
 \r
+    out_buff[0]:=MSG_START;\r
+    out_buff[1]:=MSG_SWITCH_TO_CONTROL_DONE;\r
+    out_buff[2]:=MSG_TERM_LF;\r
+    idx:=0;\r
+    repeat\r
+        serout(out_buff[idx]);\r
+        idx++;\r
+    until(idx==3)  \r
+\r
     touch_Set(TOUCH_ENABLE); // enable TS\r
     touch_Set(TOUCH_REGIONDEFAULT); // reset touch area to fullscreen\r
     \r
@@ -367,3 +408,8 @@ func main()
 endfunc\r
 \r
 \r
+\r
+\r
+\r
+\r
+\r
index fb94c1a9b0acbd6bba8ccd8610c4a0e67ce1b61c..da61241319214417f48d95dc6e436e1d05fc53a9 100644 (file)
@@ -13,6 +13,8 @@
 #constant MSG_START 150\r
 #constant MSG_TERM_LF 10\r
 \r
+#constant MSG_SWITCH_TO_STATUS_DONE 185\r
+\r
 #constant MSG_STATUS 'S'\r
 
 // Indices to the voltage_status array
@@ -28,7 +30,7 @@
 #constant HW_STATUS_WARN 2\r
 \r
 #constant MSG_CONTROL_REQ 184\r
-#constant MSG_CONTROL_REP 186\r
+#constant MSG_SWITCH_REP 200\r
 \r
 #constant HW1 1\r
 #constant HW2 2\r
@@ -500,6 +502,11 @@ func update_hw()
     draw_hw5(hw_status[5]);\r
     draw_hw6(hw_status[6]);\r
     draw_hw6a(hw_status[7]);\r
+endfunc\r
+\r
+func load_control()\r
+    clear_screen();\r
+    file_Run("CTRL.4XE",0);\r
 endfunc
 
 /*Process the message received on serial line*/
@@ -537,8 +544,11 @@ func process_msg()
         update_lift();\r
         update_pucks();\r
         update_hw();\r
+        \r
+        \r
     endif\r
-    if(msg_rcvd[0]==MSG_CONTROL_REP)\r
+    if(msg_rcvd[0]==200)\r
+        load_control();\r
     endif\r
         
 endfunc
@@ -607,9 +617,20 @@ func touchscreen()
             \r
 endfunc\r
 
-func main()
-    setbaud(6); // 9600 baud
-    com_Init(msg_buff, MSG_BUFF_LEN, ':');
+func main()\r
+    var idx;
+    setbaud(4); // 9600 baud
+    com_Init(msg_buff, MSG_BUFF_LEN, ':');\r
+    \r
+    out_buff[0]:=MSG_START;\r
+    out_buff[1]:=MSG_SWITCH_TO_STATUS_DONE;\r
+    out_buff[2]:=MSG_TERM_LF;\r
+    idx:=0;\r
+    repeat\r
+        serout(out_buff[idx]);\r
+        idx++;\r
+    until(idx==3)  \r
+
 
     touch_Set(TOUCH_ENABLE); // enable TS
     touch_Set(TOUCH_REGIONDEFAULT); // reset touch area to fullscreen\r
@@ -630,3 +651,11 @@ endfunc
 \r
 \r
 \r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r