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-15
- Revision:
- 9:89d39fc98b17
- Parent:
- 8:aa1e315bf408
- Child:
- 13:0708365334c4
File content as of revision 9:89d39fc98b17:
#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 press(){
led1=1;
}
void releas(){
npr.setLights(1, "000000");
npr.rst();
npr.setLights(12, "000000");
led1=true;
}
int main()
{
View v;
while(1){
v.updateLCD();
}
//*************************************************
int i=0;
button.rise(&press);
button.fall(&releas);
//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);
}