M5Stack Core2 touch screen button to read HIGH/LOW

What do you want to achieve?

I am trying to get the M5Stack Core2 touch screen button to read HIGH/LOW 1/0 similar to an external momentary button.

I can get the button working fine by calling a function but not quite what I’m looking for. The code I to use is

void showStartScreen() {
  M5.update();

  bool standby_mode = false;

  if (STATE_READY == currentState) {
    // RESET button
    if (LOW == digitalRead(buttonA_GPIO) || standby_mode) {
      // Debounced wait for release of RESET button
      delay(50);
      if (!test_loop_mode) {
        while (LOW == digitalRead(buttonA_GPIO)) {
          delay(10);
        }
      }
      delay(10);

      size_t bytes_written;
  
      M5.Axp.SetSpkEnable(true);
      InitI2SSpeakerOrMic(MODE_SPK);
  
      // Gate Rise
      i2s_write(SPEAKER_I2S_NUMBER, wavList[5], wavSize[5], &bytes_written, portMAX_DELAY);
      i2s_zero_dma_buffer(SPEAKER_I2S_NUMBER);

      // Set Mic Mode
      InitI2SSpeakerOrMic(MODE_MIC);
      M5.Axp.SetSpkEnable(false);

      currentState = STATE_ARMED;
	  
	  // display START button
      start_button();

      // Remember this time to allow timeout
      timing_start_ms = millis();
    }
  }
}

and this is what I am trying to replicate

if (LOW == digitalRead(buttonA_GPIO))

buttonA_GPIO is a way to define the whole screen as buttonA with M5Stack Core2, though not eally need when using Squareline Studio as adding a button to the screen creates a ‘hot zone’ area.

Am I misunderstanding something?

Screenshot or video

Others

  • SquareLine Studio version:
    1.3.1
  • Operating system:
    Windows 10
  • Target hardware:
    M5Stack Core2