CQエレクトロニクス・セミナ「実習・マイコンを動かしながら学ぶディジタル・フィルタ」で使うプログラム.1次IIRフィルタの係数をターミナルから変更できる. http://seminar.cqpub.co.jp/ccm/ES18-0020

Dependencies:   mbed Array_Matrix BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG

Revision:
0:47718d3154d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F746_Gui_New/Label.cpp	Mon Oct 09 02:36:11 2017 +0000
@@ -0,0 +1,50 @@
+//-----------------------------------------------------------
+//  Label class
+//
+//  2016/04/24, Copyright (c) 2016 MIKAMI, Naoki
+//-----------------------------------------------------------
+
+#include "Label.hpp"
+
+namespace Mikami
+{
+    // Constructor
+    Label::Label(uint16_t x, uint16_t y,
+                 const string str, TextAlignMode mode, sFONT &fonts,
+                 uint32_t textColor, uint32_t backColor)
+        : GuiBase(x, y, fonts, textColor, backColor),
+          MODE_(mode), STR_(str)
+    {
+        length_ = str.length();
+        lcd_.SetBackColor(backColor);
+        lcd_.SetTextColor(textColor);
+        lcd_.SetFont(&fonts);
+        DrawString(PosX(x), y, str);
+    }
+
+    void Label::Draw(const string str, uint32_t textColor)
+    {
+        // Erase previously-drawn string
+        lcd_.SetTextColor(BACK_COLOR_);
+        length_ = (length_ > str.length()) ? length_ : str.length();
+        lcd_.FillRect(PosX(X_), Y_, FONTS_->Width*length_+1, FONTS_->Height);
+
+        // Draw new string
+        length_ = str.length();
+        lcd_.SetFont(FONTS_);
+        lcd_.SetTextColor(textColor);
+        DrawString(PosX(X_), Y_, str);
+    }
+
+    uint16_t Label::PosX(uint16_t x)
+    {
+        if (MODE_ == LEFT) return x;
+        else
+        {
+            if (MODE_ == CENTER)
+                return x - length_*FONTS_->Width/2;
+            else
+                return x - length_*FONTS_->Width;
+        }
+    }
+}