
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-14
- Revision:
- 8:aa1e315bf408
- Parent:
- 7:1887c4e4b5de
- Child:
- 9:89d39fc98b17
File content as of revision 8:aa1e315bf408:
#include "mbed.h" #include "Thread.h" #include "rtos_idle.h" #include "mbed_critical.h" #include "NeoPixelRing12.h" #include "view.h" #include "stm32746g_discovery_lcd.h" #include "stm32746g_discovery_ts.h" #include <list> #define SCREENWIDTH 480 #define SCREENHEIGHT 272 #define USE_CRITICAL_SECTION_LOCK 1 // Set 0 to see race condition uint8_t text[30]; InterruptIn button(USER_BUTTON); DigitalOut myled(D8); DigitalOut led1(LED1); NeoPixelRing12 npr(D8); char blank[7] = "000000"; char r[7] = "ff0000"; char g[7] = "00ff00"; char b[7] = "0000ff"; 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() { TS_StateTypeDef TS_State; uint16_t x, y; uint8_t idx; uint8_t cleared = 0; uint8_t prev_nb_touches = 0; View v; while(1) { v.updateLoop(); BSP_TS_GetState(&TS_State); if (TS_State.touchDetected) { //Detecte si l'écran tactile est touché cleared = 0; //sprintf((char*)text, "Touches: %d", TS_State.touchDetected); //BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); for (idx = 0; idx < TS_State.touchDetected; idx++) { x = TS_State.touchX[idx]; y = TS_State.touchY[idx]; v.contain(x, y); } } else { if (!cleared) { v.draw(); //sprintf((char*)text, "Touches: 0"); //BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); cleared = 1; } } } //************************************************* int i=0; 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); }