File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 2626LCD_BL = 1
2727
2828I2C_BUS = 0
29- I2C_FREQ = 100000
29+ I2C_FREQ = 400000
3030TP_SDA = 48
3131TP_SCL = 47
3232TP_ADDR = 0x15
8787import mpos .battery_voltage
8888mpos .battery_voltage .init_adc (5 , 262 / 100000 )
8989
90+ # On the Waveshare ESP32-S3-Touch-LCD-2, the camera is hard-wired to power on,
91+ # so it needs a software power off to prevent it from staying hot all the time and quickly draining the battery.
92+ try :
93+ from machine import Pin , I2C
94+ i2c = I2C (1 , scl = Pin (16 ), sda = Pin (21 )) # Adjust pins and frequency
95+ devices = i2c .scan ()
96+ print ("Scan of I2C bus on scl=16, sda=21:" )
97+ print ([hex (addr ) for addr in devices ]) # finds it on 60 = 0x3C after init
98+ camera_addr = 0x3C # for OV5640
99+ reg_addr = 0x3008
100+ reg_high = (reg_addr >> 8 ) & 0xFF # 0x30
101+ reg_low = reg_addr & 0xFF # 0x08
102+ power_off_command = 0x42 # Power off command
103+ i2c .writeto (camera_addr , bytes ([reg_high , reg_low , power_off_command ]))
104+ except Exception as e :
105+ print (f"Warning: powering off camera got exception: { e } " )
106+
90107print ("boot.py finished" )
You can’t perform that action at this time.
0 commit comments