![](/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.
main.cpp@3:25af55580ef6, 2018-02-13 (annotated)
- Committer:
- ledonger
- Date:
- Tue Feb 13 15:36:17 2018 +0000
- Revision:
- 3:25af55580ef6
- Parent:
- 2:0bbd4fc5e202
FlowerColor : small program to manage led fade in fade out with pwm generation (not from pwm output)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ledonger | 0:b350f8395bff | 1 | #include "mbed.h" |
ledonger | 0:b350f8395bff | 2 | #include "LEDManager.h" |
ledonger | 0:b350f8395bff | 3 | |
ledonger | 0:b350f8395bff | 4 | Timer timer; |
ledonger | 3:25af55580ef6 | 5 | Serial pc(USBTX,USBRX/*,921600*/); |
ledonger | 0:b350f8395bff | 6 | |
ledonger | 0:b350f8395bff | 7 | |
ledonger | 3:25af55580ef6 | 8 | LEDManager *l1g = new LEDManager(D11,10000); |
ledonger | 3:25af55580ef6 | 9 | LEDManager *l1b = new LEDManager(D4,10000); |
ledonger | 3:25af55580ef6 | 10 | LEDManager *l1r = new LEDManager(D7,10000); |
ledonger | 3:25af55580ef6 | 11 | LEDManager *l2r = new LEDManager(D5,10000); |
ledonger | 3:25af55580ef6 | 12 | LEDManager *l2g = new LEDManager(D6,10000); |
ledonger | 3:25af55580ef6 | 13 | LEDManager *l2b = new LEDManager(D12,10000); |
ledonger | 3:25af55580ef6 | 14 | LEDManager *l3r = new LEDManager(D8,10000); |
ledonger | 3:25af55580ef6 | 15 | LEDManager *l3g = new LEDManager(D9,10000); |
ledonger | 3:25af55580ef6 | 16 | LEDManager *l3b = new LEDManager(D10,10000); |
ledonger | 0:b350f8395bff | 17 | |
ledonger | 0:b350f8395bff | 18 | int main() |
ledonger | 0:b350f8395bff | 19 | { |
ledonger | 2:0bbd4fc5e202 | 20 | pc.printf("Starting...\n"); |
ledonger | 0:b350f8395bff | 21 | |
ledonger | 0:b350f8395bff | 22 | printf("Test procedure\n"); |
ledonger | 1:8b80523d8959 | 23 | |
ledonger | 0:b350f8395bff | 24 | timer.start(); |
ledonger | 0:b350f8395bff | 25 | |
ledonger | 1:8b80523d8959 | 26 | |
ledonger | 1:8b80523d8959 | 27 | int time = timer.read_us(); |
ledonger | 0:b350f8395bff | 28 | |
ledonger | 3:25af55580ef6 | 29 | DigitalIn button(USER_BUTTON); |
ledonger | 3:25af55580ef6 | 30 | |
ledonger | 1:8b80523d8959 | 31 | |
ledonger | 0:b350f8395bff | 32 | while(1) |
ledonger | 0:b350f8395bff | 33 | { |
ledonger | 1:8b80523d8959 | 34 | time = timer.read_us(); |
ledonger | 2:0bbd4fc5e202 | 35 | |
ledonger | 3:25af55580ef6 | 36 | l1g->processLED(time); |
ledonger | 3:25af55580ef6 | 37 | l1b->processLED(time); |
ledonger | 3:25af55580ef6 | 38 | l1r->processLED(time); |
ledonger | 3:25af55580ef6 | 39 | l2r->processLED(time); |
ledonger | 3:25af55580ef6 | 40 | l2g->processLED(time); |
ledonger | 3:25af55580ef6 | 41 | l2b->processLED(time); |
ledonger | 3:25af55580ef6 | 42 | l3r->processLED(time); |
ledonger | 3:25af55580ef6 | 43 | l3g->processLED(time); |
ledonger | 3:25af55580ef6 | 44 | l3b->processLED(time); |
ledonger | 3:25af55580ef6 | 45 | |
ledonger | 3:25af55580ef6 | 46 | if(button == 0){ |
ledonger | 3:25af55580ef6 | 47 | l1g->setFadeUpdatePeriod(l1g->getFadeUpdatePeriod() + 1000); |
ledonger | 3:25af55580ef6 | 48 | l2g->setFadeUpdatePeriod(l2g->getFadeUpdatePeriod() + 1000); |
ledonger | 3:25af55580ef6 | 49 | l3g->setFadeUpdatePeriod(l3g->getFadeUpdatePeriod() + 1000); |
ledonger | 3:25af55580ef6 | 50 | |
ledonger | 3:25af55580ef6 | 51 | l1b->setFadeUpdatePeriod(l1b->getFadeUpdatePeriod() + 1500); |
ledonger | 3:25af55580ef6 | 52 | l2b->setFadeUpdatePeriod(l2b->getFadeUpdatePeriod() + 1500); |
ledonger | 3:25af55580ef6 | 53 | l3b->setFadeUpdatePeriod(l3b->getFadeUpdatePeriod() + 1500); |
ledonger | 3:25af55580ef6 | 54 | |
ledonger | 3:25af55580ef6 | 55 | l3r->setActive(!l3r->getActiveness()); |
ledonger | 3:25af55580ef6 | 56 | while(button != 1); |
ledonger | 3:25af55580ef6 | 57 | } |
ledonger | 3:25af55580ef6 | 58 | |
ledonger | 3:25af55580ef6 | 59 | |
ledonger | 2:0bbd4fc5e202 | 60 | |
ledonger | 0:b350f8395bff | 61 | } |
ledonger | 0:b350f8395bff | 62 | } |
ledonger | 0:b350f8395bff | 63 | |
ledonger | 3:25af55580ef6 | 64 |