Programme qui permet de piloter un bandeau de LED ring (de la marque adafruit) en fonction du son qui provient d'un microphone externe. Programme fonctionnant sur un microcontrôleur DISCO-F746NG. Ce projet a était fait dans la cadre du cour d'interface de la Licence MECSE de l'IUT de Cachan.
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG NeoPixel BUTTON_GROUP
test
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2015-12-09
- Revision:
- 4:201e97957618
- Parent:
- 3:edc98882d63a
- Child:
- 6:2736b38c1d73
File content as of revision 4:201e97957618:
//--------------------------------------------------------------- // Demo program of Button class and ButtonGroup class // // 2015/12/09, Copyright (c) 2015 MIKAMI, Naoki //--------------------------------------------------------------- #include "button_group.hpp" using namespace Mikami; TS_DISCO_F746NG ts_; LCD_DISCO_F746NG lcd_; int main() { const int Y0 = 5; const int X1 = 30; const int Y1 = 100; uint32_t backColor = 0xFF006A6C; // teal green uint32_t inActive = backColor & 0xE0FFFFFF; // color for inactive button lcd_.Clear(backColor); const int NUMBER_BUTTONS = 4; const string STR[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Button4"}; ButtonGroup bGroup(lcd_, ts_, 10, Y0, 66, 40, LCD_COLOR_BLUE, backColor, NUMBER_BUTTONS, STR, 5, 5, 3); const string STR_SW[2] = {"ON", "OFF"}; ButtonGroup sw(lcd_, ts_, 10, 160, 66, 40, LCD_COLOR_GREEN, backColor, 2, STR_SW, 5, 0, 2); Button Large(lcd_, ts_, 280, 100, 120, 60, LCD_COLOR_GREEN, backColor, "LARGE", Font24); Button reset(lcd_, ts_, 410, Y0, 60, 40, LCD_COLOR_BLUE, backColor, "Reset", Font12); reset.Draw(inActive, LCD_COLOR_GRAY); lcd_.SetTextColor(LCD_COLOR_WHITE); while (true) { int num; if (bGroup.GetTouchedNumber(num, LCD_COLOR_DARKBLUE)) { char str[20]; lcd_.SetFont(&Font16); lcd_.SetTextColor(LCD_COLOR_WHITE); sprintf(str, "Button%d pressed", num+1); lcd_.DisplayStringAt(X1, Y1, (uint8_t *)str, LEFT_MODE); reset.Redraw(); } if (sw.Touched(0, LCD_COLOR_DARKGREEN)) lcd_.DisplayStringAt(X1, 210, (uint8_t *)"ON ", LEFT_MODE); if (sw.Touched(1, LCD_COLOR_DARKGREEN)) lcd_.DisplayStringAt(X1, 210, (uint8_t *)"OFF", LEFT_MODE); if (reset.Touched()) { bGroup.Redraw(num); reset.Draw(inActive, LCD_COLOR_GRAY); lcd_.SetFont(&Font16); lcd_.DisplayStringAt(X1, Y1, (uint8_t *)" ", LEFT_MODE); } wait(0.5f); } }