programme capteur d'empreinte digital

Dependencies:   F746_GUI mbed

Committer:
MikamiUitOpen
Date:
Thu Apr 21 01:13:45 2016 +0000
Revision:
7:5788d0406bfd
Parent:
6:ea30227e7db0
Child:
8:8a55f2e374da
8

Who changed what in which revision?

UserRevisionLine numberNew 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 4:4f73a3054a67 5 // GuiBase, Button, ButtonGroup, Label, NumericLabel, BlinkLabel, SeekBar
MikamiUitOpen 0:629ff18592b9 6 //
MikamiUitOpen 7:5788d0406bfd 7 // 2016/04/21, 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 3:e92615be71c7 18 NumericLabel<float> obj2(10, 116, 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 6:ea30227e7db0 28 Label obj10(240, 4, "Dome: GUI parts, 2016/04/19", 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 7:5788d0406bfd 36 const string STR1[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Activate"};
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 3:e92615be71c7 41 // Control status of bGroup1
MikamiUitOpen 0:629ff18592b9 42 const string STR2[3] = {"0", "1", "2"};
MikamiUitOpen 0:629ff18592b9 43 ButtonGroup bGroup2(160, 150, 66, 40, 3, STR2, 5, 5, 3);
MikamiUitOpen 7:5788d0406bfd 44 bGroup2.InactivateAll();
MikamiUitOpen 1:b4bcb6fa2a1d 45
MikamiUitOpen 3:e92615be71c7 46 // Switching buttons to control barH active or inactive
MikamiUitOpen 3:e92615be71c7 47 const string STR3[3] = {"ON", "OFF"};
MikamiUitOpen 3:e92615be71c7 48 ButtonGroup bGroup3(10, 150, 66, 40, 2, STR3, 0, 0, 2);
MikamiUitOpen 3:e92615be71c7 49 bGroup3.TouchedColor(0);
MikamiUitOpen 3:e92615be71c7 50
MikamiUitOpen 1:b4bcb6fa2a1d 51 Button doNotTouch(250, 220, 120, 40, "Don't Touch", Font12,
MikamiUitOpen 1:b4bcb6fa2a1d 52 GuiBase::ENUM_TEXT, GuiBase::ENUM_BACK,
MikamiUitOpen 1:b4bcb6fa2a1d 53 LCD_COLOR_DARKGREEN, LCD_COLOR_RED);
MikamiUitOpen 0:629ff18592b9 54
MikamiUitOpen 7:5788d0406bfd 55 // Using default value for argument (Horizontal)
MikamiUitOpen 4:4f73a3054a67 56 SeekBar barH(20, 250, 200, -5, 5, 0, "-5", "", "5");
MikamiUitOpen 4:4f73a3054a67 57 NumericLabel<float> numLabel1(80, 205, "%5.1f", barH.GetValue());
MikamiUitOpen 4:4f73a3054a67 58 NumericLabel<int> numLabel2(130, 205, "%3d", (int)barH.GetValue());
MikamiUitOpen 4:4f73a3054a67 59 NumericLabel<int> numLabel3(160, 205);
MikamiUitOpen 0:629ff18592b9 60
MikamiUitOpen 3:e92615be71c7 61 // SeekBar (vertical)
MikamiUitOpen 3:e92615be71c7 62 SeekBar barV(440, 100, 150, -5, 5, 2, SeekBar::Vertical, LCD_COLOR_GREEN);
MikamiUitOpen 3:e92615be71c7 63 NumericLabel<float> numLabel4(440, 70, "%4.1f", barV.GetValue(), Label::CENTER);
MikamiUitOpen 0:629ff18592b9 64
MikamiUitOpen 0:629ff18592b9 65 timer.attach(&TimerIsr, 0.1f);
MikamiUitOpen 0:629ff18592b9 66
MikamiUitOpen 0:629ff18592b9 67 while (true)
MikamiUitOpen 0:629ff18592b9 68 {
MikamiUitOpen 0:629ff18592b9 69 if (button1.Touched()) button2.Draw();
MikamiUitOpen 0:629ff18592b9 70 if (button2.Touched()) button1.Draw();
MikamiUitOpen 0:629ff18592b9 71
MikamiUitOpen 0:629ff18592b9 72 int num;
MikamiUitOpen 0:629ff18592b9 73 if (bGroup1.GetTouchedNumber(num))
MikamiUitOpen 1:b4bcb6fa2a1d 74 bTouch.Draw("Button%d touched", num+1);
MikamiUitOpen 7:5788d0406bfd 75 if (num == 3)
MikamiUitOpen 7:5788d0406bfd 76 bGroup2.ActivateAll();
MikamiUitOpen 0:629ff18592b9 77
MikamiUitOpen 1:b4bcb6fa2a1d 78 if (bGroup2.GetTouchedNumber(num))
MikamiUitOpen 1:b4bcb6fa2a1d 79 switch (num)
MikamiUitOpen 0:629ff18592b9 80 {
MikamiUitOpen 1:b4bcb6fa2a1d 81 case 0: button1.Activate();
MikamiUitOpen 1:b4bcb6fa2a1d 82 bGroup1.Activate(1);
MikamiUitOpen 1:b4bcb6fa2a1d 83 bGroup1.DrawAll();
MikamiUitOpen 1:b4bcb6fa2a1d 84 break;
MikamiUitOpen 1:b4bcb6fa2a1d 85 case 1: button1.Inactivate();
MikamiUitOpen 1:b4bcb6fa2a1d 86 bGroup1.Inactivate(1);
MikamiUitOpen 1:b4bcb6fa2a1d 87 break;
MikamiUitOpen 1:b4bcb6fa2a1d 88 case 2: for (int n=0; n<4; n++) bGroup1.Erase(n);
MikamiUitOpen 1:b4bcb6fa2a1d 89 break;
MikamiUitOpen 0:629ff18592b9 90 }
MikamiUitOpen 0:629ff18592b9 91
MikamiUitOpen 3:e92615be71c7 92 if (barH.Slide())
MikamiUitOpen 0:629ff18592b9 93 {
MikamiUitOpen 3:e92615be71c7 94 numLabel1.Draw("%5.1f", barH.GetValue());
MikamiUitOpen 3:e92615be71c7 95 int8_t x = (int8_t)barH.GetValue();
MikamiUitOpen 0:629ff18592b9 96 numLabel2.Draw("%3d", x);
MikamiUitOpen 0:629ff18592b9 97
MikamiUitOpen 3:e92615be71c7 98 numLabel3.Draw("%3d", barH.GetIntValue());
MikamiUitOpen 0:629ff18592b9 99 }
MikamiUitOpen 0:629ff18592b9 100
MikamiUitOpen 3:e92615be71c7 101 if (barV.Slide()) { numLabel4.Draw("%4.1f", barV.GetValue()); }
MikamiUitOpen 1:b4bcb6fa2a1d 102
MikamiUitOpen 1:b4bcb6fa2a1d 103 // If "doNotTouch" button touched, trapped into endless loop
MikamiUitOpen 1:b4bcb6fa2a1d 104 if (doNotTouch.Touched())
MikamiUitOpen 1:b4bcb6fa2a1d 105 BlinkLabel warning(250, 200, "You must reset", Label::LEFT, Font16);
MikamiUitOpen 3:e92615be71c7 106
MikamiUitOpen 3:e92615be71c7 107 // SeekBar active inactive switching
MikamiUitOpen 4:4f73a3054a67 108 if (bGroup3.Touched(0))
MikamiUitOpen 4:4f73a3054a67 109 {
MikamiUitOpen 4:4f73a3054a67 110 barH.Activate();
MikamiUitOpen 4:4f73a3054a67 111 barV.Activate();
MikamiUitOpen 4:4f73a3054a67 112 }
MikamiUitOpen 4:4f73a3054a67 113 if (bGroup3.Touched(1))
MikamiUitOpen 4:4f73a3054a67 114 {
MikamiUitOpen 4:4f73a3054a67 115 barH.Inactivate();
MikamiUitOpen 4:4f73a3054a67 116 barV.Inactivate();
MikamiUitOpen 4:4f73a3054a67 117 }
MikamiUitOpen 0:629ff18592b9 118
MikamiUitOpen 0:629ff18592b9 119 wait(0.02f);
MikamiUitOpen 0:629ff18592b9 120 }
MikamiUitOpen 0:629ff18592b9 121 }