Added GUI to parser.
|
@ -45,6 +45,12 @@ void drawGui(screenMode COLOR_MODE) {
|
|||
} else {
|
||||
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_light);
|
||||
}
|
||||
|
||||
// NOT CONNECTED BLUETOOTH
|
||||
for (int i = 0; i < 4; i++) { // thicker line
|
||||
M5.lcd.drawLine(280 + i, 55, 310 + i, 5, RED);
|
||||
}
|
||||
|
||||
|
||||
M5.Lcd.drawLine(0, 60, 320, 60, COLORS[COLOR_MODE]);
|
||||
|
||||
|
|
92
src/GUI/GUI/GUI.ino
Normal file
|
@ -0,0 +1,92 @@
|
|||
#include <M5Core2.h>
|
||||
#include "icons.cpp" // icons
|
||||
|
||||
ButtonColors noDraw = {NODRAW, NODRAW, NODRAW};
|
||||
Button screenModeButton(0, 190, 50, 50, false, "", noDraw);
|
||||
Button restartButton(200, 191, 45, 50, false, "", noDraw);
|
||||
Button powerOffButton(260, 186, 55, 55, false, "", noDraw);
|
||||
|
||||
enum screenMode {DARK, LIGHT};
|
||||
screenMode COLOR_MODE = LIGHT;
|
||||
|
||||
uint16_t COLORS[2] = {WHITE, BLACK};
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
|
||||
screenModeButton.addHandler(screenModeHandler, E_TOUCH);
|
||||
restartButton.addHandler(restartHandler, E_TOUCH);
|
||||
powerOffButton.addHandler(powerOffHandler, E_TOUCH);
|
||||
drawGui(COLOR_MODE);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
M5.update();
|
||||
}
|
||||
|
||||
void drawGui(screenMode COLOR_MODE) {
|
||||
M5.Lcd.clear();
|
||||
M5.Lcd.fillScreen((COLORS[COLOR_MODE] - 1) % 2);
|
||||
M5.Lcd.setTextColor(COLORS[COLOR_MODE]);
|
||||
|
||||
// HEADER
|
||||
if (COLOR_MODE == DARK) {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_white_2_3);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_1_3);
|
||||
}
|
||||
|
||||
M5.Lcd.drawString("100", 60, 20, 4);
|
||||
|
||||
if (COLOR_MODE == DARK) {
|
||||
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_dark);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_light);
|
||||
}
|
||||
|
||||
M5.Lcd.drawLine(0, 60, 320, 60, COLORS[COLOR_MODE]);
|
||||
|
||||
// BODY
|
||||
M5.Lcd.drawString("Attention", 20, 80, 4);
|
||||
M5.Lcd.drawString("Meditation", 160, 80, 4);
|
||||
|
||||
M5.Lcd.drawString("20", 60, 130, 4);
|
||||
M5.Lcd.drawString("0", 220, 130, 4);
|
||||
|
||||
// BOTTOM
|
||||
M5.Lcd.drawLine(0, 180, 320, 180, COLORS[COLOR_MODE]);
|
||||
screenModeButton.draw();
|
||||
if (COLOR_MODE == DARK) {
|
||||
M5.lcd.drawBitmap(0, 191, 50, 50, (uint16_t *) modeSwitchDark);
|
||||
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart_white);
|
||||
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off_white);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(0, 191, 50, 50, (uint16_t *) modeSwitchLight);
|
||||
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart);
|
||||
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void screenModeHandler(Event& e) {
|
||||
if (COLOR_MODE == DARK) {
|
||||
COLOR_MODE = LIGHT;
|
||||
} else {
|
||||
COLOR_MODE = DARK;
|
||||
}
|
||||
|
||||
drawGui(COLOR_MODE);
|
||||
}
|
||||
|
||||
void restartHandler(Event& e) {
|
||||
M5.shutdown(1);
|
||||
}
|
||||
|
||||
void powerOffHandler(Event& e) {
|
||||
M5.shutdown();
|
||||
}
|
2614
src/GUI/GUI/icons.cpp
Normal file
BIN
src/GUI/img/bluetooth_dark.png
Normal file
After Width: | Height: | Size: 471 B |
BIN
src/GUI/img/bluetooth_light.png
Normal file
After Width: | Height: | Size: 471 B |
BIN
src/GUI/img/icons8-day-and-night-50.png
Normal file
After Width: | Height: | Size: 815 B |
BIN
src/GUI/img/image.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
src/GUI/img/power_off.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
src/GUI/img/power_off_white.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
src/GUI/img/restart.png
Normal file
After Width: | Height: | Size: 612 B |
BIN
src/GUI/img/restart_white.png
Normal file
After Width: | Height: | Size: 612 B |
BIN
src/GUI/img/signal_0_3.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
src/GUI/img/signal_1_3.png
Normal file
After Width: | Height: | Size: 345 B |
BIN
src/GUI/img/signal_2_3.png
Normal file
After Width: | Height: | Size: 234 B |
BIN
src/GUI/img/signal_3_3.png
Normal file
After Width: | Height: | Size: 225 B |
BIN
src/GUI/img/signal_white_0_3.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
src/GUI/img/signal_white_1_3.png
Normal file
After Width: | Height: | Size: 378 B |
BIN
src/GUI/img/signal_white_2_3.png
Normal file
After Width: | Height: | Size: 234 B |
BIN
src/GUI/img/signal_white_3_3.png
Normal file
After Width: | Height: | Size: 225 B |
184
src/core2_C_Parser/core2_C_Parser.ino
Normal file
|
@ -0,0 +1,184 @@
|
|||
#define BAUDRATE 115200
|
||||
#define DEBUGOUTPUT 0
|
||||
#include <map> // Bluetooth
|
||||
#include <BluetoothSerial.h> // Bluetooth
|
||||
#include <M5Core2.h>
|
||||
|
||||
// Bluetooth Serial, variables
|
||||
BluetoothSerial SerialBT;
|
||||
#define BT_DISCOVER_TIME 10000
|
||||
esp_spp_sec_t sec_mask=ESP_SPP_SEC_NONE;
|
||||
esp_spp_role_t role=ESP_SPP_ROLE_SLAVE;
|
||||
|
||||
// checksum variables
|
||||
byte generatedChecksum = 0;
|
||||
byte checksum = 0;
|
||||
int payloadLength = 0;
|
||||
byte payloadData[64] = {0};
|
||||
byte poorQuality = 0;
|
||||
byte attention = 0;
|
||||
byte meditation = 0;
|
||||
|
||||
// system variables
|
||||
long lastReceivedPacket = 0;
|
||||
boolean bigPacket = false;
|
||||
|
||||
//////////////////////////
|
||||
// Microprocessor Setup //
|
||||
//////////////////////////
|
||||
|
||||
void setup(){
|
||||
Serial.begin(BAUDRATE);
|
||||
M5.begin();
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//////////////////////////
|
||||
// BLUETOOTH CONNECTION //
|
||||
//////////////////////////
|
||||
|
||||
if(! SerialBT.begin("ESP32test", true) ) {
|
||||
Serial.println("========== serialBT failed!");
|
||||
abort();
|
||||
}
|
||||
|
||||
Serial.println("Starting discoverAsync...");
|
||||
BTScanResults* btDeviceList = SerialBT.getScanResults();
|
||||
if (SerialBT.discoverAsync([](BTAdvertisedDevice* pDevice) {
|
||||
Serial.printf(">>>>>>>>>>>Found a new device asynchronously: %s\n", pDevice->toString().c_str());
|
||||
} )
|
||||
) {
|
||||
delay(BT_DISCOVER_TIME);
|
||||
Serial.print("Stopping discoverAsync... ");
|
||||
SerialBT.discoverAsyncStop();
|
||||
Serial.println("discoverAsync stopped");
|
||||
delay(5000);
|
||||
if(btDeviceList->getCount() > 0) {
|
||||
BTAddress addr;
|
||||
int channel=0;
|
||||
Serial.println("Found devices:");
|
||||
for (int i=0; i < btDeviceList->getCount(); i++) {
|
||||
BTAdvertisedDevice *device=btDeviceList->getDevice(i);
|
||||
Serial.printf(" ----- %s %s %d\n", device->getAddress().toString().c_str(), device->getName().c_str(), device->getRSSI());
|
||||
std::map<int,std::string> channels=SerialBT.getChannels(device->getAddress());
|
||||
Serial.printf("scanned for services, found %d\n", channels.size());
|
||||
for(auto const &entry : channels) {
|
||||
Serial.printf(" channel %d (%s)\n", entry.first, entry.second.c_str());
|
||||
}
|
||||
if(channels.size() > 0) {
|
||||
addr = device->getAddress();
|
||||
channel=channels.begin()->first;
|
||||
}
|
||||
}
|
||||
if(addr) {
|
||||
Serial.printf("connecting to %s - %d\n", addr.toString().c_str(), channel);
|
||||
SerialBT.connect(addr, channel, sec_mask, role);
|
||||
}
|
||||
} else {
|
||||
Serial.println("Didn't find any devices");
|
||||
}
|
||||
} else {
|
||||
Serial.println("Error on discoverAsync f.e. not workin after a \"connect\"");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
// Read data from Serial Bluetooth //
|
||||
/////////////////////////////////////
|
||||
|
||||
byte ReadOneByte() {
|
||||
int ByteRead;
|
||||
if(! SerialBT.isClosed() && SerialBT.connected()) {
|
||||
while(!SerialBT.available());
|
||||
ByteRead = SerialBT.read();
|
||||
|
||||
#if DEBUGOUTPUT
|
||||
Serial.print((char)ByteRead); // echo the same byte out the USB serial (for debug purposes)
|
||||
#endif
|
||||
|
||||
return ByteRead;
|
||||
} else {
|
||||
Serial.println("not connected");
|
||||
}
|
||||
}
|
||||
|
||||
/////////////
|
||||
//MAIN LOOP//
|
||||
/////////////
|
||||
void loop() {
|
||||
// Look for sync bytes
|
||||
if(ReadOneByte() == 170) {
|
||||
if(ReadOneByte() == 170) {
|
||||
payloadLength = ReadOneByte();
|
||||
if(payloadLength > 169) //Payload length can not be greater than 169
|
||||
return;
|
||||
|
||||
generatedChecksum = 0;
|
||||
for(int i = 0; i < payloadLength; i++) {
|
||||
payloadData[i] = ReadOneByte(); //Read payload into memory
|
||||
generatedChecksum += payloadData[i];
|
||||
}
|
||||
|
||||
checksum = ReadOneByte(); //Read checksum byte from stream
|
||||
generatedChecksum = 255 - generatedChecksum; //Take one's compliment of generated checksum
|
||||
|
||||
if(checksum == generatedChecksum) {
|
||||
|
||||
poorQuality = 200;
|
||||
attention = 0;
|
||||
meditation = 0;
|
||||
|
||||
for(int i = 0; i < payloadLength; i++) { // Parse the payload
|
||||
switch (payloadData[i]) {
|
||||
case 2:
|
||||
i++;
|
||||
poorQuality = payloadData[i];
|
||||
bigPacket = true;
|
||||
break;
|
||||
case 4:
|
||||
i++;
|
||||
attention = payloadData[i];
|
||||
break;
|
||||
case 5:
|
||||
i++;
|
||||
meditation = payloadData[i];
|
||||
break;
|
||||
case 0x80:
|
||||
i = i + 3;
|
||||
break;
|
||||
case 0x83:
|
||||
i = i + 25;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
} // for loop
|
||||
|
||||
#if !DEBUGOUTPUT
|
||||
// *** Add your code here ***
|
||||
if(bigPacket) {
|
||||
Serial.print("Attention: ");
|
||||
Serial.print(attention);
|
||||
Serial.print("\n");
|
||||
Serial.print("Poor quality: ");
|
||||
Serial.print(poorQuality);
|
||||
Serial.print("\n");
|
||||
Serial.print("Meditation: ");
|
||||
Serial.print(meditation);
|
||||
Serial.print("\n");
|
||||
}
|
||||
#endif
|
||||
bigPacket = false;
|
||||
}
|
||||
else {
|
||||
// Checksum Error
|
||||
} // end if else for checksum
|
||||
} // end if read 0xAA byte
|
||||
} // end if read 0xAA byte
|
||||
}
|
2616
src/projectEEG/icons.cpp
Normal file
332
src/projectEEG/projectEEG.ino
Normal file
|
@ -0,0 +1,332 @@
|
|||
#define BAUDRATE 115200
|
||||
#define DEBUGOUTPUT 0
|
||||
#include <map> // Bluetooth
|
||||
#include <BluetoothSerial.h> // Bluetooth
|
||||
#include <M5Core2.h>
|
||||
#include "icons.cpp" // icons
|
||||
|
||||
// GUI variables
|
||||
int brightnessValue = 4;
|
||||
ButtonColors noDraw = {NODRAW, NODRAW, NODRAW};
|
||||
Button screenModeButton(0, 190, 50, 50, false, "", noDraw);
|
||||
Button brightnessButton(55, 190, 50, 50, false, "", noDraw);
|
||||
Button restartButton(200, 191, 45, 50, false, "", noDraw);
|
||||
Button powerOffButton(260, 186, 55, 55, false, "", noDraw);
|
||||
|
||||
enum screenMode {DARK, LIGHT};
|
||||
screenMode COLOR_MODE = LIGHT;
|
||||
|
||||
uint16_t COLORS[2] = {WHITE, BLACK};
|
||||
|
||||
// Bluetooth Serial, variables
|
||||
BluetoothSerial SerialBT;
|
||||
#define BT_DISCOVER_TIME 1000
|
||||
esp_spp_sec_t sec_mask=ESP_SPP_SEC_NONE;
|
||||
esp_spp_role_t role=ESP_SPP_ROLE_SLAVE;
|
||||
boolean isConnected = false;
|
||||
|
||||
// checksum variables
|
||||
byte generatedChecksum = 0;
|
||||
byte checksum = 0;
|
||||
int payloadLength = 0;
|
||||
byte payloadData[64] = {0};
|
||||
byte poorQuality = 0;
|
||||
byte attention = 0;
|
||||
byte meditation = 0;
|
||||
|
||||
// system variables
|
||||
long lastReceivedPacket = 0;
|
||||
boolean bigPacket = false;
|
||||
|
||||
//////////////////////////
|
||||
// Microprocessor Setup //
|
||||
//////////////////////////
|
||||
|
||||
void setup(){
|
||||
Serial.begin(BAUDRATE);
|
||||
M5.begin();
|
||||
M5.Axp.SetLcdVoltage(3150); // Set initial brightness
|
||||
|
||||
// GUI
|
||||
screenModeButton.addHandler(screenModeHandler, E_TOUCH);
|
||||
brightnessButton.addHandler(brightnessHandler, E_TOUCH);
|
||||
restartButton.addHandler(restartHandler, E_TOUCH);
|
||||
powerOffButton.addHandler(powerOffHandler, E_TOUCH);
|
||||
drawGui(COLOR_MODE);
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//////////////////////////
|
||||
// BLUETOOTH CONNECTION //
|
||||
//////////////////////////
|
||||
|
||||
if(! SerialBT.begin("ESP32test", true) ) {
|
||||
Serial.println("========== serialBT failed!");
|
||||
}
|
||||
|
||||
Serial.println("Starting discoverAsync...");
|
||||
BTScanResults* btDeviceList = SerialBT.getScanResults();
|
||||
if (SerialBT.discoverAsync([](BTAdvertisedDevice* pDevice) {
|
||||
Serial.printf(">>>>>>>>>>>Found a new device asynchronously: %s\n", pDevice->toString().c_str());
|
||||
} )
|
||||
) {
|
||||
delay(BT_DISCOVER_TIME);
|
||||
Serial.print("Stopping discoverAsync... ");
|
||||
SerialBT.discoverAsyncStop();
|
||||
Serial.println("discoverAsync stopped");
|
||||
delay(1000);
|
||||
if(btDeviceList->getCount() > 0) {
|
||||
BTAddress addr;
|
||||
int channel=0;
|
||||
Serial.println("Found devices:");
|
||||
for (int i=0; i < btDeviceList->getCount(); i++) {
|
||||
BTAdvertisedDevice *device=btDeviceList->getDevice(i);
|
||||
Serial.printf(" ----- %s %s %d\n", device->getAddress().toString().c_str(), device->getName().c_str(), device->getRSSI());
|
||||
std::map<int,std::string> channels=SerialBT.getChannels(device->getAddress());
|
||||
Serial.printf("scanned for services, found %d\n", channels.size());
|
||||
for(auto const &entry : channels) {
|
||||
Serial.printf(" channel %d (%s)\n", entry.first, entry.second.c_str());
|
||||
}
|
||||
if(channels.size() > 0) {
|
||||
addr = device->getAddress();
|
||||
channel=channels.begin()->first;
|
||||
}
|
||||
}
|
||||
if(addr) {
|
||||
Serial.printf("connecting to %s - %d\n", addr.toString().c_str(), channel);
|
||||
SerialBT.connect(addr, channel, sec_mask, role);
|
||||
isConnected = true;
|
||||
drawGui(COLOR_MODE);
|
||||
}
|
||||
} else {
|
||||
Serial.println("Didn't find any devices");
|
||||
}
|
||||
} else {
|
||||
Serial.println("Error on discoverAsync f.e. not workin after a \"connect\"");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
// Read data from Serial Bluetooth //
|
||||
/////////////////////////////////////
|
||||
|
||||
byte ReadOneByte() {
|
||||
int ByteRead;
|
||||
if(! SerialBT.isClosed() && SerialBT.connected()) {
|
||||
ByteRead = SerialBT.read();
|
||||
|
||||
#if DEBUGOUTPUT
|
||||
Serial.print((char)ByteRead); // echo the same byte out the USB serial (for debug purposes)
|
||||
#endif
|
||||
|
||||
return ByteRead;
|
||||
} else {
|
||||
Serial.println("not connected");
|
||||
M5.update();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////
|
||||
//MAIN LOOP//
|
||||
/////////////
|
||||
void loop() {
|
||||
M5.update();
|
||||
if (!SerialBT.connected() && isConnected == true) {
|
||||
isConnected = false;
|
||||
drawGui(COLOR_MODE);
|
||||
}
|
||||
if(! SerialBT.isClosed() && SerialBT.connected()) {
|
||||
if(ReadOneByte() == 170) {
|
||||
if(ReadOneByte() == 170) {
|
||||
payloadLength = ReadOneByte();
|
||||
if(payloadLength > 169) //Payload length can not be greater than 169
|
||||
return;
|
||||
|
||||
generatedChecksum = 0;
|
||||
|
||||
for(int i = 0; i < payloadLength; i++) {
|
||||
payloadData[i] = ReadOneByte(); //Read payload into memory
|
||||
generatedChecksum += payloadData[i];
|
||||
}
|
||||
|
||||
checksum = ReadOneByte(); //Read checksum byte from stream
|
||||
generatedChecksum = 255 - generatedChecksum; //Take one's compliment of generated checksum
|
||||
|
||||
if(checksum == generatedChecksum) {
|
||||
|
||||
poorQuality = 200;
|
||||
attention = 0;
|
||||
meditation = 0;
|
||||
|
||||
for(int i = 0; i < payloadLength; i++) { // Parse the payload
|
||||
switch (payloadData[i]) {
|
||||
case 2:
|
||||
i++;
|
||||
poorQuality = payloadData[i];
|
||||
bigPacket = true;
|
||||
break;
|
||||
case 4:
|
||||
i++;
|
||||
attention = payloadData[i];
|
||||
break;
|
||||
case 5:
|
||||
i++;
|
||||
meditation = payloadData[i];
|
||||
break;
|
||||
case 0x80:
|
||||
i = i + 3;
|
||||
break;
|
||||
case 0x83:
|
||||
i = i + 25;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
} // for loop
|
||||
|
||||
#if !DEBUGOUTPUT
|
||||
// *** Add your code here ***
|
||||
if(bigPacket) {
|
||||
drawGui(COLOR_MODE);
|
||||
Serial.print("Attention: ");
|
||||
Serial.print(attention);
|
||||
Serial.print("\n");
|
||||
Serial.print("Poor quality: ");
|
||||
Serial.print(poorQuality);
|
||||
Serial.print("\n");
|
||||
Serial.print("Meditation: ");
|
||||
Serial.print(meditation);
|
||||
Serial.print("\n");
|
||||
}
|
||||
#endif
|
||||
bigPacket = false;
|
||||
}
|
||||
else {
|
||||
// Checksum Error
|
||||
} // end if else for checksum
|
||||
} // end if read 0xAA byte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
// GUI
|
||||
|
||||
void drawGui(screenMode COLOR_MODE) {
|
||||
M5.Lcd.clear();
|
||||
M5.Lcd.fillScreen((COLORS[COLOR_MODE] - 1) % 2);
|
||||
M5.Lcd.setTextColor(COLORS[COLOR_MODE]);
|
||||
|
||||
// HEADER
|
||||
if (COLOR_MODE == DARK) {
|
||||
if (poorQuality < 50) {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_white_3_3);
|
||||
} else if ((50 < poorQuality) && (poorQuality < 150)) {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_white_2_3);
|
||||
} else if ((poorQuality == 200) || (poorQuality > 230)) {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_white_0_3);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_white_1_3);
|
||||
}
|
||||
} else {
|
||||
if (poorQuality < 50) {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_3_3);
|
||||
} else if ((50 < poorQuality) && (poorQuality < 150)) {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_2_3);
|
||||
} else if ((poorQuality == 200) || (poorQuality > 230)) {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_0_3);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_1_3);
|
||||
}
|
||||
}
|
||||
|
||||
if (poorQuality == 200) { //
|
||||
for (int i = 0; i < 4; i++) { // thicker line
|
||||
M5.lcd.drawLine(5 + i, 55, 55 + i, 5, RED);
|
||||
}
|
||||
}
|
||||
|
||||
M5.Lcd.drawString(String(poorQuality), 60, 20, 4);
|
||||
|
||||
if (COLOR_MODE == DARK) {
|
||||
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_dark);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_light);
|
||||
}
|
||||
|
||||
if (isConnected == false) { // IF BLUETOOTH DISCONNECTED
|
||||
for (int i = 0; i < 4; i++) { // thicker line
|
||||
M5.lcd.drawLine(280 + i, 55, 310 + i, 5, RED);
|
||||
}
|
||||
}
|
||||
|
||||
M5.Lcd.drawLine(0, 60, 320, 60, COLORS[COLOR_MODE]);
|
||||
|
||||
// BODY
|
||||
M5.Lcd.drawString("Attention", 20, 80, 4);
|
||||
M5.Lcd.drawString("Meditation", 160, 80, 4);
|
||||
|
||||
M5.Lcd.drawString(String(attention), 60, 130, 4);
|
||||
M5.Lcd.drawString(String(meditation), 220, 130, 4);
|
||||
|
||||
// BOTTOM
|
||||
M5.Lcd.drawLine(0, 180, 320, 180, COLORS[COLOR_MODE]);
|
||||
screenModeButton.draw();
|
||||
if (COLOR_MODE == DARK) {
|
||||
M5.lcd.drawBitmap(0, 191, 50, 50, (uint16_t *) modeSwitchDark);
|
||||
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart_white);
|
||||
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off_white);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(0, 191, 50, 50, (uint16_t *) modeSwitchLight);
|
||||
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart);
|
||||
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void screenModeHandler(Event& e) {
|
||||
if (COLOR_MODE == DARK) {
|
||||
COLOR_MODE = LIGHT;
|
||||
} else {
|
||||
COLOR_MODE = DARK;
|
||||
}
|
||||
|
||||
drawGui(COLOR_MODE);
|
||||
}
|
||||
|
||||
void brightnessHandler(Event& e) {
|
||||
switch (brightnessValue) {
|
||||
case 1:
|
||||
M5.Axp.SetLcdVoltage(2500);
|
||||
brightnessValue += 1;
|
||||
break;
|
||||
case 2:
|
||||
M5.Axp.SetLcdVoltage(2750);
|
||||
brightnessValue += 1;
|
||||
break;
|
||||
case 3:
|
||||
M5.Axp.SetLcdVoltage(2900);
|
||||
brightnessValue += 1;
|
||||
break;
|
||||
case 4:
|
||||
M5.Axp.SetLcdVoltage(3150);
|
||||
brightnessValue = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void restartHandler(Event& e) {
|
||||
M5.shutdown(1);
|
||||
}
|
||||
|
||||
void powerOffHandler(Event& e) {
|
||||
M5.shutdown();
|
||||
}
|