GithubHelp home page GithubHelp logo

Comments (4)

lovyan03 avatar lovyan03 commented on June 20, 2024

Hello, @myAlterX .
Please show me the version of the library you are using and the source code you have tried.

from m5unified.

myAlterX avatar myAlterX commented on June 20, 2024

Hi!

I'm including:

#include <M5AtomDisplay.h>
#include <M5Unified.h>

then in setup:

  auto cfg = M5.config();

  // external display setting. (Pre-include required)
  cfg.external_display.module_display = false;  // default=true. use ModuleDisplay
  cfg.external_display.atom_display   = true;  // default=true. use AtomDisplay
  cfg.external_display.unit_glass     = false; // default=true. use UnitGLASS
  cfg.external_display.unit_glass2    = false; // default=true. use UnitGLASS2
  cfg.external_display.unit_oled      = false; // default=true. use UnitOLED
  cfg.external_display.unit_mini_oled = false; // default=true. use UnitMiniOLED
  cfg.external_display.unit_lcd       = false; // default=true. use UnitLCD
  cfg.external_display.unit_rca       = false; // default=true. use UnitRCA VideoOutput
  cfg.external_display.module_rca     = false; // default=true. use ModuleRCA VideoOutput

  M5.begin(cfg);

in loop somewhere I test for:

if (M5.BtnA.wasPressed() || M5.BtnB.wasPressed() || M5.BtnC.wasPressed() || M5.BtnEXT.wasPressed())

because this doesn't seem to work, I just read the digital pin for now:

int val = digitalRead(BTN_PIN);
// Handle button press
if (M5.BtnA.wasPressed() || M5.BtnB.wasPressed() || M5.BtnC.wasPressed() || M5.BtnEXT.wasPressed() || val == LOW)

which I have set at the top to 41 thanks to your clever labeling!

const int BTN_PIN = GPIO_NUM_41;

I took a peek at the lib and found this comment:
```cpp
/*
  /// List of available buttons:
  M5Stack BASIC/GRAY/GO/FIRE:  BtnA,BtnB,BtnC
  M5Stack Core2:               BtnA,BtnB,BtnC,BtnPWR
  M5Stick C/CPlus:             BtnA,BtnB,     BtnPWR
  M5Stick CoreInk:             BtnA,BtnB,BtnC,BtnPWR,BtnEXT
  M5Paper:                     BtnA,BtnB,BtnC
  M5Station:                   BtnA,BtnB,BtnC,BtnPWR
  M5Tough:                                    BtnPWR
  M5ATOM:                      BtnA
*/

Which doesn't seem to have any mention of the AtomS3. Don't know if constants are defined. If they are, it doesn't work for me.

Thanks for your quick reply!

from m5unified.

lovyan03 avatar lovyan03 commented on June 20, 2024

Are you using M5.update?
You must run M5.update before reading the button.

#include <M5Unified.h>
void setup(void)
{
  M5.begin();
}
void loop(void)
{
  M5.delay(1);
  M5.update();  

  if (M5.BtnA.wasPressed()) {
    M5_LOGE("wasPressed");
  }
}

from m5unified.

myAlterX avatar myAlterX commented on June 20, 2024

No I was not!
After updating, BtnA does the job.
Thanks very much for your help!

  M5.update();
  if (M5.BtnA.wasPressed()) {
    // works
  }

You may close the issue!

from m5unified.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.