Skip to content

Commit

Permalink
Update to M5Stack latest version 0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed May 12, 2019
1 parent d090bf8 commit 669968b
Show file tree
Hide file tree
Showing 31 changed files with 3,372 additions and 2,317 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -25,6 +25,8 @@ https://github.com/m5stack/M5Stack/tree/master/examples

https://github.com/m5stack/M5Stack/blob/master/src/M5Stack.h#L19

https://docs.m5stack.com/#/en/api

## 4. H/W Reference

#### Pinout
Expand Down Expand Up @@ -61,7 +63,7 @@ https://github.com/m5stack/M5Stack/blob/master/src/M5Stack.h#L19
### M-BUS
![image](docs/M-BUS.jpg)

## 5. Awesome
## 5. USER CASES

* [M5Stack-SD-Updater](https://github.com/tobozo/M5Stack-SD-Updater) - Customizable menu system for M5Stack - loads apps from the Micro SD
card
Expand Down
2 changes: 2 additions & 0 deletions docs/getting_started_cn.md
Expand Up @@ -21,6 +21,8 @@ https://github.com/m5stack/M5Stack/tree/master/examples

https://github.com/m5stack/M5Stack/blob/master/src/M5Stack.h#L19

https://docs.m5stack.com/#/zh_CN/api

## 4. H/W 参考

#### 管脚映射
Expand Down
3 changes: 3 additions & 0 deletions docs/getting_started_ja.md
Expand Up @@ -25,6 +25,9 @@ https://github.com/m5stack/M5Stack/tree/master/examples

https://github.com/m5stack/M5Stack/blob/master/src/M5Stack.h#L19

https://docs.m5stack.com/#/ja/api


## 4. ハードウェア仕様

#### I/Oインタフェイス
Expand Down
2 changes: 1 addition & 1 deletion examples/Advanced/Display/JpegDraw/JpegDraw.ino
Expand Up @@ -4,7 +4,7 @@ void setup(void) {

M5.begin();

//Draw the jpeg file form TF card
//Draw the jpeg file "p2.jpg" from TF(SD) card
M5.Lcd.setBrightness(200);
M5.Lcd.drawJpgFile(SD, "/p2.jpg");
// M5.Lcd.drawJpgFile(SD, "/p1.jpg", 20, 30, 40, 50);
Expand Down
1 change: 0 additions & 1 deletion examples/Advanced/Display/TFT_Flash_Bitmap/Alert.h
Expand Up @@ -38,4 +38,3 @@ const unsigned short alert[1024] PROGMEM={
0xECA2,0xECA2,0xECC2,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4E1,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xECC2,0xECC3,0xECA2, // row 29, 960 pixels
0x8AC1,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0x9B01, // row 30, 992 pixels
0x0000,0x1880,0x51A0,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x61E0,0x28E0,0x0000}; // row 31, 1024 pixels

2 changes: 1 addition & 1 deletion examples/Advanced/Display/TFT_Flash_Bitmap/Close.h
Expand Up @@ -5,7 +5,7 @@
const uint16_t closeWidth = 32;
const uint16_t closeHeight = 32;

const unsigned short _close[1024] PROGMEM={
const unsigned short closeX[1024] PROGMEM={
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x30C3,0x4124,0x61C7,0x61C7,0x4124,0x30E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 0, 32 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x48E3,0xA249,0xEB8E,0xFCB2,0xFD14,0xFD75,0xFD96,0xFD34,0xFCF3,0xEBEF,0xA28A,0x4904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x58E3,0xC228,0xFC10,0xFD34,0xFE18,0xFE59,0xFE79,0xFE9A,0xFE9A,0xFE9A,0xFE9A,0xFE59,0xFD75,0xFC51,0xC28A,0x5904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
Expand Down
68 changes: 17 additions & 51 deletions examples/Advanced/Display/TFT_Flash_Bitmap/TFT_Flash_Bitmap.ino
@@ -1,6 +1,10 @@
// Icons are stored in tabs ^ e.g. Alert.h etc above this line
// Icon images are stored in tabs ^ e.g. Alert.h etc above this line
// more than one icon can be in a header file

// Arrays containing FLASH images can be created with UTFT library tool:
// (libraries\UTFT\Tools\ImageConverter565.exe)
// Convert to .c format then copy into a new tab

/*
This sketch demonstrates loading images from arrays stored in program (FLASH) memory.
Expand All @@ -9,7 +13,7 @@
This sketch does not use/need any fonts at all...
Code derived from ILI9341_due example
Code derived from ILI9341_due library example
Make sure all the display driver and pin comnenctions are correct by
editting the User_Setup.h file in the TFT_eSPI library folder.
Expand All @@ -22,7 +26,7 @@
#include <M5Stack.h>

// Include the header files that contain the icons
#include "alert.h"
#include "Alert.h"
#include "Close.h"
#include "Info.h"

Expand All @@ -34,10 +38,13 @@ void setup()

M5.Lcd.fillScreen(TFT_BLACK);

// Swap the colour byte order when rendering
M5.Lcd.setSwapBytes(true);

// Draw the icons
drawIcon(info, 100, 100, infoWidth, infoHeight);
drawIcon(alert, 140, 100, alertWidth, alertHeight);
drawIcon(_close, 180, 100, closeWidth, closeHeight);
M5.Lcd.pushImage(100, 100, infoWidth, infoHeight, info);
M5.Lcd.pushImage(140, 100, alertWidth, alertHeight, alert);
M5.Lcd.pushImage(180, 100, closeWidth, closeHeight, closeX);

// Pause here to admire the icons!
delay(2000);
Expand All @@ -47,56 +54,15 @@ void setup()
void loop()
{
// Loop filling and clearing screen
drawIcon(info, random(M5.Lcd.width() - infoWidth), random(M5.Lcd.height() - infoHeight), infoWidth, infoHeight);
drawIcon(alert, random(M5.Lcd.width() - alertWidth), random(M5.Lcd.height() - alertHeight), alertWidth, alertHeight);
drawIcon(_close, random(M5.Lcd.width() - closeWidth), random(M5.Lcd.height() - closeHeight), alertWidth, closeHeight);
M5.Lcd.pushImage(random(M5.Lcd.width() - infoWidth), random(M5.Lcd.height() - infoHeight), infoWidth, infoHeight, info);
M5.Lcd.pushImage(random(M5.Lcd.width() - alertWidth), random(M5.Lcd.height() - alertHeight), alertWidth, alertHeight, alert);
M5.Lcd.pushImage(random(M5.Lcd.width() - closeWidth), random(M5.Lcd.height() - closeHeight), alertWidth, closeHeight, closeX);

// Clear screen after 100 x 3 = 300 icons drawn
if (100 == count++) {
if (1000 == count++) {
count = 1;
M5.Lcd.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony!
M5.Lcd.fillScreen(TFT_BLACK);
M5.Lcd.setRotation(1);
//Serial.println(millis());
}
}


//====================================================================================
// This is the function to draw the icon stored as an array in program memory (FLASH)
//====================================================================================

// To speed up rendering we use a 64 pixel buffer
#define BUFF_SIZE 64

// Draw array "icon" of defined width and height at coordinate x,y
// Maximum icon size is 255x255 pixels to avoid integer overflow

void drawIcon(const unsigned short* icon, int16_t x, int16_t y, int8_t width, int8_t height) {

uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel)

// Set up a window the right size to stream pixels into
M5.Lcd.setWindow(x, y, x + width - 1, y + height - 1);

// Work out the number whole buffers to send
uint16_t nb = ((uint16_t)height * width) / BUFF_SIZE;

// Fill and send "nb" buffers to TFT
for (int i = 0; i < nb; i++) {
for (int j = 0; j < BUFF_SIZE; j++) {
pix_buffer[j] = pgm_read_word(&icon[i * BUFF_SIZE + j]);
}
M5.Lcd.pushColors(pix_buffer, BUFF_SIZE);
}

// Work out number of pixels not yet sent
uint16_t np = ((uint16_t)height * width) % BUFF_SIZE;

// Send any partial buffer left over
if (np) {
for (int i = 0; i < np; i++) pix_buffer[i] = pgm_read_word(&icon[nb * BUFF_SIZE + i]);
M5.Lcd.pushColors(pix_buffer, np);
}
}

2 changes: 1 addition & 1 deletion examples/Advanced/Display/TFT_Pong/TFT_Pong.ino
Expand Up @@ -105,7 +105,7 @@ void midline() {
if ((ball_x<dashline_x-ball_w) && (ball_x > dashline_x+dashline_w)) return;

// Quick way to draw a dashed line
M5.Lcd.setWindow(dashline_x,0,dashline_x+dashline_w-1,h);
M5.Lcd.setAddrWindow(dashline_x, 0, dashline_w, h);

for(int16_t i = 0; i < dashline_n; i+=2) {
M5.Lcd.pushColor(WHITE, dashline_w*dashline_h); // push dash pixels
Expand Down
Expand Up @@ -20,7 +20,7 @@ unsigned long tn = 0;

void setup() {
M5.begin();

M5.Lcd.setRotation(0);
Serial.println(""); Serial.println("");
Serial.println("Bodmer's M5Stack library Test!");
}
Expand Down Expand Up @@ -334,7 +334,7 @@ uint32_t testHaD()

for (int i = 0; i < 0x10; i++)
{
M5.Lcd.setWindow(0, 0, 240-1, 320-1);
M5.Lcd.setAddrWindow(0, 0, 240, 320);

uint16_t cnt = 0;
uint16_t color = M5.Lcd.color565((i << 4) | i, (i << 4) | i, (i << 4) | i);
Expand Down
26 changes: 18 additions & 8 deletions examples/Basics/Sleep/Sleep.ino
Expand Up @@ -2,13 +2,13 @@

void setup() {
M5.begin();
M5.Power.begin();
M5.Lcd.setBrightness(200);
M5.Lcd.begin();
M5.Lcd.clear();
Serial.begin(115200);

M5.Power.setWakeupButton(BUTTON_A_PIN);

if(!M5.Power.canControl()) {
M5.Lcd.printf("IP5306 is not i2c version\n");
}
}

void loop() {
Expand All @@ -20,12 +20,22 @@ void loop() {
M5.Lcd.printf("<<Sleep test>>\n");
M5.Lcd.printf("power-on triggered at:%s%s\n\n",c?"POWER-SW":"",d?"DeepSleep-end":"");

M5.Lcd.printf("Go lightSleep (5s or press buttonA)\n");
M5.Lcd.printf("Go lightSleep (5s or press buttonA wake up)\n");
delay(2500);
// call this fun, power btn will Invalid
// Restore power btn please call M5.Power.setPowerBoostKeepOn(false)
M5.Power.lightSleep(SLEEP_SEC(5));

M5.Lcd.printf("Go lightSleep (press buttonA wake up)\n");
delay(2500);
M5.Power.lightSleep(5000000);
// call this fun, power btn will Invalid
// Restore power btn please call M5.Power.setPowerBoostKeepOn(false)
M5.Power.lightSleep(0);

M5.Lcd.printf("resume.\n\nGo deepSleep (5s or press buttonA) ");
M5.Lcd.printf("resume.\n\nGo deepSleep (press buttonA wake up) ");
delay(2500);
M5.Power.deepSleep(5000000);
// call this fun, power btn will Invalid
// Restore power btn please call M5.Power.setPowerBoostKeepOn(false)
M5.Power.deepSleep(0);

}
2 changes: 1 addition & 1 deletion library.json
Expand Up @@ -10,7 +10,7 @@
"type": "git",
"url": "https://github.com/m5stack/m5stack.git"
},
"version": "0.2.6",
"version": "0.2.7",
"framework": "arduino",
"platforms": "espressif32"
}
2 changes: 1 addition & 1 deletion library.properties
@@ -1,5 +1,5 @@
name=M5Stack
version=0.2.6
version=0.2.7
author=M5Stack
maintainer=Zibin Zheng <bin@m5stack.com>
sentence=Library for M5Stack Core development kit
Expand Down
4 changes: 2 additions & 2 deletions src/Fonts/GFXFF/gfxfont.h
Expand Up @@ -12,7 +12,7 @@
#ifdef LOAD_GFXFF

typedef struct { // Data stored PER GLYPH
uint16_t bitmapOffset; // Pointer into GFXfont->bitmap
uint32_t bitmapOffset; // Pointer into GFXfont->bitmap
uint8_t width, height; // Bitmap dimensions in pixels
uint8_t xAdvance; // Distance to advance cursor (x axis)
int8_t xOffset, yOffset; // Dist from cursor pos to UL corner
Expand All @@ -21,7 +21,7 @@ typedef struct { // Data stored PER GLYPH
typedef struct { // Data stored for FONT AS A WHOLE:
uint8_t *bitmap; // Glyph bitmaps, concatenated
GFXglyph *glyph; // Glyph array
uint8_t first, last; // ASCII extents
uint16_t first, last; // ASCII extents
uint8_t yAdvance; // Newline distance (y axis)
} GFXfont;

Expand Down
8 changes: 4 additions & 4 deletions src/M5LoRa.cpp
Expand Up @@ -124,7 +124,7 @@ int LoRaClass::beginPacket(int implicitHeader) {
// put in standby mode
idle();

if (implicitHeader == true) {
if (implicitHeader) {
implicitHeaderMode();
} else {
explicitHeaderMode();
Expand Down Expand Up @@ -172,7 +172,7 @@ int LoRaClass::parsePacket(int size) {
_packetIndex = 0;

// read packet length
if (_implicitHeaderMode == true) {
if (_implicitHeaderMode) {
packetLength = readRegister(REG_PAYLOAD_LENGTH);
} else {
packetLength = readRegister(REG_RX_NB_BYTES);
Expand Down Expand Up @@ -232,7 +232,7 @@ int LoRaClass::available() {
}

int LoRaClass::read() {
if (!available() == true) {
if (!available()) {
return -1;
}

Expand All @@ -242,7 +242,7 @@ int LoRaClass::read() {
}

int LoRaClass::peek() {
if (!available() == true) {
if (!available()) {
return -1;
}

Expand Down
36 changes: 18 additions & 18 deletions src/M5Stack.cpp
Expand Up @@ -34,15 +34,15 @@ void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEn

// TONE
// Speaker.begin();
#ifdef ARDUINO_ODROID_ESP32
pinMode(BUTTON_MENU_PIN, INPUT_PULLUP);
pinMode(BUTTON_VOLUME_PIN, INPUT_PULLUP);
pinMode(BUTTON_SELECT_PIN, INPUT_PULLUP);
pinMode(BUTTON_START_PIN, INPUT_PULLUP);
pinMode(BUTTON_JOY_Y_PIN, INPUT_PULLDOWN);
pinMode(BUTTON_JOY_X_PIN, INPUT_PULLDOWN);
#endif

#ifdef ARDUINO_ODROID_ESP32
pinMode(BUTTON_MENU_PIN, INPUT_PULLUP);
pinMode(BUTTON_VOLUME_PIN, INPUT_PULLUP);
pinMode(BUTTON_SELECT_PIN, INPUT_PULLUP);
pinMode(BUTTON_START_PIN, INPUT_PULLUP);
pinMode(BUTTON_JOY_Y_PIN, INPUT_PULLDOWN);
pinMode(BUTTON_JOY_X_PIN, INPUT_PULLDOWN);
#endif

// Set wakeup button
Power.setWakeupButton(BUTTON_A_PIN);
Expand All @@ -65,15 +65,15 @@ void M5Stack::update() {

//Speaker update
Speaker.update();
#ifdef ARDUINO_ODROID_ESP32
BtnMenu.read();
BtnVolume.read();
BtnSelect.read();
BtnStart.read();
JOY_Y.readAxis();
JOY_X.readAxis();
battery.update();
#endif
#ifdef ARDUINO_ODROID_ESP32
BtnMenu.read();
BtnVolume.read();
BtnSelect.read();
BtnStart.read();
JOY_Y.readAxis();
JOY_X.readAxis();
battery.update();
#endif
}

/**
Expand Down

0 comments on commit 669968b

Please sign in to comment.