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

Committer:
MikamiUitOpen
Date:
Wed Dec 09 01:55:57 2015 +0000
Revision:
4:201e97957618
Parent:
3:edc98882d63a
Child:
6:2736b38c1d73
5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:35af280527cf 1 //---------------------------------------------------------------
MikamiUitOpen 0:35af280527cf 2 // Demo program of Button class and ButtonGroup class
MikamiUitOpen 0:35af280527cf 3 //
MikamiUitOpen 4:201e97957618 4 // 2015/12/09, 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 0:35af280527cf 16 const int Y0 = 5;
MikamiUitOpen 4:201e97957618 17 const int X1 = 30;
MikamiUitOpen 4:201e97957618 18 const int Y1 = 100;
MikamiUitOpen 0:35af280527cf 19
MikamiUitOpen 0:35af280527cf 20 uint32_t backColor = 0xFF006A6C; // teal green
MikamiUitOpen 0:35af280527cf 21 uint32_t inActive = backColor & 0xE0FFFFFF; // color for inactive button
MikamiUitOpen 0:35af280527cf 22 lcd_.Clear(backColor);
MikamiUitOpen 0:35af280527cf 23
MikamiUitOpen 0:35af280527cf 24 const int NUMBER_BUTTONS = 4;
MikamiUitOpen 1:83147f0d63ea 25 const string STR[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Button4"};
MikamiUitOpen 0:35af280527cf 26 ButtonGroup bGroup(lcd_, ts_, 10, Y0, 66, 40,
MikamiUitOpen 1:83147f0d63ea 27 LCD_COLOR_BLUE, backColor, NUMBER_BUTTONS, STR, 5, 5, 3);
MikamiUitOpen 0:35af280527cf 28
MikamiUitOpen 4:201e97957618 29 const string STR_SW[2] = {"ON", "OFF"};
MikamiUitOpen 4:201e97957618 30 ButtonGroup sw(lcd_, ts_, 10, 160, 66, 40,
MikamiUitOpen 4:201e97957618 31 LCD_COLOR_GREEN, backColor, 2, STR_SW, 5, 0, 2);
MikamiUitOpen 4:201e97957618 32
MikamiUitOpen 4:201e97957618 33 Button Large(lcd_, ts_, 280, 100, 120, 60,
MikamiUitOpen 3:edc98882d63a 34 LCD_COLOR_GREEN, backColor, "LARGE", Font24);
MikamiUitOpen 3:edc98882d63a 35
MikamiUitOpen 0:35af280527cf 36 Button reset(lcd_, ts_, 410, Y0, 60, 40,
MikamiUitOpen 0:35af280527cf 37 LCD_COLOR_BLUE, backColor, "Reset", Font12);
MikamiUitOpen 0:35af280527cf 38 reset.Draw(inActive, LCD_COLOR_GRAY);
MikamiUitOpen 0:35af280527cf 39
MikamiUitOpen 0:35af280527cf 40 lcd_.SetTextColor(LCD_COLOR_WHITE);
MikamiUitOpen 0:35af280527cf 41 while (true)
MikamiUitOpen 0:35af280527cf 42 {
MikamiUitOpen 0:35af280527cf 43 int num;
MikamiUitOpen 0:35af280527cf 44 if (bGroup.GetTouchedNumber(num, LCD_COLOR_DARKBLUE))
MikamiUitOpen 0:35af280527cf 45 {
MikamiUitOpen 0:35af280527cf 46 char str[20];
MikamiUitOpen 0:35af280527cf 47 lcd_.SetFont(&Font16);
MikamiUitOpen 0:35af280527cf 48 lcd_.SetTextColor(LCD_COLOR_WHITE);
MikamiUitOpen 0:35af280527cf 49 sprintf(str, "Button%d pressed", num+1);
MikamiUitOpen 0:35af280527cf 50 lcd_.DisplayStringAt(X1, Y1, (uint8_t *)str, LEFT_MODE);
MikamiUitOpen 0:35af280527cf 51
MikamiUitOpen 0:35af280527cf 52 reset.Redraw();
MikamiUitOpen 0:35af280527cf 53 }
MikamiUitOpen 0:35af280527cf 54
MikamiUitOpen 4:201e97957618 55 if (sw.Touched(0, LCD_COLOR_DARKGREEN))
MikamiUitOpen 4:201e97957618 56 lcd_.DisplayStringAt(X1, 210, (uint8_t *)"ON ", LEFT_MODE);
MikamiUitOpen 4:201e97957618 57 if (sw.Touched(1, LCD_COLOR_DARKGREEN))
MikamiUitOpen 4:201e97957618 58 lcd_.DisplayStringAt(X1, 210, (uint8_t *)"OFF", LEFT_MODE);
MikamiUitOpen 4:201e97957618 59
MikamiUitOpen 0:35af280527cf 60 if (reset.Touched())
MikamiUitOpen 0:35af280527cf 61 {
MikamiUitOpen 0:35af280527cf 62 bGroup.Redraw(num);
MikamiUitOpen 0:35af280527cf 63 reset.Draw(inActive, LCD_COLOR_GRAY);
MikamiUitOpen 0:35af280527cf 64 lcd_.SetFont(&Font16);
MikamiUitOpen 0:35af280527cf 65 lcd_.DisplayStringAt(X1, Y1, (uint8_t *)" ", LEFT_MODE);
MikamiUitOpen 0:35af280527cf 66 }
MikamiUitOpen 0:35af280527cf 67 wait(0.5f);
MikamiUitOpen 0:35af280527cf 68 }
MikamiUitOpen 0:35af280527cf 69 }
MikamiUitOpen 0:35af280527cf 70