mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Add support negative power on BL0942 using index 5..8 (#20322)
This commit is contained in:
parent
6a8435b731
commit
4393327bb9
@ -11,8 +11,9 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Matter support for password for remote Tasmota devices (#20296)
|
- Matter support for password for remote Tasmota devices (#20296)
|
||||||
- Display of active drivers using command ``status 4``
|
- Display of active drivers using command ``status 4``
|
||||||
- ESP32 used UART information
|
- ESP32 used UART information
|
||||||
- HASPmota added `haspmota.page_show()` to change page
|
- HASPmota added `haspmota.page_show()` to change page (#20333)
|
||||||
- Berry added `introspect.set()` for class attributes
|
- Berry added `introspect.set()` for class attributes (#20339)
|
||||||
|
- Support negative power on BL0942 using index 5..8 (#20322)
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
- Refactoring of Berry `animate` module for WS2812 Leds (#20236)
|
- Refactoring of Berry `animate` module for WS2812 Leds (#20236)
|
||||||
|
@ -122,7 +122,10 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||||||
- Support for Sonoff Basic R4 Magic Switch [#20247](https://github.com/arendst/Tasmota/issues/20247)
|
- Support for Sonoff Basic R4 Magic Switch [#20247](https://github.com/arendst/Tasmota/issues/20247)
|
||||||
- Display of active drivers using command ``status 4``
|
- Display of active drivers using command ``status 4``
|
||||||
- NeoPool hydrolysis FL1 and Redox flag [#20258](https://github.com/arendst/Tasmota/issues/20258)
|
- NeoPool hydrolysis FL1 and Redox flag [#20258](https://github.com/arendst/Tasmota/issues/20258)
|
||||||
|
- Support negative power on BL0942 using index 5..8 [#20322](https://github.com/arendst/Tasmota/issues/20322)
|
||||||
- ESP32 used UART information
|
- ESP32 used UART information
|
||||||
|
- Berry added `introspect.set()` for class attributes [#20339](https://github.com/arendst/Tasmota/issues/20339)
|
||||||
|
- HASPmota added `haspmota.page_show()` to change page [#20333](https://github.com/arendst/Tasmota/issues/20333)
|
||||||
- Matter support for password for remote Tasmota devices [#20296](https://github.com/arendst/Tasmota/issues/20296)
|
- Matter support for password for remote Tasmota devices [#20296](https://github.com/arendst/Tasmota/issues/20296)
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
@ -496,7 +496,7 @@ const char kSensorNamesFixed[] PROGMEM =
|
|||||||
#define MAX_BP1658CJ_DAT 16
|
#define MAX_BP1658CJ_DAT 16
|
||||||
#define MAX_DINGTIAN_SHIFT 4
|
#define MAX_DINGTIAN_SHIFT 4
|
||||||
#define MAX_MAGIC_SWITCH_MODES 2
|
#define MAX_MAGIC_SWITCH_MODES 2
|
||||||
#define MAX_BL0942_RX 4 // Baudrates 1 (4800), 2 (9600), 3 (19200), 4 (38400)
|
#define MAX_BL0942_RX 8 // Baudrates 1/5 (4800), 2/6 (9600), 3/7 (19200), 4/8 (38400), Support Positive values only 1..4, Support also negative values 5..8
|
||||||
|
|
||||||
const uint16_t kGpioNiceList[] PROGMEM = {
|
const uint16_t kGpioNiceList[] PROGMEM = {
|
||||||
GPIO_NONE, // Not used
|
GPIO_NONE, // Not used
|
||||||
|
@ -102,6 +102,7 @@ struct BL09XX {
|
|||||||
uint8_t address = 0;
|
uint8_t address = 0;
|
||||||
uint8_t model = 0;
|
uint8_t model = 0;
|
||||||
uint8_t rx_pin;
|
uint8_t rx_pin;
|
||||||
|
bool support_negative = 0;
|
||||||
bool received = false;
|
bool received = false;
|
||||||
} Bl09XX;
|
} Bl09XX;
|
||||||
|
|
||||||
@ -187,11 +188,15 @@ bool Bl09XXDecode42(void) {
|
|||||||
Bl09XX.voltage = Bl09XX.rx_buffer[6] << 16 | Bl09XX.rx_buffer[5] << 8 | Bl09XX.rx_buffer[4]; // V_RMS unsigned
|
Bl09XX.voltage = Bl09XX.rx_buffer[6] << 16 | Bl09XX.rx_buffer[5] << 8 | Bl09XX.rx_buffer[4]; // V_RMS unsigned
|
||||||
Bl09XX.current[0] = Bl09XX.rx_buffer[3] << 16 | Bl09XX.rx_buffer[2] << 8 | Bl09XX.rx_buffer[1]; // IA_RMS unsigned
|
Bl09XX.current[0] = Bl09XX.rx_buffer[3] << 16 | Bl09XX.rx_buffer[2] << 8 | Bl09XX.rx_buffer[1]; // IA_RMS unsigned
|
||||||
|
|
||||||
// Bl09XX.power[0] = Bl09XX.rx_buffer[12] << 16 | Bl09XX.rx_buffer[11] << 8 | Bl09XX.rx_buffer[10]; // WATT_A signed
|
|
||||||
// if (bitRead(Bl09XX.power[0], 23)) { Bl09XX.power[0] |= 0xFF000000; } // Extend sign bit
|
if (Bl09XX.support_negative) {
|
||||||
|
Bl09XX.power[0] = Bl09XX.rx_buffer[12] << 16 | Bl09XX.rx_buffer[11] << 8 | Bl09XX.rx_buffer[10]; // WATT_A signed
|
||||||
|
if (bitRead(Bl09XX.power[0], 23)) { Bl09XX.power[0] |= 0xFF000000; } // Extend sign bit
|
||||||
// Above reverted in favour of https://github.com/arendst/Tasmota/issues/15374#issuecomment-1105293179
|
// Above reverted in favour of https://github.com/arendst/Tasmota/issues/15374#issuecomment-1105293179
|
||||||
|
} else {
|
||||||
int32_t tmp = Bl09XX.rx_buffer[12] << 24 | Bl09XX.rx_buffer[11] << 16 | Bl09XX.rx_buffer[10] << 8; // WATT_A signed
|
int32_t tmp = Bl09XX.rx_buffer[12] << 24 | Bl09XX.rx_buffer[11] << 16 | Bl09XX.rx_buffer[10] << 8; // WATT_A signed
|
||||||
Bl09XX.power[0] = abs(tmp >> 8);
|
Bl09XX.power[0] = abs(tmp >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_BL09XX
|
#ifdef DEBUG_BL09XX
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("BL9: U %d, I %d, P %d"),
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("BL9: U %d, I %d, P %d"),
|
||||||
@ -361,7 +366,9 @@ void Bl09XXPreInit(void) {
|
|||||||
else if (PinUsed(GPIO_BL0942_RX, GPIO_ANY)) {
|
else if (PinUsed(GPIO_BL0942_RX, GPIO_ANY)) {
|
||||||
Bl09XX.model = BL0942_MODEL;
|
Bl09XX.model = BL0942_MODEL;
|
||||||
Bl09XX.rx_pin = Pin(GPIO_BL0942_RX, GPIO_ANY);
|
Bl09XX.rx_pin = Pin(GPIO_BL0942_RX, GPIO_ANY);
|
||||||
uint32_t baudrate = GetPin(Bl09XX.rx_pin) - AGPIO(GPIO_BL0942_RX); // 0 .. 3
|
uint32_t option = GetPin(Bl09XX.rx_pin) - AGPIO(GPIO_BL0942_RX); // 0 .. 7
|
||||||
|
Bl09XX.support_negative = (option > 3); // 4 .. 7
|
||||||
|
uint32_t baudrate = option & 0x3; // 0 .. 3 and 4 .. 7
|
||||||
Bl09XX.baudrate <<= baudrate; // Support 1 (4800), 2 (9600), 3 (19200), 4 (38400)
|
Bl09XX.baudrate <<= baudrate; // Support 1 (4800), 2 (9600), 3 (19200), 4 (38400)
|
||||||
}
|
}
|
||||||
if (Bl09XX.model != BL09XX_MODEL) {
|
if (Bl09XX.model != BL09XX_MODEL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user