System & Button

System

begin()

Function: Initialize E-Ink, I2C, Speaker, RTC, serial port

Syntax:int begin(bool InkEnable, bool wireEnable, bool SpeakerEnable)

Example:

#include "M5CoreInk.h"

void setup() {
  M5.begin(true,true,true);
}

update()

Function: Refresh device button/buzzer status

Syntax:void update()

Example:

#include "M5CoreInk.h"
void setup() {
  M5.begin(false,false,true);
}

void loop() {
  M5.update();
  M5.Speaker.tone(1000,1000);
  if( M5.BtnPWR.wasPressed()){
    Serial.printf("Btn wasPressed!");
  }
  delay(1000);
}

Button

Function: Detect device button status

Function list:

M5.BtnUP.wasPressed()

M5.BtnDOWN.wasPressed()

M5.BtnMID.wasPressed()

M5.BtnEXT.wasPressed()

M5.BtnPWR.wasPressed()

Function describe
BtnUP Scroll wheel up
BtnDOWN Trackwheel scroll down
BtnMID Dial down
BtnEXT Top button press
BtnPWR Right button press

Example:

#include "M5CoreInk.h"
void setup() {
  M5.begin(true,false,false);
}

void loop() {
  if( M5.BtnUP.wasPressed()){
    Serial.printf("BtnUP wasPressed!\n");
  }else if( M5.BtnDOWN.wasPressed()){
    Serial.printf("BtnDOWN wasPressed!\n");
  }else if( M5.BtnMID.wasPressed()){
    Serial.printf("BtnMID wasPressed!\n");
  }else if( M5.BtnEXT.wasPressed()){
    Serial.printf("BtnEXT wasPressed!\n");
  }else if( M5.BtnPWR.wasPressed()){
    Serial.printf("BtnPWR wasPressed!\n");
  }
  M5.update();
}

Speaker

update()

Function: Refresh device button/buzzer status

Syntax:void update()

end()

Function: Turn off the buzzer

Syntax:void end()

mute()

Function: Set the buzzer to mute

Syntax:void mute()

setBeep()

Function: Set the frequency and duration of the buzzer

Syntax:void setBeep(uint16_t frequency, uint16_t duration)

beep()

Function: Let the buzzer sound

Syntax:void beep()

Example:

#include "M5CoreInk.h"
void setup() {
  M5.begin(false,false,true);
}

void loop() {
  M5.Speaker.setBeep(1000,1000);
  M5.Speaker.beep();
  delay(1000);
  M5.update();
}

tone()

**Function:**⓵Let the buzzer keep sounding at the specified frequency ⓶Let the buzzer sound at a specified frequency for a specified duration

Syntax:

void tone(uint16_t frequency)

void tone(uint16_t frequency, uint32_t duration)

Example:

#include "M5CoreInk.h"

void setup() {
  M5.begin(false,false,true);
}

void loop() {
  M5.Speaker.tone(1000);
  delay(1000);
  M5.Speaker.noTone();
  M5.Speaker.tone(1000,1000);
  delay(1000);
  M5.Speaker.update();
}

setVolume()

Function: Set the volume of the speaker

Syntax:void setVolume(uint8_t volume)

Example:

#include "M5CoreInk.h"
void setup() {
  M5.begin(false,false,true);
}

void loop() {
  M5.Speaker.setBeep(1000,1000);
  M5.Speaker.beep();
  delay(1000);
  M5.update();
}

playMusic()

Function: Play music

Syntax:void playMusic(const uint8_t *music_data, uint16_t sample_rate)

On This Page