I am a .net developer playing in the IoT world. I am building a device to control some devices and read some temps. I have an ESP32, ILI9341 (using cap touch TS), Ammeter implementation, and OneWire implementation. I am using Visual Studio/Visual Micro for my IDE and its using Arduino/espressif - arduino-esp32 for compiling.
i have this code:
Code: Select all
void loop() {
if (ts.touched())
{
TS_Point p = ts.getPoint();
if ((p.x <= 100 && p.x >= 0) && (p.y <= 100 && p.y >= 0)) {
changeStateOfBoiler();
}
}
updateRssi();
updateAmps();
updateTemps();
}
updateTemps takes about 750ms to complete.
updateAmps() uses a millisecond counter to only actually do anything every 1 second.
Code: Select all
void updateAmps() {
unsigned long currentMillis = millis();
if (currentMillis - previousAmpSampleMillis >= interval)
{
previousAmpSampleMillis = currentMillis;
double oldAmpValue = amps;
rawAmpValue = analogRead(AMMETER_PIN);
voltage = (rawAmpValue / 1023.0) * 5.00;
amps = ((voltage - acsOffset) / mVperAmp);
if (oldAmpValue != amps)
{
updateAmpsDisplay(oldAmpValue);
}
}
}
if ts.touched() isn't getting hit for the most part. If I tap the screen repeatedly, eventually it registers and the code fires (and then locks up) so I think that im having to hit the screen in just the right time to trigger within the loop. I know that the ESP32 has 2 cores. is there a way that I can push the ts.touch() (and other items waiting for an input) to another core so that it is realtime, and the loop continues to update as needed?