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

    PPS module and touchscreen

    Modules
    2
    2
    27
    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
      BruderTom
      last edited by

      I try to use a PPS 13.2 module with a CoreS3-SE and want to adjust its output voltage via touchscreen. I use C++ in platformIO. I can get the PPS to work properly and I can get the touchscreen to work, but I can't do both together. I tried many different ways. For reference I tried this simplified code:

      #include <M5Unified.h>
      #include "M5ModulePPS.h"
      
      M5GFX display;
      M5ModulePPS pps;
      
      void setup() {
        M5.begin();
        // Button zeichnen
        M5.Display.fillScreen(TFT_BLACK);
        M5.Display.fillRoundRect(60, 80, 200, 120, 15, TFT_BLUE);
      
      
        while (!pps.begin(&Wire, M5.In_I2C.getSDA(), M5.In_I2C.getSCL(), MODULE_POWER_ADDR, 1000000U));
      
        pps.setOutputVoltage(1.0);
        pps.setOutputCurrent(0.5);
        pps.setPowerEnable(true);
      }
      
      void loop() {
        uint32_t ms = millis();
        static uint32_t last_ms = ms;
        static float OutputVoltage = 1.0;
      
        M5.update();
        if (M5.Touch.getCount() > 0) {
          auto t = M5.Touch.getDetail();
          if (t.x>=60 && t.x<=260 && t.y>=80 && t.y<=200) {
            M5.Display.fillScreen(TFT_BLACK);
            M5.Display.fillRoundRect(60, 80, 200, 120, 15, TFT_RED);
            pps.setOutputVoltage(0);
          }
        }
        if(ms-last_ms>1000)
        {
          OutputVoltage += 0.1;
          pps.setOutputVoltage(OutputVoltage);
          last_ms = ms;
        }
      }
      

      The touch works (although laggy), but the PPS doesn't update its output voltage. If I remove the line M5.update(); the PPS works but obviously the touch doesn't. The PPS program in the M5Burner works (although also laggy) so it should be possible somehow.

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

        Hello @BruderTom

        the issue seems to be an I2C conflict. Internal I2C already uses Wire1; the PPS code initializes a second I2C instance (Wire) with the same GPIOs for SDA and SCL. The result is: both I2C instances (Wire and Wire1) fight against each other.

        Try replacing below line so the correct Wire1 instance is used for PPS as well:

        //  while (!pps.begin(&Wire, M5.In_I2C.getSDA(), M5.In_I2C.getSCL(), MODULE_POWER_ADDR, 1000000U));
          while (!pps.begin((M5.In_I2C.getPort() == I2C_NUM_1) ? &Wire1 : &Wire, M5.In_I2C.getSDA(), M5.In_I2C.getSCL(), MODULE_POWER_ADDR, 1000000U));
        

        Thanks
        Felix

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

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