pdf-icon

System

begin()

Description:

Initializes E-Ink; Initializes I2C; Initializes Speaker; Clears serial buffer, sets serial baud rate to 115200;

Syntax:

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

Function Implementation:

int M5CoreInk::begin(bool InkEnable, bool wireEnable, bool SpeakerEnable){
  pinMode(POWER_HOLD_PIN, OUTPUT);
  digitalWrite(POWER_HOLD_PIN, HIGH); // Hold power

  pinMode(LED_EXT_PIN, OUTPUT);

  Serial.begin(115200);
  Serial.printf("initializing.....OK\n");

  if (wireEnable){
    Wire.begin(32, 33, 10000);
  }

  if (SpeakerEnable){
    Speaker.begin();
  }

  rtc.begin();
  rtc.clearIRQ();

  if (InkEnable){
    M5Ink.begin();
    if (!M5.M5Ink.isInit()){
      Serial.printf("Ink initialization failed\n");
      return -1;
    }
  }

  return 0;
}

Example:

#include "M5CoreInk.h"

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

update()

Description:

Refreshes 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

Description:

Checks the status of various device buttons

Function List:

M5.BtnUP.wasPressed()

M5.BtnDOWN.wasPressed()

M5.BtnMID.wasPressed()

M5.BtnEXT.wasPressed()

M5.BtnPWR.wasPressed()

Function Functionality
BtnUP Scroll wheel up
BtnDOWN Scroll wheel down
BtnMID Scroll wheel press
BtnEXT Top button press
BtnPWR Right side 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()

Description:

Refreshes device button/buzzer status

Syntax:

void update()

end()

Description:

Turns off the buzzer

Syntax:

void end()

Example:

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

void loop() {
  delay(1000);
  M5.Speaker.beep();
  delay(1000);
  M5.Speaker.end();
}

mute()

Description:

Sets the buzzer to mute

Syntax:

void mute()

Example:

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

void loop() {
  M5.Speaker.beep();
  delay(1000);
  M5.Speaker.mute();
  delay(1000);
}

setBeep()

Description:

Sets the buzzer frequency and sound duration

Syntax:

void setBeep(uint16_t frequency, uint16_t duration)

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();
}

beep()

Description:

Makes the buzzer sound

Syntax:

void beep()

Example:


cpp
#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()

Description:

  1. Makes the buzzer sound at a specified frequency indefinitely
  2. Makes 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()

Description:

Sets the volume of the buzzer

Syntax:

void setVolume(uint8_t volume)

Example:

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

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

playMusic()

Description:

Plays music through the buzzer

Syntax:

void playMusic(const uint8_t *music_data, uint16_t sample_rate)

On This Page