Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 8:8a55f2e374da
- Parent:
- 7:5788d0406bfd
- Child:
- 9:666249b332cc
diff -r 5788d0406bfd -r 8a55f2e374da main.cpp
--- a/main.cpp Thu Apr 21 01:13:45 2016 +0000
+++ b/main.cpp Sun Apr 24 11:52:19 2016 +0000
@@ -2,15 +2,16 @@
// GuiBase とその派生クラスのデモプログラム
// Demo program for GuiBase class and its derivertive classes
//
-// GuiBase, Button, ButtonGroup, Label, NumericLabel, BlinkLabel, SeekBar
+// GuiBase, Button, ButtonGroup, Label, NumericLabel, BlinkLabel,
+// SeekBar, SeekbarGroup
//
-// 2016/04/21, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki
//--------------------------------------------------------------------------------
#include "NumericLabel.hpp"
#include "BlinkLabel.hpp"
#include "ButtonGroup.hpp"
-#include "SeekBar.hpp"
+#include "SeekBarGroup.hpp"
using namespace Mikami;
@@ -25,7 +26,7 @@
int main()
{
- Label obj10(240, 4, "Dome: GUI parts, 2016/04/19", Label::CENTER, Font16);
+ Label obj10(240, 4, "Dome: GUI parts, 2016/04/24", Label::CENTER, Font16);
Label obj11(240, 24, "Label, NumericLabel, BlinkLabel, Button, ButtonGroup, SeekBar",
Label::CENTER);
@@ -36,7 +37,7 @@
const string STR1[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Activate"};
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);
+ NumericLabel<int> bTouch(240, 108, Label::LEFT, Font12, LCD_COLOR_MAGENTA);
// Control status of bGroup1
const string STR2[3] = {"0", "1", "2"};
@@ -58,9 +59,18 @@
NumericLabel<int> numLabel2(130, 205, "%3d", (int)barH.GetValue());
NumericLabel<int> numLabel3(160, 205);
- // 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);
+ // SeekbarGroup (vertical)
+ SeekbarGroup barV(400, 120, 130, 2, 50, -5, 5, 2,
+ SeekBar::Vertical, LCD_COLOR_GREEN);
+ NumericLabel<float> **numLabel4;
+ numLabel4 = new NumericLabel<float> *[2];
+ for (int n=0; n<2; n++) numLabel4[n] =
+ new NumericLabel<float>(400+n*50, 90, "%4.1f", barV.GetValue(n), Label::CENTER);
+
+ // Test of left-, cenrer-, right-justified
+ Label leftJustified(420, 50, "ABC", Label::LEFT);
+ Label centerJustified(420, 60, "ABC", Label::CENTER);
+ Label rightJustified1(420, 70, "ABC", Label::RIGHT);
timer.attach(&TimerIsr, 0.1f);
@@ -86,6 +96,11 @@
bGroup1.Inactivate(1);
break;
case 2: for (int n=0; n<4; n++) bGroup1.Erase(n);
+ for (int n=0; n<2; n++)
+ {
+ barV.Draw(n, 0); // reset seekbar
+ numLabel4[n]->Draw("%4.1f", barV.GetValue(n));
+ }
break;
}
@@ -98,8 +113,10 @@
numLabel3.Draw("%3d", barH.GetIntValue());
}
- if (barV.Slide()) { numLabel4.Draw("%4.1f", barV.GetValue()); }
-
+ int sbNum;
+ if (barV.GetSlidedNumber(sbNum))
+ numLabel4[sbNum]->Draw("%4.1f", barV.GetValue(sbNum));
+
// If "doNotTouch" button touched, trapped into endless loop
if (doNotTouch.Touched())
BlinkLabel warning(250, 200, "You must reset", Label::LEFT, Font16);
@@ -108,14 +125,15 @@
if (bGroup3.Touched(0))
{
barH.Activate();
- barV.Activate();
+ barV.ActivateAll();
}
if (bGroup3.Touched(1))
{
barH.Inactivate();
- barV.Inactivate();
+ barV.InactivateAll();
}
wait(0.02f);
}
}
+