struct sercom_data *sercom;
uint8_t msg[10];
+uint8_t hw_status[6];
bool msg_waiting;
bool wait_flag;
uint8_t mode_to_go;
struct mcl_laser laser; /* MCL implementation for laser */
struct map *map; /* Map for pathplanning (no locking) */
+
+ /* information about HW units status - for display */
+ uint8_t hw_status[6];
}; /* robot_eb2008 */
extern struct robot_eb2008 robot;
#include <math.h>
#include <robomath.h>
#include <laser-nav.h>
-
+#include <oledlib.h>
/* ----------------------------------------------------------------------
* PUBLISHER CALLBACKS - GENERIC
* ---------------------------------------------------------------------- */
odo->dy = 0;
odo->dangle = deltAlfa;
FSM_SIGNAL(LOC, EV_ODO_RECEIVED, odo);
+ robot.hw_status[STATUS_MOTION] = HW_STATUS_OK;
break;
case DEADLINE:
+ robot.hw_status[STATUS_MOTION] = HW_STATUS_FAILED;
DBG("ORTE deadline occurred - motion_irc receive\n");
break;
}
{
switch (info->status) {
case NEW_DATA:
+ robot.hw_status[STATUS_POWER]=HW_STATUS_OK;
break;
case DEADLINE:
+ robot.hw_status[STATUS_POWER]=HW_STATUS_FAILED;
DBG("ORTE deadline occurred - pwr_voltage receive\n");
break;
}
free(meas_angles);
}
break;
+ robot.hw_status[STATUS_LASER] = HW_STATUS_OK;
}
case DEADLINE:
+ robot.hw_status[STATUS_LASER] = HW_STATUS_FAILED;
DBG("%s: ORTE deadline occurred\n", __FUNCTION__);
break;
}
if (robot.cmu.color != NO_BALL)
FSM_SIGNAL(MAIN, EV_BALL_INSIDE, NULL);
break;
+ robot.hw_status[STATUS_CMU] = HW_STATUS_OK;
}
case DEADLINE:
+ robot.hw_status[STATUS_CMU] = HW_STATUS_OK;
DBG("%s: ORTE deadline occurred\n", __FUNCTION__);
break;
}
return 0;
}
+int oled_send_hw_status(uint8_t *buff, int buff_size, uint8_t *status)
+{
+ if(buff_size < HW_STATUS_MSG_SIZE)
+ return -1;
+
+ buff[0] = MSG_START;
+ buff[1] = HW_STATUS_MSG;
+ buff[2] = status[0];
+ buff[3] = status[1];
+ buff[4] = status[2];
+ buff[5] = status[3];
+ buff[6] = status[4];
+ buff[7] = status[5];
+ buff[8] = MSG_TERM;
+ printf("\n");
+ return 0;
+}
+
int oled_set_color(uint8_t *buff, int buff_size, uint8_t color)
{
if(buff_size < COLOR_MSG_SIZE)
#include <robottype.h>
#include <robottype_eb2008.h>
+#define HW_STATUS_MSG_SIZE 9
#define SWITCH_MODE_MSG_SIZE 5
#define VOLTAGE_MSG_SIZE 20
#define FSM_STATE_MSG_SIZE 40
#define RED_BALL 2
#define NO_BALL 3
#define HW_STATUS_OK 1
+#define HW_STATUS_FAILED 0
+
+#define STATUS_MOTION 0
+#define STATUS_LASER 1
+#define STATUS_CMU 2
+#define STATUS_POWER 3
+
struct mode_info {
uint8_t mode;
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);
int oled_set_balls(uint8_t *buff, int buff_size, uint8_t *carousel);
+int oled_send_hw_status(uint8_t *buff, int buff_size, uint8_t *status);
#ifdef __cplusplus
}
#endif
sercom.stopbits = 1;
sercom.mode = 0;
sercom.sighandler = sighandler;
-// sercom.saio.sa_handler = lcd_receive;
sercom_open(&sercom);
return &sercom;
}
return 0;
}
+
+
+int uoled_send_hw_status(uint8_t *status)
+{
+ int ret;
+ uint8_t msg[HW_STATUS_MSG_SIZE];
+
+ oled_send_hw_status(msg, HW_STATUS_MSG_SIZE, status);
+
+ ret = uoled_write_cmd(msg, HW_STATUS_MSG_SIZE);
+ if(ret)
+ return -1;
+
+ return 0;
+}
int uoled_send_state(const char *name, int len)
{
int ret;
int uoled_send_position(struct est_pos_type *pos);
int uoled_set_color(uint8_t color);
int uoled_set_balls(uint8_t *balls);
+int uoled_send_hw_status(uint8_t *status);
#ifdef __cplusplus
}
#endif