lib_LIBRARIES += robot
robot_SOURCES = serva.c robot.c roboorte.c fsmmove.cc \
fsmpickup.c fsmdet.c fsmjoy.c \
- movehelper.cc roboevent.c
+ movehelper.cc roboevent.c fsmdisplay.cc
include_HEADERS = robotdim.h
bin_PROGRAMS += test_timer
#include <signal.h>
#include <pthread.h>
#include <unistd.h>
+#include <uoled.h>
/**
* A thread for serial line communication.
}
+int init_display() {
+ uoled_init();
+}
+
FSM_STATE_DECL(console);
FSM_STATE_DECL(status);
FSM_STATE_DECL(map);
FSM_STATE(status) {
switch (FSM_EVENT) {
+ case EV_STATE_ENTERED:
+ FSM_TIMER(1000);
+ break;
+ case EV_TIMER:
+ uoled_send_voltage(NULL);
+ break;
case EV_SWITCH_TO_CONS:
break;
case EV_SWITCH_TO_STATUS:
"EV_LOC_LOST" : "Localization can't estimate the position of the robot.",
},
"joystick" : {
+ },
+ "display" : {
+ "EV_SWITCH_TO_CONS" : "Switch display mode to CONSOLE",
+ "EV_SWITCH_TO_STATUS" : "Switch display mode to STATUS",
+ "EV_SWITCH_TO_MAP" : "Switch display mode to MAP",
+ "EV_SWITCH_TO_MISC" : "Switch display mode to MISC",
}
}
# -*- makefile -*-
-lib_LIBRARIES = lcdlib
-lcdlib_SOURCES = lcdlib.c
+lib_LIBRARIES = oledlib
+oledlib_SOURCES = oledlib.cc
-include_HEADERS = lcdlib.h
+include_HEADERS = uoled.h
-bin_PROGRAMS = ulcdd
+#bin_PROGRAMS = ulcdd
-ulcdd_SOURCES = ulcdd.c
+#ulcdd_SOURCES = ulcdd.c
-ulcdd_LIBS = sercom lcdlib m
+#ulcdd_LIBS = sercom lcdlib m
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
+#include <string.h>
+
+#include <RobotType.h>
#include "oledlib.h"
*(buff+4) = MSG_TERM;
return 5;
-}
\ No newline at end of file
+}
+
+int oled_send_voltage(u_int8_t *buff, int buff_size, struct pwr_act_volts_type *volt) {
+ char tmp[5];
+ u_int8_t *ptr;
+
+ ptr=buff;
+
+ if(buff_size < VOLTAGE_MSG_SIZE)
+ return -1;
+
+ *buff = MSG_START;
+
+ *(buff+1) = VOLTAGE_MSG;
+
+ sprintf(tmp,"%2.2f",volt->voltage33);
+ memcpy(buff+2,tmp,5);
+
+ sprintf(tmp,"%2.2f",volt->voltage50);
+ memcpy(buff+7,tmp,5);
+
+ sprintf(tmp,"%2.2f",volt->voltage80);
+ memcpy(buff+12,tmp,5);
+
+ sprintf(tmp,"%2.2f",volt->voltageBAT);
+ memcpy(buff+17,tmp,5);
+
+ *(buff+22) = MSG_TERM;
+
+ return 0;
+}
#define SWITCH_MODE_MSG_SIZE 4
-
+#define VOLTAGE_MSG_SIZE 23 //FIXME
#define MSG_START 150
#define CHANGE_MODE_REP 200
+#define VOLTAGE_MSG 160
#define CHANGE_MODE_OK 201
#define MSG_TERM 254
struct mode_info {
u_int8_t mode;
u_int8_t status;
-};
\ No newline at end of file
+};
+
+struct voltages {
+ double voltage33;
+ double voltage50;
+ double voltage80;
+ double voltageBAT;
+};
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <RobotType.h>
struct sercom_data sercom;
+int uoled_init() {
+ strcpy((char *)&sercom.devname, "/dev/ttyUSB0");
+ sercom.baudrate = 2400;
+ sercom.parity = SERCOM_PARNONE;
+ sercom.databits = 8;
+ sercom.stopbits = 1;
+ sercom.mode = 0;
+
+// sercom.saio.sa_handler = lcd_receive;
+
+ sercom_open(&sercom);
+ return 0;
+}
+
int uoled_write_cmd(u_int8_t *buff, int size) {
int ret, i;
u_int8_t rep;
return 0;
-}
\ No newline at end of file
+}
+
+int uoled_send_voltage(struct pwr_act_volts *volt) {
+ int ret;
+ u_int8_t msg[MSG_VOLTAGE_SIZE];
+
+ oled_send_voltage(msg, VOLTAGE_MSG_SIZE, volt);
+
+ ret = uoled_write_cmd(msg, VOLTAGE_MSG_SIZE);
+ if(ret)
+ return -1;
+
+ return 0;
+}
+#ifndef _UOLED_H
+#define _UOLED_H
+
+int uoled_init();
+int uoled_send_voltage(struct pwr_act_volts_type *volt);
+#endif