Fabien MOULINNEUF
/
Projet
fini
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2016-04-10
- Revision:
- 3:e92615be71c7
- Parent:
- 2:b60c218a2432
- Child:
- 4:4f73a3054a67
File content as of revision 3:e92615be71c7:
//-------------------------------------------------------------------------------- // GuiBase とその派生クラスのデモプログラム // Demo program for GuiBase class and its derivertive classes // // GuiBase, Button, ButtonGroup, Label, NumericLabel, BlimkButton, SeekBar // // 2016/04/10, Copyright (c) 2016 MIKAMI, Naoki //-------------------------------------------------------------------------------- #include "NumericLabel.hpp" #include "BlinkLabel.hpp" #include "ButtonGroup.hpp" #include "SeekBar.hpp" using namespace Mikami; Ticker timer; NumericLabel<float> obj2(10, 116, Label::LEFT, Font16, LCD_COLOR_YELLOW); void TimerIsr() { static int sec = 0; obj2.Draw("%6.1f [s]", (float)(sec++)/10.0f); } int main() { Label obj10(240, 4, "Dome: GUI parts", Label::CENTER, Font16); Label obj11(240, 24, "Label, NumericLabel, BlinkLabel, Button, ButtonGroup, SeekBar", Label::CENTER); Button button1(10, 50, 50, 40, "1"); Button button2(62, 50, 50, 40, "2"); const int NUMBER_BUTTONS = 4; const string STR1[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Button4"}; ButtonGroup bGroup1(160, 50, 66, 40, NUMBER_BUTTONS, STR1, 5, 5, 3, 1, Font12, LCD_COLOR_WHITE, 0xFF003538, 0xFFB70068, 0xFFFF7FFF); NumericLabel<int> bTouch(234, 108, Label::LEFT, Font16, LCD_COLOR_MAGENTA); // Control status of bGroup1 const string STR2[3] = {"0", "1", "2"}; ButtonGroup bGroup2(160, 150, 66, 40, 3, STR2, 5, 5, 3); // Switching buttons to control barH active or inactive const string STR3[3] = {"ON", "OFF"}; ButtonGroup bGroup3(10, 150, 66, 40, 2, STR3, 0, 0, 2); bGroup3.TouchedColor(0); Button doNotTouch(250, 220, 120, 40, "Don't Touch", Font12, GuiBase::ENUM_TEXT, GuiBase::ENUM_BACK, LCD_COLOR_DARKGREEN, LCD_COLOR_RED); // Using default value for argument (Horisontal) SeekBar barH(20, 240, 200, -5, 5, 0); NumericLabel<float> numLabel1(20, 200, "%5.1f", barH.GetValue()); NumericLabel<int> numLabel2(90, 200, "%3d", (int)barH.GetValue()); NumericLabel<int> numLabel3(120, 200); // SeekBar (vertical) SeekBar barV(440, 100, 150, -5, 5, 2, SeekBar::Vertical, LCD_COLOR_GREEN); NumericLabel<float> numLabel4(440, 70, "%4.1f", barV.GetValue(), Label::CENTER); timer.attach(&TimerIsr, 0.1f); while (true) { if (button1.Touched()) button2.Draw(); if (button2.Touched()) button1.Draw(); int num; if (bGroup1.GetTouchedNumber(num)) bTouch.Draw("Button%d touched", num+1); if (bGroup2.GetTouchedNumber(num)) switch (num) { case 0: button1.Activate(); bGroup1.Activate(1); bGroup1.DrawAll(); break; case 1: button1.Inactivate(); bGroup1.Inactivate(1); break; case 2: for (int n=0; n<4; n++) bGroup1.Erase(n); break; } if (barH.Slide()) { numLabel1.Draw("%5.1f", barH.GetValue()); int8_t x = (int8_t)barH.GetValue(); numLabel2.Draw("%3d", x); numLabel3.Draw("%3d", barH.GetIntValue()); } if (barV.Slide()) { numLabel4.Draw("%4.1f", barV.GetValue()); } // If "doNotTouch" button touched, trapped into endless loop if (doNotTouch.Touched()) BlinkLabel warning(250, 200, "You must reset", Label::LEFT, Font16); // SeekBar active inactive switching if (bGroup3.Touched(0)) barH.Activate(); if (bGroup3.Touched(1)) barH.Inactivate(); wait(0.02f); } }