Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
GOB52 committed Jun 3, 2024
2 parents 633a2ea + 400c306 commit 9d251e9
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 32 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@

#pio
/.pio/

#VsCode
/.vscode/
/.vscode

# Doxygen
/html
/doc/html

#Emacs
\#*#

#
debug.cfg
Expand Down
12 changes: 8 additions & 4 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
[English](README.md)

## 概要
物理ボタン、タッチボタンを持たない CoreS3 上にタッチボタンを追加し、 M5.BtnX 経由で状態を取得できるようにしたライブラリです。
物理ボタン、タッチボタンを持たない CoreS3、Tough 上にソフトウェアタッチボタンを追加し、 M5.BtnX 経由で状態を取得できるようにしたライブラリです。
将来的に [M5Unified](https://github.com/m5stack/M5Unified) に同様の機能がつくまでの暫定としてお使いください。
CoreS3 以外では処理をしないので、Basic, Gray, Core2 と共通のソースで作っている方にも有用です。

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

なお CoreS3SE では M5Unified を使用していればも画面外の部分が Core2 同様にボタンとして機能します。(CoreS3 ではその部分はタッチとして機能しません)


## 必要なもの
* [M5Unified](https://github.com/m5stack/M5Unified)
* [M5GFX](https://github.com/m5stack/M5GFX)
* [M5Unified](https://github.com/m5stack/M5Unified) 0.1.16 以降
* [M5GFX](https://github.com/m5stack/M5GFX) 0.1.16 以降

**M5Unified 前提ですので、 M5Core3.h を使用した物には適用できません。**

Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
![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.
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.
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.

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.

In CoreS3SE, if M5Unified is used, the off-screen part functions as a button, as in Core2 .(In CoreS3, that part does not function as touch)

## Required libraries
* [M5Unified](https://github.com/m5stack/M5Unified)
* [M5GFX](https://github.com/m5stack/M5GFX)
* [M5Unified](https://github.com/m5stack/M5Unified) 0.1.16 or later
* [M5GFX](https://github.com/m5stack/M5GFX) 0.1.16 or later

**M5Unified is assumed, so it cannot be applied to those using M5Core3.h.**

Expand Down
5 changes: 3 additions & 2 deletions examples/rotation/rotation_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void setup()
{
M5.begin();
unifiedButton.begin(&display);
//unifiedButton.begin(&display, goblib::UnifiedButton::appearance_t::top);
display.clear(TFT_DARKGREEN);
unifiedButton.getButtonA()->setLabelText("ROTATE");
}
Expand Down Expand Up @@ -40,8 +41,8 @@ void loop()
force = true;
}

display.setCursor(16, 32);
display.setCursor(16, 64);
display.printf("R:%u W:%d H:%d\n", display.getRotation(), display.width(), display.height());
display.printf("Click A to rotate random");
display.printf("Click A to rotate buttons");
unifiedButton.draw(force);
}
17 changes: 12 additions & 5 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gob_unifiedButton",
"description": "Add touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX)",
"keywords": "M5Stack-CoreS3, M5Stack, M5Unified, M5GFX",
"description": "Add touch buttons for CoreS3 / Tough and commonality with conventional buttons (M5.BtnX)",
"keywords": "CoreS3, M5Tough, M5Stack, M5Unified, M5GFX",
"authors": {
"name": "GOB",
"url": "https://github.com/GOB52",
Expand All @@ -11,12 +11,19 @@
"type": "git",
"url": "https://github.com/GOB52/gob_unifiedButton.git"
},
"version": "0.1.4",
"version": "0.1.5",
"headers": "gob_unifiedButton.hpp",
"license": "MIT",
"platforms": "espressif32",
"frameworks": "arduino",
"dependencies": {
"m5stack/M5Unified": "^0.1.13"
"m5stack/M5Unified": "^0.1.16"
},
"export": {
"exclude":
[
"doc/html"
]
}
}
}

8 changes: 4 additions & 4 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name=gob_unifiedButton
version=0.1.4
version=0.1.5
author=GOB
maintainer=GOB
sentence=Add touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX)
paragraph=M5Stack CoreS3
sentence=Add touch buttons for CoreS3 / Tough and commonality with conventional buttons (M5.BtnX)
paragraph=M5Stack CoreS3 Tough
category=Other
url=https://github.com/GOB52/gob_unifiedButton.git
architectures=esp32,esp32s3
includes=gob_unifiedButton.hpp
depends=M5Unified (>=0.1.13)
depends=M5Unified (>=0.1.16)
5 changes: 4 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
platform = espressif32
framework = arduino

lib_deps = m5stack/M5Unified
lib_deps = m5stack/M5Unified @^0.1.16
;lib_deps = https://github.com/m5stack/M5Unified.git#develop
; https://github.com/m5stack/M5GFX.git#develop

lib_ldf_mode = deep

monitor_speed = 115200
Expand Down
19 changes: 13 additions & 6 deletions src/gob_unifiedButton.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
@file gob_unifiedButton.cpp
@brief Add touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX)
@brief Library main source
@author GOB @GOB_52_GOB https://twitter.com/GOB_52_GOB
*/
#include <M5Unified.h>
Expand All @@ -24,9 +24,17 @@ void UnifiedButton::begin(LovyanGFX* gfx, const appearance_t app)
_appearance = app;
_dirty = true;
_font = gfx->getFont();
_enable = M5.getBoard() == m5::board_t::board_M5StackCoreS3 && M5.Touch.isEnabled();

auto bd = M5.getBoard();
_enable = (bd == m5::board_t::board_M5StackCoreS3 || bd == m5::board_t::board_M5Tough)
&& M5.Touch.isEnabled();
_rotation = _gfx->getRotation();
if(_enable) { create_buttons(_appearance); }

if(M5.Touch.isEnabled() && !_enable)
{
M5_LOGW("Unsupported devices. getBoard() %u\n", bd);
}
}

void UnifiedButton::create_buttons(const appearance_t app)
Expand All @@ -39,20 +47,18 @@ void UnifiedButton::create_buttons(const appearance_t app)
{
case appearance_t::bottom:
case appearance_t::transparent_bottom:
top = _gfx->height() - h/2;
top = _gfx->height() - h;
break;
case appearance_t::top:
case appearance_t::transparent_top:
top = h/2;
break;
default: // transparent_all
h = _gfx->height();
top = h/2;
break;
}
for(uint_fast8_t i = 0; i < 3; ++i)
{
_btns[i].initButton(_gfx, left + w * i + w / 2, top, w, h, olClr, TFT_DARKGRAY, TFT_BLACK,label_table[i]);
_btns[i].initButtonUL(_gfx, left + w * i, top, w, h, olClr, TFT_DARKGRAY, TFT_BLACK,label_table[i]);
}
}

Expand Down Expand Up @@ -104,6 +110,7 @@ void UnifiedButton::update()
{
btn_bits |= (_btns[i].contains(x, y) << i);
}
//M5_LOGI("%d,%d : %x", x, y, btn_bits);
_press_bits = btn_bits;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/gob_unifiedButton.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
@file gob_unifiedButton.hpp
@brief Add touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX)
@brief Library main header
@mainpage gob_unifiedButton
Add touch buttons for CoreS3 and commonality with conventional buttons (M5.BtnX)
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.
@author GOB / GitHub:<a href="https://github.com/GOB52/">GOB52</a> / X:<a href="https://twitter.com/gob_52_gob">@GOB_52_GOB</a>
Expand Down
2 changes: 1 addition & 1 deletion src/gob_unifiedButton_version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define GOBLIB_UNIFIED_BUTTON_VERSION_MAJOR 0
#define GOBLIB_UNIFIED_BUTTON_VERSION_MINOR 1
#define GOBLIB_UNIFIED_BUTTON_VERSION_PATCH 4
#define GOBLIB_UNIFIED_BUTTON_VERSION_PATCH 5

#define GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY_AGAIN(x) #x
#define GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY(x) GOBLIB_UNIFIED_BUTTON_VERSION_STRINGIFY_AGAIN(x)
Expand Down

0 comments on commit 9d251e9

Please sign in to comment.