|
| 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 | +``` |
0 commit comments