Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Stormproof
    3. Posts
    S
    • Continue chat with Stormproof
    • Start new chat with Stormproof
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Stormproof

    • RE: Dices example not working on M5Stick C

      @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);
      }
      }

      }

      posted in M5 Stick/StickC
      S
      Stormproof
    • RE: Dices example not working on M5Stick C

      You have to change IMU type in code.Sample is for previous type.Now it is MPU...

      posted in M5 Stick/StickC
      S
      Stormproof