![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
programme capteur d'empreinte digital
main.cpp@9:666249b332cc, 2016-04-27 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Wed Apr 27 00:25:00 2016 +0000
- Revision:
- 9:666249b332cc
- Parent:
- 8:8a55f2e374da
- Child:
- 10:f23cca92f446
10
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 | 8:8a55f2e374da | 5 | // GuiBase, Button, ButtonGroup, Label, NumericLabel, BlinkLabel, |
MikamiUitOpen | 8:8a55f2e374da | 6 | // SeekBar, SeekbarGroup |
MikamiUitOpen | 0:629ff18592b9 | 7 | // |
MikamiUitOpen | 9:666249b332cc | 8 | // 2016/04/27, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 1:b4bcb6fa2a1d | 9 | //-------------------------------------------------------------------------------- |
MikamiUitOpen | 0:629ff18592b9 | 10 | |
MikamiUitOpen | 0:629ff18592b9 | 11 | #include "NumericLabel.hpp" |
MikamiUitOpen | 1:b4bcb6fa2a1d | 12 | #include "BlinkLabel.hpp" |
MikamiUitOpen | 0:629ff18592b9 | 13 | #include "ButtonGroup.hpp" |
MikamiUitOpen | 8:8a55f2e374da | 14 | #include "SeekBarGroup.hpp" |
MikamiUitOpen | 0:629ff18592b9 | 15 | |
MikamiUitOpen | 0:629ff18592b9 | 16 | using namespace Mikami; |
MikamiUitOpen | 0:629ff18592b9 | 17 | |
MikamiUitOpen | 0:629ff18592b9 | 18 | Ticker timer; |
MikamiUitOpen | 3:e92615be71c7 | 19 | NumericLabel<float> obj2(10, 116, Label::LEFT, Font16, LCD_COLOR_YELLOW); |
MikamiUitOpen | 0:629ff18592b9 | 20 | |
MikamiUitOpen | 0:629ff18592b9 | 21 | void TimerIsr() |
MikamiUitOpen | 0:629ff18592b9 | 22 | { |
MikamiUitOpen | 0:629ff18592b9 | 23 | static int sec = 0; |
MikamiUitOpen | 0:629ff18592b9 | 24 | obj2.Draw("%6.1f [s]", (float)(sec++)/10.0f); |
MikamiUitOpen | 0:629ff18592b9 | 25 | } |
MikamiUitOpen | 0:629ff18592b9 | 26 | |
MikamiUitOpen | 0:629ff18592b9 | 27 | int main() |
MikamiUitOpen | 0:629ff18592b9 | 28 | { |
MikamiUitOpen | 9:666249b332cc | 29 | Label obj10(240, 4, "Dome: GUI parts, 2016/04/27, 08:24", Label::CENTER, Font16); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 30 | Label obj11(240, 24, "Label, NumericLabel, BlinkLabel, Button, ButtonGroup, SeekBar", |
MikamiUitOpen | 0:629ff18592b9 | 31 | Label::CENTER); |
MikamiUitOpen | 0:629ff18592b9 | 32 | |
MikamiUitOpen | 2:b60c218a2432 | 33 | Button button1(10, 50, 50, 40, "1"); |
MikamiUitOpen | 0:629ff18592b9 | 34 | Button button2(62, 50, 50, 40, "2"); |
MikamiUitOpen | 0:629ff18592b9 | 35 | |
MikamiUitOpen | 0:629ff18592b9 | 36 | const int NUMBER_BUTTONS = 4; |
MikamiUitOpen | 7:5788d0406bfd | 37 | const string STR1[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Activate"}; |
MikamiUitOpen | 0:629ff18592b9 | 38 | ButtonGroup bGroup1(160, 50, 66, 40, NUMBER_BUTTONS, STR1, 5, 5, 3, 1, |
MikamiUitOpen | 0:629ff18592b9 | 39 | Font12, LCD_COLOR_WHITE, 0xFF003538, 0xFFB70068, 0xFFFF7FFF); |
MikamiUitOpen | 8:8a55f2e374da | 40 | NumericLabel<int> bTouch(240, 108, Label::LEFT, Font12, LCD_COLOR_MAGENTA); |
MikamiUitOpen | 0:629ff18592b9 | 41 | |
MikamiUitOpen | 3:e92615be71c7 | 42 | // Control status of bGroup1 |
MikamiUitOpen | 0:629ff18592b9 | 43 | const string STR2[3] = {"0", "1", "2"}; |
MikamiUitOpen | 0:629ff18592b9 | 44 | ButtonGroup bGroup2(160, 150, 66, 40, 3, STR2, 5, 5, 3); |
MikamiUitOpen | 7:5788d0406bfd | 45 | bGroup2.InactivateAll(); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 46 | |
MikamiUitOpen | 3:e92615be71c7 | 47 | // Switching buttons to control barH active or inactive |
MikamiUitOpen | 3:e92615be71c7 | 48 | const string STR3[3] = {"ON", "OFF"}; |
MikamiUitOpen | 3:e92615be71c7 | 49 | ButtonGroup bGroup3(10, 150, 66, 40, 2, STR3, 0, 0, 2); |
MikamiUitOpen | 3:e92615be71c7 | 50 | bGroup3.TouchedColor(0); |
MikamiUitOpen | 3:e92615be71c7 | 51 | |
MikamiUitOpen | 1:b4bcb6fa2a1d | 52 | Button doNotTouch(250, 220, 120, 40, "Don't Touch", Font12, |
MikamiUitOpen | 1:b4bcb6fa2a1d | 53 | GuiBase::ENUM_TEXT, GuiBase::ENUM_BACK, |
MikamiUitOpen | 1:b4bcb6fa2a1d | 54 | LCD_COLOR_DARKGREEN, LCD_COLOR_RED); |
MikamiUitOpen | 0:629ff18592b9 | 55 | |
MikamiUitOpen | 7:5788d0406bfd | 56 | // Using default value for argument (Horizontal) |
MikamiUitOpen | 4:4f73a3054a67 | 57 | SeekBar barH(20, 250, 200, -5, 5, 0, "-5", "", "5"); |
MikamiUitOpen | 4:4f73a3054a67 | 58 | NumericLabel<float> numLabel1(80, 205, "%5.1f", barH.GetValue()); |
MikamiUitOpen | 4:4f73a3054a67 | 59 | NumericLabel<int> numLabel2(130, 205, "%3d", (int)barH.GetValue()); |
MikamiUitOpen | 4:4f73a3054a67 | 60 | NumericLabel<int> numLabel3(160, 205); |
MikamiUitOpen | 0:629ff18592b9 | 61 | |
MikamiUitOpen | 8:8a55f2e374da | 62 | // SeekbarGroup (vertical) |
MikamiUitOpen | 8:8a55f2e374da | 63 | SeekbarGroup barV(400, 120, 130, 2, 50, -5, 5, 2, |
MikamiUitOpen | 8:8a55f2e374da | 64 | SeekBar::Vertical, LCD_COLOR_GREEN); |
MikamiUitOpen | 8:8a55f2e374da | 65 | NumericLabel<float> **numLabel4; |
MikamiUitOpen | 8:8a55f2e374da | 66 | numLabel4 = new NumericLabel<float> *[2]; |
MikamiUitOpen | 8:8a55f2e374da | 67 | for (int n=0; n<2; n++) numLabel4[n] = |
MikamiUitOpen | 8:8a55f2e374da | 68 | new NumericLabel<float>(400+n*50, 90, "%4.1f", barV.GetValue(n), Label::CENTER); |
MikamiUitOpen | 8:8a55f2e374da | 69 | |
MikamiUitOpen | 8:8a55f2e374da | 70 | // Test of left-, cenrer-, right-justified |
MikamiUitOpen | 8:8a55f2e374da | 71 | Label leftJustified(420, 50, "ABC", Label::LEFT); |
MikamiUitOpen | 8:8a55f2e374da | 72 | Label centerJustified(420, 60, "ABC", Label::CENTER); |
MikamiUitOpen | 8:8a55f2e374da | 73 | Label rightJustified1(420, 70, "ABC", Label::RIGHT); |
MikamiUitOpen | 0:629ff18592b9 | 74 | |
MikamiUitOpen | 0:629ff18592b9 | 75 | timer.attach(&TimerIsr, 0.1f); |
MikamiUitOpen | 0:629ff18592b9 | 76 | |
MikamiUitOpen | 0:629ff18592b9 | 77 | while (true) |
MikamiUitOpen | 0:629ff18592b9 | 78 | { |
MikamiUitOpen | 0:629ff18592b9 | 79 | if (button1.Touched()) button2.Draw(); |
MikamiUitOpen | 0:629ff18592b9 | 80 | if (button2.Touched()) button1.Draw(); |
MikamiUitOpen | 0:629ff18592b9 | 81 | |
MikamiUitOpen | 0:629ff18592b9 | 82 | int num; |
MikamiUitOpen | 0:629ff18592b9 | 83 | if (bGroup1.GetTouchedNumber(num)) |
MikamiUitOpen | 1:b4bcb6fa2a1d | 84 | bTouch.Draw("Button%d touched", num+1); |
MikamiUitOpen | 7:5788d0406bfd | 85 | if (num == 3) |
MikamiUitOpen | 7:5788d0406bfd | 86 | bGroup2.ActivateAll(); |
MikamiUitOpen | 0:629ff18592b9 | 87 | |
MikamiUitOpen | 1:b4bcb6fa2a1d | 88 | if (bGroup2.GetTouchedNumber(num)) |
MikamiUitOpen | 1:b4bcb6fa2a1d | 89 | switch (num) |
MikamiUitOpen | 0:629ff18592b9 | 90 | { |
MikamiUitOpen | 1:b4bcb6fa2a1d | 91 | case 0: button1.Activate(); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 92 | bGroup1.Activate(1); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 93 | bGroup1.DrawAll(); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 94 | break; |
MikamiUitOpen | 1:b4bcb6fa2a1d | 95 | case 1: button1.Inactivate(); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 96 | bGroup1.Inactivate(1); |
MikamiUitOpen | 1:b4bcb6fa2a1d | 97 | break; |
MikamiUitOpen | 1:b4bcb6fa2a1d | 98 | case 2: for (int n=0; n<4; n++) bGroup1.Erase(n); |
MikamiUitOpen | 8:8a55f2e374da | 99 | for (int n=0; n<2; n++) |
MikamiUitOpen | 8:8a55f2e374da | 100 | { |
MikamiUitOpen | 8:8a55f2e374da | 101 | barV.Draw(n, 0); // reset seekbar |
MikamiUitOpen | 8:8a55f2e374da | 102 | numLabel4[n]->Draw("%4.1f", barV.GetValue(n)); |
MikamiUitOpen | 8:8a55f2e374da | 103 | } |
MikamiUitOpen | 1:b4bcb6fa2a1d | 104 | break; |
MikamiUitOpen | 0:629ff18592b9 | 105 | } |
MikamiUitOpen | 0:629ff18592b9 | 106 | |
MikamiUitOpen | 3:e92615be71c7 | 107 | if (barH.Slide()) |
MikamiUitOpen | 0:629ff18592b9 | 108 | { |
MikamiUitOpen | 3:e92615be71c7 | 109 | numLabel1.Draw("%5.1f", barH.GetValue()); |
MikamiUitOpen | 3:e92615be71c7 | 110 | int8_t x = (int8_t)barH.GetValue(); |
MikamiUitOpen | 0:629ff18592b9 | 111 | numLabel2.Draw("%3d", x); |
MikamiUitOpen | 0:629ff18592b9 | 112 | |
MikamiUitOpen | 3:e92615be71c7 | 113 | numLabel3.Draw("%3d", barH.GetIntValue()); |
MikamiUitOpen | 0:629ff18592b9 | 114 | } |
MikamiUitOpen | 0:629ff18592b9 | 115 | |
MikamiUitOpen | 8:8a55f2e374da | 116 | int sbNum; |
MikamiUitOpen | 8:8a55f2e374da | 117 | if (barV.GetSlidedNumber(sbNum)) |
MikamiUitOpen | 8:8a55f2e374da | 118 | numLabel4[sbNum]->Draw("%4.1f", barV.GetValue(sbNum)); |
MikamiUitOpen | 8:8a55f2e374da | 119 | |
MikamiUitOpen | 1:b4bcb6fa2a1d | 120 | // If "doNotTouch" button touched, trapped into endless loop |
MikamiUitOpen | 1:b4bcb6fa2a1d | 121 | if (doNotTouch.Touched()) |
MikamiUitOpen | 1:b4bcb6fa2a1d | 122 | BlinkLabel warning(250, 200, "You must reset", Label::LEFT, Font16); |
MikamiUitOpen | 3:e92615be71c7 | 123 | |
MikamiUitOpen | 3:e92615be71c7 | 124 | // SeekBar active inactive switching |
MikamiUitOpen | 4:4f73a3054a67 | 125 | if (bGroup3.Touched(0)) |
MikamiUitOpen | 4:4f73a3054a67 | 126 | { |
MikamiUitOpen | 4:4f73a3054a67 | 127 | barH.Activate(); |
MikamiUitOpen | 8:8a55f2e374da | 128 | barV.ActivateAll(); |
MikamiUitOpen | 4:4f73a3054a67 | 129 | } |
MikamiUitOpen | 4:4f73a3054a67 | 130 | if (bGroup3.Touched(1)) |
MikamiUitOpen | 4:4f73a3054a67 | 131 | { |
MikamiUitOpen | 4:4f73a3054a67 | 132 | barH.Inactivate(); |
MikamiUitOpen | 8:8a55f2e374da | 133 | barV.InactivateAll(); |
MikamiUitOpen | 4:4f73a3054a67 | 134 | } |
MikamiUitOpen | 0:629ff18592b9 | 135 | |
MikamiUitOpen | 0:629ff18592b9 | 136 | wait(0.02f); |
MikamiUitOpen | 0:629ff18592b9 | 137 | } |
MikamiUitOpen | 0:629ff18592b9 | 138 | } |
MikamiUitOpen | 8:8a55f2e374da | 139 | |
MikamiUitOpen | 9:666249b332cc | 140 | |
MikamiUitOpen | 9:666249b332cc | 141 |