Junkers modes sorted.

This commit is contained in:
MichaelDvP
2020-06-30 16:36:45 +02:00
parent 876489494f
commit 1b00a4405b
5 changed files with 63 additions and 43 deletions

View File

@@ -261,6 +261,12 @@ void Thermostat::thermostat_cmd(const char * message) {
if (float f = doc[hc_name]["nofrosttemp"]) {
set_temperature(f, HeatingCircuit::Mode::NOFROST, hc_num);
}
if (float f = doc[hc_name]["ecotemp"]) {
set_temperature(f, HeatingCircuit::Mode::ECO, hc_num);
}
if (float f = doc[hc_name]["heattemp"]) {
set_temperature(f, HeatingCircuit::Mode::HEAT, hc_num);
}
if (float f = doc[hc_name]["summertemp"]) {
set_temperature(f, HeatingCircuit::Mode::SUMMER, hc_num);
}
@@ -341,6 +347,12 @@ void Thermostat::thermostat_cmd(const char * message) {
if (float f = doc["nofrosttemp"]) {
set_temperature(f, HeatingCircuit::Mode::NOFROST, hc_num);
}
if (float f = doc["ecotemp"]) {
set_temperature(f, HeatingCircuit::Mode::ECO, hc_num);
}
if (float f = doc["heattemp"]) {
set_temperature(f, HeatingCircuit::Mode::HEAT, hc_num);
}
if (float f = doc["summertemp"]) {
set_temperature(f, HeatingCircuit::Mode::SUMMER, hc_num);
}
@@ -785,6 +797,8 @@ uint8_t Thermostat::HeatingCircuit::get_mode(uint8_t flags) const {
return HeatingCircuit::Mode::MANUAL;
} else if (mode == 2) {
return HeatingCircuit::Mode::AUTO;
} else if (mode == 3) {
return HeatingCircuit::Mode::HOLIDAY;
}
} else { // default for all other thermostats
if (mode == 0) {
@@ -806,9 +820,11 @@ uint8_t Thermostat::HeatingCircuit::get_mode_type(uint8_t flags) const {
if (flags == EMS_DEVICE_FLAG_JUNKERS) {
if (mode_type == 3) {
return HeatingCircuit::Mode::DAY;
return HeatingCircuit::Mode::HEAT;
} else if (mode == 2) {
return HeatingCircuit::Mode::NIGHT;
return HeatingCircuit::Mode::ECO;
} else if (mode == 1) {
return HeatingCircuit::Mode::NOFROST;
}
} else if ((flags == EMS_DEVICE_FLAG_RC35) || (flags == EMS_DEVICE_FLAG_RC30_1)) {
if (mode_type == 0) {
@@ -1130,7 +1146,7 @@ void Thermostat::process_JunkersMonitor(std::shared_ptr<const Telegram> telegram
telegram->read_value(hc->curr_roomTemp, 4); // value is * 10
telegram->read_value(hc->setpoint_roomTemp, 2); // value is * 10
telegram->read_bitvalue(hc->mode_type, 0, 0); // first bit 1=day, 0=night
telegram->read_value(hc->mode_type, 0); // 1 = nofrost, 2 = eco, 3 = heat
telegram->read_value(hc->mode, 1); // 1 = manual, 2 = auto
}
@@ -1458,7 +1474,7 @@ void Thermostat::set_mode(const uint8_t mode, const uint8_t hc_num) {
validate_typeid = monitor_typeids[hc_p];
if (mode == HeatingCircuit::Mode::NOFROST) {
set_mode_value = 0x01;
} else if (mode == HeatingCircuit::Mode::ECO) {
} else if (mode == HeatingCircuit::Mode::ECO || (mode == HeatingCircuit::Mode::NIGHT)) {
set_mode_value = 0x02;
} else if ((mode == HeatingCircuit::Mode::DAY) || (mode == HeatingCircuit::Mode::HEAT)) {
set_mode_value = 0x03; // comfort
@@ -1603,15 +1619,17 @@ void Thermostat::set_temperature(const float temperature, const uint8_t mode, co
offset = EMS_OFFSET_JunkersSetMessage_no_frost_temp;
break;
case HeatingCircuit::Mode::NIGHT:
case HeatingCircuit::Mode::ECO:
offset = EMS_OFFSET_JunkersSetMessage_night_temp;
break;
case HeatingCircuit::Mode::HEAT:
case HeatingCircuit::Mode::DAY:
offset = EMS_OFFSET_JunkersSetMessage_day_temp;
break;
default:
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
uint8_t mode_type = hc->get_mode_type(flags());
offset = (mode_type == HeatingCircuit::Mode::NIGHT) ? EMS_OFFSET_JunkersSetMessage_night_temp : EMS_OFFSET_JunkersSetMessage_day_temp;
offset = (mode_type == HeatingCircuit::Mode::NIGHT || mode_type == HeatingCircuit::Mode::ECO) ? EMS_OFFSET_JunkersSetMessage_night_temp : EMS_OFFSET_JunkersSetMessage_day_temp;
break;
}
@@ -1622,10 +1640,12 @@ void Thermostat::set_temperature(const float temperature, const uint8_t mode, co
offset = EMS_OFFSET_JunkersSetMessage2_no_frost_temp;
break;
case HeatingCircuit::Mode::ECO:
case HeatingCircuit::Mode::NIGHT:
offset = EMS_OFFSET_JunkersSetMessage2_eco_temp;
break;
default:
case HeatingCircuit::Mode::HEAT:
case HeatingCircuit::Mode::DAY:
offset = EMS_OFFSET_JunkersSetMessage3_heat;
break;
}

View File

@@ -188,7 +188,7 @@ class Thermostat : public EMSdevice {
static constexpr uint8_t EMS_OFFSET_RCPLUSSet_temp_setpoint = 8; // temp setpoint, when changing of templevel (in auto) value is reset to FF
static constexpr uint8_t EMS_OFFSET_RCPLUSSet_manual_setpoint = 10; // manual setpoint
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_daymode = 0; // 3 = day, 2 = night
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_daymode = 0; // 3 = day, 2 = night, 1 = nofrost
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_mode = 1; // current mode, 1 = manual, 2 = auto
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_setpoint = 2; // setpoint temp
static constexpr uint8_t EMS_OFFSET_JunkersStatusMessage_curr = 4; // current temp

View File

@@ -868,7 +868,7 @@ void EMSESP::console_commands(Shell & shell, unsigned int context) {
uint8_t watch = emsesp::EMSESP::watch();
if (watch == WATCH_OFF) {
shell.printfln(F("Watch is off"));
shell.printfln(F("Watching telegrams is off"));
return;
}

View File

@@ -85,19 +85,38 @@ std::string Telegram::to_string() const {
if (message_length == 0) {
return read_flash_string(F("<empty>"));
}
std::string str(160, '\0');
char buffer[4];
char * p = &str[0];
for (uint8_t i = 0; i < this->message_length; i++) {
Helpers::hextoa(buffer, this->message_data[i]);
*p++ = buffer[0];
*p++ = buffer[1];
*p++ = ' '; // space
uint8_t data[EMS_MAX_TELEGRAM_LENGTH];
uint8_t length = 0;
data[0] = this->src ^ RxService::ems_mask();
if (this->operation == Telegram::Operation::TX_READ) {
data[1] = this->dest | 0x80;
data[4] = this->message_data[0];
if (this->type_id > 0xFF) {
data[2] = 0xFF;
data[5] = (this->type_id >> 8) - 1;
data[6] = this->type_id & 0xFF;
length = 7;
} else {
data[2] = this->type_id;
length = 5;
}
*--p = '\0'; // null terminate just in case, loosing the trailing space
return str;
}
if (this->operation == Telegram::Operation::TX_WRITE) {
data[1] = this->dest;
if (this->type_id > 0xFF) {
data[2] = 0xFF;
data[4] = (this->type_id >> 8) - 1;
data[5] = this->type_id & 0xFF;
length = 6;
} else {
data[2] = this->type_id;
length = 4;
}
for (uint8_t i = 0; i < this->message_length; i++) {
data[length++] = this->message_data[i];
}
}
return Helpers::data_to_hex(data, length);
}
// returns telegram's full telegram message in hex
@@ -538,7 +557,7 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
return;
}
LOG_DEBUG(F("[DEBUG] Last Tx %s operation failed. Retry #%d. sent message data: %s, received: %s"),
LOG_DEBUG(F("[DEBUG] Last Tx %s operation failed. Retry #%d. sent message: %s, received: %s"),
(operation == Telegram::Operation::TX_WRITE) ? F("Write") : F("Read"),
retry_count_,
telegram_last_->to_string().c_str(),

View File

@@ -60,7 +60,7 @@ void EMSuart::emsuart_recvTask(void * para) {
void IRAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) {
static uint8_t rxbuf[EMS_MAXBUFFERSIZE];
static uint8_t length;
UART_MUTEX_LOCK();
if (EMS_UART.int_st.rxfifo_full) {
EMS_UART.int_clr.rxfifo_full = 1;
emsTxBufIdx++;
@@ -93,7 +93,6 @@ void IRAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) {
xRingbufferSendFromISR(buf_handle, rxbuf, length - 1, &baseType);
}
drop_next_rx = false;
UART_MUTEX_UNLOCK();
}
}
@@ -102,17 +101,16 @@ void IRAM_ATTR EMSuart::emsuart_tx_timer_intr_handler() {
if (emsTxBufIdx > EMS_MAXBUFFERSIZE) {
return;
}
UART_MUTEX_LOCK();
emsTxBufIdx++;
if (emsTxBufIdx < emsTxBufLen) {
EMS_UART.fifo.rw_byte = emsTxBuf[emsTxBufIdx];
timerWrite(timer, 0);
timerAlarmWrite(timer, emsTxWait, false);
timerAlarmEnable(timer);
} else if (emsTxBufIdx == emsTxBufLen) {
EMS_UART.conf0.txd_brk = 1; // <brk> after send
}
UART_MUTEX_UNLOCK();
}
/*
@@ -126,7 +124,6 @@ void EMSuart::start(uint8_t tx_mode) {
return;
}
tx_mode_ = tx_mode;
UART_MUTEX_LOCK();
uart_config_t uart_config = {
.baud_rate = EMSUART_BAUD,
@@ -151,24 +148,20 @@ void EMSuart::start(uint8_t tx_mode) {
emsTxBufLen = 0;
timer = timerBegin(1, 80, true); // timer prescale to 1 µs, countup
timerAttachInterrupt(timer, &emsuart_tx_timer_intr_handler, true); // Timer with edge interrupt
UART_MUTEX_UNLOCK();
}
/*
* Stop, disables interrupt
*/
void EMSuart::stop() {
UART_MUTEX_LOCK();
EMS_UART.int_ena.val = 0; // disable all intr.
// timerAlarmDisable(timer);
UART_MUTEX_UNLOCK();
};
/*
* Restart Interrupt
*/
void EMSuart::restart() {
UART_MUTEX_LOCK();
if (EMS_UART.int_raw.brk_det) {
EMS_UART.int_clr.brk_det = 1; // clear flag
drop_next_rx = true; // and drop first frame
@@ -176,7 +169,6 @@ void EMSuart::restart() {
EMS_UART.int_ena.brk_det = 1; // activate only break
emsTxBufIdx = 0;
emsTxBufLen = 0;
UART_MUTEX_UNLOCK();
}
/*
@@ -184,12 +176,10 @@ void EMSuart::restart() {
*/
void EMSuart::send_poll(uint8_t data) {
// if (tx_mode_ >= 6 || tx_mode_ < 4) { // modes 1, 2, 3 also here
UART_MUTEX_LOCK();
if (tx_mode_ >= 5) {
EMS_UART.fifo.rw_byte = data;
emsTxBufIdx = 0;
emsTxBufLen = 1;
timerWrite(timer, 0);
timerAlarmWrite(timer, emsTxWait, false);
timerAlarmEnable(timer);
} else if (tx_mode_ == 5) {
@@ -222,7 +212,6 @@ void EMSuart::send_poll(uint8_t data) {
}
EMS_UART.conf0.txd_brk = 1; // <brk>
}
UART_MUTEX_UNLOCK();
}
/*
@@ -234,7 +223,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
if (len == 0 || len >= EMS_MAXBUFFERSIZE) {
return EMS_TX_STATUS_ERR;
}
UART_MUTEX_LOCK();
// if (tx_mode_ >= 6 || tx_mode_ < 4) { // timer controlled modes, also modes 1, 2, 3 because delays not working
if (tx_mode_ >= 5) { // timer controlled modes
@@ -244,10 +232,8 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.fifo.rw_byte = buf[0];
emsTxBufIdx = 0;
emsTxBufLen = len;
timerWrite(timer, 0);
timerAlarmWrite(timer, emsTxWait, false);
timerAlarmEnable(timer);
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK;
}
@@ -260,7 +246,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
emsTxBufLen = len;
EMS_UART.conf1.rxfifo_full_thrhd = 1;
EMS_UART.int_ena.rxfifo_full = 1;
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK;
}
@@ -269,7 +254,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.fifo.rw_byte = buf[i];
}
EMS_UART.conf0.txd_brk = 1; // <brk> after send
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK;
}
@@ -281,7 +265,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send
// delayMicroseconds(EMSUART_TX_WAIT_BRK);
// EMS_UART.conf0.txd_brk = 0;
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK;
}
@@ -293,7 +276,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send
// delayMicroseconds(EMSUART_TX_WAIT_BRK);
// EMS_UART.conf0.txd_brk = 0;
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK;
}
@@ -312,7 +294,6 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
EMS_UART.conf0.txd_brk = 1; // <brk> after send, cleard by hardware after send
// delayMicroseconds(EMSUART_TX_WAIT_BRK);
// EMS_UART.conf0.txd_brk = 0;
UART_MUTEX_UNLOCK();
return EMS_TX_STATUS_OK;
}