diff --git a/docs/ELECROW.md b/docs/ELECROW.md index 8c916fb..a75dba7 100644 --- a/docs/ELECROW.md +++ b/docs/ELECROW.md @@ -39,19 +39,18 @@ suits a screen that stands further away. ### Touch -The GT911 is polled every 20 ms over I2C at 400 kHz, with no interrupt pin and no reset: the **V3.0** has a PCA9557 -I/O expander (I2C 0x18) on the GT911's reset and interrupt lines, and writing it during boot is what breaks the touch -on that revision. It powers up with every pin as an input, a pull-up brings the GT911 out of reset before the firmware -starts, and the driver finds it ready. A bus scan at boot upsets the GT911 too, so `scan: false`. +The GT911 is polled every 20 ms over I2C at 400 kHz. The **V3.0** has a PCA9557 I/O expander (I2C 0x18) on the +GT911's reset (IO0) and interrupt (IO1) lines, and a unit tested here kept its GT911 in reset until something drove +them (`touchscreen is marked FAILED: Calibration error` in the log, firmware 0.2.79 and 0.2.80). The board file +(firmware 0.2.81) declares the expander as ESPHome's `pca9554` (the same register map) and hands the GT911 driver its +reset and interrupt pins on it: the driver runs Elecrow's own sequence, reset low with the interrupt line low, reset +high, then 56 ms, which also fixes the address at 0x5D. A V2.0 board without the expander boots its GT911 by the +pull-up as before; the expander's setup fails there, harmlessly, and the driver tries 0x14 by itself when 0x5D does +not answer, so no address override is ever needed. -The GT911 takes I2C address **0x5D** when GPIO 38 reads low at power-on and **0x14** when it reads high; on this -board it is 0x5D on most units, and a unit that never reports a touch may be a 0x14. Give that screen an Override YAML -in ESP Screens (Screen settings → Override YAML) with: - -```yaml -touchscreen: - address: 0x14 -``` +The bus is scanned at boot. For a diagnosis, give the screen `logger: level: DEBUG` in its Override YAML (Screen +settings → Override YAML) and read its log: the scan lists 0x18 (the expander) and 0x5D or 0x14 (the GT911), and the +driver logs `Switches ADDR: 0x5D`; a screen without a working bus lists nothing. **GPIO 19 and 20, the touch I2C, are the ESP32-S3's USB D- and D+.** The ROM leaves the USB PHY on those pads and ESP-IDF's I2C driver cannot take them back: the bus reads as `I2C software timeout` and the touch never answers diff --git a/packages/boards/elecrow-crowpanel7.yaml b/packages/boards/elecrow-crowpanel7.yaml index 0515abf..eadb8f3 100644 --- a/packages/boards/elecrow-crowpanel7.yaml +++ b/packages/boards/elecrow-crowpanel7.yaml @@ -488,16 +488,27 @@ text_sensor: lambda: 'return {"elecrow"};' # Pinout of the CrowPanel 7.0" (DIS08070H, V2.0 and V3.0): Elecrow's wiki and the ESPHome devices page. The V3.0 has a -# PCA9557 I/O expander at I2C 0x18 on the GT911's reset and interrupt lines; it is left alone on purpose: it powers up -# with every pin as an input, a pull-up brings the GT911 out of reset before the firmware starts, and writing it during -# boot is what breaks the touch. No interrupt pin either: the GT911 is polled. +# PCA9557 I/O expander at I2C 0x18 on the GT911's reset (IO0) and interrupt (IO1) lines, and the GT911 stays in reset +# until something drives them (firmware 0.2.81: a unit whose touch never answered, "Calibration error" at setup). The +# expander gets the same register map as the PCA9554 ESPHome knows, and the GT911 driver does Elecrow's own reset +# through it: reset low with the interrupt line low (that picks address 0x5D), reset high, 56 ms. On a V2.0 without +# the expander its setup fails, the GT911 boots by its pull-up as before, and the driver still finds it (it tries 0x14 +# by itself when 0x5D does not answer). i2c: id: touch_bus sda: GPIO19 scl: GPIO20 frequency: 400kHz - # A bus scan at boot upsets the GT911; the touchscreen names its address instead. - scan: false + # The scan logs what answers on the bus (0x18 the expander, 0x5D or 0x14 the GT911), with `logger: level: DEBUG` in + # a screen's Override YAML: which revision a screen is, and whether the bus is alive at all. It runs before the + # GT911's reset, so it upsets nothing. + scan: true + +pca9554: + - id: touch_expander + i2c_id: touch_bus + address: 0x18 + pin_count: 8 output: - platform: ledc @@ -520,9 +531,14 @@ touchscreen: platform: gt911 id: ts_touch i2c_id: touch_bus - # The GT911 takes 0x5D when GPIO38 reads low at power-on, 0x14 when high; on this board it is 0x5D on most units. - # A unit that never reports a touch may be a 0x14: the Override YAML of that screen changes it (docs/ELECROW.md). + # The reset through the expander picks 0x5D; the driver tries 0x14 by itself when that does not answer. address: 0x5D + reset_pin: + pca9554: touch_expander + number: 0 + interrupt_pin: + pca9554: touch_expander + number: 1 display: my_display update_interval: 20ms transform: diff --git a/packages/core.yaml b/packages/core.yaml index 9f02b47..eb2532e 100644 --- a/packages/core.yaml +++ b/packages/core.yaml @@ -14,7 +14,7 @@ # fonts/materialdesignicons-webfont.ttf (Apache 2.0, github.com/Templarian/MaterialDesign-Webfont). ############################################################ substitutions: - SCREEN_FIRMWARE_VERSION: "0.2.80" + SCREEN_FIRMWARE_VERSION: "0.2.81" DASHBOARD_INBOX_INTERNAL: "false" CALIBRATION_ON_BOOT: "false" # a bench build: start on the touch test page ROOM_NAME: "" # top left until ESP Screens sends the screen name diff --git a/screen_manager/CHANGELOG.md b/screen_manager/CHANGELOG.md index d79bbe7..fe8ab33 100644 --- a/screen_manager/CHANGELOG.md +++ b/screen_manager/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.2.95 (firmware 0.2.81) + +The Elecrow's touch chip brought out of reset. + +- **Elecrow CrowPanel 7.0" V3.0: the GT911 is reset through the PCA9557.** On the V3.0 board the touch chip's reset and interrupt lines hang on a PCA9557 I/O expander (I2C 0x18), and on a unit whose touch never answered the driver reported `Calibration error` at setup: the chip was still in reset. The board file now drives Elecrow's own sequence through the expander (reset low with the interrupt line low, reset high, 56 ms), which also fixes the address at 0x5D. A V2.0 without the expander boots its GT911 by the pull-up as before. The touch bus is scanned at boot; `logger: level: DEBUG` in a screen's Override YAML shows what answers. +- Needs firmware 0.2.81 on an Elecrow: press **Update** on the screen. Elecrow firmware: 1,867,200 bytes, 91.9 % of its update slot. + ## 0.2.94 (firmware 0.2.80) The Elecrow's touch, when Wi-Fi takes its pins. diff --git a/screen_manager/app/core.py b/screen_manager/app/core.py index db83e82..5790e92 100644 --- a/screen_manager/app/core.py +++ b/screen_manager/app/core.py @@ -54,7 +54,7 @@ REFS = {'cyd': 'main', 'guition': 'main', 'elecrow': 'main'} # is the small one. The Elecrow CrowPanel 7.0" (app 0.2.93) is the Guition's kind at 800x480, without the Rotation. LARGE_BOARDS = ('guition', 'elecrow') # Firmware shipped with this app release; screens below it get an update offer. -FIRMWARE_VERSION = '0.2.80' +FIRMWARE_VERSION = '0.2.81' # The Auto standby switch a screen offers Home Assistant automations. AUTO_STANDBY_MIN_FIRMWARE = '0.2.41' # The settings page the screen opens itself, and the screen.settings tile that opens it. diff --git a/screen_manager/config.yaml b/screen_manager/config.yaml index 5ecfadb..43c91f8 100644 --- a/screen_manager/config.yaml +++ b/screen_manager/config.yaml @@ -1,5 +1,5 @@ name: ESP Screen Manager -version: "0.2.94" +version: "0.2.95" slug: esp_screen_manager description: Choose tiles for your CYD and Guition touchscreen, without reflashing. url: https://gittea.trippedonmy.name/Xandrossian/homeassistant_espscreen diff --git a/tests/test_elecrow.py b/tests/test_elecrow.py index 5bd03e4..c527f06 100644 --- a/tests/test_elecrow.py +++ b/tests/test_elecrow.py @@ -52,14 +52,15 @@ class BoardFile(unittest.TestCase): self.assertIn('blue: [15, 7, 6, 5, 4]', TEXT) self.assertIn('sda: GPIO19', TEXT) self.assertIn('scl: GPIO20', TEXT) - self.assertIn('scan: false', TEXT) + self.assertIn('scan: true', TEXT) self.assertIn('address: 0x5D', TEXT) self.assertIn('pin: GPIO2', TEXT) - # The USB pins are the touch I2C: the header that frees them, and no interrupt pin or I/O expander. + # The USB pins are the touch I2C: the header that frees them. self.assertIn('', TEXT) - code = '\n'.join(line for line in TEXT.split('\n') if not line.lstrip().startswith('#')) - self.assertNotIn('interrupt_pin', code) - self.assertNotIn('pca9557', code.lower()) + # The V3.0's PCA9557 (as ESPHome's pca9554, the same registers) brings the GT911 out of reset (firmware 0.2.81). + self.assertIn('address: 0x18', TEXT) + for pin, number in (('reset_pin', 0), ('interrupt_pin', 1)): + self.assertIn(f' {pin}:\n pca9554: touch_expander\n number: {number}', TEXT) self.assertIn('assertion_level: SILENT', TEXT) def test_the_flash_fits_by_three_measures(self):