■ M5Stackを分解したり電源を入れてみて、いろいろ思ったこと
https://www.mgo-tec.com/blog-entry-m5stack-initial-operation.html
■ M5Stack-SD-Updaterのすすめ
■ PACMAN with M5STACK
Gameboy Panel は ATmega328P で構成され I2C で通信しています。
アドレスは 0x88 です。
サンプル(faces_joystick)ではなぜか#define FACE_JOY_ADDR 0x5e で定義されていてそのままでは動かず、0x88にしたら動いた
…と思ったけど、なんかそもそも別のサンプルっぽい?アナログを取ってる気配が。
#include#define FACE_JOY_ADDR 0x88 #define KEY_U 0x01 #define KEY_D 0x02 #define KEY_L 0x04 #define KEY_R 0x08 #define KEY_A 0x10 #define KEY_B 0x20 #define KEY_SL 0x40 #define KEY_ST 0x80 char strBuf[100]; int cnt=0; void setup() { randomSeed(analogRead(0)); Serial.begin(115200); M5.begin(); Wire.begin(); M5.Lcd.fillScreen(TFT_BLACK); pinMode(5, INPUT_PULLUP); delay(100); M5.Lcd.setTextFont(2); } uint8_t key_val; void loop() { M5.Lcd.fillScreen(TFT_BLACK); if(digitalRead(5) == LOW) { cnt++; Wire.requestFrom(0X88, 1); // request 1 byte from keyboard while (Wire.available()) { key_val = Wire.read(); // receive a byte as character key_val ^= 0xff; } } M5.Lcd.setCursor(50, 50); sprintf(strBuf, "kay_val : %x cnt : %d\n", key_val, cnt); M5.Lcd.print(strBuf); if( key_val & KEY_U ) M5.Lcd.print("UP "); if( key_val & KEY_D ) M5.Lcd.print("DOWN "); if( key_val & KEY_L ) M5.Lcd.print("LEFT "); if( key_val & KEY_R ) M5.Lcd.print("RIGHT "); if( key_val & KEY_A ) M5.Lcd.print("A "); if( key_val & KEY_B ) M5.Lcd.print("B "); if( key_val & KEY_SL ) M5.Lcd.print("SL "); if( key_val & KEY_ST ) M5.Lcd.print("ST "); delay(1); }
■ M5Stack の液晶ディスプレイ ILI9341 をちょっと解明してみた
■ M5StackでGrove超音波距離センサの値を画面表示
元のサンプルは9600だったが、Serial.begin(115200) にしないといけないらしい。
#include "Ultrasonic.h" #includeUltrasonic ultrasonic(22); void setup() { M5.begin(); Serial.begin(115200); delay(500); M5.Lcd.setTextFont(2); M5.Lcd.setCursor(10, 10); } void loop() { long RangeInCentimeters; Serial.println("The distance to obstacles in front is: "); RangeInCentimeters = ultrasonic.MeasureInCentimeters(); // two measurements should keep an interval M5.Lcd.clear(); M5.Lcd.setCursor(10, 10); M5.Lcd.setTextColor(YELLOW); M5.Lcd.setTextSize(2); M5.Lcd.printf("Ultrasonic distance\n"); M5.Lcd.setCursor(50, 50); M5.Lcd.setTextColor(YELLOW); M5.Lcd.setTextSize(2); M5.Lcd.printf("%d cm\n", RangeInCentimeters); delay(16); Serial.print(RangeInCentimeters);//0~400cm Serial.println(" cm"); M5.update(); }