h4r_x52_joyext
LED and MFD Control for Saitek X52 Pro
 All Classes Files Functions Variables Enumerator Macros Pages
x52_joyext.h
Go to the documentation of this file.
1 /*
2  * x52_joyext Node
3  * by Christian Holl (www.rad-lab.net)
4  * License: BSD
5  *
6  * Have Fun! :-)
7  */
8 
9 /*
10  * Modified by Murilo FM (muhrix@gmail.com)
11  * 12 Dec 2013
12  *
13  */
14 
26 #include <ros/ros.h>
27 
28 #include <std_msgs/UInt8.h>
29 #include <boost/thread/mutex.hpp>
30 #include <string>
31 #include <inttypes.h>
32 #include "h4r_x52_joyext/x52_date.h"
33 #include "h4r_x52_joyext/x52_time.h"
34 #include "h4r_x52_joyext/x52_led_color.h"
35 #include "h4r_x52_joyext/x52_mfd.h"
36 
37 extern "C" {
38 #include <x52pro.h>
39 }
40 
41 #ifndef X52JOYEXT_HPP_
42 #define X52JOYEXT_HPP_
43 
45 {
46  ros::NodeHandle &nh;
47  ros::Rate *loop_rate;
48 
49 
50  bool updateLED[10];
52  bool updateMFD[3];
54  bool updateDate;
55  bool updateTime;
56  bool updateOffset[2];
59 
60 
61  uint8_t LED[19];
62  std::string mfd_content[3];
63  uint8_t Date[3];
64  uint8_t Time_24;
65  uint8_t Time[2];
66  uint8_t Offset[2];
67  uint8_t Offset_24[2];
68  uint8_t Offset_Inv[2];
69  uint8_t brightnessMFD;
70  uint8_t brightnessLED;
71 
72 
73  ros::Subscriber subleds;
74  ros::Subscriber submfd_text;
75  ros::Subscriber subdate;
76  ros::Subscriber subtime;
77  ros::Subscriber subbrightnessMFD;
78  ros::Subscriber subbrightnessLED;
79 
80  void setLEDs(uint8_t inValue, uint8_t *red, uint8_t *green, bool *update)
81  {
82  switch(inValue)
83  {
84  case h4r_x52_joyext::x52_led_color::NO_STATUS_CHANGE:
85  *update=false;
86  break;
87  case h4r_x52_joyext::x52_led_color::OFF:
88  *red=0;
89  *green=0;
90  break;
91  case h4r_x52_joyext::x52_led_color::RED:
92  *red=1;
93  *green=0;
94  break;
95  case h4r_x52_joyext::x52_led_color::GREEN:
96  *red=0;
97  *green=1;
98  break;
99  case h4r_x52_joyext::x52_led_color::YELLOW:
100  *red=1;
101  *green=1;
102  break;
103  default:
104  ROS_WARN("WRONG VALUE (%i) FOR LED FOUND! Value must be in the range of 0-4",inValue);
105  return;
106  break;
107  }
108  *update=true;
109  }
110 
111  void cb_leds(const h4r_x52_joyext::x52_led_colorConstPtr &msg);
112  void cb_mfd_text(const h4r_x52_joyext::x52_mfdConstPtr &msg);
113  void cb_date(const h4r_x52_joyext::x52_dateConstPtr &msg);
114  void cb_time(const h4r_x52_joyext::x52_timeConstPtr &msg);
115  void cb_brighnessMFD(const std_msgs::UInt8ConstPtr &msg);
116  void cb_brighnessLED(const std_msgs::UInt8ConstPtr &msg);
117 
118 
119 public:
120  X52_JoyExt(ros::NodeHandle &n);
121  virtual ~X52_JoyExt();
122 
123  void send_to_joystick();
124 };
125 
126 #endif /* X52JOYEXT_HPP_ */
uint8_t brightnessLED
Definition: x52_joyext.h:70
ros::Subscriber subbrightnessLED
Definition: x52_joyext.h:78
uint8_t Date[3]
Definition: x52_joyext.h:63
bool updateMFD[3]
Definition: x52_joyext.h:52
uint8_t brightnessMFD
Definition: x52_joyext.h:69
ros::Subscriber submfd_text
Definition: x52_joyext.h:74
ros::Rate * loop_rate
Definition: x52_joyext.h:47
ros::Subscriber subdate
Definition: x52_joyext.h:75
bool updateLED[10]
Definition: x52_joyext.h:50
uint8_t Time_24
Definition: x52_joyext.h:64
void cb_brighnessMFD(const std_msgs::UInt8ConstPtr &msg)
Definition: x52_joyext.cpp:173
std::string mfd_content[3]
Definition: x52_joyext.h:62
bool updateMFD_b
Definition: x52_joyext.h:53
bool updateBrightnessLED
Definition: x52_joyext.h:58
bool updateBrightnessMFD
Definition: x52_joyext.h:57
bool updateDate
Definition: x52_joyext.h:54
bool updateOffset[2]
Definition: x52_joyext.h:56
uint8_t Offset_Inv[2]
Definition: x52_joyext.h:68
void cb_brighnessLED(const std_msgs::UInt8ConstPtr &msg)
Definition: x52_joyext.cpp:179
X52_JoyExt(ros::NodeHandle &n)
Definition: x52_joyext.cpp:18
void setLEDs(uint8_t inValue, uint8_t *red, uint8_t *green, bool *update)
Definition: x52_joyext.h:80
uint8_t Time[2]
Definition: x52_joyext.h:65
void cb_mfd_text(const h4r_x52_joyext::x52_mfdConstPtr &msg)
Definition: x52_joyext.cpp:90
void send_to_joystick()
Definition: x52_joyext.cpp:188
void cb_date(const h4r_x52_joyext::x52_dateConstPtr &msg)
Definition: x52_joyext.cpp:138
ros::NodeHandle & nh
Definition: x52_joyext.h:46
void cb_leds(const h4r_x52_joyext::x52_led_colorConstPtr &msg)
Definition: x52_joyext.cpp:69
void cb_time(const h4r_x52_joyext::x52_timeConstPtr &msg)
Definition: x52_joyext.cpp:146
uint8_t Offset[2]
Definition: x52_joyext.h:66
virtual ~X52_JoyExt()
Definition: x52_joyext.cpp:64
ros::Subscriber subbrightnessMFD
Definition: x52_joyext.h:77
ros::Subscriber subtime
Definition: x52_joyext.h:76
uint8_t LED[19]
Definition: x52_joyext.h:61
uint8_t Offset_24[2]
Definition: x52_joyext.h:67
ros::Subscriber subleds
Definition: x52_joyext.h:73
bool updateLED_b
Definition: x52_joyext.h:51
bool updateTime
Definition: x52_joyext.h:55