Skip to content

Commit 94c4967

Browse files
committed
Merge branch 'develop'
2 parents 12ed4cb + 421bc58 commit 94c4967

File tree

6 files changed

+3011
-1
lines changed

6 files changed

+3011
-1
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,10 @@
3030
*.exe
3131
*.out
3232
*.app
33+
34+
# PlatformIO
35+
.pio
36+
.vscode/.browse.c_cpp.db*
37+
.vscode/c_cpp_properties.json
38+
.vscode/launch.json
39+
.vscode/ipch

README.en.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# gob_unifiedButton
2+
3+
[日本語](README.md)
4+
5+
## Overview
6+
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.
7+
Please use this as an interim feature until a similar feature is added to [M5Unified](https://github.com/m5stack/M5Unified) in the future.
8+
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.
9+
10+
## Required libraries
11+
* [M5Unified](https://github.com/m5stack/M5Unified)
12+
* [M5GFX](https://github.com/m5stack/M5GFX)
13+
14+
**M5Unified is assumed, so it cannot be applied to those using M5Core3.h.**
15+
16+
## How to install
17+
Install in an appropriate way depending on your environment.
18+
* git clone and extract into place
19+
or
20+
* platformio.ini
21+
```ini
22+
lib_deps = https://github.com/GOB52/gob_unifiedButton
23+
```
24+
25+
## How to use
26+
27+
```cpp
28+
#include <M5Unified.h>
29+
#include <gob_unifiedButton.hpp>
30+
31+
gob::UnifiedButton unfiedButton;
32+
33+
void setup()
34+
{
35+
M5.begin();
36+
unfiedButton.begin(&M5.Display);
37+
}
38+
39+
void loop()
40+
{
41+
unfiedButton.update(); // Must be call before M5.update
42+
M5.update();
43+
44+
// M5.BtnX can be used to obtain status
45+
if(M5.BtnA.wasHold())
46+
{
47+
// ...
48+
}
49+
else if(M5.BtnA.wasClicked())
50+
{
51+
// ...
52+
}
53+
54+
// Drawing Buttons
55+
unfiedButton.draw();
56+
}
57+
```
58+
59+
## Appearance changes
60+
You can specify it with begin or change it with changeAppearance.
61+
62+
|Argument gob::UnifiedButton::appearance\_t|Description|
63+
|---|---|
64+
|bottom| Display buttons at the bottom of the screen (default)|
65+
|top|Display buttons at the top of the screen|
66+
|custom|Customize your own buttons|
67+
|transparent\_bottom|Transparent buttons on the bottom of the screen|
68+
|transparent\_top|Transparent buttons on the top of the screen|
69+
|transparent_all|Transparent buttons are placed on the entire screen (three vertical sections)|
70+
71+
72+
## Customize Buttons
73+
If after specifying gob::UnifiedButton::appearance\_t::custom,
74+
getButtonA / getButtonB / getButtonC to get LGFX_Button\*.
75+
76+
```cpp
77+
78+
void setup()
79+
{
80+
M5.begin();
81+
unfiedButton.begin(&M5.Display, gob::UnifiedButton::appearance_t::custom);
82+
83+
auto btnA = unfiedButton.getButtonA();
84+
auto btnB = unfiedButton.getButtonB();
85+
auto btnC = unfiedButton.getButtonC();
86+
87+
// Re-create buttons with unique shape, color, and text
88+
btnA->initButton(unfiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]");
89+
...
90+
}
91+
```

README.md

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,91 @@
1-
# gob_unifiedButton
1+
# gob_unifiedButton
2+
3+
[English](README.en.md)
4+
5+
## 概要
6+
物理ボタン、タッチボタンを持たない CoreS3 上にタッチボタンを追加し、 M5.BtnX 経由で状態を取得できるようにしたライブラリです。
7+
将来的に [M5Unified](https://github.com/m5stack/M5Unified) に同様の機能がつくまでの暫定としてお使いください。
8+
CoreS3 以外では処理をしないので、Basic, Gray, Core2 と共通のソースで作っている方にも有用です。
9+
10+
## 必要なもの
11+
* [M5Unified](https://github.com/m5stack/M5Unified)
12+
* [M5GFX](https://github.com/m5stack/M5GFX)
13+
14+
**M5Unified 前提ですので、 M5Core3.h を使用した物には適用できません。**
15+
16+
## 導入
17+
環境によって適切な方法でインストールしてください
18+
* git clone して所定の位置へ展開する
19+
または
20+
* platformio.ini
21+
```ini
22+
lib_deps = https://github.com/GOB52/gob_unifiedButton
23+
```
24+
25+
## 使い方
26+
27+
```cpp
28+
#include <M5Unified.h>
29+
#include <gob_unifiedButton.hpp>
30+
31+
gob::UnifiedButton unfiedButton;
32+
33+
void setup()
34+
{
35+
M5.begin();
36+
unfiedButton.begin(&M5.Display);
37+
}
38+
39+
void loop()
40+
{
41+
unfiedButton.update(); // M5.update() の前に呼ぶ事
42+
M5.update();
43+
44+
// M5.BtnX 経由で同様に状態取得
45+
if(M5.BtnA.wasHold())
46+
{
47+
// ...
48+
}
49+
else if(M5.BtnA.wasClicked())
50+
{
51+
// ...
52+
}
53+
54+
// ボタンを描画する
55+
unfiedButton.draw();
56+
}
57+
```
58+
59+
## 外観変更
60+
61+
begin で指定、または changeAppearance で変更できます。
62+
63+
|引数 gob::UnifiedButton::appearance\_t|外観|
64+
|---|---|
65+
|bottom| 画面下側にボタンを表示 (default)|
66+
|top|画面上側にボタンを表示|
67+
|custom|独自にボタンをカスタマイズ(下記参照)|
68+
|transparent\_bottom|bottom と同様の位置に透明ボタンを配置|
69+
|transparent\_top|bottom と同様の位置に透明ボタンを配置|
70+
|transparent_all|画面全体に透明ボタンを配置(縦3分割)|
71+
72+
## ボタンのカスタマイズ
73+
74+
gob::UnifiedButton::appearance\_t::custom を指定した後であれば、
75+
getButoonA / getButtonB / getButtonC で LGFX_Button\* を取得できます。
76+
```cpp
77+
78+
void setup()
79+
{
80+
M5.begin();
81+
unfiedButton.begin(&M5.Display, gob::UnifiedButton::appearance_t::custom);
82+
83+
auto btnA = unfiedButton.getButtonA();
84+
auto btnB = unfiedButton.getButtonB();
85+
auto btnC = unfiedButton.getButtonC();
86+
87+
// 独自形状、色、テキストのボタンを再作成
88+
btnA->initButton(unfiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]");
89+
...
90+
}
91+
```

0 commit comments

Comments
 (0)