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@3:edc98882d63a, 2015-12-08 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Tue Dec 08 14:20:25 2015 +0000
- Revision:
- 3:edc98882d63a
- Parent:
- 2:b88f2ec606d3
- Child:
- 4:201e97957618
4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:35af280527cf | 1 | //--------------------------------------------------------------- |
MikamiUitOpen | 0:35af280527cf | 2 | // Demo program of Button class and ButtonGroup class |
MikamiUitOpen | 0:35af280527cf | 3 | // |
MikamiUitOpen | 2:b88f2ec606d3 | 4 | // 2015/12/05, Copyright (c) 2015 MIKAMI, Naoki |
MikamiUitOpen | 0:35af280527cf | 5 | //--------------------------------------------------------------- |
MikamiUitOpen | 0:35af280527cf | 6 | |
MikamiUitOpen | 0:35af280527cf | 7 | #include "button_group.hpp" |
MikamiUitOpen | 0:35af280527cf | 8 | |
MikamiUitOpen | 0:35af280527cf | 9 | using namespace Mikami; |
MikamiUitOpen | 0:35af280527cf | 10 | |
MikamiUitOpen | 0:35af280527cf | 11 | TS_DISCO_F746NG ts_; |
MikamiUitOpen | 0:35af280527cf | 12 | LCD_DISCO_F746NG lcd_; |
MikamiUitOpen | 0:35af280527cf | 13 | |
MikamiUitOpen | 0:35af280527cf | 14 | int main() |
MikamiUitOpen | 0:35af280527cf | 15 | { |
MikamiUitOpen | 3:edc98882d63a | 16 | printf("\r\n23:13"); |
MikamiUitOpen | 0:35af280527cf | 17 | const int Y0 = 5; |
MikamiUitOpen | 0:35af280527cf | 18 | const int X1 = 50; |
MikamiUitOpen | 0:35af280527cf | 19 | const int Y1 = 200; |
MikamiUitOpen | 0:35af280527cf | 20 | |
MikamiUitOpen | 0:35af280527cf | 21 | uint32_t backColor = 0xFF006A6C; // teal green |
MikamiUitOpen | 0:35af280527cf | 22 | uint32_t inActive = backColor & 0xE0FFFFFF; // color for inactive button |
MikamiUitOpen | 0:35af280527cf | 23 | lcd_.Clear(backColor); |
MikamiUitOpen | 0:35af280527cf | 24 | |
MikamiUitOpen | 0:35af280527cf | 25 | const int NUMBER_BUTTONS = 4; |
MikamiUitOpen | 1:83147f0d63ea | 26 | const string STR[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Button4"}; |
MikamiUitOpen | 0:35af280527cf | 27 | ButtonGroup bGroup(lcd_, ts_, 10, Y0, 66, 40, |
MikamiUitOpen | 1:83147f0d63ea | 28 | LCD_COLOR_BLUE, backColor, NUMBER_BUTTONS, STR, 5, 5, 3); |
MikamiUitOpen | 0:35af280527cf | 29 | |
MikamiUitOpen | 3:edc98882d63a | 30 | Button Large(lcd_, ts_, 200, 100, 120, 60, |
MikamiUitOpen | 3:edc98882d63a | 31 | LCD_COLOR_GREEN, backColor, "LARGE", Font24); |
MikamiUitOpen | 3:edc98882d63a | 32 | |
MikamiUitOpen | 0:35af280527cf | 33 | Button reset(lcd_, ts_, 410, Y0, 60, 40, |
MikamiUitOpen | 0:35af280527cf | 34 | LCD_COLOR_BLUE, backColor, "Reset", Font12); |
MikamiUitOpen | 0:35af280527cf | 35 | reset.Draw(inActive, LCD_COLOR_GRAY); |
MikamiUitOpen | 0:35af280527cf | 36 | |
MikamiUitOpen | 0:35af280527cf | 37 | lcd_.SetTextColor(LCD_COLOR_WHITE); |
MikamiUitOpen | 0:35af280527cf | 38 | while (true) |
MikamiUitOpen | 0:35af280527cf | 39 | { |
MikamiUitOpen | 0:35af280527cf | 40 | int num; |
MikamiUitOpen | 0:35af280527cf | 41 | if (bGroup.GetTouchedNumber(num, LCD_COLOR_DARKBLUE)) |
MikamiUitOpen | 0:35af280527cf | 42 | { |
MikamiUitOpen | 0:35af280527cf | 43 | char str[20]; |
MikamiUitOpen | 0:35af280527cf | 44 | lcd_.SetFont(&Font16); |
MikamiUitOpen | 0:35af280527cf | 45 | lcd_.SetTextColor(LCD_COLOR_WHITE); |
MikamiUitOpen | 0:35af280527cf | 46 | sprintf(str, "Button%d pressed", num+1); |
MikamiUitOpen | 0:35af280527cf | 47 | lcd_.DisplayStringAt(X1, Y1, (uint8_t *)str, LEFT_MODE); |
MikamiUitOpen | 0:35af280527cf | 48 | |
MikamiUitOpen | 0:35af280527cf | 49 | reset.Redraw(); |
MikamiUitOpen | 0:35af280527cf | 50 | } |
MikamiUitOpen | 0:35af280527cf | 51 | |
MikamiUitOpen | 0:35af280527cf | 52 | if (reset.Touched()) |
MikamiUitOpen | 0:35af280527cf | 53 | { |
MikamiUitOpen | 0:35af280527cf | 54 | bGroup.Redraw(num); |
MikamiUitOpen | 0:35af280527cf | 55 | reset.Draw(inActive, LCD_COLOR_GRAY); |
MikamiUitOpen | 0:35af280527cf | 56 | lcd_.SetFont(&Font16); |
MikamiUitOpen | 0:35af280527cf | 57 | lcd_.DisplayStringAt(X1, Y1, (uint8_t *)" ", LEFT_MODE); |
MikamiUitOpen | 0:35af280527cf | 58 | } |
MikamiUitOpen | 0:35af280527cf | 59 | wait(0.5f); |
MikamiUitOpen | 0:35af280527cf | 60 | } |
MikamiUitOpen | 0:35af280527cf | 61 | } |
MikamiUitOpen | 0:35af280527cf | 62 |