From c4b3ee5a76bd1b059778b20159ec5a49792e4b0a Mon Sep 17 00:00:00 2001 From: GOB Date: Wed, 15 Nov 2023 16:16:20 +0900 Subject: [PATCH 1/5] Fixes typo --- README.en.md | 18 +++++++++--------- README.md | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.en.md b/README.en.md index 7953751..362905c 100644 --- a/README.en.md +++ b/README.en.md @@ -29,18 +29,18 @@ lib_deps = https://github.com/GOB52/gob_unifiedButton #include #include -goblib::UnifiedButton unfiedButton; +goblib::UnifiedButton unifiedButton; void setup() { M5.begin(); - unfiedButton.begin(&M5.Display); + unifiedButton.begin(&M5.Display); } void loop() { M5.update(); - unfiedButton.update(); // Must be call after M5.update. (Changed to call after M5.update() since 0.1.0) + unifiedButton.update(); // Must be call after M5.update. (Changed to call after M5.update() since 0.1.0) // M5.BtnX can be used to obtain status if(M5.BtnA.wasHold()) @@ -53,7 +53,7 @@ void loop() } // Drawing Buttons - unfiedButton.draw(); + unifiedButton.draw(); } ``` @@ -79,14 +79,14 @@ getButtonA / getButtonB / getButtonC to get LGFX_Button\*. void setup() { M5.begin(); - unfiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom); + unifiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom); - auto btnA = unfiedButton.getButtonA(); - auto btnB = unfiedButton.getButtonB(); - auto btnC = unfiedButton.getButtonC(); + auto btnA = unifiedButton.getButtonA(); + auto btnB = unifiedButton.getButtonB(); + auto btnC = unifiedButton.getButtonC(); // Re-create buttons with unique shape, color, and text - btnA->initButton(unfiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]"); + btnA->initButton(unifiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]"); ... } ``` diff --git a/README.md b/README.md index 93e9d30..e11c60a 100644 --- a/README.md +++ b/README.md @@ -28,18 +28,18 @@ lib_deps = https://github.com/GOB52/gob_unifiedButton #include #include -goblib::UnifiedButton unfiedButton; +goblib::UnifiedButton unifiedButton; void setup() { M5.begin(); - unfiedButton.begin(&M5.Display); + unifiedButton.begin(&M5.Display); } void loop() { M5.update(); - unfiedButton.update(); // M5.update() の後に呼ぶ事 (0.1.0 から後呼びに変更されました) + unifiedButton.update(); // M5.update() の後に呼ぶ事 (0.1.0 から後呼びに変更されました) // M5.BtnX 経由で同様に状態取得 if(M5.BtnA.wasHold()) @@ -52,7 +52,7 @@ void loop() } // ボタンを描画する - unfiedButton.draw(); + unifiedButton.draw(); } ``` @@ -78,14 +78,14 @@ getButoonA / getButtonB / getButtonC で LGFX_Button\* を取得できます。 void setup() { M5.begin(); - unfiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom); + unifiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom); - auto btnA = unfiedButton.getButtonA(); - auto btnB = unfiedButton.getButtonB(); - auto btnC = unfiedButton.getButtonC(); + auto btnA = unifiedButton.getButtonA(); + auto btnB = unifiedButton.getButtonB(); + auto btnC = unifiedButton.getButtonC(); // 独自形状、色、テキストのボタンを再作成 - btnA->initButton(unfiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]"); + btnA->initButton(unifiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]"); ... } ``` From d124707664f44e801b48808c388274e6e49f4abb Mon Sep 17 00:00:00 2001 From: GOB Date: Sat, 25 Nov 2023 13:12:46 +0900 Subject: [PATCH 2/5] Add font settings --- examples/simple/simple_main.cpp | 5 +++- src/gob_unifiedButton.cpp | 5 ++++ src/gob_unifiedButton.hpp | 45 +++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/examples/simple/simple_main.cpp b/examples/simple/simple_main.cpp index bdcffce..5877253 100644 --- a/examples/simple/simple_main.cpp +++ b/examples/simple/simple_main.cpp @@ -14,6 +14,9 @@ void setup() unifiedButton.begin(&M5.Display); M5.Display.clear(TFT_DARKGREEN); M5_LOGI("gob_unifiedButton %s / %x", GOBLIB_UNIFIED_BUTTON_VERSION_STRING, GOBLIB_UNIFIED_BUTTON_VERSION_VALUE); + + // You can change text font of button. + unifiedButton.setFont(&fonts::Font4); } void loop() @@ -62,6 +65,6 @@ void loop() } } } - + unifiedButton.draw(); } diff --git a/src/gob_unifiedButton.cpp b/src/gob_unifiedButton.cpp index c51d462..00776b4 100644 --- a/src/gob_unifiedButton.cpp +++ b/src/gob_unifiedButton.cpp @@ -16,6 +16,7 @@ void UnifiedButton::begin(LovyanGFX* gfx, const appearance_t app) _gfx = gfx; _appearance = app; _dirty = true; + _font = gfx->getFont(); createButtons(_appearance); } @@ -94,11 +95,15 @@ void UnifiedButton::draw(const bool force) if(!(_appearance & appearance_t::transparent_bottom) && _show && (_dirty || force)) { + auto gfont = _gfx->getFont(); + _gfx->setFont(_font); + _dirty = false; for(int i=0; i<3; ++i) { _btns[i].drawButton(_press_bits & (1<setFont(gfont); } } // diff --git a/src/gob_unifiedButton.hpp b/src/gob_unifiedButton.hpp index 05f6114..28b7d9f 100644 --- a/src/gob_unifiedButton.hpp +++ b/src/gob_unifiedButton.hpp @@ -46,9 +46,6 @@ class UnifiedButton UnifiedButton() {} - //! @brief Gets the target gfx - LovyanGFX* gfx() { return _gfx; } - /*! @brief Initialize @param gfx Target for drawing @@ -56,22 +53,6 @@ class UnifiedButton */ void begin(LovyanGFX* gfx, const appearance_t app = appearance_t::bottom); - /// @name Drawing control - ///@{ - inline void show(const bool b) { _dirty |= _show = b; } //!< @brief Show or hide buttons - inline void show() { show(true); } //!< @brief Show buttons - inline void hide() { show(false); } //!< @brief Hide buttons - ///@} - - /// @cond 0 - [[deprecated("please use show(const bool)")]] - inline void showButtons(const bool b) { show(b); } - [[deprecated("please use show()")]] - inline void showButtons() { show(true); } - [[deprecated("please use hide()")]] - inline void hideButtons() { show(false); } - /// @endcond - /*! @brief Update status @warning Call it after M5.update() @@ -84,6 +65,22 @@ class UnifiedButton */ void draw(const bool force = false); + //! @brief Gets the target gfx + LovyanGFX* gfx() { return _gfx; } + + /// @name Drawing control + ///@{ + inline void show(const bool b) { _dirty |= _show = b; } //!< @brief Show or hide buttons + inline void show() { show(true); } //!< @brief Show buttons + inline void hide() { show(false); } //!< @brief Hide buttons + ///@} + + ///@name Font + ///@{ + const lgfx::IFont* getFont() const { return _font; } //!< @brief Getss the font of the button text + void setFont(const lgfx::IFont* f) { assert(f && "nullptr"); _font = f; } //!< @brief Set font of the button text + ///@} + /*! @brief Change appearance @param app Button appearance @@ -105,6 +102,15 @@ class UnifiedButton LGFX_Button* getButtonB() { return _appearance == appearance_t::custom ? &_btns[1] : nullptr; } //!< @brief Gets the LGFX_Button B LGFX_Button* getButtonC() { return _appearance == appearance_t::custom ? &_btns[2] : nullptr; } //!< @brief Gets the LGFX_Button C ///@} + + /// @cond 0 + [[deprecated("please use show(const bool)")]] + inline void showButtons(const bool b) { show(b); } + [[deprecated("please use show()")]] + inline void showButtons() { show(true); } + [[deprecated("please use hide()")]] + inline void hideButtons() { show(false); } + /// @endcond private: void createButtons(const appearance_t app); @@ -115,6 +121,7 @@ class UnifiedButton bool _dirty{}, _show{true};; appearance_t _appearance{appearance_t::bottom}; m5::board_t _board{m5::board_t::board_unknown}; + const lgfx::IFont* _font{}; }; // } From 462b75dfa9ec8fd9de6e19b56af519fc3b6b4c54 Mon Sep 17 00:00:00 2001 From: GOB Date: Sat, 25 Nov 2023 13:59:17 +0900 Subject: [PATCH 3/5] Change document defaults to English --- README.en.md | 96 -------------------------------------------------- README.ja.md | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 73 ++++++++++++++++++++------------------ 3 files changed, 137 insertions(+), 130 deletions(-) delete mode 100644 README.en.md create mode 100644 README.ja.md diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 362905c..0000000 --- a/README.en.md +++ /dev/null @@ -1,96 +0,0 @@ -# gob_unifiedButton - -[日本語](README.md) - -## Overview -This library adds touch buttons on CoreS3, which does not have physical buttons or touch buttons, and enables the user to acquire the status via M5.BtnX. -Please use this as an interim feature until a similar feature is added to [M5Unified](https://github.com/m5stack/M5Unified) in the future. -It is also useful for those who are making a common source for Basic, Gray, and Core2, as it does not process anything other than CoreS3. - -## Required libraries -* [M5Unified](https://github.com/m5stack/M5Unified) -* [M5GFX](https://github.com/m5stack/M5GFX) - -**M5Unified is assumed, so it cannot be applied to those using M5Core3.h.** - -## How to install -Install in an appropriate way depending on your environment. -* git clone or download zip, and extract into place -* platformio.ini -```ini -lib_deps = https://github.com/GOB52/gob_unifiedButton -``` -* Use library manager on ArduinoIDE - - -## How to use - -```cpp -#include -#include - -goblib::UnifiedButton unifiedButton; - -void setup() -{ - M5.begin(); - unifiedButton.begin(&M5.Display); -} - -void loop() -{ - M5.update(); - unifiedButton.update(); // Must be call after M5.update. (Changed to call after M5.update() since 0.1.0) - - // M5.BtnX can be used to obtain status - if(M5.BtnA.wasHold()) - { - // ... - } - else if(M5.BtnA.wasClicked()) - { - // ... - } - - // Drawing Buttons - unifiedButton.draw(); -} -``` - -## Appearance changes -You can specify it with begin or change it with changeAppearance. - -|Argument goblib::UnifiedButton::appearance\_t|Description| -|---|---| -|bottom| Display buttons at the bottom of the screen (default)| -|top|Display buttons at the top of the screen| -|custom|Customize your own buttons| -|transparent\_bottom|Transparent buttons on the bottom of the screen| -|transparent\_top|Transparent buttons on the top of the screen| -|transparent_all|Transparent buttons are placed on the entire screen (three vertical sections)| - - -## Customize Buttons -If after specifying goblib::UnifiedButton::appearance\_t::custom, -getButtonA / getButtonB / getButtonC to get LGFX_Button\*. - -```cpp - -void setup() -{ - M5.begin(); - unifiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom); - - auto btnA = unifiedButton.getButtonA(); - auto btnB = unifiedButton.getButtonB(); - auto btnC = unifiedButton.getButtonC(); - - // Re-create buttons with unique shape, color, and text - btnA->initButton(unifiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]"); - ... -} -``` - -## Document -Can be created from a [configuration file](doc/Doxyfile) and [shell script](doc/doxy.sh) for [Doxygen](https://www.doxygen.nl/). - diff --git a/README.ja.md b/README.ja.md new file mode 100644 index 0000000..cdca388 --- /dev/null +++ b/README.ja.md @@ -0,0 +1,98 @@ +# gob_unifiedButton + +![gob_unifiedButton](https://github.com/GOB52/gob_unifiedButton/assets/26270227/590cde0d-f4b6-4fe6-8cae-e25d27b32f8b) + +[English](README.md) + +## 概要 +物理ボタン、タッチボタンを持たない CoreS3 上にタッチボタンを追加し、 M5.BtnX 経由で状態を取得できるようにしたライブラリです。 +将来的に [M5Unified](https://github.com/m5stack/M5Unified) に同様の機能がつくまでの暫定としてお使いください。 +CoreS3 以外では処理をしないので、Basic, Gray, Core2 と共通のソースで作っている方にも有用です。 + +## 必要なもの +* [M5Unified](https://github.com/m5stack/M5Unified) +* [M5GFX](https://github.com/m5stack/M5GFX) + +**M5Unified 前提ですので、 M5Core3.h を使用した物には適用できません。** + +## 導入 +環境によって適切な方法でインストールしてください +* git clone や Zip ダウンロードからの展開 +* platformio.ini +```ini +lib_deps = lib_deps = gob/gob_unifiedButton +``` +* ArduinoIDE ライブラリマネージャからのインストール + +## 使い方 +```cpp +#include +#include + +goblib::UnifiedButton unifiedButton; + +void setup() +{ + M5.begin(); + unifiedButton.begin(&M5.Display); +} + +void loop() +{ + M5.update(); + unifiedButton.update(); // M5.update() の後に呼ぶ事 (0.1.0 から後呼びに変更されました) + + // M5.BtnX 経由で同様に状態取得 + if(M5.BtnA.wasHold()) + { + // ... + } + else if(M5.BtnA.wasClicked()) + { + // ... + } + + // ボタンを描画する + unifiedButton.draw(); +} +``` + +## ボタンのテキストフォント変更 +M5GFX で使用できるフォントを設定できます。 +```cpp + unifiedButton.setFont(&fonts::Font4); +``` + +## 外観変更 +begin で指定、または changeAppearance で変更できます。 + +|引数 goblib::UnifiedButton::appearance\_t|外観| +|---|---| +|bottom| 画面下側にボタンを表示 (default)| +|top|画面上側にボタンを表示| +|custom|独自にボタンをカスタマイズ(下記参照)| +|transparent\_bottom|bottom と同様の位置に透明ボタンを配置| +|transparent\_top|top と同様の位置に透明ボタンを配置| +|transparent_all|画面全体に透明ボタンを配置(縦3分割)| + +## ボタンのカスタマイズ +goblib::UnifiedButton::appearance\_t::custom を指定した後であれば、 +getButoonA / getButtonB / getButtonC で LGFX_Button\* を取得できます。 +```cpp +void setup() +{ + M5.begin(); + unifiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom); + + auto btnA = unifiedButton.getButtonA(); + auto btnB = unifiedButton.getButtonB(); + auto btnC = unifiedButton.getButtonC(); + + // 独自形状、色、テキストのボタンを再作成 + btnA->initButton(unifiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]"); + ... +} +``` + +## ドキュメント +[Doxygen](https://www.doxygen.nl/) 用の[設定ファイル](doc/Doxyfile)と[シェルスクリプト](doc/doxy.sh)で作成できます。 diff --git a/README.md b/README.md index e11c60a..edeb8f0 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,30 @@ # gob_unifiedButton -[English](README.en.md) +[日本語](https://github.com/GOB52/gob_unifiedButton/blob/master/README.ja.md) -## 概要 -物理ボタン、タッチボタンを持たない CoreS3 上にタッチボタンを追加し、 M5.BtnX 経由で状態を取得できるようにしたライブラリです。 -将来的に [M5Unified](https://github.com/m5stack/M5Unified) に同様の機能がつくまでの暫定としてお使いください。 -CoreS3 以外では処理をしないので、Basic, Gray, Core2 と共通のソースで作っている方にも有用です。 +![gob_unifiedButton](https://github.com/GOB52/gob_unifiedButton/assets/26270227/590cde0d-f4b6-4fe6-8cae-e25d27b32f8b) -## 必要なもの +## Overview +This library adds touch buttons on CoreS3, which does not have physical buttons or touch buttons, and enables the user to acquire the status via M5.BtnX. +Please use this as an interim feature until a similar feature is added to [M5Unified](https://github.com/m5stack/M5Unified) in the future. +It is also useful for those who are making a common source for Basic, Gray, and Core2, as it does not process anything other than CoreS3. + +## Required libraries * [M5Unified](https://github.com/m5stack/M5Unified) * [M5GFX](https://github.com/m5stack/M5GFX) -**M5Unified 前提ですので、 M5Core3.h を使用した物には適用できません。** +**M5Unified is assumed, so it cannot be applied to those using M5Core3.h.** -## 導入 -環境によって適切な方法でインストールしてください -* git clone や Zip ダウンロードからの展開 +## How to install +Install in an appropriate way depending on your environment. +* git clone or download zip, and extract into place * platformio.ini ```ini -lib_deps = https://github.com/GOB52/gob_unifiedButton +lib_deps = gob/gob_unifiedButton ``` -* ArduinoIDE ライブラリマネージャからのインストール - -## 使い方 +* Use library manager on ArduinoIDE +## How to use ```cpp #include #include @@ -39,9 +40,9 @@ void setup() void loop() { M5.update(); - unifiedButton.update(); // M5.update() の後に呼ぶ事 (0.1.0 から後呼びに変更されました) + unifiedButton.update(); // Must be call after M5.update. (Changed to call after M5.update() since 0.1.0) - // M5.BtnX 経由で同様に状態取得 + // M5.BtnX can be used to obtain status if(M5.BtnA.wasHold()) { // ... @@ -51,30 +52,33 @@ void loop() // ... } - // ボタンを描画する + // Drawing Buttons unifiedButton.draw(); } ``` +## Button text font changes +You can configure which fonts can be used with M5GFX. +```cpp + unifiedButton.setFont(&fonts::Font4); +``` -## 外観変更 - -begin で指定、または changeAppearance で変更できます。 +## Appearance changes +You can specify it with begin or change it with changeAppearance. -|引数 goblib::UnifiedButton::appearance\_t|外観| +|Argument goblib::UnifiedButton::appearance\_t|Description| |---|---| -|bottom| 画面下側にボタンを表示 (default)| -|top|画面上側にボタンを表示| -|custom|独自にボタンをカスタマイズ(下記参照)| -|transparent\_bottom|bottom と同様の位置に透明ボタンを配置| -|transparent\_top|top と同様の位置に透明ボタンを配置| -|transparent_all|画面全体に透明ボタンを配置(縦3分割)| +|bottom| Display buttons at the bottom of the screen (default)| +|top|Display buttons at the top of the screen| +|custom|Customize your own buttons| +|transparent\_bottom|Transparent buttons on the bottom of the screen| +|transparent\_top|Transparent buttons on the top of the screen| +|transparent_all|Transparent buttons are placed on the entire screen (three vertical sections)| -## ボタンのカスタマイズ +## Customize Buttons +If after specifying goblib::UnifiedButton::appearance\_t::custom, +getButtonA / getButtonB / getButtonC to get LGFX_Button\*. -goblib::UnifiedButton::appearance\_t::custom を指定した後であれば、 -getButoonA / getButtonB / getButtonC で LGFX_Button\* を取得できます。 ```cpp - void setup() { M5.begin(); @@ -84,11 +88,12 @@ void setup() auto btnB = unifiedButton.getButtonB(); auto btnC = unifiedButton.getButtonC(); - // 独自形状、色、テキストのボタンを再作成 + // Re-create buttons with unique shape, color, and text btnA->initButton(unifiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]"); ... } ``` -## ドキュメント -[Doxygen](https://www.doxygen.nl/) 用の[設定ファイル](doc/Doxyfile)と[シェルスクリプト](doc/doxy.sh)で作成できます。 +## Document +Can be created from a [configuration file](doc/Doxyfile) and [shell script](doc/doxy.sh) for [Doxygen](https://www.doxygen.nl/). + From fbdc6954a23fff90e0581babfab1283d865c6b1a Mon Sep 17 00:00:00 2001 From: GOB Date: Sat, 25 Nov 2023 14:00:22 +0900 Subject: [PATCH 4/5] Raise version to 0.1.1 --- library.json | 10 ++-------- library.properties | 2 +- src/gob_unifiedButton_version.hpp | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/library.json b/library.json index 57f35b6..5e28b2d 100644 --- a/library.json +++ b/library.json @@ -11,18 +11,12 @@ "type": "git", "url": "https://github.com/GOB52/gob_unifiedButton.git" }, - "version": "0.1.0", - "build": { - "libArchive": false - }, + "version": "0.1.1", "headers": "gob_unifiedButton.hpp", "license": "MIT", "platforms": "espressif32", "frameworks": "arduino", "dependencies": { "m5stack/M5Unified": "^0.1.10" - }, - "export": { - "include" : [ ".gitignore", "README.en.md", "platformio.ini", "src", "examples", "doc/Doxyfile", "doc/doxy.sh" ] } -} +} \ No newline at end of file diff --git a/library.properties b/library.properties index e9920c8..11231ed 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=gob_unifiedButton -version=0.1.0 +version=0.1.1 author=GOB maintainer=GOB sentence=Add touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX) diff --git a/src/gob_unifiedButton_version.hpp b/src/gob_unifiedButton_version.hpp index 227eaf6..1bb72bc 100644 --- a/src/gob_unifiedButton_version.hpp +++ b/src/gob_unifiedButton_version.hpp @@ -3,7 +3,7 @@ #define GOBLIB_UNIFIED_BUTTON_VERSION_MAJOR 0 #define GOBLIB_UNIFIED_BUTTON_VERSION_MINOR 1 -#define GOBLIB_UNIFIED_BUTTON_VERSION_PATCH 0 +#define GOBLIB_UNIFIED_BUTTON_VERSION_PATCH 1 #define GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY_AGAIN(x) #x #define GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY(x) GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY_AGAIN(x) From 694852f48d17f2cf8b9b4afbd6f442fd0ec9504a Mon Sep 17 00:00:00 2001 From: GOB Date: Sat, 25 Nov 2023 14:01:43 +0900 Subject: [PATCH 5/5] Fixes typo --- README.ja.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.ja.md b/README.ja.md index cdca388..826fd7b 100644 --- a/README.ja.md +++ b/README.ja.md @@ -20,7 +20,7 @@ CoreS3 以外では処理をしないので、Basic, Gray, Core2 と共通のソ * git clone や Zip ダウンロードからの展開 * platformio.ini ```ini -lib_deps = lib_deps = gob/gob_unifiedButton +lib_deps = gob/gob_unifiedButton ``` * ArduinoIDE ライブラリマネージャからのインストール