
Interfaçage NeoPixel Ring 12, LPRO MECSE, Arnaud A.
Dependencies: lcd neoPixelRing12 view2 BSP_DISCO_F746NG view1 button
main.cpp
- Committer:
- Rhamao
- Date:
- 2020-06-24
- Revision:
- 16:a5bfabe7c884
- Parent:
- 15:567aecbdc323
- Child:
- 17:60720d5cb48f
File content as of revision 16:a5bfabe7c884:
#include "mbed.h" #include "Thread.h" #include "rtos_idle.h" #include "mbed_critical.h" #include "neoPixelRing12/neoPixelRing12.h" #include "view1.h" #include "stm32746g_discovery_lcd.h" #include "stm32746g_discovery_ts.h" #include "lcd/lcd.h" #include "view2/view2.h" #include "rtos.h" #include <list> #define SCREENWIDTH 480 #define SCREENHEIGHT 272 #define USE_CRITICAL_SECTION_LOCK 1 // Set 0 to see race condition NeoPixelRing12 npr(D8); LCD disco; View1 v1; View2 v2; TS_StateTypeDef TS_State; char RGBmap[12][7]; Thread t1; Thread t2; /*int main() { disco.initLCD(); v1.initView(); v2.initView(); npr.setLights(12, "000000"); CriticalSectionLock lock; //npr.setLights(12, "000000"); while(1) npr.rainbowAnimations(); CriticalSectionLock unlock; while(1){ if(!v1.getViewChanged()){ v1.updateLCD(); if(v1.getSetNewColorEnabled()){ v1.getRGBmap(RGBmap); CriticalSectionLock lock; npr.setLights(RGBmap); CriticalSectionLock unlock; } }else{ v2.updateLCD(); v1.setViewChanged(!v2.getViewChanged()); } } }*/ void ui() { while (true) { if(!v1.getViewChanged()){ v1.updateLCD(); if(v1.getSetNewColorEnabled()){ v1.getRGBmap(RGBmap); CriticalSectionLock lock; npr.setLights(RGBmap); CriticalSectionLock unlock; } }else{ v2.updateLCD(); v1.setViewChanged(!v2.getViewChanged()); } Thread::wait(1); } } void leds() { while (true) { t2.signal_set(0x1); Thread::signal_wait(0x1); Thread::wait(1000); } } int main() { npr.setLights(12, "000000"); disco.initLCD(); v1.initView(); v2.initView(); t1.start(ui); t2.start(leds); Thread::wait(osWaitForever); }