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 TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG
NumericLabel.hpp
00001 //----------------------------------------------------------- 00002 // NumericLabel class -- derived class of Label class 00003 // 00004 // 2016/11/07, Copyright (c) 2016 MIKAMI, Naoki 00005 //----------------------------------------------------------- 00006 00007 #ifndef F746_NUMERIC_LABEL_HPP 00008 #define F746_NUMERIC_LABEL_HPP 00009 00010 #include "Label.hpp" 00011 00012 namespace Mikami 00013 { 00014 template <typename T> class NumericLabel : public Label 00015 { 00016 public: 00017 // Constructor without drawing value 00018 NumericLabel(uint16_t x, uint16_t y, 00019 const char fmt[], 00020 TextAlignMode mode = LEFT, 00021 sFONT &fonts = Font12, 00022 uint32_t textColor = GuiBase::ENUM_TEXT, 00023 uint32_t backColor = GuiBase::ENUM_BACK) 00024 : Label(x, y, "", mode, fonts, textColor, backColor), FMT_(fmt) {} 00025 00026 // Constructor with drawing value 00027 NumericLabel(uint16_t x, uint16_t y, 00028 const char fmt[], T val, 00029 TextAlignMode mode = LEFT, 00030 sFONT &fonts = Font12, 00031 uint32_t textColor = GuiBase::ENUM_TEXT, 00032 uint32_t backColor = GuiBase::ENUM_BACK) 00033 : Label(x, y, "", mode, fonts, textColor, backColor), FMT_(fmt) 00034 { Draw(val); } 00035 00036 // Draw value using format specified in constructor 00037 void Draw(T val) 00038 { 00039 sprintf(str_, FMT_, val); 00040 Label::Draw(str_); 00041 } 00042 00043 // Draw value 00044 void Draw(const char fmt[], T val) 00045 { 00046 sprintf(str_, fmt, val); 00047 Label::Draw(str_); 00048 } 00049 00050 // Draw previous value with specified color 00051 void Redraw(uint32_t color) 00052 { Label::Draw(str_, color); } 00053 00054 private: 00055 const char *const FMT_; 00056 char str_[81]; 00057 00058 // disallow copy constructor and assignment operator 00059 NumericLabel(const NumericLabel&); 00060 NumericLabel& operator=(const NumericLabel&); 00061 }; 00062 } 00063 #endif // F746_NUMERIC_LABEL_HPP 00064
Generated on Thu Jul 14 2022 07:59:59 by
