//#inherit "4DGL-System.fnc"
\r
#constant MSG_TERM '~'\r
-#constant MSG_BUFF_LEN 88\r
+#constant MSG_BUFF_LEN 90\r
#constant MSG_POWER 'V'\r
#constant MSG_POSITION 'P'\r
#constant MSG_FSM_STATE 'F'\r
var move_fsm_state[20];\r
var move_fsm_state_len;\r
\r
-var lift_pos;\r
+var lift_pos[4];\r
var pucks_nr;\r
func init()\r
idx++;\r
until(idx == 5);\r
\r
- lift_pos:='0';\r
+ lift_pos[0]:='0';\r
+ lift_pos[1]:='0';\r
+ lift_pos[2]:='0';\r
+ lift_pos[3]:='0';\r
pucks_nr:='0';\r
endfunc\r
\r
endfunc\r
\r
func update_pucks()\r
+ gfx_Rectangle(0, 142, 70, 170, BLACK);\r
txt_Set(FONT_SIZE, FONT4);\r
txt_MoveCursor(9, 3); // move the cursor to line 4, column 5\r
txt_Set(TEXT_COLOUR, LEMONCHIFFON);\r
endfunc\r
\r
func update_lift()\r
+ gfx_Rectangle(170, 142, 239, 170, BLACK);\r
txt_Set(FONT_SIZE, FONT4);\r
txt_MoveCursor(9, 15); // move the cursor to line 4, column 5\r
txt_Set(TEXT_COLOUR, LEMONCHIFFON);\r
- putch(lift_pos);\r
+ putch(lift_pos[0]);\r
+ putch(lift_pos[1]);\r
+ putch(lift_pos[2]);\r
+ putch(lift_pos[3]);\r
endfunc\r
\r
func draw_lift()\r
game_color := RED;\r
endif\r
\r
- lift_pos := msg_rcvd[83];\r
- pucks_nr := msg_rcvd[86];\r
+ mem_Copy(msg_rcvd+82, lift_pos, 8);\r
+ pucks_nr := msg_rcvd[90];\r
\r
draw_voltage33();\r
draw_voltage50();\r
\r
\r
\r
+\r
robot.orte.pwr_voltage.voltage80 = 8.35;
robot.orte.pwr_voltage.voltageBAT = 12.35;
+ robot.pucks_inside = 3;
+ robot.orte.actuator_status.lift_pos=1234;
+
robot.fsm.main.transition_callback = trans_callback;
robot.fsm.motion.transition_callback = move_trans_callback;
buff[4] = status[3];
buff[5] = status[4];
buff[6] = status[5];
- buff[7] = MSG_TERM;
+ buff[7] = status[6];
+ buff[8] = status[7];
+ buff[9] = MSG_TERM;
return HW_STATUS_MSG_SIZE;
}
return FSM_STATE_MSG_SIZE;
}
+int oled_send_pucks_nr(uint8_t *buff, int buff_size, char nr)
+{
+ if(buff_size < PUCKS_MSG_SIZE)
+ return -1;
+
+ buff[0] = PUCKS_MSG;
+ sprintf((char*)buff+1, "%1d", nr);
+ buff[2] = MSG_TERM;
+
+ return PUCKS_MSG_SIZE;
+}
+
+int oled_send_lift_pos(uint8_t *buff, int buff_size, uint16_t pos)
+{
+ if(buff_size < LIFT_MSG_SIZE)
+ return -1;
+
+ buff[0] = LIFT_MSG;
+ sprintf((char*)buff+1, "%4d", pos);
+ buff[5] = MSG_TERM;
+
+ return LIFT_MSG_SIZE;
+}
+
#define MSG_SIZE 31
#define MSG_TERM '~'
-#define HW_STATUS_MSG_SIZE 8
+#define HW_STATUS_MSG_SIZE 10
#define SWITCH_MODE_MSG_SIZE 4
#define VOLTAGE_MSG_SIZE 19
#define FSM_STATE_MSG_SIZE 22
#define POSITION_MSG_SIZE 14
#define COLOR_MSG_SIZE 3
+#define LIFT_MSG_SIZE 6
+#define PUCKS_MSG_SIZE 3
#define VOLTAGE_MSG 'V'
#define FSM_STATE_MSG 'F'
#define COLOR_MSG 164
#define POSITION_MSG 'P'
#define MOVE_FSM_STATE_MSG 'M'
+#define LIFT_MSG 'L'
+#define PUCKS_MSG 'p'
#define ACTUATORS 180
#define GET_READY 181
int oled_send_position(uint8_t *buff, int buff_size, struct est_pos_type *pos);
int oled_send_fsm_state(uint8_t *buff, int buff_size, const char *name, int len, uint8_t type);
int oled_send_hw_status(uint8_t *buff, int buff_size, uint8_t *status);
+int oled_send_pucks_nr(uint8_t *buff, int buff_size, char nr);
+int oled_send_lift_pos(uint8_t *buff, int buff_size, uint16_t pos);
#ifdef __cplusplus
}
#endif
#define DEBUG
#endif
+#define DEBUG
static struct sercom_data sercom;
struct sercom_data* uoled_init(void(*sighandler)(int))
else
idx += ret;
+ ret = oled_send_lift_pos(msg+idx, sizeof(msg)-idx, state->orte.actuator_status.lift_pos);
+ if(ret==-1)
+ return -1;
+ else
+ idx += ret;
+
+ ret = oled_send_pucks_nr(msg+idx, sizeof(msg)-idx, state->pucks_inside);
+ if(ret==-1)
+ return -1;
+ else
+ idx += ret;
+
ret = uoled_write_cmd(msg, idx);
if(ret)