├── crack.jpg ├── .gitattributes ├── README.md ├── LICENSE └── M5Stack_CrackScreen.ino /crack.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nomolk/M5Stack_CrackScreen/HEAD/crack.jpg -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # M5Stack_CrackScreen 2 | 3 | Video: 4 | 5 | M5Stack Gray (with MPU9250) is needed. 6 | 7 | M5Stack_CrackScreen.ino -> M5Stack 8 | crack.jpg -> micro SD 9 | 10 | Hit M5Stack to crack. Push a button to remove the crack. 11 | 12 | Enjoy! -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Daiju Ishikawa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /M5Stack_CrackScreen.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "utility/MPU9250.h" 3 | 4 | MPU9250 IMU; 5 | 6 | void setup(void) { 7 | 8 | M5.begin(); 9 | Wire.begin(); 10 | Serial.begin(115200); 11 | 12 | M5.Lcd.setBrightness(200); 13 | M5.Lcd.fillScreen(BLACK); 14 | IMU.calibrateMPU9250(IMU.gyroBias, IMU.accelBias); 15 | IMU.initMPU9250(); 16 | } 17 | 18 | void loop() { 19 | if (IMU.readByte(MPU9250_ADDRESS, INT_STATUS) & 0x01) 20 | { 21 | IMU.readAccelData(IMU.accelCount); 22 | IMU.getAres(); 23 | 24 | IMU.ax = (float)IMU.accelCount[0]*IMU.aRes; // - accelBias[0]; 25 | IMU.ay = (float)IMU.accelCount[1]*IMU.aRes; // - accelBias[1]; 26 | IMU.az = (float)IMU.accelCount[2]*IMU.aRes; // - accelBias[2]; 27 | 28 | } 29 | 30 | IMU.delt_t = millis() - IMU.count; 31 | 32 | if (IMU.delt_t > 200) 33 | { 34 | Serial.println(abs((int)1000*IMU.ax) + abs((int)1000*IMU.ay) + abs((int)1000*IMU.az)); 35 | 36 | if(abs((int)1000*IMU.ax) + abs((int)1000*IMU.ay) + abs((int)1000*IMU.az) > 3000){ 37 | M5.Lcd.drawJpgFile(SD, "/crack.jpg"); 38 | } 39 | } 40 | 41 | M5.update(); 42 | if(M5.BtnA.wasPressed() || M5.BtnB.wasPressed() || M5.BtnC.wasPressed()) { 43 | M5.Lcd.fillScreen(BLACK); 44 | } 45 | } 46 | --------------------------------------------------------------------------------