![](/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@0:b350f8395bff, 2017-08-18 (annotated)
- Committer:
- ledonger
- Date:
- Fri Aug 18 08:39:43 2017 +0000
- Revision:
- 0:b350f8395bff
- Child:
- 1:8b80523d8959
FlowerColor v0.1 problem with L073 : LED not synchronized
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 | PinName pin_array[] = {LED1,D11,D4,D2,D5,D6,D7,D8,D9,D10}; |
ledonger | 0:b350f8395bff | 5 | //int pin_array_size = 10/*sizeof(pin_array)/sizeof(PinName)*/; |
ledonger | 0:b350f8395bff | 6 | |
ledonger | 0:b350f8395bff | 7 | //DigitalOut** io_array; |
ledonger | 0:b350f8395bff | 8 | Timer timer; |
ledonger | 0:b350f8395bff | 9 | //Serial pc(USBTX,USBRX,921600); |
ledonger | 0:b350f8395bff | 10 | |
ledonger | 0:b350f8395bff | 11 | //void set_pin_high(); |
ledonger | 0:b350f8395bff | 12 | //void set_pin_low(); |
ledonger | 0:b350f8395bff | 13 | |
ledonger | 0:b350f8395bff | 14 | |
ledonger | 0:b350f8395bff | 15 | int main() |
ledonger | 0:b350f8395bff | 16 | { |
ledonger | 0:b350f8395bff | 17 | //Init |
ledonger | 0:b350f8395bff | 18 | //pc.printf("Starting...\n"); |
ledonger | 0:b350f8395bff | 19 | //printf("pin_array_size : %d\n",pin_array_size); |
ledonger | 0:b350f8395bff | 20 | |
ledonger | 0:b350f8395bff | 21 | //io_array = new DigitalOut*[pin_array_size]; |
ledonger | 0:b350f8395bff | 22 | |
ledonger | 0:b350f8395bff | 23 | /*int i; |
ledonger | 0:b350f8395bff | 24 | for(i = 0; i < pin_array_size; i++) |
ledonger | 0:b350f8395bff | 25 | { |
ledonger | 0:b350f8395bff | 26 | io_array[i] = new DigitalOut(pin_array[i]); |
ledonger | 0:b350f8395bff | 27 | } |
ledonger | 0:b350f8395bff | 28 | printf("Init : OK\n"); |
ledonger | 0:b350f8395bff | 29 | |
ledonger | 0:b350f8395bff | 30 | printf("Test procedure\n"); |
ledonger | 0:b350f8395bff | 31 | for(i = 0; i < pin_array_size; i++) |
ledonger | 0:b350f8395bff | 32 | { |
ledonger | 0:b350f8395bff | 33 | *(io_array[i]) = 1; |
ledonger | 0:b350f8395bff | 34 | wait(0.1); |
ledonger | 0:b350f8395bff | 35 | *(io_array[i]) = 0; |
ledonger | 0:b350f8395bff | 36 | wait(0.1); |
ledonger | 0:b350f8395bff | 37 | }*/ |
ledonger | 0:b350f8395bff | 38 | timer.start(); |
ledonger | 0:b350f8395bff | 39 | |
ledonger | 0:b350f8395bff | 40 | /*int period_us = 10000; |
ledonger | 0:b350f8395bff | 41 | float highTime1 = period_us*0.5;//50% |
ledonger | 0:b350f8395bff | 42 | float lowTime1 = (period_us-highTime1); |
ledonger | 0:b350f8395bff | 43 | int prevTime = timer.read_us(); |
ledonger | 0:b350f8395bff | 44 | |
ledonger | 0:b350f8395bff | 45 | int prevUpdateTime = timer.read_us(); |
ledonger | 0:b350f8395bff | 46 | int updateTime = 10000; |
ledonger | 0:b350f8395bff | 47 | int fadeFactor = 75; |
ledonger | 0:b350f8395bff | 48 | |
ledonger | 0:b350f8395bff | 49 | int situation1 = 1; |
ledonger | 0:b350f8395bff | 50 | int situation2 = 1;*/ |
ledonger | 0:b350f8395bff | 51 | |
ledonger | 0:b350f8395bff | 52 | LEDManager *led1 = new LEDManager(D11,10000); |
ledonger | 0:b350f8395bff | 53 | LEDManager *led2 = new LEDManager(D4,10000); |
ledonger | 0:b350f8395bff | 54 | LEDManager *led3 = new LEDManager(D2,10000); |
ledonger | 0:b350f8395bff | 55 | LEDManager *led4 = new LEDManager(D5,10000); |
ledonger | 0:b350f8395bff | 56 | LEDManager *led5 = new LEDManager(D6,10000); |
ledonger | 0:b350f8395bff | 57 | LEDManager *led6 = new LEDManager(D7,10000); |
ledonger | 0:b350f8395bff | 58 | LEDManager *led7 = new LEDManager(D8,10000); |
ledonger | 0:b350f8395bff | 59 | LEDManager *led8 = new LEDManager(D9,10000); |
ledonger | 0:b350f8395bff | 60 | LEDManager *led9 = new LEDManager(D10,10000); |
ledonger | 0:b350f8395bff | 61 | //pc.printf("Test : OK\n"); |
ledonger | 0:b350f8395bff | 62 | int time = timer.read_us(); |
ledonger | 0:b350f8395bff | 63 | while(1) |
ledonger | 0:b350f8395bff | 64 | { |
ledonger | 0:b350f8395bff | 65 | led1->processLED(time); |
ledonger | 0:b350f8395bff | 66 | led2->processLED(time); |
ledonger | 0:b350f8395bff | 67 | led3->processLED(time); |
ledonger | 0:b350f8395bff | 68 | led4->processLED(time); |
ledonger | 0:b350f8395bff | 69 | led5->processLED(time); |
ledonger | 0:b350f8395bff | 70 | led6->processLED(time); |
ledonger | 0:b350f8395bff | 71 | led7->processLED(time); |
ledonger | 0:b350f8395bff | 72 | led8->processLED(time); |
ledonger | 0:b350f8395bff | 73 | led9->processLED(time); |
ledonger | 0:b350f8395bff | 74 | |
ledonger | 0:b350f8395bff | 75 | //printf("%d\n",timer.read_us()-time); |
ledonger | 0:b350f8395bff | 76 | time = timer.read_us(); |
ledonger | 0:b350f8395bff | 77 | } |
ledonger | 0:b350f8395bff | 78 | } |
ledonger | 0:b350f8395bff | 79 |