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.
Dependencies: F746_GUI_vV mbed Vision_Indus_IHM
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2016-04-30
- Revision:
- 11:0195d802ab3d
- Parent:
- 10:f23cca92f446
- Child:
- 12:262492b42b04
File content as of revision 11:0195d802ab3d:
//--------------------------------------------------------------------------------
// GuiBase とその派生クラスのデモプログラム
// Demo program for GuiBase class and its derivertive classes
//
// GuiBase, Button, ButtonGroup, Label, NumericLabel, BlinkLabel,
// SeekBar, SeekbarGroup
//
// 2016/04/30, Copyright (c) 2016 MIKAMI, Naoki
//--------------------------------------------------------------------------------
#include "NumericLabel.hpp"
#include "BlinkLabel.hpp"
#include "ButtonGroup.hpp"
#include "SeekbarGroup.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, 2, "Dome: GUI parts, 2016/04/30, 15:31", Label::CENTER, Font16);
Label obj11(240, 20, "Button, ButtonGroup, Label, NumericLabel, BlinkLabel,",
Label::CENTER);
Label obj12(240, 32, "SeekBar, SeekbarGroup",
Label::CENTER);
Button button1(10, 52, 50, 40, "1");
Button button2(62, 52, 50, 40, "2");
const int NUMBER_BUTTONS = 4;
const string STR1[NUMBER_BUTTONS] = {"Button1", "Button2", "Button3", "Activate"};
ButtonGroup bGroup1(160, 52, 66, 40, NUMBER_BUTTONS, STR1, 5, 5, 3, 1,
Font12, LCD_COLOR_WHITE, 0xFF003538, 0xFFB70068, 0xFFFF7FFF);
NumericLabel<int> bTouch(240, 112, Label::LEFT, Font12, 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);
bGroup2.InactivateAll();
// 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 (Horizontal)
SeekBar barH(20, 250, 200, -5, 5, 0, "-5", "", "5");
NumericLabel<float> numLabel1(80, 205, "%5.1f", barH.GetValue());
NumericLabel<int> numLabel2(130, 205, "%3d", (int)barH.GetValue());
NumericLabel<int> numLabel3(160, 205);
// SeekbarGroup (vertical)
SeekbarGroup barV(400, 120, 130, 2, 50, -5, 5, 2,
SeekBar::Vertical, 0xFFA0FFC0);
NumericLabel<float> **numLabel4;
numLabel4 = new NumericLabel<float> *[2];
for (int n=0; n<2; n++) numLabel4[n] =
new NumericLabel<float>(400+n*50, 94, "%4.1f", barV.GetValue(n), Label::CENTER);
// Test of left-, cenrer-, right-justified
Label leftJustified(420, 52, "ABC", Label::LEFT);
Label centerJustified(420, 62, "ABC", Label::CENTER);
Label rightJustified1(420, 72, "ABC", Label::RIGHT);
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 (num == 3)
bGroup2.ActivateAll();
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);
for (int n=0; n<2; n++)
{
barV.Draw(n, 0); // reset seekbar
numLabel4[n]->Draw("%4.1f", barV.GetValue(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());
}
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);
// SeekBar active inactive switching
if (bGroup3.Touched(0))
{
barH.Activate();
barV.ActivateAll();
}
if (bGroup3.Touched(1))
{
barH.Inactivate();
barV.InactivateAll();
}
wait(0.02f);
}
}