![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fini
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2016-03-31
- Revision:
- 0:629ff18592b9
- Child:
- 1:b4bcb6fa2a1d
File content as of revision 0:629ff18592b9:
//--------------------------------------------------------------------- // GuiBase とその派生クラスのデモプログラム // Demo program for GuiBase class and its derivertive classes // GuiBase, Button, ButtonGroup, Label, NumericLabel, SeekBar // // 2016/03/31, Copyright (c) 2016 MIKAMI, Naoki //--------------------------------------------------------------------- #include "NumericLabel.hpp" #include "ButtonGroup.hpp" #include "SeekBar.hpp" using namespace Mikami; Ticker timer; NumericLabel<float> obj2(10, 150, 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, "Test: GUI parts", Label::CENTER, Font16); Label obj11(240, 20, "Label, NumericLabel, Button, ButtonGroup, SeekBar", Label::CENTER); Button button1(10, 50, 50, 40, "1"); Button button2(62, 50, 50, 40, "2"); button1.Erase(); wait(0.5f); button1.Draw(); 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); const string STR2[3] = {"0", "1", "2"}; ButtonGroup bGroup2(160, 150, 66, 40, 3, STR2, 5, 5, 3); // 引数にデフォルト値を使う場合(横方向) SeekBar bar(20, 240, 200, -5, 5, 0); NumericLabel<float> numLabel1(20, 200, "%5.1f", bar.GetValue()); NumericLabel<int> numLabel2(90, 200, "%3d", (int)bar.GetValue()); NumericLabel<int> numLabel3(120, 200); SeekBar bar2(440, 100, 150, -5, 5, 2, SeekBar::Vertical, LCD_COLOR_GREEN); NumericLabel<float> numLabel4(440, 70, "%4.1f", bar2.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)) printf("Button%d touched\r\n", num+1); if (bGroup2.Touched(0)) { button1.Activate(); bGroup1.Activate(1); } if (bGroup2.Touched(1)) { button1.Inactivate(); bGroup1.Inactivate(1); } if (bar.Slide()) { numLabel1.Draw("%5.1f", bar.GetValue()); int8_t x = (int8_t)bar.GetValue(); numLabel2.Draw("%3d", x); numLabel3.Draw("%3d", bar.GetIntValue()); } if (bar2.Slide()) { numLabel4.Draw("%4.1f", bar2.GetValue()); } wait(0.02f); } }