![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
programme capteur d'empreinte digital
main.cpp@2:b60c218a2432, 2016-04-08 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Fri Apr 08 09:44:35 2016 +0000
- Revision:
- 2:b60c218a2432
- Parent:
- 1:b4bcb6fa2a1d
- Child:
- 3:e92615be71c7
3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 1:b4bcb6fa2a1d | 1 | //-------------------------------------------------------------------------------- |
MikamiUitOpen | 0:629ff18592b9 | 2 | // GuiBase とその派生クラスのデモプログラム |
MikamiUitOpen | 0:629ff18592b9 | 3 | // Demo program for GuiBase class and its derivertive classes |
MikamiUitOpen | 1:b4bcb6fa2a1d | 4 | // |
MikamiUitOpen | 1:b4bcb6fa2a1d | 5 | // GuiBase, Button, ButtonGroup, Label, NumericLabel, BlimkButton, SeekBar |
MikamiUitOpen | 0:629ff18592b9 | 6 | // |
MikamiUitOpen | 1:b4bcb6fa2a1d | 7 | // 2016/04/08, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 1:b4bcb6fa2a1d | 8 | //-------------------------------------------------------------------------------- |
MikamiUitOpen | 0:629ff18592b9 | 9 | |
MikamiUitOpen | 0:629ff18592b9 | 10 | #include "NumericLabel.hpp" |
MikamiUitOpen | 1:b4bcb6fa2a1d | 11 | #include "BlinkLabel.hpp" |
MikamiUitOpen | 0:629ff18592b9 | 12 | #include "ButtonGroup.hpp" |
MikamiUitOpen | 0:629ff18592b9 | 13 | #include "SeekBar.hpp" |
MikamiUitOpen | 0:629ff18592b9 | 14 | |
MikamiUitOpen | 0:629ff18592b9 | 15 | using namespace Mikami; |
MikamiUitOpen | 0:629ff18592b9 | 16 | |
MikamiUitOpen | 0:629ff18592b9 | 17 | Ticker timer; |
MikamiUitOpen | 0:629ff18592b9 | 18 | NumericLabel<float> obj2(10, 150, Label::LEFT, Font16, LCD_COLOR_YELLOW); |
MikamiUitOpen | 0:629ff18592b9 | 19 | |
MikamiUitOpen | 0:629ff18592b9 | 20 | void TimerIsr() |
MikamiUitOpen | 0:629ff18592b9 | 21 | { |
MikamiUitOpen | 0:629ff18592b9 | 22 | static int sec = 0; |
MikamiUitOpen | 0:629ff18592b9 | 23 | obj2.Draw("%6.1f [s]", (float)(sec++)/10.0f); |
MikamiUitOpen | 0:629ff18592b9 | 24 | } |
MikamiUitOpen | 0:629ff18592b9 | 25 | |
MikamiUitOpen | 0:629ff18592b9 | 26 | int main() |
MikamiUitOpen | 0:629ff18592b9 | 27 | { |
MikamiUitOpen | 1:b4bcb6fa2a1d | 28 | Label obj10(240, 4, "Dome: GUI parts", Label::CENTER, Font16); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 29 | Label obj11(240, 24, "Label, NumericLabel, BlinkLabel, Button, ButtonGroup, SeekBar", |
MikamiUitOpen | 0:629ff18592b9 | 30 | Label::CENTER); |
MikamiUitOpen | 0:629ff18592b9 | 31 | |
MikamiUitOpen | 2:b60c218a2432 | 32 | Button button1(10, 50, 50, 40, "1"); |
MikamiUitOpen | 0:629ff18592b9 | 33 | Button button2(62, 50, 50, 40, "2"); |
MikamiUitOpen | 0:629ff18592b9 | 34 | |
MikamiUitOpen | 0:629ff18592b9 | 35 | const int NUMBER_BUTTONS = 4; |
MikamiUitOpen | 0:629ff18592b9 | 36 | const string STR1[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Button4"}; |
MikamiUitOpen | 0:629ff18592b9 | 37 | ButtonGroup bGroup1(160, 50, 66, 40, NUMBER_BUTTONS, STR1, 5, 5, 3, 1, |
MikamiUitOpen | 0:629ff18592b9 | 38 | Font12, LCD_COLOR_WHITE, 0xFF003538, 0xFFB70068, 0xFFFF7FFF); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 39 | NumericLabel<int> bTouch(234, 108, Label::LEFT, Font16, LCD_COLOR_MAGENTA); |
MikamiUitOpen | 0:629ff18592b9 | 40 | |
MikamiUitOpen | 0:629ff18592b9 | 41 | const string STR2[3] = {"0", "1", "2"}; |
MikamiUitOpen | 0:629ff18592b9 | 42 | ButtonGroup bGroup2(160, 150, 66, 40, 3, STR2, 5, 5, 3); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 43 | |
MikamiUitOpen | 1:b4bcb6fa2a1d | 44 | Button doNotTouch(250, 220, 120, 40, "Don't Touch", Font12, |
MikamiUitOpen | 1:b4bcb6fa2a1d | 45 | GuiBase::ENUM_TEXT, GuiBase::ENUM_BACK, |
MikamiUitOpen | 1:b4bcb6fa2a1d | 46 | LCD_COLOR_DARKGREEN, LCD_COLOR_RED); |
MikamiUitOpen | 0:629ff18592b9 | 47 | |
MikamiUitOpen | 1:b4bcb6fa2a1d | 48 | // Using default value for argument (Horisontal) |
MikamiUitOpen | 0:629ff18592b9 | 49 | SeekBar bar(20, 240, 200, -5, 5, 0); |
MikamiUitOpen | 0:629ff18592b9 | 50 | NumericLabel<float> numLabel1(20, 200, "%5.1f", bar.GetValue()); |
MikamiUitOpen | 0:629ff18592b9 | 51 | NumericLabel<int> numLabel2(90, 200, "%3d", (int)bar.GetValue()); |
MikamiUitOpen | 0:629ff18592b9 | 52 | NumericLabel<int> numLabel3(120, 200); |
MikamiUitOpen | 0:629ff18592b9 | 53 | |
MikamiUitOpen | 1:b4bcb6fa2a1d | 54 | // Vertical |
MikamiUitOpen | 0:629ff18592b9 | 55 | SeekBar bar2(440, 100, 150, -5, 5, 2, SeekBar::Vertical, LCD_COLOR_GREEN); |
MikamiUitOpen | 0:629ff18592b9 | 56 | NumericLabel<float> numLabel4(440, 70, "%4.1f", bar2.GetValue(), Label::CENTER); |
MikamiUitOpen | 0:629ff18592b9 | 57 | |
MikamiUitOpen | 0:629ff18592b9 | 58 | timer.attach(&TimerIsr, 0.1f); |
MikamiUitOpen | 0:629ff18592b9 | 59 | |
MikamiUitOpen | 0:629ff18592b9 | 60 | while (true) |
MikamiUitOpen | 0:629ff18592b9 | 61 | { |
MikamiUitOpen | 0:629ff18592b9 | 62 | if (button1.Touched()) button2.Draw(); |
MikamiUitOpen | 0:629ff18592b9 | 63 | if (button2.Touched()) button1.Draw(); |
MikamiUitOpen | 0:629ff18592b9 | 64 | |
MikamiUitOpen | 0:629ff18592b9 | 65 | int num; |
MikamiUitOpen | 0:629ff18592b9 | 66 | if (bGroup1.GetTouchedNumber(num)) |
MikamiUitOpen | 1:b4bcb6fa2a1d | 67 | bTouch.Draw("Button%d touched", num+1); |
MikamiUitOpen | 0:629ff18592b9 | 68 | |
MikamiUitOpen | 1:b4bcb6fa2a1d | 69 | if (bGroup2.GetTouchedNumber(num)) |
MikamiUitOpen | 1:b4bcb6fa2a1d | 70 | switch (num) |
MikamiUitOpen | 0:629ff18592b9 | 71 | { |
MikamiUitOpen | 1:b4bcb6fa2a1d | 72 | case 0: button1.Activate(); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 73 | bGroup1.Activate(1); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 74 | bGroup1.DrawAll(); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 75 | break; |
MikamiUitOpen | 1:b4bcb6fa2a1d | 76 | case 1: button1.Inactivate(); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 77 | bGroup1.Inactivate(1); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 78 | break; |
MikamiUitOpen | 1:b4bcb6fa2a1d | 79 | case 2: for (int n=0; n<4; n++) bGroup1.Erase(n); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 80 | break; |
MikamiUitOpen | 0:629ff18592b9 | 81 | } |
MikamiUitOpen | 0:629ff18592b9 | 82 | |
MikamiUitOpen | 0:629ff18592b9 | 83 | if (bar.Slide()) |
MikamiUitOpen | 0:629ff18592b9 | 84 | { |
MikamiUitOpen | 0:629ff18592b9 | 85 | numLabel1.Draw("%5.1f", bar.GetValue()); |
MikamiUitOpen | 0:629ff18592b9 | 86 | int8_t x = (int8_t)bar.GetValue(); |
MikamiUitOpen | 0:629ff18592b9 | 87 | numLabel2.Draw("%3d", x); |
MikamiUitOpen | 0:629ff18592b9 | 88 | |
MikamiUitOpen | 0:629ff18592b9 | 89 | numLabel3.Draw("%3d", bar.GetIntValue()); |
MikamiUitOpen | 0:629ff18592b9 | 90 | } |
MikamiUitOpen | 0:629ff18592b9 | 91 | |
MikamiUitOpen | 0:629ff18592b9 | 92 | if (bar2.Slide()) { numLabel4.Draw("%4.1f", bar2.GetValue()); } |
MikamiUitOpen | 1:b4bcb6fa2a1d | 93 | |
MikamiUitOpen | 1:b4bcb6fa2a1d | 94 | // If "doNotTouch" button touched, trapped into endless loop |
MikamiUitOpen | 1:b4bcb6fa2a1d | 95 | if (doNotTouch.Touched()) |
MikamiUitOpen | 1:b4bcb6fa2a1d | 96 | BlinkLabel warning(250, 200, "You must reset", Label::LEFT, Font16); |
MikamiUitOpen | 0:629ff18592b9 | 97 | |
MikamiUitOpen | 0:629ff18592b9 | 98 | wait(0.02f); |
MikamiUitOpen | 0:629ff18592b9 | 99 | } |
MikamiUitOpen | 0:629ff18592b9 | 100 | } |