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

Committer:
nightmechanic
Date:
Sat Mar 26 21:36:24 2016 +0000
Revision:
4:7e4bb0c29d3b
Parent:
3:0c2d9355ed8c
Added source info to the MPU6050 files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nightmechanic 0:0bb3687e39da 1 //#define __SERIAL_DEBUG__
nightmechanic 0:0bb3687e39da 2
nightmechanic 0:0bb3687e39da 3 #define NUM_OF_COLORS 4
nightmechanic 0:0bb3687e39da 4 #define LED_PWM_PERIOD 5 //msec
nightmechanic 0:0bb3687e39da 5 #define NORM_LIGHT_INTENS (15*LED_PWM_PERIOD * 1000)/100 //in usec = 30% of LED_PWM_PERIOD
nightmechanic 0:0bb3687e39da 6 #define LOW_LIGHT_INTENS (7*LED_PWM_PERIOD * 1000)/100 //in usec = 15% of LED_PWM_PERIOD
nightmechanic 0:0bb3687e39da 7 #define BUTTON_PRESS_THR 5
nightmechanic 0:0bb3687e39da 8 #define BUTTON_RELEASE_THR 10
nightmechanic 0:0bb3687e39da 9 #define VBAT_AVG_LEN 8
nightmechanic 0:0bb3687e39da 10 #define VBAT_THR 34000 //about 3.15V per cell
nightmechanic 0:0bb3687e39da 11 #define VBAT_HYST 1000
nightmechanic 0:0bb3687e39da 12 #define MPU_BUFFER_LEN 100
nightmechanic 0:0bb3687e39da 13 #define MPU_DATA_STABLE 1000
nightmechanic 0:0bb3687e39da 14 #define MPU_AVG_LEN 16
nightmechanic 0:0bb3687e39da 15 #define ACCEL_THR 4000 //1g
nightmechanic 0:0bb3687e39da 16 #define YPR_THR 450 //45 degrees
nightmechanic 0:0bb3687e39da 17
nightmechanic 0:0bb3687e39da 18 #define TRUE true
nightmechanic 0:0bb3687e39da 19 #define FALSE false
nightmechanic 0:0bb3687e39da 20
nightmechanic 0:0bb3687e39da 21 typedef enum {
nightmechanic 0:0bb3687e39da 22 BLUE = 0,
nightmechanic 0:0bb3687e39da 23 GREEN,
nightmechanic 0:0bb3687e39da 24 PURPLE,
nightmechanic 0:0bb3687e39da 25 RED
nightmechanic 0:0bb3687e39da 26 } color_type;
nightmechanic 0:0bb3687e39da 27
nightmechanic 0:0bb3687e39da 28
nightmechanic 0:0bb3687e39da 29 // function prototypes
nightmechanic 0:0bb3687e39da 30 bool motion_sensor_init();
nightmechanic 0:0bb3687e39da 31 bool motion_update_data(MPU_data_type * new_data);
nightmechanic 0:0bb3687e39da 32 void mpu_calc_avg(MPU_data_type * MPU_data,int mpu_pointer, MPU_data_type * MPU_avg_data, int avg_len);
nightmechanic 0:0bb3687e39da 33 void init_color(int *new_color, int pulsewidth);
nightmechanic 0:0bb3687e39da 34 void change_color(color_type new_color, int new_pulsewidth);
nightmechanic 3:0c2d9355ed8c 35 bool sound_player(const int sound_table[][6], int table_lines);