Example of Button class and ButtonGroup class for DISCO-F746NG. DISCO-F746NG 用の,Button クラス,ButtonGroup クラスの使用例.
Dependencies: BSP_DISCO_F746NG BUTTON_GROUP LCD_DISCO_F746NG TS_DISCO_F746NG mbed
Revision 12:e2bb579c4455, committed 2016-02-22
- Comitter:
- MikamiUitOpen
- Date:
- Mon Feb 22 13:40:13 2016 +0000
- Parent:
- 11:74a4d2c3870e
- Commit message:
- 13
Changed in this revision
BUTTON_GROUP.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/BUTTON_GROUP.lib Thu Feb 18 10:05:00 2016 +0000 +++ b/BUTTON_GROUP.lib Mon Feb 22 13:40:13 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/MikamiUitOpen/code/BUTTON_GROUP/#710078d50d9b +http://mbed.org/users/MikamiUitOpen/code/BUTTON_GROUP/#af578b53ff0e
--- a/main.cpp Thu Feb 18 10:05:00 2016 +0000 +++ b/main.cpp Mon Feb 22 13:40:13 2016 +0000 @@ -1,7 +1,7 @@ //--------------------------------------------------------------- // Demo program of Button class and ButtonGroup class // -// 2016/02/18, Copyright (c) 2016 MIKAMI, Naoki +// 2016/02/22, Copyright (c) 2016 MIKAMI, Naoki //--------------------------------------------------------------- #include "button_group.hpp" @@ -30,19 +30,32 @@ ButtonGroup sw(lcd_, ts_, 10, 160, 66, 40, LCD_COLOR_GREEN, BACK_COLOR, 2, STR_SW, 5, 0, 2); - Button Large(lcd_, ts_, 280, 100, 120, 60, - LCD_COLOR_GREEN, BACK_COLOR, "LARGE", Font24); - Button reset(lcd_, ts_, 410, Y0, 60, 40, LCD_COLOR_BLUE, BACK_COLOR, "Reset", Font12); reset.Draw(INACTIVE, LCD_COLOR_GRAY); + const string MULTI[2] = {"ON", "OFF"}; + ButtonGroup multiTouch(lcd_, ts_, 300, Y0+100, 60, 40, + LCD_COLOR_BLUE, BACK_COLOR, 2, MULTI, 5, 0, 2); + multiTouch.Draw(0, LCD_COLOR_DARKBLUE); + lcd_.SetTextColor(LCD_COLOR_WHITE); - lcd_.DisplayStringAt(100, 260, (uint8_t *)"02/17 15:27", LEFT_MODE); + lcd_.SetFont(&Font16); + lcd_.DisplayStringAt(250, Y0+80, (uint8_t *)"Multi-touch ON, OFF", LEFT_MODE); + + lcd_.SetFont(&Font20); + lcd_.DisplayStringAt(120, 250, (uint8_t *)"02/22 22:36", LEFT_MODE); + + DigitalOut dOut(D7); int num; + while (true) { - if (bGroup.GetTouchedNumber(num, LCD_COLOR_DARKBLUE)) + dOut = 1; + bool touched = bGroup.GetTouchedNumber(num, LCD_COLOR_DARKBLUE); + dOut = 0; + + if (touched) { char str[20]; lcd_.SetFont(&Font16); @@ -65,6 +78,17 @@ lcd_.SetFont(&Font16); lcd_.DisplayStringAt(X1, Y1, (uint8_t *)" ", LEFT_MODE); } - wait(0.5f); + + int mNum; + if (multiTouch.GetTouchedNumber(mNum, LCD_COLOR_DARKBLUE)) + { + Button::SetMultiTouch(mNum == 0); // Set or reset multi-touch + if (mNum == 0) + lcd_.DisplayStringAt(320, Y0+150, (uint8_t *)"ON ", LEFT_MODE); + else + lcd_.DisplayStringAt(320, Y0+150, (uint8_t *)"OFF", LEFT_MODE); + } + wait(0.01f); } } +