From 464b573e092b24e9862b6da3acc460a566b5d802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=B2=E5=B1=8E=E5=B0=86=E5=86=9B?= <37292630+wlmh110@users.noreply.github.com> Date: Thu, 17 Feb 2022 23:50:30 +0800 Subject: [PATCH] Add: Custom I2C address/Output switch with delay --- PiSugar-3-Series.md | 83 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/PiSugar-3-Series.md b/PiSugar-3-Series.md index c62a4bc..89820a8 100644 --- a/PiSugar-3-Series.md +++ b/PiSugar-3-Series.md @@ -11,6 +11,11 @@ PiSugar 3 is the third generation of PiSugar Raspberry Pi battery power supply s * **OTA firmware upgrade** A new design based on the feedback of PiSugar2, using independent MCU control to achieve communication and functions. The device firmware can be upgraded without any additional equipment. Only with a simple demand, firmware upgrades can be achieved through Raspberry Pi, letting the device get new features at any time. + + You can use following command to update the firmware of PiSugar3: + + `curl https://cdn.pisugar.com/release/PiSugarUpdate.sh | sudo bash` + * **TypeC charging interface** Both the PiSugar 3 and PiSugar 3 Plus have the TypeC charging port.PiSugar3 Plus has an extra micro-USB charging port @@ -30,7 +35,6 @@ PiSugar 3 is the third generation of PiSugar Raspberry Pi battery power supply s PiSugar 3 adds a software watchdog function. When the function is turned on, the dog needs to be kicked regularly, which can effectively prevent the Raspberry Pi from crashing and improve the reliability of the system. * **Onboard RTC** - With the ultra-low power consumption design, the onboard RTC can keep the clock running for more than one year when PiSugar is off. * **Hardware battery protection** @@ -47,7 +51,6 @@ PiSugar 3 is the third generation of PiSugar Raspberry Pi battery power supply s | Size of PCB | 65mmX56mm | 65mmX30mm | ## Table of I2C - c.ntrol **Register address:** @@ -109,7 +112,7 @@ Some functions can be operated on WebUI, indicating that this function does not **Register address:** - the 5th bit of the 0X02 address + the 2th bit of the 0X02 address **Register operation:** @@ -121,7 +124,7 @@ Some functions can be operated on WebUI, indicating that this function does not **Function description:** - When output switch is turned off, PiSugar does not output voltage externally. When output switch is turned on, PiSugar outputs 5V voltage externally. If the automatic hibernate function is turned on and PiSugar is turned off, the PiSugar system will immediately go into the hibernate state, and I2C will be inoperable. + When output switch is turned off, PiSugar does not output voltage. When output switch is turned on, PiSugar outputs 5V voltage. If the automatic hibernate function is turned on and PiSugar is turned off, the PiSugar system will immediately go into the hibernate state, and I2C will be inoperable. (About turning off PiSugar: The shutdown command is executed in the PiSugar-Poweroff client.) @@ -131,6 +134,38 @@ Some functions can be operated on WebUI, indicating that this function does not This function will be reset to on each time the device is turned on. **WebUI does not support this function.** +1. Output switch with delay + + **Register address:** + + the 5th bit of the 0X02 address. 0x09 Set Delay Time + + **Register operation:** + + can be read or written + + **Data description:** + + 1 is on, 0 is off + + **Function description:** + + When setting the control bit to off, PiSugar will count down by the number set by 0x09 bit. When the countdown reaches 0, the system output will be turned off. + + PiSugar will not start countdown immediately after setting 0x09. Each time you use a delay, set 0x09 first, then set 0x02 to start countdown to turn off the output. + + Delay range 0-255 seconds, inaccurate timing. + + + **default value:** + + 0x09 will be reset to zero each time you restart. + + **WebUI does not support this function.** + + **Minimum firmware version: 1.0.6** + + 1. Automatically resume booting when power is reconnected **Register address:** @@ -402,4 +437,42 @@ WebUI supports this function. c. Turning off this function requires manual settings. -**WebUI supports this function** + **WebUI supports this function** + +1. Custom I2C address + + **Register address:** + + 0x50 + + **Register operation:** + + can be read or written. + + **Data description:** + + the highest bit is even parity check bit. If the number of 1 in the data is odd, the highest bit is 1, otherwise it is 0 + + For example, if the data is 0x57, the binary representation is 0b010110111, and the count of 1 is 5, so the highest bit is 1, and the final date is 0xd7, the binary representation is 0b11010111 + + **Function description:** + + Changing this register will change the operation address of I2C (0x57 by default). The change takes effect immediately. + + The I2C address range is 0x03-0x77. If date beyond the range, it will not be written successfully. + + **Default value** + + 0xd7 (actual address 0x57). This value will not be reset whether turned off or reset the system. So if you want change it, make sure you know what are you doing. + + + **WebUI not supports this function** + + If you want to change the I2C address of WebUI, you can modify i2c_addr of /etc/pisugar-server/config.json + + If the i2c_addr isn't in your file, you can add it. + + For example, the address is 0x30: + "i2c_addr"= 48, + + **Minimum firmware version: 1.0.6**