Resolve I2C pin conflict on Waveshare RLCD board, use SoftI2C for dynamic configurations, and add RTC/SHTC3 utilities to upload list
This commit is contained in:
+16
-12
@@ -68,11 +68,13 @@ def detect_board():
|
||||
return
|
||||
|
||||
# 2. We are on ESP32 platform.
|
||||
# Try scanning I2C(0) on Hosyond pins (SDA=16, SCL=15)
|
||||
# Use SoftI2C for dynamic detection scan to avoid hardware I2C pin conflicts
|
||||
from machine import SoftI2C
|
||||
|
||||
# Try scanning SDA=16, SCL=15 (Hosyond pins)
|
||||
try:
|
||||
test_i2c = I2C(0, sda=Pin(16), scl=Pin(15))
|
||||
test_i2c = SoftI2C(sda=Pin(16), scl=Pin(15))
|
||||
devices = test_i2c.scan()
|
||||
# FT6336U touchscreen is at 0x38 on Hosyond
|
||||
if 0x38 in devices:
|
||||
print("Auto-detected: Hosyond ESP32-S3 Touchscreen board")
|
||||
BOARD_TYPE = 'HOSYOND'
|
||||
@@ -83,7 +85,8 @@ def detect_board():
|
||||
has_rtc = False
|
||||
led_pin = 48
|
||||
|
||||
i2c_bus = test_i2c
|
||||
# Now initialize SoftI2C
|
||||
i2c_bus = SoftI2C(sda=Pin(16), scl=Pin(15))
|
||||
|
||||
# Setup SPI
|
||||
spi_bus = SPI(1, baudrate=40000000, polarity=0, phase=0, sck=Pin(12), mosi=Pin(11), miso=Pin(13))
|
||||
@@ -114,13 +117,12 @@ def detect_board():
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
print("I2C scan on Hosyond pins failed:", e)
|
||||
print("SoftI2C scan on Hosyond pins failed:", e)
|
||||
|
||||
# 3. Try scanning I2C(0) on Waveshare RLCD pins (SDA=13, SCL=14)
|
||||
# 3. Try scanning SDA=13, SCL=14 (Waveshare RLCD pins)
|
||||
try:
|
||||
test_i2c = I2C(0, sda=Pin(13), scl=Pin(14))
|
||||
test_i2c = SoftI2C(sda=Pin(13), scl=Pin(14))
|
||||
devices = test_i2c.scan()
|
||||
# SHTC3 is at 0x70, PCF85063 RTC is at 0x51
|
||||
if 0x70 in devices or 0x51 in devices:
|
||||
print("Auto-detected: Waveshare ESP32-S3-RLCD-4.2 board")
|
||||
BOARD_TYPE = 'WAVESHARE_RLCD'
|
||||
@@ -131,8 +133,6 @@ def detect_board():
|
||||
has_rtc = True
|
||||
led_pin = 38
|
||||
|
||||
i2c_bus = test_i2c
|
||||
|
||||
# Setup SPI
|
||||
spi_bus = SPI(1, baudrate=20000000, polarity=0, phase=0, sck=Pin(11), mosi=Pin(12))
|
||||
|
||||
@@ -140,6 +140,9 @@ def detect_board():
|
||||
import rlcd
|
||||
display_instance = rlcd.RLCD(spi_bus, cs=Pin(40), dc=Pin(5), rst=Pin(41))
|
||||
|
||||
# Now initialize SoftI2C (after SPI/Display setup to avoid MISO pin conflict on Pin 13)
|
||||
i2c_bus = SoftI2C(sda=Pin(13), scl=Pin(14))
|
||||
|
||||
# Audio pins & clocks configuration
|
||||
audio_mclk_pin = 16
|
||||
audio_mclk_freq = 12288000
|
||||
@@ -155,7 +158,7 @@ def detect_board():
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
print("I2C scan on Waveshare RLCD pins failed:", e)
|
||||
print("SoftI2C scan on Waveshare RLCD pins failed:", e)
|
||||
|
||||
# 4. Fallback default if auto-detection failed completely
|
||||
print("Auto-detection failed. Falling back to Hosyond ESP32-S3 defaults...")
|
||||
@@ -166,7 +169,8 @@ def detect_board():
|
||||
led_pin = 48
|
||||
|
||||
try:
|
||||
i2c_bus = I2C(0, sda=Pin(16), scl=Pin(15))
|
||||
from machine import SoftI2C
|
||||
i2c_bus = SoftI2C(sda=Pin(16), scl=Pin(15))
|
||||
spi_bus = SPI(1, baudrate=40000000, polarity=0, phase=0, sck=Pin(12), mosi=Pin(11), miso=Pin(13))
|
||||
import ili9341
|
||||
display_instance = ili9341.ILI9341(spi_bus, cs=Pin(10), dc=Pin(46), bl=Pin(45), rst=None)
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@ class PCF85063:
|
||||
def __init__(self, i2c=None):
|
||||
if i2c is None:
|
||||
# Default to ESP32-S3-RLCD-4.2 onboard I2C pins
|
||||
self.i2c = I2C(0, sda=Pin(13), scl=Pin(14))
|
||||
from machine import SoftI2C
|
||||
self.i2c = SoftI2C(sda=Pin(13), scl=Pin(14))
|
||||
else:
|
||||
self.i2c = i2c
|
||||
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@ class SHTC3:
|
||||
def __init__(self, i2c=None):
|
||||
if i2c is None:
|
||||
# Default to ESP32-S3-RLCD-4.2 onboard I2C pins
|
||||
self.i2c = I2C(0, sda=Pin(13), scl=Pin(14))
|
||||
from machine import SoftI2C
|
||||
self.i2c = SoftI2C(sda=Pin(13), scl=Pin(14))
|
||||
else:
|
||||
self.i2c = i2c
|
||||
|
||||
|
||||
Reference in New Issue
Block a user