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

    Using atom-mate with cback-driver.

    Scheduled Pinned Locked Moved Atom
    4 Posts 2 Posters 6.5k Views
    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.
    • B Offline
      benalb
      last edited by

      I¡m trying to run a couple of servos with atom lite, using the atom-mate and the cback-driver for m5stick. Using platformio, I've copied CBACK_DRIVER.h and CBACK_DRIVER.cpp to the include dir in the project, modified the obvious #include <M5Atom.h>, and with this code:

      #include <M5Atom.h>
      #include "CBACK_DRIVER.h"
      
      bool flag = true;
      
      CBACK_DRIVER Driver;
      int C_BLACK = 0x000000;
      int C_WHITE = 0xffffff;
      int C_RED = 0xff0000;
      int C_GREEN = 0x00ff00;
      int C_BLUE = 0x0000ff;
      
      
      void setup() {
              M5.begin(true, false, true);
              // let's check the atom is ok
              delay(50);
              M5.dis.drawpix(0, C_GREEN); // green
              delay(1000);
              M5.dis.drawpix(0, C_BLACK); // black
              Serial.begin(115200);
                      Driver.Init();
                      delay(1000);
                      Serial.println("C Back Driver Test...");
      
      }
      void loop() {
              if(M5.Btn.wasPressed()){
                      flag = !flag;
                      Serial.println("toggle flag value");
              }
              if(flag){
                      for(int i=1; i<=4;i++){
                              Driver.SetServoAngle(i,90);
                              Serial.println("servo 90");
                              // Driver.ReadServoPulse(i,1500);
                      }
                      Driver.SetOutput(1);
              }else{
                      for(int i=1; i<=4;i++){
                              Driver.SetServoAngle(i,120);
                              Serial.println("servo 120");
                              // Driver.ReadServoPulse(i,2000);
                      }
                      Driver.SetOutput(0);
              }
              Serial.print("PortB ADC: ");
              Serial.println(Driver.ReadADC());
              M5.update();
      }
      

      I get this error:

      Building in release mode
      Linking .pio/build/m5stack-atom/firmware.elf
      .pio/build/m5stack-atom/src/main.cpp.o:(.literal._Z5setupv+0x2c): undefined reference to `CBACK_DRIVER::Init()'
      .pio/build/m5stack-atom/src/main.cpp.o:(.literal._Z4loopv+0x18): undefined reference to `CBACK_DRIVER::SetServoAngle(unsigned char, unsigned char)'
      .pio/build/m5stack-atom/src/main.cpp.o:(.literal._Z4loopv+0x1c): undefined reference to `CBACK_DRIVER::SetOutput(unsigned char)'
      .pio/build/m5stack-atom/src/main.cpp.o:(.literal._Z4loopv+0x20): undefined reference to `CBACK_DRIVER::ReadADC()'
      .pio/build/m5stack-atom/src/main.cpp.o: In function `setup()':
      /home/benalb/Projects/m5atom/cback/src/main.cpp:22: undefined reference to `CBACK_DRIVER::Init()'
      .pio/build/m5stack-atom/src/main.cpp.o: In function `loop()':
      /home/benalb/Projects/m5atom/cback/src/main.cpp:36: undefined reference to `CBACK_DRIVER::SetServoAngle(unsigned char, unsigned char)'
      /home/benalb/Projects/m5atom/cback/src/main.cpp:40: undefined reference to `CBACK_DRIVER::SetServoAngle(unsigned char, unsigned char)'
      /home/benalb/Projects/m5atom/cback/src/main.cpp:44: undefined reference to `CBACK_DRIVER::SetOutput(unsigned char)'
      /home/benalb/Projects/m5atom/cback/src/main.cpp:47: undefined reference to `CBACK_DRIVER::ReadADC()'
      collect2: error: ld returned 1 exit status
      *** [.pio/build/m5stack-atom/firmware.elf] Error 1
      ========================================================= [FAILED] Took 13.90 seconds =========================================================
      
      

      any ideas?

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

        Hello @benalb

        the .cpp file should go into the src instead of the include directory, else it doesn't get compiled nor linked.

        Thanks
        Felix

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

        B 1 Reply Last reply Reply Quote 0
        • B Offline
          benalb @felmue
          last edited by

          @felmue thanks, now it compiles and uploads to the atom. But it does not work. I have also changed the ports in CBACK_DRIVER.cpp to match the ones of the atom-mate, from

          Wire.begin(0, 26);
          

          to

          Wire.begin(19,22);
          

          but no luck.

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

            Hello @benalb

            according to the C Back Driver schematic the four channels are powered from the +BAT pin the M5StickC provides but is missing when using an M5Atom with the atom-mate.

            Thanks
            Felix

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

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post