Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
RGBA_LED.h
00001 #ifndef RGBA_LED_H 00002 #define RGBA_LED_H 00003 00004 #include "RGBA.h" 00005 #include "PCA9634.h" 00006 #include "colors.h" 00007 #include "defines.h" 00008 #include "mbed.h" 00009 #include "math.h" 00010 #include <vector> 00011 #include <string> 00012 00013 class RGBA_LED 00014 { 00015 public: 00016 RGBA_LED(I2C *i2c, DigitalOut *inv_out_en, int addr, bool amber_enabled); 00017 00018 void disableAmber(); 00019 void disableAmber(int stripID); 00020 void enableAmber(); 00021 void enableAmber(int stripID); 00022 00023 void setColor(RGBA<float> color); 00024 void setColor(RGBA<float> color, int stripID); 00025 void setBrightness(float alpha); 00026 void setBrightness(float alpha, int stripID); 00027 00028 // TODO 00029 void fadeColor(RGBA<float>, int duration); 00030 void fadeColor(RGBA<float>, int duration, int stripID); 00031 void fadeBrightness(float alpha, int duration); 00032 void fadeBrightness(float alpha, int duration, int stripID); 00033 00034 void setDefaultColorFadeTime(int def_color_fade_time); 00035 void setDefaultBrightnessFadeTime(int def_alpha_fade_time); 00036 void setStepTime(int step_time); // TODO 00037 int getStepTime(); 00038 void step(); 00039 00040 // TODO 00041 void turnOn(); 00042 void turnOn(int stripID); 00043 void turnOff(); 00044 void turnOff(int stripID); 00045 00046 // TODO 00047 //void setColorProgram(int preset_id, bool fadeInto); 00048 //void setColorProgram(int preset_id, int stripID, bool fadeInto); 00049 void setColorProgram(vector<RGBA<float> > color_program, vector<float> time_program, bool fadeInto); 00050 void setColorProgram(vector<RGBA<float> > color_program, vector<float> time_program, int stripID, bool fadeInto); 00051 //void setBrightnessProgram(int preset_id, bool fadeInto); 00052 //void setBrightnessProgram(int preset_id, int stripID, bool fadeInto); 00053 void setBrightnessProgram(vector<float> alpha_program, vector<float> time_program, bool fadeInto); 00054 void setBrightnessProgram(vector<float> alpha_program, vector<float> time_program, int stripID, bool fadeInto); 00055 00056 RGBA<float> getPresetColor(char colorID); 00057 vector<RGBA<float> > getPresetColorProgram(int programID); 00058 //vector<RGBA<float> > genColorProgram(string sequence); 00059 //vector<RGBA<float> > genDoubleColorProgram(vector<RGBA<float> > colorProgram); // Dublicates each color in sequence 00060 //vector<RGBA<float> > genHalfColorProgram(vector<RGBA<float> > colorProgram); // For undoing genDoubleColorProgram 00061 vector<float> getPresetAlphaProgram(int programID); 00062 //vector<float> genFadeAlphaProgram(float duration); // For simple fading without breaks 00063 //vector<float> genDelayedFadeAlphaProgram(float duration1, float duration2); // For fading while staying at each color for a while 00064 00065 private: 00066 PCA9634 *led_driver_; 00067 00068 RGBA<ledID> strip_leds_[2]; // Contains ids of LEDs associated with strips 00069 00070 RGBA<float> cur_color_[2], dcolor_[2]; // Colors range from 0 to 255 00071 float cur_alpha_[2], dalpha_[2]; // Brightness ranges from 0.0 to 1.0 00072 00073 int count_color_[2], count_alpha_[2]; 00074 int ind_color_program_[2], ind_alpha_program_[2]; 00075 int step_time_; // In milliseconds 00076 float def_color_fade_time_, def_alpha_fade_time_; 00077 00078 vector<RGBA<float> > color_program_[2]; 00079 vector<float> alpha_program_[2]; 00080 vector<float> color_time_program_[2], alpha_time_program_[2]; 00081 00082 void updatePWMs(); 00083 void updatePWMs(int stripID); 00084 00085 }; 00086 00087 00088 00089 #endif
Generated on Tue Jul 12 2022 21:35:43 by
