mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' of github.com:arendst/Tasmota into pr_tm1638
This commit is contained in:
commit
728074ccd2
|
@ -7,7 +7,10 @@
|
||||||
#endif //PROJECTOR_CTRL_PWR_BY_RELAY
|
#endif //PROJECTOR_CTRL_PWR_BY_RELAY
|
||||||
|
|
||||||
#define PROJECTOR_CTRL_SERIAL_TIMEOUT 10 //up to 254 seconds
|
#define PROJECTOR_CTRL_SERIAL_TIMEOUT 10 //up to 254 seconds
|
||||||
|
|
||||||
|
#ifndef PROJECTOR_CTRL_SERIAL_BAUDRATE
|
||||||
#define PROJECTOR_CTRL_SERIAL_BAUDRATE 9600
|
#define PROJECTOR_CTRL_SERIAL_BAUDRATE 9600
|
||||||
|
#endif //PROJECTOR_CTRL_SERIAL_BAUDRATE
|
||||||
|
|
||||||
#ifdef USE_PROJECTOR_CTRL_NEC
|
#ifdef USE_PROJECTOR_CTRL_NEC
|
||||||
/* see the serial codes in
|
/* see the serial codes in
|
||||||
|
@ -32,6 +35,8 @@ static const struct projector_ctrl_command_info_s projector_ctrl_commands[] = {
|
||||||
};
|
};
|
||||||
#define PROJECTOR_CTRL_QRYPWR_ON 0x04
|
#define PROJECTOR_CTRL_QRYPWR_ON 0x04
|
||||||
#define PROJECTOR_CTRL_QRYPWR_COOLING 0x05
|
#define PROJECTOR_CTRL_QRYPWR_COOLING 0x05
|
||||||
|
#define PROJECTOR_CTRL_QRYPWR_STARTING 0x01 //undocumented state, seen on V300W
|
||||||
|
#define PROJECTOR_CTRL_QRYPWR_WARMING 0x02 //undocumented state, seen on V300W
|
||||||
|
|
||||||
|
|
||||||
#elif defined(USE_PROJECTOR_CTRL_OPTOMA)
|
#elif defined(USE_PROJECTOR_CTRL_OPTOMA)
|
||||||
|
@ -56,6 +61,8 @@ static const struct projector_ctrl_command_info_s projector_ctrl_commands[] = {
|
||||||
};
|
};
|
||||||
#define PROJECTOR_CTRL_QRYPWR_ON 0x31
|
#define PROJECTOR_CTRL_QRYPWR_ON 0x31
|
||||||
#define PROJECTOR_CTRL_QRYPWR_COOLING 0x31 //placebo
|
#define PROJECTOR_CTRL_QRYPWR_COOLING 0x31 //placebo
|
||||||
|
#define PROJECTOR_CTRL_QRYPWR_STARTING 0x31 //placebo
|
||||||
|
#define PROJECTOR_CTRL_QRYPWR_WARMING 0x31 //placebo
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#define XDRV_53 53
|
#define XDRV_53 53
|
||||||
|
|
||||||
#ifndef USE_PROJECTOR_CTRL_NEC
|
#if !defined(USE_PROJECTOR_CTRL_NEC) && !defined(USE_PROJECTOR_CTRL_OPTOMA)
|
||||||
#define USE_PROJECTOR_CTRL_NEC // Use at least one projector
|
#define USE_PROJECTOR_CTRL_NEC // Use at least one projector
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -324,15 +324,29 @@ projector_ctrl_loop(struct projector_ctrl_softc_s *sc)
|
||||||
oldstate = sc->sc_ser_state;
|
oldstate = sc->sc_ser_state;
|
||||||
switch (sc->sc_ser_state = (projector_ctrl_serial_state_e)projector_ctrl_parse(sc, serial->read())) {
|
switch (sc->sc_ser_state = (projector_ctrl_serial_state_e)projector_ctrl_parse(sc, serial->read())) {
|
||||||
case PROJECTOR_CTRL_S_UNCONNECTED:
|
case PROJECTOR_CTRL_S_UNCONNECTED:
|
||||||
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
|
if (sc->sc_dev_state!=PROJECTOR_CTRL_DEV_UNKNOWN){
|
||||||
|
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
|
||||||
|
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(unexpected input)"));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PROJECTOR_CTRL_S_IDLE:
|
case PROJECTOR_CTRL_S_IDLE:
|
||||||
if ((oldstate==PROJECTOR_CTRL_S_QRY_PWR)&&(sc->sc_ser_result==PROJECTOR_CTRL_R_PASS)){
|
if ((oldstate==PROJECTOR_CTRL_S_QRY_PWR)&&(sc->sc_ser_result==PROJECTOR_CTRL_R_PASS)){
|
||||||
if(((sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_ON)||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_COOLING))&&(sc->sc_dev_state!=PROJECTOR_CTRL_DEV_PWR_ON)){
|
if(sc->sc_dev_state==PROJECTOR_CTRL_DEV_UNKNOWN){
|
||||||
|
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": CONNECTED"));
|
||||||
|
};
|
||||||
|
if(( (sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_ON)
|
||||||
|
||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_COOLING)
|
||||||
|
||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_STARTING)
|
||||||
|
||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_WARMING)
|
||||||
|
)&&(sc->sc_dev_state!=PROJECTOR_CTRL_DEV_PWR_ON)){
|
||||||
sc->sc_dev_state=PROJECTOR_CTRL_DEV_PWR_ON;
|
sc->sc_dev_state=PROJECTOR_CTRL_DEV_PWR_ON;
|
||||||
ExecuteCommandPower(sc->sc_device, POWER_ON, SRC_IGNORE);
|
ExecuteCommandPower(sc->sc_device, POWER_ON, SRC_IGNORE);
|
||||||
};
|
};
|
||||||
if(((sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_ON)&&(sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_COOLING))&&(sc->sc_dev_state!=PROJECTOR_CTRL_DEV_PWR_OFF)){
|
if(( (sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_ON)
|
||||||
|
&&(sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_COOLING)
|
||||||
|
&&(sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_STARTING)
|
||||||
|
&&(sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_WARMING)
|
||||||
|
)&&(sc->sc_dev_state!=PROJECTOR_CTRL_DEV_PWR_OFF)){
|
||||||
sc->sc_dev_state=PROJECTOR_CTRL_DEV_PWR_OFF;
|
sc->sc_dev_state=PROJECTOR_CTRL_DEV_PWR_OFF;
|
||||||
ExecuteCommandPower(sc->sc_device, POWER_OFF, SRC_IGNORE);
|
ExecuteCommandPower(sc->sc_device, POWER_OFF, SRC_IGNORE);
|
||||||
};
|
};
|
||||||
|
@ -375,7 +389,7 @@ projector_ctrl_tick(struct projector_ctrl_softc_s *sc)
|
||||||
};
|
};
|
||||||
}else if(sc->sc_ticks > sc->sc_cmd_info->timeout_ticks){
|
}else if(sc->sc_ticks > sc->sc_cmd_info->timeout_ticks){
|
||||||
//current CMD has ran out of time, drop connection
|
//current CMD has ran out of time, drop connection
|
||||||
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED"));
|
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(timeout)"));
|
||||||
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
|
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
|
||||||
sc->sc_ser_state=PROJECTOR_CTRL_S_UNCONNECTED;
|
sc->sc_ser_state=PROJECTOR_CTRL_S_UNCONNECTED;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
|
|
||||||
//#define CSE7761_SIMULATE
|
//#define CSE7761_SIMULATE
|
||||||
|
|
||||||
#define CSE7761_UREF 10000 // Gain 1 * 10000 in V
|
#define CSE7761_UREF 42563 // RmsUc
|
||||||
#define CSE7761_IREF 160000 // Gain 16 * 10000 in A
|
#define CSE7761_IREF 52241 // RmsIAC
|
||||||
#define CSE7761_PREF 50000 // in W
|
#define CSE7761_PREF 44513 // PowerPAC
|
||||||
|
|
||||||
#define CSE7761_REG_SYSCON 0x00 // System Control Register
|
#define CSE7761_REG_SYSCON 0x00 // System Control Register
|
||||||
#define CSE7761_REG_EMUCON 0x01 // Metering control register
|
#define CSE7761_REG_EMUCON 0x01 // Metering control register
|
||||||
|
@ -80,6 +80,7 @@ struct {
|
||||||
uint32_t current_rms[2] = { 0 };
|
uint32_t current_rms[2] = { 0 };
|
||||||
uint32_t energy[2] = { 0 };
|
uint32_t energy[2] = { 0 };
|
||||||
uint32_t active_power[2] = { 0 };
|
uint32_t active_power[2] = { 0 };
|
||||||
|
uint16_t coefficient[8] = { 0 };
|
||||||
uint8_t energy_update = 0;
|
uint8_t energy_update = 0;
|
||||||
uint8_t init = 4;
|
uint8_t init = 4;
|
||||||
uint8_t ready = 0;
|
uint8_t ready = 0;
|
||||||
|
@ -113,7 +114,7 @@ void Cse7761Write(uint32_t reg, uint32_t data) {
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("C61: Tx %*_H"), len, buffer);
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("C61: Tx %*_H"), len, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Cse7761Read(uint32_t reg) {
|
uint32_t Cse7761Read(uint32_t reg, uint32_t size) {
|
||||||
while (Cse7761Serial->available()) { Cse7761Serial->read(); }
|
while (Cse7761Serial->available()) { Cse7761Serial->read(); }
|
||||||
|
|
||||||
Cse7761Write(reg, 0);
|
Cse7761Write(reg, 0);
|
||||||
|
@ -121,6 +122,8 @@ uint32_t Cse7761Read(uint32_t reg) {
|
||||||
uint8_t buffer[8] = { 0 };
|
uint8_t buffer[8] = { 0 };
|
||||||
uint32_t rcvd = 0;
|
uint32_t rcvd = 0;
|
||||||
uint32_t timeout = millis() + 3;
|
uint32_t timeout = millis() + 3;
|
||||||
|
|
||||||
|
// while (!TimeReached(timeout) && (rcvd <= size)) {
|
||||||
while (!TimeReached(timeout)) {
|
while (!TimeReached(timeout)) {
|
||||||
int value = Cse7761Serial->read();
|
int value = Cse7761Serial->read();
|
||||||
if ((value > -1) && (rcvd < sizeof(buffer) -1)) {
|
if ((value > -1) && (rcvd < sizeof(buffer) -1)) {
|
||||||
|
@ -154,24 +157,44 @@ uint32_t Cse7761Read(uint32_t reg) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Cse7761ReadFallback(uint32_t reg, uint32_t prev) {
|
uint32_t Cse7761ReadFallback(uint32_t reg, uint32_t prev, uint32_t size) {
|
||||||
uint32_t value = Cse7761Read(reg);
|
uint32_t value = Cse7761Read(reg, size);
|
||||||
if (1 == value) { // CRC Error so use previous value read
|
if (1 == value) { // CRC Error so use previous value read
|
||||||
value = prev;
|
value = prev;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Cse7761Ref(uint32_t unit) {
|
||||||
|
switch (unit) {
|
||||||
|
case RmsUC: return 0x400000 * 100 / CSE7761Data.coefficient[RmsUC];
|
||||||
|
case RmsIAC: return (0x800000 * 100 / CSE7761Data.coefficient[RmsIAC]) * 10; // Stay within 32 bits
|
||||||
|
case PowerPAC: return 0x80000000 / CSE7761Data.coefficient[PowerPAC];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool Cse7761ChipInit(void) {
|
bool Cse7761ChipInit(void) {
|
||||||
uint16_t calc_chksum = 0xFFFF;
|
uint16_t calc_chksum = 0xFFFF;
|
||||||
for (uint32_t i = 0; i < 8; i++) {
|
for (uint32_t i = 0; i < 8; i++) {
|
||||||
calc_chksum = Cse7761Read(CSE7761_REG_RMSIAC + i);
|
CSE7761Data.coefficient[i] = Cse7761Read(CSE7761_REG_RMSIAC + i, 2);
|
||||||
|
calc_chksum += CSE7761Data.coefficient[i];
|
||||||
}
|
}
|
||||||
calc_chksum = ~calc_chksum;
|
calc_chksum = ~calc_chksum;
|
||||||
// uint16_t dummy = Cse7761Read(CSE7761_REG_COEFFOFFSET);
|
// uint16_t dummy = Cse7761Read(CSE7761_REG_COEFFOFFSET, 2);
|
||||||
uint16_t coeff_chksum = Cse7761Read(CSE7761_REG_COEFFCHKSUM);
|
uint16_t coeff_chksum = Cse7761Read(CSE7761_REG_COEFFCHKSUM, 2);
|
||||||
if (calc_chksum != coeff_chksum) {
|
if ((calc_chksum != coeff_chksum) || (!calc_chksum)) {
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("C61: Not calibrated"));
|
AddLog(LOG_LEVEL_DEBUG, PSTR("C61: Default calibration"));
|
||||||
|
CSE7761Data.coefficient[RmsIAC] = CSE7761_IREF;
|
||||||
|
// CSE7761Data.coefficient[RmsIBC] = 0xCC05;
|
||||||
|
CSE7761Data.coefficient[RmsUC] = CSE7761_UREF;
|
||||||
|
CSE7761Data.coefficient[PowerPAC] = CSE7761_PREF;
|
||||||
|
// CSE7761Data.coefficient[PowerPBC] = 0xADD7;
|
||||||
|
}
|
||||||
|
if (HLW_PREF_PULSE == Settings.energy_power_calibration) {
|
||||||
|
Settings.energy_voltage_calibration = Cse7761Ref(RmsUC);
|
||||||
|
Settings.energy_current_calibration = Cse7761Ref(RmsIAC);
|
||||||
|
Settings.energy_power_calibration = Cse7761Ref(PowerPAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cse7761Write(CSE7761_SPECIAL_COMMAND, CSE7761_CMD_ENABLE_WRITE);
|
Cse7761Write(CSE7761_SPECIAL_COMMAND, CSE7761_CMD_ENABLE_WRITE);
|
||||||
|
@ -180,7 +203,7 @@ bool Cse7761ChipInit(void) {
|
||||||
uint32_t timeout = millis() + 8;
|
uint32_t timeout = millis() + 8;
|
||||||
while (!TimeReached(timeout)) { }
|
while (!TimeReached(timeout)) { }
|
||||||
|
|
||||||
uint8_t sys_status = Cse7761Read(CSE7761_REG_SYSSTATUS);
|
uint8_t sys_status = Cse7761Read(CSE7761_REG_SYSSTATUS, 1);
|
||||||
#ifdef CSE7761_SIMULATE
|
#ifdef CSE7761_SIMULATE
|
||||||
sys_status = 0x11;
|
sys_status = 0x11;
|
||||||
#endif
|
#endif
|
||||||
|
@ -315,34 +338,31 @@ void Cse7761GetData(void) {
|
||||||
// The effective value of current and voltage Rms is a 24-bit signed number, the highest bit is 0 for valid data,
|
// The effective value of current and voltage Rms is a 24-bit signed number, the highest bit is 0 for valid data,
|
||||||
// and when the highest bit is 1, the reading will be processed as zero
|
// and when the highest bit is 1, the reading will be processed as zero
|
||||||
// The active power parameter PowerA/B is in two’s complement format, 32-bit data, the highest bit is Sign bit.
|
// The active power parameter PowerA/B is in two’s complement format, 32-bit data, the highest bit is Sign bit.
|
||||||
uint32_t value = Cse7761ReadFallback(CSE7761_REG_RMSU, CSE7761Data.voltage_rms);
|
uint32_t value = Cse7761ReadFallback(CSE7761_REG_RMSU, CSE7761Data.voltage_rms, 3);
|
||||||
#ifdef CSE7761_SIMULATE
|
#ifdef CSE7761_SIMULATE
|
||||||
// value = 2342160; // 234.2V
|
value = 2342160; // 237.7V
|
||||||
value = 2000000; // 200V
|
|
||||||
#endif
|
#endif
|
||||||
CSE7761Data.voltage_rms = (value >= 0x800000) ? 0 : value;
|
CSE7761Data.voltage_rms = (value >= 0x800000) ? 0 : value;
|
||||||
|
|
||||||
value = Cse7761ReadFallback(CSE7761_REG_RMSIA, CSE7761Data.current_rms[0]);
|
value = Cse7761ReadFallback(CSE7761_REG_RMSIA, CSE7761Data.current_rms[0], 3);
|
||||||
#ifdef CSE7761_SIMULATE
|
#ifdef CSE7761_SIMULATE
|
||||||
value = 455;
|
value = 455;
|
||||||
#endif
|
#endif
|
||||||
CSE7761Data.current_rms[0] = ((value >= 0x800000) || (value < 1600)) ? 0 : value; // No load threshold of 10mA
|
CSE7761Data.current_rms[0] = ((value >= 0x800000) || (value < 1600)) ? 0 : value; // No load threshold of 10mA
|
||||||
value = Cse7761ReadFallback(CSE7761_REG_POWERPA, CSE7761Data.active_power[0]);
|
value = Cse7761ReadFallback(CSE7761_REG_POWERPA, CSE7761Data.active_power[0], 4);
|
||||||
#ifdef CSE7761_SIMULATE
|
#ifdef CSE7761_SIMULATE
|
||||||
value = 217;
|
value = 217;
|
||||||
#endif
|
#endif
|
||||||
CSE7761Data.active_power[0] = (0 == CSE7761Data.current_rms[0]) ? 0 : (value & 0x80000000) ? (~value) + 1 : value;
|
CSE7761Data.active_power[0] = (0 == CSE7761Data.current_rms[0]) ? 0 : (value & 0x80000000) ? (~value) + 1 : value;
|
||||||
|
|
||||||
value = Cse7761ReadFallback(CSE7761_REG_RMSIB, CSE7761Data.current_rms[1]);
|
value = Cse7761ReadFallback(CSE7761_REG_RMSIB, CSE7761Data.current_rms[1], 3);
|
||||||
#ifdef CSE7761_SIMULATE
|
#ifdef CSE7761_SIMULATE
|
||||||
// value = 29760; // 0.186A
|
value = 29760; // 0.185A
|
||||||
value = 800000; // 5A
|
|
||||||
#endif
|
#endif
|
||||||
CSE7761Data.current_rms[1] = ((value >= 0x800000) || (value < 1600)) ? 0 : value; // No load threshold of 10mA
|
CSE7761Data.current_rms[1] = ((value >= 0x800000) || (value < 1600)) ? 0 : value; // No load threshold of 10mA
|
||||||
value = Cse7761ReadFallback(CSE7761_REG_POWERPB, CSE7761Data.active_power[1]);
|
value = Cse7761ReadFallback(CSE7761_REG_POWERPB, CSE7761Data.active_power[1], 4);
|
||||||
#ifdef CSE7761_SIMULATE
|
#ifdef CSE7761_SIMULATE
|
||||||
// value = 2126641; // 42.5W
|
value = 2126641; // 44.05W
|
||||||
value = 50000000; // 1000W
|
|
||||||
#endif
|
#endif
|
||||||
CSE7761Data.active_power[1] = (0 == CSE7761Data.current_rms[1]) ? 0 : (value & 0x80000000) ? (~value) + 1 : value;
|
CSE7761Data.active_power[1] = (0 == CSE7761Data.current_rms[1]) ? 0 : (value & 0x80000000) ? (~value) + 1 : value;
|
||||||
|
|
||||||
|
@ -352,24 +372,25 @@ void Cse7761GetData(void) {
|
||||||
CSE7761Data.active_power[0], CSE7761Data.active_power[1]);
|
CSE7761Data.active_power[0], CSE7761Data.active_power[1]);
|
||||||
|
|
||||||
if (Energy.power_on) { // Powered on
|
if (Energy.power_on) { // Powered on
|
||||||
|
// Voltage = RmsU * RmsUC * 10 / 0x400000
|
||||||
|
// Energy.voltage[0] = (float)(((uint64_t)CSE7761Data.voltage_rms * CSE7761Data.coefficient[RmsUC] * 10) >> 22) / 1000; // V
|
||||||
Energy.voltage[0] = ((float)CSE7761Data.voltage_rms / Settings.energy_voltage_calibration); // V
|
Energy.voltage[0] = ((float)CSE7761Data.voltage_rms / Settings.energy_voltage_calibration); // V
|
||||||
|
|
||||||
for (uint32_t channel = 0; channel < 2; channel++) {
|
for (uint32_t channel = 0; channel < 2; channel++) {
|
||||||
Energy.data_valid[channel] = 0;
|
Energy.data_valid[channel] = 0;
|
||||||
|
// Active power = PowerPA * PowerPAC * 1000 / 0x80000000
|
||||||
|
// Energy.active_power[channel] = (float)(((uint64_t)CSE7761Data.active_power[channel] * CSE7761Data.coefficient[PowerPAC + channel] * 1000) >> 31) / 1000; // W
|
||||||
Energy.active_power[channel] = (float)CSE7761Data.active_power[channel] / Settings.energy_power_calibration; // W
|
Energy.active_power[channel] = (float)CSE7761Data.active_power[channel] / Settings.energy_power_calibration; // W
|
||||||
if (0 == Energy.active_power[channel]) {
|
if (0 == Energy.active_power[channel]) {
|
||||||
Energy.current[channel] = 0;
|
Energy.current[channel] = 0;
|
||||||
} else {
|
} else {
|
||||||
|
// Current = RmsIA * RmsIAC / 0x800000
|
||||||
|
// Energy.current[channel] = (float)(((uint64_t)CSE7761Data.current_rms[channel] * CSE7761Data.coefficient[RmsIAC + channel]) >> 23) / 1000; // A
|
||||||
Energy.current[channel] = (float)CSE7761Data.current_rms[channel] / Settings.energy_current_calibration; // A
|
Energy.current[channel] = (float)CSE7761Data.current_rms[channel] / Settings.energy_current_calibration; // A
|
||||||
CSE7761Data.energy[channel] += Energy.active_power[channel];
|
CSE7761Data.energy[channel] += Energy.active_power[channel];
|
||||||
CSE7761Data.energy_update++;
|
CSE7761Data.energy_update++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
} else { // Powered off
|
|
||||||
Energy.data_valid[0] = ENERGY_WATCHDOG;
|
|
||||||
Energy.data_valid[1] = ENERGY_WATCHDOG;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +408,7 @@ void Cse7761EverySecond(void) {
|
||||||
Cse7761Write(CSE7761_SPECIAL_COMMAND, CSE7761_CMD_RESET);
|
Cse7761Write(CSE7761_SPECIAL_COMMAND, CSE7761_CMD_RESET);
|
||||||
}
|
}
|
||||||
else if (2 == CSE7761Data.init) {
|
else if (2 == CSE7761Data.init) {
|
||||||
uint16_t syscon = Cse7761Read(0x00); // Default 0x0A04
|
uint16_t syscon = Cse7761Read(0x00, 2); // Default 0x0A04
|
||||||
#ifdef CSE7761_SIMULATE
|
#ifdef CSE7761_SIMULATE
|
||||||
syscon = 0x0A04;
|
syscon = 0x0A04;
|
||||||
#endif
|
#endif
|
||||||
|
@ -428,11 +449,6 @@ void Cse7761SnsInit(void) {
|
||||||
SetSerial(38400, TS_SERIAL_8E1);
|
SetSerial(38400, TS_SERIAL_8E1);
|
||||||
ClaimSerial();
|
ClaimSerial();
|
||||||
}
|
}
|
||||||
if (HLW_PREF_PULSE == Settings.energy_power_calibration) {
|
|
||||||
Settings.energy_voltage_calibration = CSE7761_UREF;
|
|
||||||
Settings.energy_current_calibration = CSE7761_IREF;
|
|
||||||
Settings.energy_power_calibration = CSE7761_PREF;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
TasmotaGlobal.energy_driver = ENERGY_NONE;
|
TasmotaGlobal.energy_driver = ENERGY_NONE;
|
||||||
}
|
}
|
||||||
|
@ -455,15 +471,15 @@ bool Cse7761Command(void) {
|
||||||
uint32_t value = (uint32_t)(CharToFloat(XdrvMailbox.data) * 100); // 1.23 = 123
|
uint32_t value = (uint32_t)(CharToFloat(XdrvMailbox.data) * 100); // 1.23 = 123
|
||||||
|
|
||||||
if (CMND_POWERCAL == Energy.command_code) {
|
if (CMND_POWERCAL == Energy.command_code) {
|
||||||
if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = CSE7761_PREF; }
|
if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = Cse7761Ref(PowerPAC); }
|
||||||
// Service in xdrv_03_energy.ino
|
// Service in xdrv_03_energy.ino
|
||||||
}
|
}
|
||||||
else if (CMND_VOLTAGECAL == Energy.command_code) {
|
else if (CMND_VOLTAGECAL == Energy.command_code) {
|
||||||
if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = CSE7761_UREF; }
|
if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = Cse7761Ref(RmsUC); }
|
||||||
// Service in xdrv_03_energy.ino
|
// Service in xdrv_03_energy.ino
|
||||||
}
|
}
|
||||||
else if (CMND_CURRENTCAL == Energy.command_code) {
|
else if (CMND_CURRENTCAL == Energy.command_code) {
|
||||||
if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = CSE7761_IREF; }
|
if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = Cse7761Ref(RmsIAC); }
|
||||||
// Service in xdrv_03_energy.ino
|
// Service in xdrv_03_energy.ino
|
||||||
}
|
}
|
||||||
else if (CMND_POWERSET == Energy.command_code) {
|
else if (CMND_POWERSET == Energy.command_code) {
|
||||||
|
|
Loading…
Reference in New Issue