AlexanderTonn / SolarPowerhouse

Solar balkony power plant, which includes control logic for switching between micro inverter and battery depending on the state of charge. The repository containing any drawings and manuals.
Apache License 2.0
0 stars 0 forks source link

[NEW] Use Touch_Interrupt pin #19

Closed AlexanderTonn closed 8 months ago

AlexanderTonn commented 10 months ago

 :rocket: Please describe your feature request

 :pencil2: Describe the solution you'd like

 :pushpin: Describe alternatives you've considered

Additional context

AlexanderTonn commented 10 months ago

Touch IRQ will not work for some reason with this code. Wiring is definitely correct

constexpr static uint8_t TOUCH_IRQ = 2; // Touch Interrupt
constexpr static uint8_t TOUCH_CS = 3; // Touch Chip Select

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
XPT2046_Touchscreen touch(TOUCH_CS, TOUCH_IRQ);

  // Detecting touch
  if (touch.tirqTouched())
  {
    if(touch.touched())
    {
    TS_Point touchPoint = touch.getPoint();
    touchPoint.x = map(touchPoint.x, TOUCH_X_MIN, TOUCH_X_MAX, tft.width(), 0);
    touchPoint.y = map(touchPoint.y, TOUCH_Y_MIN, TOUCH_Y_MAX, 0, tft.height());
    Serial.print("(x: ");
    Serial.print(touchPoint.x);
    Serial.print(")");
    Serial.print("(y: ");
    Serial.print(touchPoint.y);
    Serial.println(")");
    Serial.print("Touch Pressure: ");
    Serial.println(touchPoint.z);

    detectTouch(touchPoint.x, touchPoint.y, byPageId);
    }
  }