Functionality:
Initializes E-Ink; Initializes I2C; Initializes Speaker; Clears serial buffer, sets serial baud rate to 115200;
Function Prototype:
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;
}
Usage Example:
#include "M5CoreInk.h"
void setup() {
M5.begin(true,true,true);
}
Functionality:
Refreshes device button/buzzer status
Function Prototype:
void update()
Usage 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);
}
Functionality:
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 |
Usage 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();
}
Functionality:
Refreshes device button/buzzer status
Function Prototype:
void update()
Functionality:
Turns off the buzzer
Function Prototype:
void end()
Usage Example:
#include "M5CoreInk.h"
void setup() {
M5.begin(false,false,true);
}
void loop() {
delay(1000);
M5.Speaker.beep();
delay(1000);
M5.Speaker.end();
}
Functionality:
Sets the buzzer to mute
Function Prototype:
void mute()
Usage Example:
#include "M5CoreInk.h"
void setup() {
M5.begin(false,false,true);
}
void loop() {
M5.Speaker.beep();
delay(1000);
M5.Speaker.mute();
delay(1000);
}
Functionality:
Sets the buzzer frequency and sound duration
Function Prototype:
void setBeep(uint16_t frequency, uint16_t duration)
Usage 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();
}
Functionality:
Makes the buzzer sound
Function Prototype:
void beep()
Usage 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();
}
Functionality:
Function Prototype:
void tone(uint16_t frequency)
void tone(uint16_t frequency, uint32_t duration)
Usage 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();
}
Functionality:
Sets the volume of the buzzer
Function Prototype:
void setVolume(uint8_t volume)
Usage Example:
#include "M5CoreInk.h"
void setup() {
M5.begin(false,false,true);
}
void loop() {
M5.Speaker.volume(1000);
M5.Speaker.beep();
delay(1000);
M5.update();
}
Functionality:
Plays music through the buzzer
Function Prototype:
void playMusic(const uint8_t *music_data, uint16_t sample_rate)