Skip to content

Commit 09730a5

Browse files
committed
Merge branch 'develop'
2 parents 46ae74a + 51f05e4 commit 09730a5

File tree

10 files changed

+78
-47
lines changed

10 files changed

+78
-47
lines changed

.github/workflows/doxygen-gh-pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ jobs:
1111
with:
1212
github_token: ${{ secrets.GITHUB_TOKEN }}
1313
branch: gh-pages
14-
folder: doc/html
15-
config_file: doc/Doxyfile
14+
folder: docs/html
15+
config_file: docs/Doxyfile

README.ja.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
## 概要
88
物理ボタン、タッチボタンを持たない CoreS3、Tough 上にソフトウェアタッチボタンを追加し、 M5.BtnX 経由で状態を取得できるようにしたライブラリです。
9-
将来的に [M5Unified](https://github.com/m5stack/M5Unified) に同様の機能がつくまでの暫定としてお使いください。
9+
10+
~~将来的に [M5Unified](https://github.com/m5stack/M5Unified) に同様の機能がつくまでの暫定としてお使いください。~~
11+
M5Unified 0.2.3 より、 **M5.setTouchButtonHeightByRatio(uint8_t ratio)** が追加され、画面を M5.BtnX として使用できるようになりました。
12+
今後はこちらの機能を使うと良いでしょう。
1013

1114
CoreS3、Tough 以外では処理をしないので、Basic, Gray, Core2 等と共通のソースで作っている方にも有用です。
1215

@@ -17,7 +20,7 @@ CoreS3、Tough 以外では処理をしないので、Basic, Gray, Core2 等と
1720
* [M5Unified](https://github.com/m5stack/M5Unified) 0.1.16 以降
1821
* [M5GFX](https://github.com/m5stack/M5GFX) 0.1.16 以降
1922

20-
**M5Unified 前提ですので、 M5Core3.h を使用した物には適用できません**
23+
**M5Unifiedを前提としているため、M5Core3.hなどデバイス固有のヘッダを使用している場合は適用できません**
2124

2225
## 導入
2326
環境によって適切な方法でインストールしてください
@@ -79,7 +82,7 @@ begin で指定、または changeAppearance で変更できます。
7982
|transparent_all|画面全体に透明ボタンを配置(縦3分割)|
8083

8184
## ボタンのカスタマイズ
82-
LGFX_Button\* を取得できます。
85+
LGFX\_Button\* を取得できます。
8386
```cpp
8487
void setup()
8588
{
@@ -93,14 +96,14 @@ void setup()
9396
btnA->setLabelText("Own");
9497
}
9598
```
96-
LGFX_Button については[こちら](https://github.com/m5stack/M5GFX/blob/master/src/lgfx/v1/LGFX_Button.hpp)を参照してください。
99+
LGFX\_Button については[こちら](https://github.com/m5stack/M5GFX/blob/master/src/lgfx/v1/LGFX_Button.hpp)を参照してください。
97100

98101

99102
## ドキュメント
100-
[Doxygen](https://www.doxygen.nl/) 用の[設定ファイル](doc/Doxyfile)[シェルスクリプト](doc/doxy.sh)で作成できます。
103+
[Doxygen](https://www.doxygen.nl/) 用の[設定ファイル](docs/Doxyfile)[シェルスクリプト](docs/doxy.sh)で作成できます。
101104
出力先は doc/html です。
102105
```
103-
bash doc/doxy.sh
106+
bash docs/doxy.sh
104107
```
105108

106109
または[GitHub Pages](https://gob52.github.io/gob_unifiedButton/)を参照してください。

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
## Overview
88
This library adds software touch buttons on CoreS3 and Tough, which does not have physical buttons or touch buttons, and enables the user to acquire the status via M5.BtnX.
9-
Please use this as an interim feature until a similar feature is added to [M5Unified](https://github.com/m5stack/M5Unified) in the future.
9+
~~Please use this as an interim feature until a similar feature is added to [M5Unified](https://github.com/m5stack/M5Unified) in the future.~~
10+
11+
Since M5Unified 0.2.3, **M5.setTouchButtonHeightByRatio(uint8_t ratio)** has been added, allowing the screen to be used as button (M5.BtnX)
12+
You may want to use this feature.
1013

1114
It is also useful for those who are making a common source for Basic, Gray, Core2 and more, as it does not process anything other than CoreS3 and Tough.
1215

@@ -16,7 +19,7 @@ In CoreS3SE, if M5Unified is used, the off-screen part functions as a button, as
1619
* [M5Unified](https://github.com/m5stack/M5Unified) 0.1.16 or later
1720
* [M5GFX](https://github.com/m5stack/M5GFX) 0.1.16 or later
1821

19-
**M5Unified is assumed, so it cannot be applied to those using M5Core3.h.**
22+
**M5Unified is assumed, it is not applicable when device-specific headers such as M5Core3.h are used.**
2023

2124
## How to install
2225
Install in an appropriate way depending on your environment.
@@ -77,7 +80,7 @@ You can specify it with begin or change it with changeAppearance.
7780
|transparent_all|Transparent buttons are placed on the entire screen (three vertical sections)|
7881

7982
## Customize Buttons
80-
You can get LGFX_Button\*.
83+
You can get LGFX\_Button\*.
8184

8285
```cpp
8386
void setup()
@@ -93,9 +96,10 @@ void setup()
9396
btnA->setLabelText("Own");
9497
}
9598
```
99+
Click [here](https://github.com/m5stack/M5GFX/blob/master/src/lgfx/v1/LGFX_Button.hpp) for more information about LGFX\_Button].
96100

97101
## Document
98-
Can be created from a [configuration file](doc/Doxyfile) and [shell script](doc/doxy.sh) for [Doxygen](https://www.doxygen.nl/).
102+
Can be created from a [configuration file](docs/Doxyfile) and [shell script](docs/doxy.sh) for [Doxygen](https://www.doxygen.nl/).
99103
Output is to doc/html
100104
```
101105
bash doc/doxy.sh
File renamed without changes.
File renamed without changes.

library.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
2-
"name": "gob_unifiedButton",
3-
"description": "Add touch buttons for CoreS3 / Tough and commonality with conventional buttons (M5.BtnX)",
4-
"keywords": "CoreS3, M5Tough, M5Stack, M5Unified, M5GFX",
5-
"authors": {
6-
"name": "GOB",
7-
"url": "https://github.com/GOB52",
8-
"maintainer": true
9-
},
10-
"repository": {
11-
"type": "git",
12-
"url": "https://github.com/GOB52/gob_unifiedButton.git"
13-
},
14-
"version": "0.1.6",
15-
"headers": "gob_unifiedButton.hpp",
16-
"license": "MIT",
17-
"platforms": "espressif32",
18-
"frameworks": "arduino",
19-
"dependencies": {
20-
"m5stack/M5Unified": "^0.1.16"
21-
},
22-
"export": {
23-
"exclude": [
24-
"doc/html"
25-
]
26-
}
27-
}
2+
"name": "gob_unifiedButton",
3+
"description": "Add touch buttons for CoreS3 / Tough and commonality with conventional buttons (M5.BtnX)",
4+
"keywords": "CoreS3, M5Tough, M5Stack, M5Unified, M5GFX",
5+
"authors": {
6+
"name": "GOB",
7+
"url": "https://github.com/GOB52",
8+
"maintainer": true
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/GOB52/gob_unifiedButton.git"
13+
},
14+
"version": "0.1.7",
15+
"headers": "gob_unifiedButton.hpp",
16+
"license": "MIT",
17+
"platforms": "espressif32",
18+
"frameworks": "arduino",
19+
"dependencies": {
20+
"m5stack/M5Unified": ">=0.1.16"
21+
},
22+
"export": {
23+
"exclude": [
24+
"doc/html"
25+
]
26+
}
27+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=gob_unifiedButton
2-
version=0.1.6
2+
version=0.1.7
33
author=GOB
44
maintainer=GOB
55
sentence=Add touch buttons for CoreS3 / Tough and commonality with conventional buttons (M5.BtnX)

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
platform = espressif32
66
framework = arduino
77

8-
lib_deps = m5stack/M5Unified @^0.1.16
8+
lib_deps = m5stack/M5Unified @>=0.1.16
99
;lib_deps = https://github.com/m5stack/M5Unified.git#develop
1010
; https://github.com/m5stack/M5GFX.git#develop
1111

src/gob_unifiedButton.cpp

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
#include <M5Unified.h>
77
#include "gob_unifiedButton.hpp"
88

9+
#define GUB_M5UNIFIED_VERSION \
10+
((M5UNIFIED_VERSION_MAJOR << 16) | (M5UNIFIED_VERSION_MINOR << 8) | M5UNIFIED_VERSION_PATCH)
11+
12+
#if GUB_M5UNIFIED_VERSION >= 0x0203
13+
#define USING_M5UNIFIED_023_OR_LATER
14+
#endif
15+
916
namespace
1017
{
1118
constexpr char labelA[] = "BtnA";
@@ -27,14 +34,26 @@ void UnifiedButton::begin(LovyanGFX* gfx, const appearance_t app)
2734

2835
auto bd = M5.getBoard();
2936
_enable = (bd == m5::board_t::board_M5StackCoreS3 || bd == m5::board_t::board_M5Tough)
30-
&& M5.Touch.isEnabled();
37+
&& M5.Touch.isEnabled();
3138
_rotation = _gfx->getRotation();
3239
if(_enable) { create_buttons(_appearance); }
3340

34-
if(M5.Touch.isEnabled() && !_enable)
41+
if(!_enable)
3542
{
3643
M5_LOGW("Unsupported devices. getBoard() %u\n", bd);
44+
return;
3745
}
46+
47+
M5_LOGD("M5Unified [%X] %u.%u.%u",
48+
GUB_M5UNIFIED_VERSION, M5UNIFIED_VERSION_MAJOR,M5UNIFIED_VERSION_MINOR,M5UNIFIED_VERSION_PATCH);
49+
50+
_m5btns[0] = M5.BtnA;
51+
_m5btns[1] = M5.BtnB;
52+
_m5btns[2] = M5.BtnC;
53+
54+
#if defined(USING_M5UNIFIED_023_OR_LATER)
55+
M5.setTouchButtonHeightByRatio(0); // Disable M5Unified virtual screen buttons (0.2.3 or later)
56+
#endif
3857
}
3958

4059
void UnifiedButton::create_buttons(const appearance_t app)
@@ -89,7 +108,7 @@ void UnifiedButton::update()
89108
if (M5.BtnC.isPressed()) { btn_bits |= 1 << 2; }
90109
if (btn_bits || !(det.state & m5::touch_state_t::mask_moving))
91110
{
92-
// Correct coordinates to match rotation.
111+
// Correct coordinates to match rotation
93112
auto x = raw.x;
94113
auto y = raw.y;
95114
const uint32_t rot = _gfx->getRotation();
@@ -115,11 +134,15 @@ void UnifiedButton::update()
115134
}
116135
}
117136
}
118-
// Set status to M5.BtnX
119-
M5.BtnA.setRawState(ms, btn_bits & 1);
120-
M5.BtnB.setRawState(ms, btn_bits & 2);
121-
M5.BtnC.setRawState(ms, btn_bits & 4);
122137

138+
// Set status to M5.BtnX
139+
_m5btns[0].setRawState(ms, btn_bits & 1);
140+
_m5btns[1].setRawState(ms, btn_bits & 2);
141+
_m5btns[2].setRawState(ms, btn_bits & 4);
142+
M5.BtnA = _m5btns[0];
143+
M5.BtnB = _m5btns[1];
144+
M5.BtnC = _m5btns[2];
145+
123146
_dirty |= (prev != _press_bits);
124147
}
125148

src/gob_unifiedButton.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class UnifiedButton
132132
appearance_t _appearance{appearance_t::bottom};
133133
const lgfx::IFont* _font{};
134134
uint_fast8_t _rotation{(uint_fast8_t)-1}; // Same as M5GFX
135+
m5::Button_Class _m5btns[3];
135136
};
136137
//
137138
}

0 commit comments

Comments
 (0)