Interfaçage NeoPixel Ring 12, LPRO MECSE, Arnaud A.

Dependencies:   lcd neoPixelRing12 view2 BSP_DISCO_F746NG view1 button

Committer:
Rhamao
Date:
Wed Jun 24 19:08:56 2020 +0000
Revision:
16:a5bfabe7c884
Parent:
15:567aecbdc323
Child:
17:60720d5cb48f
Debut du rtos

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:b045ca817e2c 1 #include "mbed.h"
Rhamao 6:91e478ee227e 2 #include "Thread.h"
Rhamao 6:91e478ee227e 3 #include "rtos_idle.h"
Rhamao 6:91e478ee227e 4 #include "mbed_critical.h"
Rhamao 14:7b74ad030896 5 #include "neoPixelRing12/neoPixelRing12.h"
Rhamao 14:7b74ad030896 6 #include "view1.h"
Rhamao 8:aa1e315bf408 7 #include "stm32746g_discovery_lcd.h"
Rhamao 8:aa1e315bf408 8 #include "stm32746g_discovery_ts.h"
Rhamao 13:0708365334c4 9 #include "lcd/lcd.h"
Rhamao 14:7b74ad030896 10 #include "view2/view2.h"
Rhamao 16:a5bfabe7c884 11 #include "rtos.h"
Rhamao 8:aa1e315bf408 12 #include <list>
Rhamao 8:aa1e315bf408 13 #define SCREENWIDTH 480
Rhamao 8:aa1e315bf408 14 #define SCREENHEIGHT 272
Rhamao 6:91e478ee227e 15
Rhamao 6:91e478ee227e 16 #define USE_CRITICAL_SECTION_LOCK 1 // Set 0 to see race condition
Rhamao 6:91e478ee227e 17
Rhamao 7:1887c4e4b5de 18 NeoPixelRing12 npr(D8);
Rhamao 13:0708365334c4 19 LCD disco;
Rhamao 14:7b74ad030896 20 View1 v1;
Rhamao 14:7b74ad030896 21 View2 v2;
Rhamao 14:7b74ad030896 22 TS_StateTypeDef TS_State;
Rhamao 14:7b74ad030896 23 char RGBmap[12][7];
Rhamao 16:a5bfabe7c884 24 Thread t1;
Rhamao 16:a5bfabe7c884 25 Thread t2;
bcostm 0:b045ca817e2c 26
Rhamao 16:a5bfabe7c884 27 /*int main()
Jerome Coutant 5:e8f8a8037256 28 {
Rhamao 13:0708365334c4 29
Rhamao 13:0708365334c4 30 disco.initLCD();
Rhamao 14:7b74ad030896 31 v1.initView();
Rhamao 14:7b74ad030896 32 v2.initView();
Rhamao 14:7b74ad030896 33 npr.setLights(12, "000000");
Rhamao 14:7b74ad030896 34 CriticalSectionLock lock;
Rhamao 14:7b74ad030896 35 //npr.setLights(12, "000000");
Rhamao 15:567aecbdc323 36 while(1)
Rhamao 15:567aecbdc323 37 npr.rainbowAnimations();
Rhamao 14:7b74ad030896 38 CriticalSectionLock unlock;
Rhamao 9:89d39fc98b17 39 while(1){
Rhamao 14:7b74ad030896 40 if(!v1.getViewChanged()){
Rhamao 14:7b74ad030896 41 v1.updateLCD();
Rhamao 14:7b74ad030896 42 if(v1.getSetNewColorEnabled()){
Rhamao 14:7b74ad030896 43 v1.getRGBmap(RGBmap);
Rhamao 14:7b74ad030896 44 CriticalSectionLock lock;
Rhamao 14:7b74ad030896 45 npr.setLights(RGBmap);
Rhamao 14:7b74ad030896 46 CriticalSectionLock unlock;
Rhamao 14:7b74ad030896 47 }
Rhamao 14:7b74ad030896 48 }else{
Rhamao 14:7b74ad030896 49 v2.updateLCD();
Rhamao 14:7b74ad030896 50 v1.setViewChanged(!v2.getViewChanged());
Rhamao 14:7b74ad030896 51 }
Rhamao 14:7b74ad030896 52 }
Rhamao 16:a5bfabe7c884 53 }*/
Rhamao 16:a5bfabe7c884 54
Rhamao 16:a5bfabe7c884 55 void ui() {
Rhamao 16:a5bfabe7c884 56 while (true) {
Rhamao 16:a5bfabe7c884 57 if(!v1.getViewChanged()){
Rhamao 16:a5bfabe7c884 58 v1.updateLCD();
Rhamao 16:a5bfabe7c884 59 if(v1.getSetNewColorEnabled()){
Rhamao 16:a5bfabe7c884 60 v1.getRGBmap(RGBmap);
Rhamao 16:a5bfabe7c884 61 CriticalSectionLock lock;
Rhamao 16:a5bfabe7c884 62 npr.setLights(RGBmap);
Rhamao 16:a5bfabe7c884 63 CriticalSectionLock unlock;
Rhamao 16:a5bfabe7c884 64 }
Rhamao 16:a5bfabe7c884 65 }else{
Rhamao 16:a5bfabe7c884 66 v2.updateLCD();
Rhamao 16:a5bfabe7c884 67 v1.setViewChanged(!v2.getViewChanged());
Rhamao 16:a5bfabe7c884 68 }
Rhamao 16:a5bfabe7c884 69 Thread::wait(1);
Rhamao 16:a5bfabe7c884 70 }
Rhamao 16:a5bfabe7c884 71 }
Rhamao 16:a5bfabe7c884 72
Rhamao 16:a5bfabe7c884 73 void leds() {
Rhamao 16:a5bfabe7c884 74 while (true) {
Rhamao 16:a5bfabe7c884 75 t2.signal_set(0x1);
Rhamao 16:a5bfabe7c884 76 Thread::signal_wait(0x1);
Rhamao 16:a5bfabe7c884 77 Thread::wait(1000);
Rhamao 16:a5bfabe7c884 78 }
Rhamao 16:a5bfabe7c884 79 }
Rhamao 16:a5bfabe7c884 80
Rhamao 16:a5bfabe7c884 81 int main() {
Rhamao 16:a5bfabe7c884 82 npr.setLights(12, "000000");
Rhamao 16:a5bfabe7c884 83 disco.initLCD();
Rhamao 16:a5bfabe7c884 84 v1.initView();
Rhamao 16:a5bfabe7c884 85 v2.initView();
Rhamao 16:a5bfabe7c884 86 t1.start(ui);
Rhamao 16:a5bfabe7c884 87 t2.start(leds);
Rhamao 16:a5bfabe7c884 88 Thread::wait(osWaitForever);
Rhamao 6:91e478ee227e 89 }
bcostm 0:b045ca817e2c 90
bcostm 0:b045ca817e2c 91
Rhamao 16:a5bfabe7c884 92
Rhamao 16:a5bfabe7c884 93