![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A project that aims at making a LED based light system controlled by microcontroller and with BLE (soon) with smooth color transitions.
Revision 3:25af55580ef6, committed 2018-02-13
- Comitter:
- ledonger
- Date:
- Tue Feb 13 15:36:17 2018 +0000
- Parent:
- 2:0bbd4fc5e202
- Commit message:
- FlowerColor : small program to manage led fade in fade out with pwm generation (not from pwm output)
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BLE_API.lib Tue Feb 13 15:36:17 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#65474dc93927
--- a/LEDManager.h Fri Aug 18 11:26:01 2017 +0000 +++ b/LEDManager.h Tue Feb 13 15:36:17 2018 +0000 @@ -15,8 +15,9 @@ this->lowTime = this->period_us - this->highTime; this->fadeFactor = 100; this->situation = 1; - this->fadeUpdatePeriod = 10000; + this->fadeUpdatePeriod = 40000; this->prevFadeUpdate = 0; + this->isActive = true; } LEDManager(DigitalOut *io, int period_us) @@ -33,6 +34,10 @@ void processLED(int time) { + if(!this->isActive) + { + return; + } if(situation == 1){ if((time - prevUpdate) < highTime){ io->write(1); @@ -66,18 +71,14 @@ } } - /*void setFadeUpdatePeriod(int period) - { - this->fadeUpdatePeriod = period; - } - void setFadeFactor(int fadeFactor) - { - this->fadeFactor = fadeFactor; - }*/ - int getHighTime() - { - return this->highTime; - } + void setFadeUpdatePeriod(int period){ this->fadeUpdatePeriod = period;} + int getFadeUpdatePeriod(){ return this->fadeUpdatePeriod;} + void setFadeFactor(int fadeFactor){ this->fadeFactor = fadeFactor;} + int getFadeFactor(){ return this->fadeFactor;} + int getHighTime(){ return this->highTime;} + void setActive(bool state){ this->isActive = state;} + bool getActiveness(){ return this->isActive;} + private: DigitalOut *io; @@ -90,6 +91,7 @@ int prevFadeUpdate; int fadeFactor; int fadeUpdatePeriod; + bool isActive; }; #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IDB0XA1.lib Tue Feb 13 15:36:17 2018 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/ST/code/X_NUCLEO_IDB0XA1/#fa98703ece8e
--- a/main.cpp Fri Aug 18 11:26:01 2017 +0000 +++ b/main.cpp Tue Feb 13 15:36:17 2018 +0000 @@ -2,18 +2,18 @@ #include "LEDManager.h" Timer timer; -Serial pc(USBTX,USBRX,921600); +Serial pc(USBTX,USBRX/*,921600*/); -LEDManager *led1 = new LEDManager(D11,10000); -LEDManager *led2 = new LEDManager(D4,10000); -LEDManager *led3 = new LEDManager(D7,10000); -LEDManager *led4 = new LEDManager(D5,10000); -LEDManager *led5 = new LEDManager(D6,10000); -LEDManager *led6 = new LEDManager(D12,10000); -LEDManager *led7 = new LEDManager(D8,10000); -LEDManager *led8 = new LEDManager(D9,10000); -LEDManager *led9 = new LEDManager(D10,10000); +LEDManager *l1g = new LEDManager(D11,10000); +LEDManager *l1b = new LEDManager(D4,10000); +LEDManager *l1r = new LEDManager(D7,10000); +LEDManager *l2r = new LEDManager(D5,10000); +LEDManager *l2g = new LEDManager(D6,10000); +LEDManager *l2b = new LEDManager(D12,10000); +LEDManager *l3r = new LEDManager(D8,10000); +LEDManager *l3g = new LEDManager(D9,10000); +LEDManager *l3b = new LEDManager(D10,10000); int main() { @@ -26,22 +26,39 @@ int time = timer.read_us(); - + DigitalIn button(USER_BUTTON); + while(1) { time = timer.read_us(); - led1->processLED(time); - led2->processLED(time); - led3->processLED(time); - led4->processLED(time); - led5->processLED(time); - led6->processLED(time); - led7->processLED(time); - led8->processLED(time); - led9->processLED(time); + l1g->processLED(time); + l1b->processLED(time); + l1r->processLED(time); + l2r->processLED(time); + l2g->processLED(time); + l2b->processLED(time); + l3r->processLED(time); + l3g->processLED(time); + l3b->processLED(time); + + if(button == 0){ + l1g->setFadeUpdatePeriod(l1g->getFadeUpdatePeriod() + 1000); + l2g->setFadeUpdatePeriod(l2g->getFadeUpdatePeriod() + 1000); + l3g->setFadeUpdatePeriod(l3g->getFadeUpdatePeriod() + 1000); + + l1b->setFadeUpdatePeriod(l1b->getFadeUpdatePeriod() + 1500); + l2b->setFadeUpdatePeriod(l2b->getFadeUpdatePeriod() + 1500); + l3b->setFadeUpdatePeriod(l3b->getFadeUpdatePeriod() + 1500); + + l3r->setActive(!l3r->getActiveness()); + while(button != 1); + } + + } } +
--- a/mbed.bld Fri Aug 18 11:26:01 2017 +0000 +++ b/mbed.bld Tue Feb 13 15:36:17 2018 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/fd96258d940d \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897 \ No newline at end of file