Rleg  2
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Functions
Functions to deal the User Inteface using ncurses

Functions

int ui_init (void)
 Initialize UI. More...
 
int ui_close (void)
 Close UI. More...
 
int ui_update (IMU_DATA_STRUCT *pimu_data, EFF_DATA_STRUCT *peff_data, MRA_DATA_STRUCT *pmra_data, ENC_DATA_STRUCT *enc_data, int total, int failure)
 Update Screen with new data of sensors. More...
 
int ui_imu_data (IMU_DATA_STRUCT *pimu_data)
 Print IMU data. More...
 
int ui_mra_data (MRA_DATA_STRUCT *pmra_data)
 Print MRA data. More...
 

Detailed Description

Function Documentation

int ui_close ( void  )

Close UI.

Definition at line 41 of file ui.c.

References SUCCESS.

Referenced by main(), and threads_linux_init().

42 {
43  #if UI_MODULE_ENABLED
44  clear();
45  printw("Cleaning up...\n");
46  refresh();
47  endwin();
48  #endif
49 
50  return SUCCESS;
51 }
#define SUCCESS
Definition: calibration.h:6

Here is the caller graph for this function:

int ui_imu_data ( IMU_DATA_STRUCT pimu_data)

Print IMU data.

Definition at line 135 of file ui.c.

References IMU_DATA_STRUCT::acc, IMU_DATA_STRUCT::calibrated::acc, IMU_DATA_STRUCT::calib, IMU_DATA_STRUCT::gyr, IMU_DATA_STRUCT::calibrated::gyr, IMU_DATA_STRUCT::mag, IMU_DATA_STRUCT::calibrated::mag, SUCCESS, DATA_XYZ::x, DATA_XYZ_DOUBLE::x, DATA_XYZ::y, DATA_XYZ_DOUBLE::y, DATA_XYZ::z, and DATA_XYZ_DOUBLE::z.

Referenced by ui_update().

136 {
137  mvprintw(2, 0, "Accelerometer X (raw): %d", pimu_data->acc.x);
138  mvprintw(2, 40, "Accelerometer X (g): %lf", pimu_data->calib.acc.x);
139  mvprintw(3, 0, "Accelerometer Y (raw): %d", pimu_data->acc.y);
140  mvprintw(3, 40, "Accelerometer Y (g): %lf", pimu_data->calib.acc.y);
141  mvprintw(4, 0, "Accelerometer Z (raw): %d", pimu_data->acc.z);
142  mvprintw(4, 40, "Accelerometer Z (g): %lf", pimu_data->calib.acc.z);
143  mvprintw(5, 0, "Gyrometer X (raw): %d", pimu_data->gyr.x);
144  mvprintw(5, 40, "Gyrometer X (rad/sec): %lf", pimu_data->calib.gyr.x);
145  mvprintw(6, 0, "Gyrometer Y (raw): %d", pimu_data->gyr.y);
146  mvprintw(6, 40, "Gyrometer Y (rad/sec): %lf", pimu_data->calib.gyr.y);
147  mvprintw(7, 0, "Gyrometer Z (raw): %d", pimu_data->gyr.z);
148  mvprintw(7, 40, "Gyrometer Z (rad/sec): %lf", pimu_data->calib.gyr.z);
149  mvprintw(8, 0, "Magnetometer X (raw): %d", pimu_data->mag.x);
150  mvprintw(8, 40, "Magnetometer X (B): %lf", pimu_data->calib.mag.x);
151  mvprintw(9, 0, "Magnetometer Y (raw): %d", pimu_data->mag.y);
152  mvprintw(9, 40, "Magnetometer Y (B): %lf", pimu_data->calib.mag.y);
153  mvprintw(10,0, "Magnetometer Z (raw): %d", pimu_data->mag.z);
154  mvprintw(10,40, "Magnetometer Z (B): %lf", pimu_data->calib.mag.z);
155  mvprintw(12,0,"Total Acceleromter: %lf",sqrt(pimu_data->calib.acc.x*pimu_data->calib.acc.x+pimu_data->calib.acc.y*pimu_data->calib.acc.y+pimu_data->calib.acc.z*pimu_data->calib.acc.z));
156  mvprintw(13,0,"Total Gyrometer: %lf",sqrt(pimu_data->calib.gyr.x*pimu_data->calib.gyr.x+pimu_data->calib.gyr.y*pimu_data->calib.gyr.y+pimu_data->calib.gyr.z*pimu_data->calib.gyr.z));
157  mvprintw(14,0,"Total Magnetometer: %lf",sqrt(pimu_data->calib.mag.x*pimu_data->calib.mag.x+pimu_data->calib.mag.y*pimu_data->calib.mag.y+pimu_data->calib.mag.z*pimu_data->calib.mag.z));
158  //mvprintw(15, 0, "Encoder (raw): %lf", enc.data);
159 
160  return SUCCESS;
161 }
short int y
Definition: communication.h:77
DATA_XYZ mag
Magnetormeter Vector.
Definition: communication.h:96
DATA_XYZ acc
Accel Vector.
Definition: communication.h:94
#define SUCCESS
Definition: calibration.h:6
short int z
Definition: communication.h:78
struct IMU_DATA_STRUCT::calibrated calib
DATA_XYZ gyr
Gyrometer Vector.
Definition: communication.h:95
short int x
Definition: communication.h:76

Here is the caller graph for this function:

int ui_init ( void  )

Initialize UI.

Definition at line 26 of file ui.c.

References SUCCESS, and TRUE.

Referenced by main(), and threads_linux_init().

27 {
28  #if UI_MODULE_ENABLED
29  //NCURSES
30  initscr();
31  scrollok(stdscr,TRUE);
32  //resizeterm(33,100);
33  //wresize(scr,32,100);
34  //erase();
35  timeout(0); //No delay for getch();
36  #endif
37 
38  return SUCCESS;
39 }
#define TRUE
#define SUCCESS
Definition: calibration.h:6

Here is the caller graph for this function:

int ui_mra_data ( MRA_DATA_STRUCT pmra_data)

Print MRA data.

Definition at line 188 of file ui.c.

References SUCCESS, MRA_DATA_STRUCT::v_ctl, and MRA_DATA_STRUCT::v_ctl_read.

Referenced by ui_update().

189 {
190  mvprintw(2,0,"V_ctl (bits): %d",pmra_data->v_ctl);
191  mvprintw(3,0,"V_ctl_read (bits): %d",pmra_data->v_ctl_read);
192  //mvprintw(2,40,"Fx (N): %lf",peff_data->??);
193 
194  return SUCCESS;
195 }
short int v_ctl_read
Voltage level read from the actuator.
#define SUCCESS
Definition: calibration.h:6
short int v_ctl
Voltage level for control output.

Here is the caller graph for this function:

int ui_update ( IMU_DATA_STRUCT pimu_data,
EFF_DATA_STRUCT peff_data,
MRA_DATA_STRUCT pmra_data,
ENC_DATA_STRUCT enc_data,
int  total,
int  failure 
)

Update Screen with new data of sensors.

Definition at line 53 of file ui.c.

References DATALOGGER_RUNNING, datalogger_start(), datalogger_status(), datalogger_stop(), exit_program(), FAILURE, SUCCESS, ui_eff_data(), ui_enc_data(), ui_imu_data(), ui_menu(), ui_mra_data(), and ui_overview_data().

Referenced by periodic_task_2(), threads_linux_periodic_task_2(), and ui_task().

54 {
55  unsigned char user_char = 0;
56 
57  static enum {UI_OVERVIEW = 0, UI_IMU, UI_EFF, UI_MRA , UI_ENC} ui_state;
58 
59  erase();
60  //wresize(scr,32,100);
61  attron(A_STANDOUT);
62 
63  mvaddstr(0,15,"RLEG Data");
64  attroff(A_STANDOUT);
65 
66  switch(ui_state)
67  {
68  case UI_IMU:
69  if(ui_imu_data(pimu_data) != SUCCESS) return FAILURE;
70  break;
71  case UI_EFF:
72  if(ui_eff_data(peff_data) != SUCCESS) return FAILURE;
73  break;
74  case UI_MRA:
75  if(ui_mra_data(pmra_data) != SUCCESS) return FAILURE;
76  break;
77  case UI_ENC:
78  if(ui_enc_data(enc_data) != SUCCESS) return FAILURE;
79  break;
80  case UI_OVERVIEW:
81  default:
82  if(ui_overview_data(total, failure, pimu_data, peff_data, pmra_data, enc_data) != SUCCESS) return FAILURE;
83  break;
84  }
85 
86  ui_menu();
87 
88  refresh();
89 
90  user_char = getch(); //Getting a char typed by the user
91  switch(user_char)
92  {
93  case 'Q':
94  case 'q': //Quit
95  exit_program();
96  break;
97  case 'I':
98  case 'i': //IMU view
99  ui_state = UI_IMU;
100  break;
101  case 'F':
102  case 'f': //EFF view
103  ui_state = UI_EFF;
104  break;
105  case 'E':
106  case 'e': // ENCODER view
107  ui_state = UI_ENC;
108  break;
109  case 'O':
110  case 'o': //Overview
111  ui_state = UI_OVERVIEW;
112  break;
113  case 'M':
114  case 'm': //MRA
115  ui_state = UI_MRA;
116  break;
117  case 'D':
118  case 'd': //Datalogger start/stop
120  {
121  datalogger_stop();
122  }
123  else
124  {
126  }
127  break;
128  default:
129  break;
130  }
131 
132  return SUCCESS;
133 }
int ui_eff_data(EFF_DATA_STRUCT *peff_data)
Definition: ui.c:163
int ui_mra_data(MRA_DATA_STRUCT *pmra_data)
Print MRA data.
Definition: ui.c:188
int datalogger_start(void)
Definition: datalogger.c:584
#define DATALOGGER_RUNNING
Definition: datalogger.h:30
#define FAILURE
Definition: calibration.h:7
int ui_enc_data(ENC_DATA_STRUCT *enc_data)
Print ENCODER data.
Definition: ui.c:181
int failure
Definition: main.c:36
void exit_program(void)
Internal function to end program.
Definition: main.c:180
#define SUCCESS
Definition: calibration.h:6
int ui_overview_data(int total, int failures, IMU_DATA_STRUCT *pimu_data, EFF_DATA_STRUCT *peff_data, MRA_DATA_STRUCT *pmra_data, ENC_DATA_STRUCT *enc_data)
Print ALL sensors data.
Definition: ui.c:197
int ui_menu()
Print the menu.
Definition: ui.c:264
int ui_imu_data(IMU_DATA_STRUCT *pimu_data)
Print IMU data.
Definition: ui.c:135
int datalogger_status(void)
Definition: datalogger.c:571
int datalogger_stop(void)
Definition: datalogger.c:601
int total
Definition: main.c:35

Here is the call graph for this function:

Here is the caller graph for this function: