2017-04-28 21:53:40 +08:00
|
|
|
// Copyright (c) M5Stack. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
#include "M5Stack.h"
|
|
|
|
|
|
2017-07-16 16:27:27 +08:00
|
|
|
void M5Stack::begin() {
|
2017-07-18 18:27:56 +08:00
|
|
|
|
2017-07-20 17:53:07 +08:00
|
|
|
// UART
|
2017-07-18 18:27:56 +08:00
|
|
|
Serial.begin(115200);
|
2017-07-19 18:42:30 +08:00
|
|
|
Serial.flush();
|
|
|
|
|
Serial.println("M5Stack init...");
|
2017-04-28 21:53:40 +08:00
|
|
|
|
2017-07-18 18:27:56 +08:00
|
|
|
// TONE
|
|
|
|
|
Speaker.begin();
|
2017-04-28 21:53:40 +08:00
|
|
|
|
2017-07-18 18:27:56 +08:00
|
|
|
// Setup the button with an internal pull-up
|
|
|
|
|
pinMode(BUTTON_A_PIN, INPUT_PULLUP);
|
|
|
|
|
pinMode(BUTTON_B_PIN, INPUT_PULLUP);
|
|
|
|
|
pinMode(BUTTON_C_PIN, INPUT_PULLUP);
|
2017-06-05 09:26:37 +08:00
|
|
|
|
2017-07-20 17:53:07 +08:00
|
|
|
// TF Card
|
|
|
|
|
SD.begin(TFCARD_CS_PIN);
|
2017-07-19 18:42:30 +08:00
|
|
|
|
|
|
|
|
// M5 LCD INIT
|
|
|
|
|
Lcd.begin();
|
|
|
|
|
Lcd.fillScreen(BLACK);
|
|
|
|
|
Lcd.setCursor(0, 0);
|
|
|
|
|
Lcd.setTextColor(WHITE);
|
|
|
|
|
Lcd.setTextSize(1);
|
|
|
|
|
Lcd.setBrightness(80);
|
2017-04-28 21:53:40 +08:00
|
|
|
}
|
|
|
|
|
|
2017-07-16 16:27:27 +08:00
|
|
|
void M5Stack::update() {
|
2017-04-28 21:53:40 +08:00
|
|
|
|
2017-07-18 18:27:56 +08:00
|
|
|
//Button update
|
|
|
|
|
BtnA.read();
|
|
|
|
|
BtnB.read();
|
|
|
|
|
BtnC.read();
|
2017-06-05 09:26:37 +08:00
|
|
|
|
2017-07-18 18:27:56 +08:00
|
|
|
//Speaker update
|
|
|
|
|
Speaker.update();
|
2017-06-05 09:26:37 +08:00
|
|
|
}
|
|
|
|
|
|
2017-04-28 21:53:40 +08:00
|
|
|
M5Stack m5;
|