mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Create base touchscreen component and refactor ektf2232 (#3083)
Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
This commit is contained in:
		| @@ -313,7 +313,7 @@ binary_sensor: | ||||
|       then: | ||||
|         - lambda: 'ESP_LOGI("ar1:", "%d", x);' | ||||
|   - platform: xpt2046 | ||||
|     xpt2046_id: touchscreen | ||||
|     xpt2046_id: xpt_touchscreen | ||||
|     id: touch_key0 | ||||
|     x_min: 80 | ||||
|     x_max: 160 | ||||
| @@ -327,6 +327,16 @@ binary_sensor: | ||||
|       sx1509: sx1509_hub | ||||
|       number: 3 | ||||
|  | ||||
|   - platform: touchscreen | ||||
|     id: touch_key1 | ||||
|     x_min: 0 | ||||
|     x_max: 100 | ||||
|     y_min: 0 | ||||
|     y_max: 100 | ||||
|     on_press: | ||||
|       - logger.log: "Touched" | ||||
|  | ||||
|  | ||||
| climate: | ||||
|   - platform: tuya | ||||
|     id: tuya_climate | ||||
| @@ -509,7 +519,7 @@ external_components: | ||||
|   - source: ../esphome/components | ||||
|     components: ["sntp"] | ||||
| xpt2046: | ||||
|   id: touchscreen | ||||
|   id: xpt_touchscreen | ||||
|   cs_pin: 17 | ||||
|   irq_pin: 16 | ||||
|   update_interval: 50ms | ||||
| @@ -526,12 +536,12 @@ xpt2046: | ||||
|     - lambda: |- | ||||
|         ESP_LOGI("main", "args x=%d, y=%d, touched=%s", x, y, (touched ? "touch" : "release")); | ||||
|         ESP_LOGI("main", "member x=%d, y=%d, touched=%d, x_raw=%d, y_raw=%d, z_raw=%d", | ||||
|             id(touchscreen).x, | ||||
|             id(touchscreen).y, | ||||
|             (int) id(touchscreen).touched, | ||||
|             id(touchscreen).x_raw, | ||||
|             id(touchscreen).y_raw, | ||||
|             id(touchscreen).z_raw | ||||
|             id(xpt_touchscreen).x, | ||||
|             id(xpt_touchscreen).y, | ||||
|             (int) id(xpt_touchscreen).touched, | ||||
|             id(xpt_touchscreen).x_raw, | ||||
|             id(xpt_touchscreen).y_raw, | ||||
|             id(xpt_touchscreen).z_raw | ||||
|             ); | ||||
|  | ||||
| button: | ||||
| @@ -541,3 +551,13 @@ button: | ||||
|     name: Safe Mode Button | ||||
|   - platform: shutdown | ||||
|     name: Shutdown Button | ||||
|  | ||||
| touchscreen: | ||||
|   - platform: ektf2232 | ||||
|     interrupt_pin: GPIO36 | ||||
|     rts_pin: GPIO5 | ||||
|     display: inkplate_display | ||||
|     on_touch: | ||||
|       - logger.log: | ||||
|           format: Touch at (%d, %d) | ||||
|           args: ["touch.x", "touch.y"] | ||||
|   | ||||
| @@ -231,12 +231,3 @@ switch: | ||||
|     register_type: coil | ||||
|     address: 2 | ||||
|     bitmask: 1 | ||||
|  | ||||
| ektf2232: | ||||
|   interrupt_pin: GPIO36 | ||||
|   rts_pin: GPIO5 | ||||
|   rotation: 90 | ||||
|   on_touch: | ||||
|     - logger.log: | ||||
|         format: Touch at (%d, %d) | ||||
|         args: ["touch.x", "touch.y"] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user