Table des matières

m5Stack Basic : API et programmes arduino

Boutons

Parametres

Lire (Read)

Syntaxe:

  uint8_t read();

Description:

Paramètres:

Retour:

Exemple0001.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
  M5.Lcd.println("Please pressed Button A.");
}
 
void loop() {
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.printf("Button A Status: %d ",M5.BtnA.read());
}

dernier changement (lastChange )

Syntaxe:

   uint32_t lastChange();

Description:

Paramètres:

Retour:

Exemple0002.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
  M5.Lcd.println("Please pressed Button A.");
}
 
void loop() {
  M5.update();
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.printf("The last change at %d ms /n",M5.BtnA.lastChange());
}

est pressé (isPressed)

Syntaxe:

  uint8_t isPressed();

Description:

Paramètres:

Retour:

Exemple0003.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
  M5.Lcd.println("Please pressed Button A.");
}
 
void loop() {
  M5.update();
  M5.Lcd.setCursor(0, 0);
  if (M5.BtnA.isPressed()) {
    M5.Lcd.println("Button is Pressed.");
  }else{
    M5.Lcd.println("Button is Released.");
  }
  delay(20);
}

était pressé (wasPressed)

Syntaxe:

  uint8_t wasPressed();

Description:

Paramètres:

Retour:

Exemple04.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
  M5.Lcd.println("Please pressed Button A.");
}
 
void loop() {
  M5.update();
  if (M5.BtnA.wasPressed()) {    
    M5.Lcd.println("Button is pressed.");
  } 
  delay(20);
}

presséPour (pressedFor)

Syntaxe:

  uint8_t pressedFor(uint32_t ms);

Description:

Paramètres:

Retour:

Exemple005.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
  M5.Lcd.println("Please pressed Button A.");
}
 
void loop() {
  M5.update();
  if (M5.BtnA.pressedFor(2000)) {
    M5.Lcd.println("Button A was pressed for more than 2 seconds.");
    delay(1000);
  }
}

est publié (isPressed)

Syntaxe:

  uint8_t isPressed();

Description:

Paramètres:

Retour:

Exemple0006.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
}
 
void loop() {
  M5.update();
  if (M5.BtnA.isReleased()) {
    M5.Lcd.println("Button is released.");
  }else{
    M5.Lcd.println("Button is Pressed .");
  }
  delay(20);
}

publiéPour (pressedFor)

Syntaxe:

  uint8_t pressedFor(uint32_t ms);

Description:

Paramètres:

Retour:

Exemple007.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
}
 
void loop() {
  M5.update();
  M5.Lcd.setCursor(0, 0);
  if (M5.BtnA.releasedFor(2000)) {
    M5.Lcd.println("Button A was released for more than 2 seconds.");
    delay(1000);
  }else{
    M5.Lcd.println("Button A is pressed                           ");
  }
}

a été libéré ( wasReleased )

Syntaxe:

  uint8_t wasReleased();

Description:

Paramètres:

Retour:

Exemple008.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
  M5.Lcd.println("Please pressed Button A.");
}
 
void loop() {
  M5.update();
  if(M5.BtnA.wasReleased()) {
    M5.Lcd.println("Button is Released.");
  }
  delay(20);
}

étaitLibérépour (wasReleasefor)

Syntaxe:

  uint8_t wasReleasefor(uint32_t ms);

Description:

Paramètres:

Retour:

Exemple009.ino
#include <M5Stack.h>
 
void setup() {
  M5.begin();
  M5.Lcd.println("Please pressed Button A.");
}
 
void loop() {
  M5.update();
  if (M5.BtnA.wasReleasefor(3000)) {
      M5.Lcd.println("OK");
  }
}