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.