
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-04
- Revision:
- 7:1887c4e4b5de
- Parent:
- 6:91e478ee227e
- Child:
- 8:aa1e315bf408
File content as of revision 7:1887c4e4b5de:
#include "mbed.h" #include "Thread.h" #include "rtos_idle.h" #include "mbed_critical.h" #include "NeoPixelRing12.h" #define USE_CRITICAL_SECTION_LOCK 1 // Set 0 to see race condition InterruptIn button(USER_BUTTON); DigitalOut myled(D8); DigitalOut led1(LED1); NeoPixelRing12 npr(D8); void bit0(){ myled = 1; wait_ns(190); myled = 0; wait_ns(740); } void bit1(){ myled = 1; wait_ns(600); myled = 0; wait_ns(600); } void pressed(){ led1=1; } void released(){ npr.setLights(1, "000000"); npr.rst(); npr.setLights(12, "000000"); led1=true; } int main() { int i=0; char blank[100] = "000000"; char r[100] = "ff0000"; char g[100] = "00ff00"; char b[100] = "0000ff"; button.rise(&pressed); button.fall(&released); //CriticalSectionLock lock; //bit0(); //CriticalSectionLock unlock; //Une led à 0 avant d'envoyer la trame pour éviter //le bug de trame npr.setLights(1, "ff0000"); npr.rst(); //la trame npr.setLights(5, r); npr.setLights(2, g); npr.setLights(4, b); npr.rst(); wait(100.0); }