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: Array_Matrix BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
Fork of F746_GUI by
Revision 24:6dcf9676d0c5, committed 2016-11-06
- Comitter:
- MikamiUitOpen
- Date:
- Sun Nov 06 13:02:29 2016 +0000
- Parent:
- 23:2078556088a6
- Child:
- 25:d1acf9d53f98
- Commit message:
- 25
Changed in this revision
| NumericLabel.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/NumericLabel.hpp Sun Oct 02 07:25:06 2016 +0000
+++ b/NumericLabel.hpp Sun Nov 06 13:02:29 2016 +0000
@@ -1,7 +1,7 @@
//-----------------------------------------------------------
// NumericLabel class -- derived class of Label class
//
-// 2016/04/12, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/11/06, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------
#ifndef F746_NUMERIC_LABEL_HPP
@@ -16,11 +16,12 @@
public:
// Constructor without drawing value
NumericLabel(uint16_t x, uint16_t y,
+ const char fmt[],
TextAlignMode mode = LEFT,
sFONT &fonts = Font12,
uint32_t textColor = GuiBase::ENUM_TEXT,
uint32_t backColor = GuiBase::ENUM_BACK)
- : Label(x, y, "", mode, fonts, textColor, backColor) {}
+ : Label(x, y, "", mode, fonts, textColor, backColor), FMT_(fmt) {}
// Constructor with drawing value
NumericLabel(uint16_t x, uint16_t y,
@@ -29,8 +30,15 @@
sFONT &fonts = Font12,
uint32_t textColor = GuiBase::ENUM_TEXT,
uint32_t backColor = GuiBase::ENUM_BACK)
- : Label(x, y, "", mode, fonts, textColor, backColor)
- { Draw(fmt, val); }
+ : Label(x, y, "", mode, fonts, textColor, backColor), FMT_(fmt)
+ { Draw(val); }
+
+ // Draw value using format specified in constructor
+ void Draw(T val)
+ {
+ sprintf(str_, FMT_, val);
+ Label::Draw(str_);
+ }
// Draw value
void Draw(const char fmt[], T val)
@@ -44,6 +52,7 @@
{ Label::Draw(str_, color); }
private:
+ const char *const FMT_;
char str_[81];
// disallow copy constructor and assignment operator
@@ -52,3 +61,4 @@
};
}
#endif // F746_NUMERIC_LABEL_HPP
+
