A Jedi light saber controller program with the following "features": - Using RGB LEDs - User can change light colors with a button - Motion dependent (PWM) sounds with a MPU6050 motion sensor - Low voltage detection

Dependencies:   L152RE_USBDevice STM32_USB48MHz Watchdog mbed

Revision:
0:0bb3687e39da
Child:
2:59a7d4677474
diff -r 000000000000 -r 0bb3687e39da LightSaber.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LightSaber.h	Tue Mar 22 10:30:16 2016 +0000
@@ -0,0 +1,42 @@
+//#define __SERIAL_DEBUG__
+
+#define NUM_OF_COLORS           4
+#define LED_PWM_PERIOD          5 //msec
+#define NORM_LIGHT_INTENS       (15*LED_PWM_PERIOD * 1000)/100 //in usec =  30% of LED_PWM_PERIOD
+#define LOW_LIGHT_INTENS        (7*LED_PWM_PERIOD * 1000)/100 //in usec = 15% of LED_PWM_PERIOD
+#define BUTTON_PRESS_THR        5
+#define BUTTON_RELEASE_THR      10
+#define VBAT_AVG_LEN            8
+#define VBAT_THR                34000 //about 3.15V per cell
+#define VBAT_HYST               1000
+#define MPU_BUFFER_LEN          100 
+#define MPU_DATA_STABLE         1000
+#define MPU_AVG_LEN             16
+#define ACCEL_THR               4000 //1g
+#define YPR_THR                 450  //45 degrees
+
+#define TRUE                    true
+#define FALSE                   false
+
+typedef enum {
+  BLUE = 0,
+  GREEN,
+  PURPLE,
+  RED
+} color_type;
+
+typedef struct {
+    int ax;
+    int ay;
+    int az;
+    int yaw;
+    int pitch;
+    int roll;
+} MPU_data_type;
+
+// function prototypes
+bool motion_sensor_init();
+bool motion_update_data(MPU_data_type * new_data);
+void mpu_calc_avg(MPU_data_type * MPU_data,int mpu_pointer, MPU_data_type * MPU_avg_data, int avg_len);
+void init_color(int *new_color, int pulsewidth);
+void change_color(color_type new_color, int new_pulsewidth);