Skip to content

Commit 3c65fa1

Browse files
committed
Merge branch 'develop'
2 parents f4eb97c + 42bdbd3 commit 3c65fa1

15 files changed

+362
-53
lines changed

README.en.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ It is also useful for those who are making a common source for Basic, Gray, and
1515

1616
## How to install
1717
Install in an appropriate way depending on your environment.
18-
* git clone and extract into place
19-
or
18+
* git clone or download zip, and extract into place
2019
* platformio.ini
2120
```ini
2221
lib_deps = https://github.com/GOB52/gob_unifiedButton
2322
```
23+
* Use library manager on ArduinoIDE
24+
2425

2526
## How to use
2627

2728
```cpp
2829
#include <M5Unified.h>
2930
#include <gob_unifiedButton.hpp>
3031

31-
gob::UnifiedButton unfiedButton;
32+
goblib::UnifiedButton unfiedButton;
3233

3334
void setup()
3435
{
@@ -38,8 +39,8 @@ void setup()
3839

3940
void loop()
4041
{
41-
unfiedButton.update(); // Must be call before M5.update
4242
M5.update();
43+
unfiedButton.update(); // Must be call after M5.update. (Changed to call after M5.update() since 0.1.0)
4344

4445
// M5.BtnX can be used to obtain status
4546
if(M5.BtnA.wasHold())
@@ -59,7 +60,7 @@ void loop()
5960
## Appearance changes
6061
You can specify it with begin or change it with changeAppearance.
6162

62-
|Argument gob::UnifiedButton::appearance\_t|Description|
63+
|Argument goblib::UnifiedButton::appearance\_t|Description|
6364
|---|---|
6465
|bottom| Display buttons at the bottom of the screen (default)|
6566
|top|Display buttons at the top of the screen|
@@ -70,15 +71,15 @@ You can specify it with begin or change it with changeAppearance.
7071

7172

7273
## Customize Buttons
73-
If after specifying gob::UnifiedButton::appearance\_t::custom,
74+
If after specifying goblib::UnifiedButton::appearance\_t::custom,
7475
getButtonA / getButtonB / getButtonC to get LGFX_Button\*.
7576

7677
```cpp
7778

7879
void setup()
7980
{
8081
M5.begin();
81-
unfiedButton.begin(&M5.Display, gob::UnifiedButton::appearance_t::custom);
82+
unfiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom);
8283

8384
auto btnA = unfiedButton.getButtonA();
8485
auto btnB = unfiedButton.getButtonB();
@@ -89,3 +90,7 @@ void setup()
8990
...
9091
}
9192
```
93+
94+
## Document
95+
Can be created from a [configuration file](doc/Doxyfile) and [shell script](doc/doxy.sh) for [Doxygen](https://www.doxygen.nl/).
96+

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ CoreS3 以外では処理をしないので、Basic, Gray, Core2 と共通のソ
1515

1616
## 導入
1717
環境によって適切な方法でインストールしてください
18-
* git clone して所定の位置へ展開する
19-
または
18+
* git clone や Zip ダウンロードからの展開
2019
* platformio.ini
2120
```ini
2221
lib_deps = https://github.com/GOB52/gob_unifiedButton
2322
```
23+
* ArduinoIDE ライブラリマネージャからのインストール
2424

2525
## 使い方
2626

2727
```cpp
2828
#include <M5Unified.h>
2929
#include <gob_unifiedButton.hpp>
3030

31-
gob::UnifiedButton unfiedButton;
31+
goblib::UnifiedButton unfiedButton;
3232

3333
void setup()
3434
{
@@ -38,8 +38,8 @@ void setup()
3838

3939
void loop()
4040
{
41-
unfiedButton.update(); // M5.update() の前に呼ぶ事
4241
M5.update();
42+
unfiedButton.update(); // M5.update() の後に呼ぶ事 (0.1.0 から後呼びに変更されました)
4343

4444
// M5.BtnX 経由で同様に状態取得
4545
if(M5.BtnA.wasHold())
@@ -60,7 +60,7 @@ void loop()
6060

6161
begin で指定、または changeAppearance で変更できます。
6262

63-
|引数 gob::UnifiedButton::appearance\_t|外観|
63+
|引数 goblib::UnifiedButton::appearance\_t|外観|
6464
|---|---|
6565
|bottom| 画面下側にボタンを表示 (default)|
6666
|top|画面上側にボタンを表示|
@@ -71,14 +71,14 @@ begin で指定、または changeAppearance で変更できます。
7171

7272
## ボタンのカスタマイズ
7373

74-
gob::UnifiedButton::appearance\_t::custom を指定した後であれば、
74+
goblib::UnifiedButton::appearance\_t::custom を指定した後であれば、
7575
getButoonA / getButtonB / getButtonC で LGFX_Button\* を取得できます。
7676
```cpp
7777

7878
void setup()
7979
{
8080
M5.begin();
81-
unfiedButton.begin(&M5.Display, gob::UnifiedButton::appearance_t::custom);
81+
unfiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom);
8282

8383
auto btnA = unfiedButton.getButtonA();
8484
auto btnB = unfiedButton.getButtonB();
@@ -89,3 +89,6 @@ void setup()
8989
...
9090
}
9191
```
92+
93+
## ドキュメント
94+
[Doxygen](https://www.doxygen.nl/) 用の[設定ファイル](doc/Doxyfile)[シェルスクリプト](doc/doxy.sh)で作成できます。

doc/doxy.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
## Get version from library.properties
4+
## Get git rev of HEAD
5+
LIB_VERSION="$(pcregrep -o1 "^\s*version\s*=\s*(\*|\d+(\.\d+){0,3}(\.\*)?)" ../library.properties)"
6+
#echo ${DOXYGEN_PROJECT_NUMBER}
7+
DOXYGEN_PROJECT_NUMBER="${LIB_VERSION} git rev:$(git rev-parse HEAD)" doxygen
8+
9+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Dependency extraction for ArduinoIDE
2+
#include <M5Unified.h>
3+
#include <gob_unifiedButton.hpp>
4+
// setup/loop in customButton_main.cpp
5+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
gob_unifiedButton example
3+
customButton for CoreS3
4+
*/
5+
#include <M5Unified.h>
6+
#include <gob_unifiedButton.hpp>
7+
8+
goblib::UnifiedButton unifiedButton; // gob_unifiedButton instance
9+
10+
void setup()
11+
{
12+
M5.begin();
13+
unifiedButton.begin(&M5.Display, goblib::UnifiedButton::appearance_t::custom);
14+
M5.Display.clear(TFT_DARKGREEN);
15+
16+
// Customize buttons
17+
// see also https://github.com/m5stack/M5GFX/blob/master/src/lgfx/v1/LGFX_Button.hpp
18+
auto btnA = unifiedButton.getButtonA();
19+
assert(btnA);
20+
btnA->initButton(unifiedButton.gfx(),
21+
M5.Display.width()/2, M5.Display.height()/8, M5.Display.width(), M5.Display.height()/4,
22+
TFT_ORANGE, TFT_WHITE, TFT_BLUE, "A Button", 2.0f, 4.0f);
23+
24+
auto btnB = unifiedButton.getButtonB();
25+
assert(btnB);
26+
btnB->initButton(unifiedButton.gfx(),
27+
M5.Display.width()/4, M5.Display.height()/8*5, M5.Display.width()/2, M5.Display.height()*3/4,
28+
TFT_LIGHTGRAY, TFT_DARKGRAY, TFT_BLACK, " Btn-B", 4.0f, 6.0f);
29+
30+
auto btnC = unifiedButton.getButtonC();
31+
assert(btnC);
32+
btnC->initButtonUL(unifiedButton.gfx(),
33+
M5.Display.width()/2, M5.Display.height()/4, M5.Display.width()/2, M5.Display.height()*3/4,
34+
TFT_CYAN, TFT_MAGENTA, TFT_RED, " CCC", 3.0f, 3.0f);
35+
36+
}
37+
38+
void loop()
39+
{
40+
M5.update();
41+
unifiedButton.update();
42+
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())
49+
{
50+
M5_LOGI("A button was clicked");
51+
}
52+
53+
if(M5.BtnB.pressedFor(1000))
54+
{
55+
M5_LOGI("B button pressed for 1000 ms");
56+
}
57+
58+
if(M5.BtnC.wasReleased())
59+
{
60+
M5_LOGI("C button was released");
61+
}
62+
63+
unifiedButton.draw();
64+
}

examples/simple/simple.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Dependency extraction for ArduinoIDE
2+
#include <M5Unified.h>
3+
#include <gob_unifiedButton.hpp>
4+
// setup/loop in simple_main.cpp

examples/simple/simple_main.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
gob_unifiedButton example
3+
simple for Core/Core2/CoreS3
4+
*/
5+
#include <M5Unified.h>
6+
#include <gob_unifiedButton.hpp>
7+
#include <gob_unifiedButton_version.hpp>
8+
9+
goblib::UnifiedButton unifiedButton; // gob_unifiedButton instance
10+
11+
void setup()
12+
{
13+
M5.begin();
14+
unifiedButton.begin(&M5.Display);
15+
M5.Display.clear(TFT_DARKGREEN);
16+
M5_LOGI("gob_unifiedButton %s / %x", GOBLIB_UNIFIED_BUTTON_VERSION_STRING, GOBLIB_UNIFIED_BUTTON_VERSION_VALUE);
17+
}
18+
19+
void loop()
20+
{
21+
static bool showButton{true};
22+
23+
M5.update();
24+
unifiedButton.update();
25+
26+
// Core/Core2/CoreS3 Can work with common code.
27+
if(M5.BtnA.wasHold())
28+
{
29+
M5_LOGI("A button was hold");
30+
}
31+
else if(M5.BtnA.wasClicked())
32+
{
33+
showButton = !showButton;
34+
M5_LOGI("A button was clicked. button %s", showButton ? "show" : "hide(clear screen)");
35+
if(!showButton) { M5.Display.clear(TFT_DARKGREEN); }
36+
unifiedButton.show(showButton);
37+
}
38+
39+
if(M5.BtnB.pressedFor(1000))
40+
{
41+
M5_LOGI("B button pressed for 1000 ms");
42+
}
43+
44+
if(M5.BtnC.wasReleased())
45+
{
46+
M5_LOGI("C button was released");
47+
}
48+
49+
// Can use with behavior as a touch screen if exists.
50+
if(M5.Touch.isEnabled())
51+
{
52+
auto dt = M5.Touch.getDetail();
53+
if(dt.y < M5.Display.height() - 32+8)
54+
{
55+
if(dt.isHolding())
56+
{
57+
M5.Lcd.fillCircle(dt.x, dt.y, 8, TFT_ORANGE);
58+
}
59+
else if(dt.isPressed())
60+
{
61+
M5.Lcd.fillCircle(dt.x, dt.y, 8, TFT_WHITE);
62+
}
63+
}
64+
}
65+
66+
unifiedButton.draw();
67+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Dependency extraction for ArduinoIDE
2+
#include <M5Unified.h>
3+
#include <gob_unifiedButton.hpp>
4+
// setup/loop in transparency_main.cpp
5+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
gob_unifiedButton example
3+
tranparency for Core/Core2/CoreS3
4+
*/
5+
#include <M5Unified.h>
6+
#include <gob_unifiedButton.hpp>
7+
8+
goblib::UnifiedButton unifiedButton; // gob_unifiedButton instance
9+
10+
void setup()
11+
{
12+
M5.begin();
13+
/*
14+
3 transparent buttons.
15+
Split screen vertically into 3 sections.
16+
+---+---+---+
17+
| | | |
18+
| A | B | C |
19+
| | | |
20+
+---+---+---+
21+
*/
22+
unifiedButton.begin(&M5.Display, goblib::UnifiedButton::transparent_all);
23+
M5.Display.clear(TFT_DARKGREEN);
24+
}
25+
26+
void loop()
27+
{
28+
M5.update();
29+
unifiedButton.update();
30+
31+
if(M5.BtnA.wasHold())
32+
{
33+
M5_LOGI("A button was hold");
34+
}
35+
else if(M5.BtnA.wasClicked())
36+
{
37+
M5_LOGI("A button was clicked");
38+
}
39+
40+
if(M5.BtnB.pressedFor(1000))
41+
{
42+
M5_LOGI("B button pressed for 1000 ms");
43+
}
44+
45+
if(M5.BtnC.wasReleased())
46+
{
47+
M5_LOGI("C button was released");
48+
}
49+
50+
unifiedButton.draw(); // For transparent buttons, nothing is drawn when invoked.
51+
}

library.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gob_unifiedButton",
3-
"description": "Touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX)",
3+
"description": "Add touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX)",
44
"keywords": "M5Stack-CoreS3, M5Stack, M5Unified, M5GFX",
55
"authors": {
66
"name": "GOB",
@@ -11,7 +11,7 @@
1111
"type": "git",
1212
"url": "https://github.com/GOB52/gob_unifiedButton.git"
1313
},
14-
"version": "0.0.3",
14+
"version": "0.1.0",
1515
"build": {
1616
"libArchive": false
1717
},
@@ -20,6 +20,9 @@
2020
"platforms": "espressif32",
2121
"frameworks": "arduino",
2222
"dependencies": {
23-
"m5stack/M5Unified": "^0.1.6"
23+
"m5stack/M5Unified": "^0.1.10"
24+
},
25+
"export": {
26+
"include" : [ ".gitignore", "README.en.md", "platformio.ini", "src", "examples", "doc/Doxyfile", "doc/doxy.sh" ]
2427
}
25-
}
28+
}

0 commit comments

Comments
 (0)