Skip to content

Commit

Permalink
Cleanup. Color changes. Pointed out using latest M5STACK.
Browse files Browse the repository at this point in the history
  • Loading branch information
sboger committed Apr 9, 2019
1 parent 832c535 commit 4001936
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
34 changes: 20 additions & 14 deletions M5-BT-TFT_Terminal.ino
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
#include <M5Stack.h>
#include "BluetoothSerial.h"
#include "WiFi.h"
//#include "WiFi.h"

BluetoothSerial SerialBT;

// The scrolling area setup. Must be a integral multiple of TEXT_HEIGHT
#define TEXT_HEIGHT 16 // Height of text to be printed and scrolled
#define TEXT_HEIGHT 8 // Height of text to be printed and scrolled
#define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
#define TOP_FIXED_AREA 16 // Number of lines in top fixed area (lines counted from top of screen)
#define YMAX 240 // Bottom of screen area
// end scrolling

#define INPUT_COLOR1 TFT_CYAN
#define INPUT_COLOR2 TFT_WHITE //TFT_MAGENTA

#define SECS_TO_SLEEP 30 // Set auto sleep time to 30 seconds
// Note: Will auto-awaken on input
boolean sleepMode = 0; // Start with sleep mode on (1) or off (0).


int LcdBrightness = 80; // 50%
int LcdBrightness = 100; //


// The initial y coordinate of the top of the scrolling area
Expand Down Expand Up @@ -45,7 +47,7 @@ int blank[19];
void setup() {
M5.begin();

WiFi.mode(WIFI_OFF);
//WiFi.mode(WIFI_OFF);

M5.Power.begin();

Expand All @@ -57,12 +59,12 @@ void setup() {

SerialBT.begin("BLUETERM5"); //Bluetooth device name

M5.Lcd.setTextColor(TFT_WHITE, TFT_BLUE);
M5.Lcd.setTextColor(TFT_CYAN, TFT_BLUE);
M5.Lcd.fillRect(0,0,320,16, TFT_BLUE);
M5.Lcd.drawCentreString(" BLUETERM5 ",320/2,0,2);

// Change color for scrolling zone text
M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
M5.Lcd.setTextColor(TFT_WHITE, TFT_TRANSPARENT);

// Setup scroll area
setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
Expand All @@ -83,6 +85,7 @@ void loop(void) {
sleepMode = 0;
} else if (M5.BtnA.wasReleasefor(400)) {
sleepMode = 1;
timeSinceLastUpdate = millis(); // needed or display goes to sleep immediately
}

// Y U BROKEN???
Expand Down Expand Up @@ -116,18 +119,21 @@ void loop(void) {
}

if (data > 31 && data < 128) {
xPos += M5.Lcd.drawChar(data,xPos,yDraw,2);
xPos += M5.Lcd.drawChar(data,xPos,yDraw,1);
blank[(18+(yStart-TOP_FIXED_AREA)/TEXT_HEIGHT)%19]=xPos; // Keep a record of line lengths
}
}
}

changeTripped = 1;

if (sleepMode) {
if (millis() - timeSinceLastUpdate > (1000L*SECS_TO_SLEEP)) {
M5.Lcd.setBrightness(0);
M5.Lcd.sleep();
timeSinceLastUpdate = millis();
}
}

}

// ##############################################################################################
Expand All @@ -145,8 +151,8 @@ void displayBatt() {
battstat = String(M5.Power.getBatteryLevel()) + "%";
}

M5.Lcd.setTextColor(TFT_WHITE, TFT_BLUE);
M5.Lcd.drawString("["+battstat.substring(0,4)+"] ",270,1,1);
M5.Lcd.setTextColor(TFT_CYAN, TFT_BLUE);
M5.Lcd.drawString(battstat,290,1,1);
}

// ##############################################################################################
Expand All @@ -155,7 +161,7 @@ void displayBatt() {
void displaySleepMode(boolean mode) {

String sMode = (String)(mode ? "Zzz " : "NoZ ");
M5.Lcd.setTextColor(TFT_WHITE, TFT_BLUE);
M5.Lcd.setTextColor(TFT_CYAN, TFT_BLUE);
M5.Lcd.drawString(sMode,10,1,1);
}

Expand Down Expand Up @@ -205,11 +211,11 @@ void scrollAddress(uint16_t vsp) {
// ##############################################################################################
void colorRotator() {
if (changeTripped) {
if (changeColor) {
M5.Lcd.setTextColor(TFT_CYAN, TFT_BLACK);
if (changeColor) {
M5.Lcd.setTextColor(INPUT_COLOR1, TFT_TRANSPARENT);
changeColor=0;
} else {
M5.Lcd.setTextColor(TFT_MAGENTA, TFT_BLACK);
M5.Lcd.setTextColor(INPUT_COLOR2, TFT_TRANSPARENT);
changeColor=1;
}
changeTripped=0;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This MAIN m5stack branch is for work on integrating into M5Stack.
* Battery status upper right
* Auto-Sleep status in upper left.

I'm using the latest M5STACK from github.
In Arduino, set Tool->Partition Scheme-> No OTA (Large APP)

Linux Example:
Expand Down

0 comments on commit 4001936

Please sign in to comment.