10 #include <robottype.h>
16 int oled_send_hw_status(uint8_t *buff, int buff_size, uint8_t *status)
18 if(buff_size < HW_STATUS_MSG_SIZE)
21 buff[0] = HW_STATUS_MSG;
31 return HW_STATUS_MSG_SIZE;
34 int oled_set_color(uint8_t *buff, int buff_size, uint8_t color)
36 if(buff_size < COLOR_MSG_SIZE)
42 return COLOR_MSG_SIZE;
45 int oled_send_game_conf(uint8_t *buff, int buff_size, uint8_t conf)
47 if(buff_size < CONF_MSG_SIZE)
50 buff[0] = GAME_CONF_MSG;
51 sprintf((char*)buff+1, "%1d", conf);
52 sprintf((char*)buff+2, "%1d", conf);
57 int oled_switch_mode(uint8_t *buff, int buff_size, uint8_t mode, uint8_t status)
59 if(buff_size < SWITCH_MODE_MSG_SIZE)
62 *(buff+0) = CHANGE_MODE_REP;
67 return SWITCH_MODE_MSG_SIZE;
70 int oled_send_voltage(uint8_t *buff, int buff_size, struct pwr_voltage_type *volt)
73 if(buff_size < VOLTAGE_MSG_SIZE)
76 buff[0] = VOLTAGE_MSG;
78 sprintf((char*)(buff+1),"%1.2f",volt->voltage33);
80 sprintf((char*)(buff+5),"%1.2f",volt->voltage50);
82 sprintf((char*)(buff+9),"%1.2f",volt->voltage80);
84 sprintf((char*)(buff+13),"%2.2f",volt->voltageBAT);
86 *(buff+18) = MSG_TERM;
88 return VOLTAGE_MSG_SIZE;
91 int oled_send_position(uint8_t *buff, int buff_size, struct est_pos_type *pos)
93 if(buff_size < POSITION_MSG_SIZE)
96 buff[0] = POSITION_MSG;
98 sprintf((char*)(buff+1),"%1.2f",pos->x);
100 sprintf((char*)(buff+5),"%1.2f",pos->y);
102 sprintf((char*)(buff+9),"%3.0f ",RAD2DEG(pos->phi));
104 *(buff+13) = MSG_TERM;
106 return POSITION_MSG_SIZE;
109 int oled_send_fsm_state(uint8_t *buff, int buff_size, const char *name, int len, uint8_t type)
111 memset(buff, ' ', FSM_STATE_MSG_SIZE);
113 strncpy((char*)buff+1, name, (len > 20) ? 20 : len);
114 buff[FSM_STATE_MSG_SIZE-1] = MSG_TERM;
116 return FSM_STATE_MSG_SIZE;
119 int oled_send_pucks_nr(uint8_t *buff, int buff_size, char nr)
121 if(buff_size < PUCKS_MSG_SIZE)
125 sprintf((char*)buff+1, "%1d", nr);
128 return PUCKS_MSG_SIZE;
131 int oled_send_lift_pos(uint8_t *buff, int buff_size, uint16_t pos)
133 if(buff_size < LIFT_MSG_SIZE)
137 sprintf((char*)buff+1, "%4d", pos);
140 return LIFT_MSG_SIZE;