Dices example not working on M5Stick C
-
M5StickC - It compile without error, but nothing happens when shaking. Any suggestion?
-
Id start trying to make simple code with label and displaying imu data on it, to see if imu works
-
You have to change IMU type in code.Sample is for previous type.Now it is MPU...
-
This post is deleted! -
@stormproof said in Dices example not working on M5Stick C:
A
/*
A couple of dices on a tiny 80x160px TFT display
Author: Alfonso de Cala alfonso@el-magnifico.org
*/
#include <M5StickC.h>
#define DOT_SIZE 6
int dot[6][6][2] {
{{35,35}},
{{15,15},{55,55}},
{{15,15},{35,35},{55,55}},
{{15,15},{15,55},{55,15},{55,55}},
{{15,15},{15,55},{35,35},{55,15},{55,55}},
{{15,15},{15,35},{15,55},{55,15},{55,35},{55,55}},
};int16_t accX = 0;
int16_t accY = 0;
int16_t accZ = 0;void setup(void) {
M5.begin();
M5.MPU6886.Init();M5.Lcd.setRotation(1);
M5.Lcd.fillScreen(TFT_GREEN);
M5.Lcd.setTextColor(TFT_BLACK); // Adding a background colour erases previous text automatically
M5.Lcd.setCursor(10, 30);
M5.Lcd.setTextSize(3);
M5.Lcd.print("SHAKE ME");
delay(1000);
}void loop() {
while(1) {
M5.MPU6886.getAccelAdc(&accX,&accY,&accZ);
if (((float) accX) * M5.MPU6886.aRes > 1 || ((float) accY) * M5.MPU6886.aRes > 1 ) {
break;
}
}M5.Lcd.fillScreen(TFT_GREEN);
// Draw first dice
delay(1000); // A little delay to increase suspense :-D
int number = random(0, 6);
draw_dice(5,5,number);// Draw second dice
delay(1000);
number = random(0, 6);
draw_dice(85,5,number);}
void draw_dice(int16_t x, int16_t y, int n) {
M5.Lcd.fillRect(x, y, 70, 70, WHITE);
for(int d = 0; d < 7; d++) {
if (dot[n][d][0] > 0) {
M5.Lcd.fillCircle(x+dot[n][d][0], y+dot[n][d][1], DOT_SIZE, TFT_BLACK);
}
}}
-
I'm having a similar problem, except that I'm definitely using the MPU6886 code. There are two files in the examples, almost identical, except for the IMU code. I chose the MPU6886 version, and it never detects any movement. I've also tried the IMU sample, and that sample doesn't show any change - all values are always zero.
-
To get around this I saved the Example sketch to disk, deleted the file Dices.ino and then opened Dices_MPU6886.iso. You will get a message about requiring that the directory name be changed, which it does for you.
You should now be able to successfully compile the sketch to the m5stick.
-
@noiseislife said in Dices example not working on M5Stick C:
To get around this I saved the Example sketch to disk, deleted the file Dices.ino and then opened Dices_MPU6886.iso. You will get a message about requiring that the directory name be changed, which it does for you.
You should now be able to successfully compile the sketch to the m5stick.
Thank you. Now it works !