🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5Dial TFT_eSPI pinout

    SOFTWARE
    5
    17
    6.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ajb2k3A
      ajb2k3
      last edited by

      This is the Micropython code I used to get a basic "Hello World" working.

      import os, sys, io
      import M5
      from M5 import *
      
      label0 = None
      
      def setup():
        global label0
      
        M5.begin()
        label0 = Widgets.Label("label", 50, 100, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
      
        label0.setCursor(x=50, y=100)
        label0.setText(str('Hello World'))
        label0.setVisible(True)
      
      def loop():
        global label0
        M5.update()
      
      if __name__ == '__main__':
        try:
          setup()
          while True:
            loop()
        except (Exception, KeyboardInterrupt) as e:
          try:
            from utility import print_error_msg
            print_error_msg(e)
          except ImportError:
            print("please update to latest firmware”)
      
      

      UIFlow, so easy an adult can learn it!
      If I don't know it, be patient!
      I've ether not learned it or am too drunk to remember it!
      Author of the WIP UIFlow Handbook!
      M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

      1 Reply Last reply Reply Quote 0
      • gordshG
        gordsh
        last edited by

        @ajb2k3 said in M5Dial TFT_eSPI pinout:

        M5

        Thank you.

        1 Reply Last reply Reply Quote 0
        • felmueF
          felmue
          last edited by

          Hello @gordsh

          re TFT_eSPI : try adding the following define in Setup200_GC9A01.h

          #define TFT_BACKLIGHT_ON HIGH
          

          re GC9A01_demo : please find an M5Dial version here.

          Thanks
          Felix

          GPIO translation table M5Stack / M5Core2
          Information about various M5Stack products.
          Code examples

          1 Reply Last reply Reply Quote 0
          • gordshG
            gordsh
            last edited by

            @felmue, thanks very much, This worked perfectly.

            M 1 Reply Last reply Reply Quote 0
            • M
              mukul_100_ @gordsh
              last edited by

              @gordsh Hi ,
              did you get this working ?
              I am banging my head against the wall with this one right now ,
              I am trying to use EEZ Studio with M5dial and using platform.io (or arduino ide whichever works)

              also if you have the file of user_setup.h for GC9A01. kindly share
              Thank You

              M 1 Reply Last reply Reply Quote 0
              • M
                mukul_100_ @mukul_100_
                last edited by

                @mukul_100_ Got this workking by using m5unified instead of tft_espi
                But i can get the touch to work
                as per what i read lvgl uses polling to get the touch coordinates using lv_timer_handler();

                but i dont understand how to implement M5Dial.Touch.getDetail(); to get the touch

                gordshG 2 Replies Last reply Reply Quote 0
                • gordshG
                  gordsh @mukul_100_
                  last edited by

                  @mukul_100_ I did get this working, I am having a different issue now but I will send you a small demo program that I wrote using LVGL with touch.

                  1 Reply Last reply Reply Quote 0
                  • gordshG
                    gordsh @mukul_100_
                    last edited by gordsh

                    @mukul_100_ Here is a small demo of the M5Dial with touch and LVGL. Hope this helps and sorry for the delay.

                    M5DialLVGLTouchDemo.ino

                    unnamed.jpg

                    M gordshG S 3 Replies Last reply Reply Quote 0
                    • M
                      mukul_100_ @gordsh
                      last edited by

                      @gordsh Oh great thanks a lot, I actually got it working,
                      and after seeing your code i tried to implement the button part with encoder but the dial seems to crash repeatedly because of it. For now that is not my focus so i will try it again later.
                      Also , do you have any idea how the implementation of encoder is eez studio is.
                      i understood that the group is to be made but didnt quite understand how to append/impelment the encoder events to it
                      If anyone has any idea or reference, Thank you in advance.

                      also this is the code for how i implemented the button press with encoder

                      // Encoder read function
                      void encoder_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
                          long newPosition = M5Dial.Encoder.read() / 4; // Normalize encoder position
                          if (newPosition != oldPosition) {
                              int encoderDiff = newPosition - oldPosition;
                              oldPosition = newPosition;
                      
                              // React to encoder rotation
                              if (encoderDiff > 0) {
                                  lv_group_focus_next(group);
                              } else if (encoderDiff < 0) {
                                  lv_group_focus_prev(group);
                              }
                          }
                      
                          // Check button press
                          if (M5Dial.BtnA.wasPressed()) {
                              data->state = LV_INDEV_STATE_PR;
                              Serial.println("M5.BtnA Pressed");
                          } else {
                              data->state = LV_INDEV_STATE_REL;
                          }
                      }
                      
                      // Display flush function
                      void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) {
                          uint32_t width = (area->x2 - area->x1 + 1);
                          uint32_t height = (area->y2 - area->y1 + 1);
                      
                          M5.Display.startWrite();
                          M5.Display.setAddrWindow(area->x1, area->y1, width, height);
                          M5.Display.pushPixels((uint16_t *)&color_p->full, width * height, true);
                          M5.Display.endWrite();
                      
                          lv_disp_flush_ready(disp);
                      }
                      
                      void setup() {
                          auto cfg = M5.config();
                          M5Dial.begin(cfg, true, false);
                          Serial.begin(115200);
                      
                          // LVGL initialization
                          lv_init();
                          lv_disp_draw_buf_init(&drawBuffer, buffer, NULL, SCREEN_WIDTH * SCREEN_HEIGHT / 10);
                      
                          static lv_disp_drv_t disp_drv;
                          lv_disp_drv_init(&disp_drv);
                          disp_drv.hor_res = SCREEN_WIDTH;
                          disp_drv.ver_res = SCREEN_HEIGHT;
                          disp_drv.flush_cb = my_disp_flush;
                          disp_drv.draw_buf = &drawBuffer;
                          lv_disp_drv_register(&disp_drv);
                      
                          static lv_indev_drv_t encoder_drv;
                          lv_indev_drv_init(&encoder_drv);
                          encoder_drv.type = LV_INDEV_TYPE_ENCODER;
                          encoder_drv.read_cb = encoder_read;
                          encoder_indev = lv_indev_drv_register(&encoder_drv);
                      
                          // Create a group and assign it to the encoder input device
                          group = lv_group_create();
                          lv_indev_set_group(encoder_indev, group);
                      
                          // Create focusable widgets
                          lv_obj_t *btn1 = lv_btn_create(lv_scr_act());
                          lv_obj_align(btn1, LV_ALIGN_CENTER, -60, 0);
                          lv_obj_t *label1 = lv_label_create(btn1);
                          lv_label_set_text(label1, "Button 1");
                      
                          lv_obj_t *btn2 = lv_btn_create(lv_scr_act());
                          lv_obj_align(btn2, LV_ALIGN_CENTER, 60, 0);
                          lv_obj_t *label2 = lv_label_create(btn2);
                          lv_label_set_text(label2, "Button 2");
                      
                          lv_obj_t *btn3 = lv_btn_create(lv_scr_act());
                          lv_obj_align(btn3, LV_ALIGN_CENTER, 0, 50);
                          lv_obj_t *label3 = lv_label_create(btn3);
                          lv_label_set_text(label3, "Button 3");
                      
                          // Add widgets to the group
                          lv_group_add_obj(group, btn1);
                          lv_group_add_obj(group, btn2);
                          lv_group_add_obj(group, btn3);
                      }
                      
                      1 Reply Last reply Reply Quote 0
                      • gordshG
                        gordsh @gordsh
                        last edited by

                        @gordsh thanks for sending, I actually don't know eez studio at all, I have never used it..

                        M 1 Reply Last reply Reply Quote 1
                        • M
                          mukul_100_ @gordsh
                          last edited by

                          @gordsh in your code, is the press function working successfully?
                          i am getting crashes for now, i am trying to use the button as a external button and not as a encoder button, the main problems seems to be init of button

                          1 Reply Last reply Reply Quote 1
                          • S
                            SadE54 @gordsh
                            last edited by

                            @gordsh Do you think with the lvgl m5dial setup , that Squareline Studio is usable ?

                            gordshG 1 Reply Last reply Reply Quote 0
                            • gordshG
                              gordsh @SadE54
                              last edited by

                              @SadE54 I believe it is.

                              1 Reply Last reply Reply Quote 2
                              • First post
                                Last post