mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 00:51:49 +00:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			max6956_gp
			...
			jesserockz
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					6bf78e2e82 | ||
| 
						 | 
					817ee70db0 | 
@@ -7,13 +7,24 @@ namespace touchscreen {
 | 
			
		||||
 | 
			
		||||
static const char *const TAG = "touchscreen";
 | 
			
		||||
 | 
			
		||||
void TouchscreenInterrupt::gpio_intr(TouchscreenInterrupt *store) { store->touched = true; }
 | 
			
		||||
void TouchscreenInterrupt::gpio_intr(TouchscreenInterrupt *store) {
 | 
			
		||||
  bool new_state = store->isr_pin_.digital_read();
 | 
			
		||||
  if (new_state != store->inverted) {
 | 
			
		||||
    store->touched = true;
 | 
			
		||||
    if (store->component_ != nullptr) {
 | 
			
		||||
      store->component_->enable_loop_soon_any_context();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Touchscreen::attach_interrupt_(InternalGPIOPin *irq_pin, esphome::gpio::InterruptType type) {
 | 
			
		||||
  this->store_.isr_pin_ = irq_pin->to_isr();
 | 
			
		||||
  this->store_.component_ = this;
 | 
			
		||||
  this->store_.inverted = irq_pin->is_inverted();
 | 
			
		||||
  irq_pin->attach_interrupt(TouchscreenInterrupt::gpio_intr, &this->store_, type);
 | 
			
		||||
  this->store_.init = true;
 | 
			
		||||
  this->store_.touched = false;
 | 
			
		||||
  ESP_LOGD(TAG, "Attach Touch Interupt");
 | 
			
		||||
  ESP_LOGD(TAG, "Attach Touch Interrupt");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Touchscreen::call_setup() {
 | 
			
		||||
@@ -71,6 +82,8 @@ void Touchscreen::loop() {
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  if (this->store_.init)
 | 
			
		||||
    this->disable_loop();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,13 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "esphome/core/defines.h"
 | 
			
		||||
#include "esphome/components/display/display.h"
 | 
			
		||||
#include "esphome/core/defines.h"
 | 
			
		||||
 | 
			
		||||
#include "esphome/core/automation.h"
 | 
			
		||||
#include "esphome/core/hal.h"
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace touchscreen {
 | 
			
		||||
@@ -30,9 +30,12 @@ struct TouchPoint {
 | 
			
		||||
using TouchPoints_t = std::vector<TouchPoint>;
 | 
			
		||||
 | 
			
		||||
struct TouchscreenInterrupt {
 | 
			
		||||
  ISRInternalGPIOPin isr_pin_;
 | 
			
		||||
  volatile bool touched{true};
 | 
			
		||||
  bool init{false};
 | 
			
		||||
  bool inverted{false};
 | 
			
		||||
  static void gpio_intr(TouchscreenInterrupt *store);
 | 
			
		||||
  Component *component_{nullptr};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class TouchListener {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user