System

begin()

機能です:

E-Inkを初期化; I2Cを初期化; スピーカーを初期化; RTCを初期化; シリアル通信バッファーをクリア、シリアル通信のボーレートを115200に設定; デバイスのボタン/ブザー状態を更新

原型関数です:

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

関数実装です:

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 initializ is faild\n");
      return -1;
    }
  }

  return 0;
}

使用例です:

#include "M5CoreInk.h"

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

update()

機能です:

デバイスボタン/ブザー状態をリフレッシュします

原型関数です:

void update()

使用例です:

#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

機能です:

デバイスの各ボタン状態を検出

函数列表:

M5.BtnUP.wasPressed()

M5.BtnDOWN.wasPressed()

M5.BtnMID.wasPressed()

M5.BtnEXT.wasPressed()

M5.BtnPWR.wasPressed()

関数 関数の機能
BtnUP BtnUP 回転式選択ボタンを上方向にスクロール
BtnDOWN BtnDOWN 回転式選択ボタンを下方向にスクロール
BtnMID BtnMID 回転式選択ボタンを押下
BtnEXT BtnEXT 上部のボタンを押下
BtnPWR BtnPWR 右側のボタンを押下

使用例です:

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

機能です:

デバイスのボタン/ブザー状態を更新

原型関数です:

void update()

end()

機能です:

ブザーを停止

原型関数です:

void end()

使用例です:

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

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

mute()

機能です:

ブザーを静音に設定

原型関数です:

void mute()

使用例です:

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

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

setBeep()

機能です:

ブザーの周波数と発声時間を設定

原型関数です:

void setBeep(uint16_t frequency, uint16_t duration)

使用例です:

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

機能です:

ブザーを鳴らす

原型関数です:

void beep()

使用例です:

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

機能です:

ブザーを指定の周波数で連続発声

原型関数です:

void tone(uint16_t frequency)

void tone(uint16_t frequency, uint32_t duration)

使用例です:

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

機能です:

ブザーの音量を設定

原型関数です:

void setVolume(uint8_t volume)

使用例です:

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

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

playMusic()

機能です:

ブザーに音楽を再生

原型関数です:

void playMusic(const uint8_t *music_data, uint16_t sample_rate)

On This Page