Demo program for GuiBase class and its derivertive classes. GuiBase とその派生クラスのデモプログラム. GuiBase, Button, ButtonGroup, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup, NumericUpDown

Dependencies:   F746_GUI mbed

Revision:
1:b4bcb6fa2a1d
Parent:
0:629ff18592b9
Child:
2:b60c218a2432
--- a/main.cpp	Thu Mar 31 07:33:36 2016 +0000
+++ b/main.cpp	Fri Apr 08 09:33:24 2016 +0000
@@ -1,12 +1,14 @@
-//---------------------------------------------------------------------
+//--------------------------------------------------------------------------------
 //  GuiBase とその派生クラスのデモプログラム
 //  Demo program for GuiBase class and its derivertive classes
-//      GuiBase, Button, ButtonGroup, Label, NumericLabel, SeekBar
+//
+//      GuiBase, Button, ButtonGroup, Label, NumericLabel, BlimkButton, SeekBar
 //
-//  2016/03/31, Copyright (c) 2016 MIKAMI, Naoki
-//---------------------------------------------------------------------
+//  2016/04/08, Copyright (c) 2016 MIKAMI, Naoki
+//--------------------------------------------------------------------------------
 
 #include "NumericLabel.hpp"
+#include "BlinkLabel.hpp"
 #include "ButtonGroup.hpp"
 #include "SeekBar.hpp"
 
@@ -23,31 +25,33 @@
 
 int main()
 {
-    Label obj10(240, 4, "Test: GUI parts", Label::CENTER, Font16);
-    Label obj11(240, 20, "Label, NumericLabel, Button, ButtonGroup, SeekBar",
+    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 button1(10, 55, 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);
+    NumericLabel<int> bTouch(234, 108, Label::LEFT, Font16, LCD_COLOR_MAGENTA);
 
     const string STR2[3] = {"0", "1", "2"};
     ButtonGroup bGroup2(160, 150, 66, 40,  3, STR2, 5, 5, 3);
+    
+    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 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);
     
+    // Vertical
     SeekBar bar2(440, 100, 150, -5, 5, 2, SeekBar::Vertical, LCD_COLOR_GREEN);
     NumericLabel<float> numLabel4(440, 70, "%4.1f", bar2.GetValue(), Label::CENTER);
 
@@ -60,18 +64,20 @@
 
         int num;
         if (bGroup1.GetTouchedNumber(num))
-            printf("Button%d touched\r\n", num+1);
+            bTouch.Draw("Button%d touched", num+1);
 
-        if (bGroup2.Touched(0))
+        if (bGroup2.GetTouchedNumber(num))
+        switch (num)
         {
-            button1.Activate();
-            bGroup1.Activate(1);
-        }
-
-        if (bGroup2.Touched(1))
-        {
-            button1.Inactivate();
-            bGroup1.Inactivate(1);
+            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 (bar.Slide())
@@ -84,6 +90,10 @@
         }        
 
         if (bar2.Slide()) { numLabel4.Draw("%4.1f", bar2.GetValue()); }
+        
+        // If "doNotTouch" button touched, trapped into endless loop
+        if (doNotTouch.Touched())
+            BlinkLabel warning(250, 200, "You must reset", Label::LEFT, Font16);
 
         wait(0.02f);
     }