Skip to content

Commit cab9f4e

Browse files
committed
Merge branch 'develop'
2 parents bf1a4be + b972b88 commit cab9f4e

File tree

8 files changed

+61
-46
lines changed

8 files changed

+61
-46
lines changed

.gitignore

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,21 @@
3131
*.out
3232
*.app
3333

34-
# PlatformIO
35-
.pio
36-
.vscode/.browse.c_cpp.db*
37-
.vscode/c_cpp_properties.json
38-
.vscode/launch.json
39-
.vscode/ipch
34+
# Executables
35+
*.exe
36+
*.out
37+
*.app
38+
39+
#pio
40+
/.pio/
41+
42+
#VsCode
43+
/.vscode/
44+
45+
# Doxygen
46+
/html
47+
48+
#
49+
debug.cfg
50+
debug_custom.json
51+
*.svd

README.ja.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,27 @@ begin で指定、または changeAppearance で変更できます。
7070
|---|---|
7171
|bottom| 画面下側にボタンを表示 (default)|
7272
|top|画面上側にボタンを表示|
73-
|custom|独自にボタンをカスタマイズ(下記参照)|
7473
|transparent\_bottom|bottom と同様の位置に透明ボタンを配置|
7574
|transparent\_top|top と同様の位置に透明ボタンを配置|
7675
|transparent_all|画面全体に透明ボタンを配置(縦3分割)|
7776

7877
## ボタンのカスタマイズ
79-
goblib::UnifiedButton::appearance\_t::custom を指定した後であれば、
80-
getButoonA / getButtonB / getButtonC で LGFX_Button\* を取得できます。
78+
LGFX_Button\* を取得できます。
8179
```cpp
8280
void setup()
8381
{
8482
M5.begin();
85-
unifiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom);
83+
unifiedButton.begin(&M5.Display);
8684

8785
auto btnA = unifiedButton.getButtonA();
88-
auto btnB = unifiedButton.getButtonB();
89-
auto btnC = unifiedButton.getButtonC();
90-
9186
// 独自形状、色、テキストのボタンを再作成
9287
btnA->initButton(unifiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]");
93-
...
88+
// ラベル変更
89+
btnA->setLabelText("Own");
9490
}
9591
```
92+
LGFX_Button については[こちら](https://github.com/m5stack/M5GFX/blob/master/src/lgfx/v1/LGFX_Button.hpp)を参照してください。
93+
9694

9795
## ドキュメント
9896
[Doxygen](https://www.doxygen.nl/) 用の[設定ファイル](doc/Doxyfile)[シェルスクリプト](doc/doxy.sh)で作成できます。

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,25 @@ You can specify it with begin or change it with changeAppearance.
6969
|---|---|
7070
|bottom| Display buttons at the bottom of the screen (default)|
7171
|top|Display buttons at the top of the screen|
72-
|custom|Customize your own buttons|
7372
|transparent\_bottom|Transparent buttons on the bottom of the screen|
7473
|transparent\_top|Transparent buttons on the top of the screen|
7574
|transparent_all|Transparent buttons are placed on the entire screen (three vertical sections)|
7675

7776
## Customize Buttons
78-
If after specifying goblib::UnifiedButton::appearance\_t::custom,
79-
getButtonA / getButtonB / getButtonC to get LGFX_Button\*.
77+
You can get LGFX_Button\*.
8078

8179
```cpp
8280
void setup()
8381
{
8482
M5.begin();
85-
unifiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom);
83+
unifiedButton.begin(&M5.Display);
8684

8785
auto btnA = unifiedButton.getButtonA();
88-
auto btnB = unifiedButton.getButtonB();
89-
auto btnC = unifiedButton.getButtonC();
9086

9187
// Re-create buttons with unique shape, color, and text
9288
btnA->initButton(unifiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]");
93-
...
89+
// Change label text
90+
btnA->setLabelText("Own");
9491
}
9592
```
9693

examples/customButton/customButton_main.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
*/
55
#include <M5Unified.h>
66
#include <gob_unifiedButton.hpp>
7+
#include "esp_random.h"
78

89
goblib::UnifiedButton unifiedButton; // gob_unifiedButton instance
910

1011
void setup()
1112
{
1213
M5.begin();
13-
unifiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom);
14+
unifiedButton.begin(&M5.Display);
1415
M5.Display.clear(TFT_DARKGREEN);
1516

1617
// Customize buttons
@@ -32,33 +33,42 @@ void setup()
3233
btnC->initButtonUL(unifiedButton.gfx(),
3334
M5.Display.width()/2, M5.Display.height()/4, M5.Display.width()/2, M5.Display.height()*3/4,
3435
TFT_CYAN, TFT_MAGENTA, TFT_RED, " CCC", 3.0f, 3.0f);
35-
3636
}
3737

3838
void loop()
3939
{
40+
bool force{};
41+
4042
M5.update();
4143
unifiedButton.update();
4244

43-
// Core/Core2/CoreS3 Can work with common code.
44-
if(M5.BtnA.wasHold())
45-
{
46-
M5_LOGI("A button was hold");
47-
}
48-
else if(M5.BtnA.wasClicked())
45+
auto btnA = unifiedButton.getButtonA();
46+
auto btnB = unifiedButton.getButtonB();
47+
48+
static bool pa{};
49+
bool ba = M5.BtnA.isPressed();
50+
if(pa != ba)
4951
{
50-
M5_LOGI("A button was clicked");
52+
M5_LOGI("A button was changed");
53+
btnA->setLabelText(M5.BtnA.isPressed() ? "Pressed" : "Released");
54+
force = true;
5155
}
56+
pa = ba;
5257

53-
if(M5.BtnB.pressedFor(1000))
58+
if(M5.BtnB.wasClicked())
5459
{
55-
M5_LOGI("B button pressed for 1000 ms");
60+
M5_LOGI("B button was clicked");
61+
uint16_t clr = esp_random() & 0xFFFF;
62+
btnB->setOutlineColor(clr);
63+
btnB->setFillColor(clr ^ 0xFFFF);
64+
btnB->setTextColor(clr ^ 0xFF00);
65+
force = true;
5666
}
5767

5868
if(M5.BtnC.wasReleased())
5969
{
6070
M5_LOGI("C button was released");
6171
}
6272

63-
unifiedButton.draw();
73+
unifiedButton.draw(force /*Force drawing to immediately reflect changes to LGFX_Button if true*/ );
6474
}

library.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"type": "git",
1212
"url": "https://github.com/GOB52/gob_unifiedButton.git"
1313
},
14-
"version": "0.1.1",
14+
"version": "0.1.2",
1515
"headers": "gob_unifiedButton.hpp",
1616
"license": "MIT",
1717
"platforms": "espressif32",
1818
"frameworks": "arduino",
1919
"dependencies": {
20-
"m5stack/M5Unified": "^0.1.10"
20+
"m5stack/M5Unified": "^0.1.13"
2121
}
22-
}
22+
}

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=gob_unifiedButton
2-
version=0.1.1
2+
version=0.1.2
33
author=GOB
44
maintainer=GOB
55
sentence=Add touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX)
@@ -8,4 +8,4 @@ category=Other
88
url=https://github.com/GOB52/gob_unifiedButton.git
99
architectures=esp32,esp32s3
1010
includes=gob_unifiedButton.hpp
11-
depends=M5Unified,M5GFX
11+
depends=M5Unified (>= 0.1.13), M5GFX (>= 0.1.13)

src/gob_unifiedButton.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class UnifiedButton
3838
{
3939
bottom, //!< Display buttons at the bottom of the screen (default)
4040
top, //!< Display buttons at the top of the screen
41-
custom, //!< Customize your own buttons
4241
transparent_bottom = 0x40, //!< Transparent buttons on the bottom of the screen
4342
transparent_top, //!< Transparent buttons on the top of the screen
4443
transparent_all, //!< Transparent buttons are placed on the entire screen (three vertical sections)
@@ -95,15 +94,14 @@ class UnifiedButton
9594
}
9695
}
9796

98-
///@name For customize buttons
99-
///@warning Must be appearance is custom.
97+
///@name Gets the LGFX_Button
10098
///@{
101-
LGFX_Button* getButtonA() { return _appearance == appearance_t::custom ? &_btns[0] : nullptr; } //!< @brief Gets the LGFX_Button A
102-
LGFX_Button* getButtonB() { return _appearance == appearance_t::custom ? &_btns[1] : nullptr; } //!< @brief Gets the LGFX_Button B
103-
LGFX_Button* getButtonC() { return _appearance == appearance_t::custom ? &_btns[2] : nullptr; } //!< @brief Gets the LGFX_Button C
99+
LGFX_Button* getButtonA() { return &_btns[0]; } //!< @brief Gets the button A
100+
LGFX_Button* getButtonB() { return &_btns[1]; } //!< @brief Gets the button B
101+
LGFX_Button* getButtonC() { return &_btns[2]; } //!< @brief Gets the button C
104102
///@}
105103

106-
/// @cond 0
104+
/// @cond
107105
[[deprecated("please use show(const bool)")]]
108106
inline void showButtons(const bool b) { show(b); }
109107
[[deprecated("please use show()")]]

src/gob_unifiedButton_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#define GOBLIB_UNIFIED_BUTTON_VERSION_MAJOR 0
55
#define GOBLIB_UNIFIED_BUTTON_VERSION_MINOR 1
6-
#define GOBLIB_UNIFIED_BUTTON_VERSION_PATCH 1
6+
#define GOBLIB_UNIFIED_BUTTON_VERSION_PATCH 2
77

88
#define GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY_AGAIN(x) #x
99
#define GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY(x) GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY_AGAIN(x)

0 commit comments

Comments
 (0)