Skip to content

Add software touch buttons for CoreS3 and Tough, and commonality with conventional buttons (M5.BtnX)

License

Notifications You must be signed in to change notification settings

GOB52/gob_unifiedButton

Repository files navigation

gob_unifiedButton

日本語

gob_unifiedButton

Overview

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 in the future.

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 is assumed, so it cannot be applied to those using M5Core3.h.

How to install

Install in an appropriate way depending on your environment.

  • git clone or download zip, and extract into place
  • platformio.ini
lib_deps = gob/gob_unifiedButton
  • Use library manager on ArduinoIDE

How to use

#include <M5Unified.h>
#include <gob_unifiedButton.hpp>

goblib::UnifiedButton unifiedButton;

void setup()
{
    M5.begin();
    unifiedButton.begin(&M5.Display);
}

void loop()
{
    M5.update();
    unifiedButton.update(); // Must be call after M5.update. (Changed to call after M5.update() since 0.1.0)

    // M5.BtnX can be used to obtain status
    if(M5.BtnA.wasHold())
    {
        // ...
    }
    else if(M5.BtnA.wasClicked())
    {
        // ...
    }

    // Drawing Buttons
    unifiedButton.draw();
}

Button text font changes

You can configure which fonts can be used with M5GFX.

    unifiedButton.setFont(&fonts::Font4);

Appearance changes

You can specify it with begin or change it with changeAppearance.

Argument goblib::UnifiedButton::appearance_t Description
bottom Display buttons at the bottom of the screen (default)
top Display buttons at the top of the screen
transparent_bottom Transparent buttons on the bottom of the screen
transparent_top Transparent buttons on the top of the screen
transparent_all Transparent buttons are placed on the entire screen (three vertical sections)

Customize Buttons

You can get LGFX_Button*.

void setup()
{
    M5.begin();
    unifiedButton.begin(&M5.Display);

    auto btnA = unifiedButton.getButtonA();

    // Re-create buttons with unique shape, color, and text
    btnA->initButton(unifiedButton.gfx(), 40, 120, 80, 240 ,TFT_GREEN, TFT_BLUE, TFT_WHITE, "[A]");
    // Change label text
    btnA->setLabelText("Own");
}

Document

Can be created from a configuration file and shell script for Doxygen.
Output is to doc/html

bash doc/doxy.sh

or See also GitHub Pages

About

Add software touch buttons for CoreS3 and Tough, and commonality with conventional buttons (M5.BtnX)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages