Class library: Button class and ButtonGroup class for DISCO-F746NG. クラスライブラリ: DISCO-F746NG 用の,Button クラス,ButtonGroup クラス.

Dependents:   F746_SpectralAnalysis_NoPhoto F746_Fourier_series_of_square_wave_01 F746_ButtonGroup_Demo F746_Mandelbrot ... more

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Tue Dec 08 14:19:41 2015 +0000
Parent:
4:543ec60c2814
Child:
6:d268555e2f50
Commit message:
6

Changed in this revision

button.cpp Show annotated file Show diff for this revision Revisions of this file
button.hpp Show annotated file Show diff for this revision Revisions of this file
button_group.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/button.cpp	Sat Dec 05 11:09:29 2015 +0000
+++ b/button.cpp	Tue Dec 08 14:19:41 2015 +0000
@@ -1,7 +1,7 @@
 //-----------------------------------------------------------
 //  Button class
 //
-//  2015/12/05, Copyright (c) 2015 MIKAMI, Naoki
+//  2015/12/08, Copyright (c) 2015 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #include "button.hpp"
@@ -21,12 +21,10 @@
             lcd_.SetBackColor(color);
             lcd_.SetTextColor(textColor);
 
-            sFONT *font = lcd_.GetFont();
-            uint16_t x0 = X_ + (W_ - (font->Width)*(STR_.length()))/2;
-            uint16_t y0 = Y_ + (H_ - font->Height)/2;
-
-            lcd_.DisplayStringAt(x0, y0, (uint8_t *)STR_.c_str(), LEFT_MODE);
-            
+            uint16_t x0 = X_ + (W_ - FONT_WIDTH_*(STR_.length()))/2;
+            uint16_t y0 = Y_ + (H_ - FONT_HEIGHT_)/2 + 1;
+            lcd_.DisplayStringAt(x0, y0, (uint8_t *)STR_.c_str(),
+                                 LEFT_MODE);
             lcd_.SetBackColor(BACK_COLOR_); // recover back color
         }            
     }
--- a/button.hpp	Sat Dec 05 11:09:29 2015 +0000
+++ b/button.hpp	Tue Dec 08 14:19:41 2015 +0000
@@ -1,7 +1,7 @@
 //-----------------------------------------------------------
 //  Button class -- Header
 //
-//  2015/12/05, Copyright (c) 2015 MIKAMI, Naoki
+//  2015/12/08, Copyright (c) 2015 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #ifndef F746_BUTTON_HPP
@@ -24,8 +24,9 @@
                const string str = "", sFONT &fonts = Font12,
                uint32_t textColor = LCD_COLOR_WHITE)
               : lcd_(lcd), ts_(ts), X_(x), Y_(y), W_(width), H_(height),
-                     ORIGINAL_COLOR_(color), BACK_COLOR_(backColor),
-                     STR_(str), FONTS_(&fonts)
+                ORIGINAL_COLOR_(color), BACK_COLOR_(backColor),
+                STR_(str), FONTS_(&fonts), FONT_WIDTH_(fonts.Width),
+                FONT_HEIGHT_(fonts.Height)
         {   Draw(color, textColor); }
 
         // Draw button
@@ -55,10 +56,12 @@
         LCD_DISCO_F746NG &lcd_;
         TS_DISCO_F746NG &ts_;
         const uint16_t X_, Y_, W_, H_;
-        const uint32_t ORIGINAL_COLOR_;          // original color
+        const uint32_t ORIGINAL_COLOR_; // original color
         const uint32_t BACK_COLOR_;     // back color of screen
         const string STR_;
         sFONT *const FONTS_;
+        const uint16_t FONT_WIDTH_;
+        const uint16_t FONT_HEIGHT_;
         
         uint32_t currentColor_;
 
@@ -69,4 +72,3 @@
 }
 #endif  // F746_BUTTON_HPP
 
-
--- a/button_group.cpp	Sat Dec 05 11:09:29 2015 +0000
+++ b/button_group.cpp	Tue Dec 08 14:19:41 2015 +0000
@@ -1,7 +1,7 @@
 //-----------------------------------------------------------
-//  Button group class -- Header
+//  Button group class
 //
-//  2015/12/05, Copyright (c) 2015 MIKAMI, Naoki
+//  2015/12/07, Copyright (c) 2015 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #include "button_group.hpp"
@@ -66,4 +66,3 @@
             return false;
     }
 }
-