Skip to content

Commit

Permalink
Merge branch 'arendst:development' into IDF55
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Jan 25, 2025
2 parents d271059 + 53dee5b commit 7e9832f
Show file tree
Hide file tree
Showing 12 changed files with 1,213 additions and 21 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ All notable changes to this project will be documented in this file.
- Berry `serial.read()` read only `n` bytes (#22835)
- Display template for Waveshare ESP32-C6 LCD 1.47 (#22863)
- Berry `tasmota.global.tele_period` and `tasmota.settings.tele_period` (#22865)
- Command `PixelType` to change the WS2812 color order and channel number
- ESP32 command `PixelType` to change the WS2812 color order and channel number (#22876)
- Berry driver for AXP2102 and M5CoreS3 (#22878)
- GPS driver select baudrate using GPIO GPS_RX1 (9600bps), GPS_RX2 (19200bps) or GPS_RX3 (38400bps) (#22869)
- LVLG/HASPmota add color names from OpenHASP (#22879)

### Breaking Changed

Expand Down
4 changes: 4 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Support for PCF85063 RTC [#22727](https://github.com/arendst/Tasmota/issues/22727)
- Support for Senseair S88 CO2 sensor [#22733](https://github.com/arendst/Tasmota/issues/22733)
- Support for ESP32 Two-Wire Automotive Interface (TWAI) or Controller Area Network (CAN) busses
- GPS driver select baudrate using GPIO GPS_RX1 (9600bps), GPS_RX2 (19200bps) or GPS_RX3 (38400bps) [#22869](https://github.com/arendst/Tasmota/issues/22869)
- I2S AAC support for web radio [#22787](https://github.com/arendst/Tasmota/issues/22787)
- I2S Opus stream and file support for opus/aac [#22795](https://github.com/arendst/Tasmota/issues/22795)
- ESP32 command `PixelType` to change the WS2812 color order and channel number [#22876](https://github.com/arendst/Tasmota/issues/22876)
- ESP32 TasmotaLED change dynamically the number of pixels [#22754](https://github.com/arendst/Tasmota/issues/22754)
- ESP32 expand `Pixels` with reverse, height and alternate [#22755](https://github.com/arendst/Tasmota/issues/22755)
- Display template for Waveshare ESP32-C6 LCD 1.47 [#22863](https://github.com/arendst/Tasmota/issues/22863)
Expand All @@ -138,6 +140,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Berry WS2812 real-time Leds panel as app [#22788](https://github.com/arendst/Tasmota/issues/22788)
- Berry `serial.read()` read only `n` bytes [#22835](https://github.com/arendst/Tasmota/issues/22835)
- Berry `tasmota.global.tele_period` and `tasmota.settings.tele_period` [#22865](https://github.com/arendst/Tasmota/issues/22865)
- Berry driver for AXP2102 and M5CoreS3 [#22878](https://github.com/arendst/Tasmota/issues/22878)
- LVLG/HASPmota add color names from OpenHASP [#22879](https://github.com/arendst/Tasmota/issues/22879)

### Breaking Changed

Expand Down
2 changes: 2 additions & 0 deletions lib/libesp32/berry/default/be_modtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ be_extern_native_class(Wire);
be_extern_native_class(I2C_Driver);
be_extern_native_class(AXP192);
be_extern_native_class(AXP202);
be_extern_native_class(AXP2102);
be_extern_native_class(OneWire);
be_extern_native_class(Leds_ntv);
be_extern_native_class(Leds);
Expand Down Expand Up @@ -279,6 +280,7 @@ BERRY_LOCAL bclass_array be_class_table = {
&be_native_class(I2C_Driver),
&be_native_class(AXP192),
&be_native_class(AXP202),
&be_native_class(AXP2102),
#endif // USE_I2C
&be_native_class(md5),
#ifdef USE_WEBCLIENT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*******************************************************************/
#include "solidify/solidified_AXP192.h"
#include "solidify/solidified_AXP202.h"
#include "solidify/solidified_AXP2102.h"
169 changes: 169 additions & 0 deletions lib/libesp32/berry_tasmota/src/embedded/AXP2102.be
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#-------------------------------------------------------------
- Generic driver for AXP2102 - solidified
-------------------------------------------------------------#

# Specs
# DCDC1 : 1.5-3.4V, 2000mA
# DCDC2 : 0.5-1.2V,1.22-1.54V, 2000mA
# DCDC3 : 0.5-1.2V,1.22-1.54V, 1.6-3.4V, 2000mA
# DCDC4 : 0.5-1.2V, 1.22-1.84V, 1500mA
# DCDC5 : 1.2V , 1.4-3.7V, 1000mA
#
# RTCLDO1/2 : 1.8V/2.5V/3V/3.3V, 30mA
# ALDO1~4 : 0.5-3.5V, 100mV/step 300mA

# LDO index:
# 0=ALDO1 ~ 3=ALDO4 / 4=BLDO1 / 5=BLDO2

#@ solidify:AXP2102
class AXP2102 : I2C_Driver
def init(addr)
if (addr == nil) addr = 0x34 end # default address is 0x34
super(self).init("AXP2102", addr)
end

# Return True = Battery Exist
def battery_present()
return bool(self.wire.read(self.addr, 0x00, 1) & 0x08)
end

# # Battery Charging Status
def get_battery_charging_status()
var val = (self.read8(0x01) >> 5) & 0x03
# 1:charge / 2:dischage / 0:stanby
return (val == 1) ? 1 : ((val == 2) ? -1 : 0)
end

def is_charging()
return (self.read8(0x01) & 0x60) == 0x20
end

def get_battery_level()
return self.read8(0xA4)
end

# AXP chip temperature in °C
def get_temp()
return 22 + ((7274 - self.read16(0x3C)) / 20);
end

def get_bat_power()
return 0
end

def get_bat_voltage()
return self.read14(0x34) / 1000.0
end
def get_bat_current()
return 0
end
def get_bat_charge_current()
return 0
end
def get_aps_voltage()
return 0
end
def get_vbus_good()
return bool(self.wire.read(self.addr, 0x00, 1) & 0x20)
end
def get_vbus_voltage()
if (!self.get_vbus_good()) return 0 end
var vbus = self.read14(0x38)
if (vbus > 16375) return 0 end
return vbus / 1000.0
end
def get_vbus_current()
return 0
end

# set LDO voltage
# 0=ALDO1 ~ 3=ALDO4 / 4=BLDO1 / 5=BLDO2
# voltage: (mV) 0.5-3.5V in 100mV steps
def set_ldo_voltage(num, voltage)
if (num < 0 || num > 5) return end
var reg_volt = num + 0x92
voltage -= 500
# convert voltage to value
var val = (voltage < 0) ? 0 : voltage / 100
if (val > 0x1E) val = 0x1E end
self.write8(reg_volt, val)

var reg90bit = 1 << num
if (voltage < 0)
self.write8(0x90, self.read8(0x90) & ~reg90bit) # bit off
else
self.write8(0x90, self.read8(0x90) | reg90bit) # bit on
end
end

# det DLDO voltage
def set_dldo_voltage(num, voltage)
if (num < 0 || num > 1) return end
var reg_volt = num + 0x99
voltage -= 500
# convert voltage to value
var val = (voltage < 0) ? 0 : voltage / (num ? 50 : 100)
if (val > (num ? 0x13 : 0x1C)) val = num ? 0x13 : 0x1C end
self.write8(reg_volt, val)

var reg = 0x90 + num
var bit = num ? 0x01 : 0x80
if (voltage < 0)
self.write8(0x90, self.read8(reg) & ~bit) # bit off
else
self.write8(0x90, self.read8(reg) | bit) # bit on
end
end

# get LDO enable
def get_ldo_enable(num)
var res = false
if (num <= 5)
var reg90bit = 1 << num
res = bool(self.read8(0x90) & reg90bit)
end
return res
end

def set_battery_charge(enable)
self.write8(0x18, (self.read8(0x18) & 0xFD) | ((enable ? 1 : 0) << 1))
end

static var _pre_charge = [0, 25, 50, 75, 100, 125, 150, 175, 200, 255]
def set_pre_charge_current(max_mA)
if (max_mA < 0) max_mA = 0 end
if (max_mA > 200) max_mA = 200 end
var i = 0
while (self._pre_charge[i] <= max_mA)
i += 1
end
self.write8(0x61, i)
end

static var _charge = [ 25, 30, 35, 40, 60, 80, 100, 120, 140, 160, 180, 200, 255]
def set_charge_current(max_mA)
if (max_mA < 0) max_mA = 0 end
if (max_mA > 200) max_mA = 200 end
var i = 0
while (self._charge[i] <= max_mA)
i += 1
end
i += 4
self.write8(0x62, i)
end

static var _charge_voltage = [410, 420, 435, 440, 460, 655]
def set_charge_voltage(max_mV)
if (max_mV < 0) max_mV = 0 end
if (max_mV > 460) max_mV = 460 end
var i = 0
while (self._charge_voltage[i] <= max_mV)
i += 1
end
i += 1
if (i >= 6) i = 0 end
self.write8(0x64, i)
end

end
return AXP2102
Loading

0 comments on commit 7e9832f

Please sign in to comment.