Skip to content

Commit 9044e93

Browse files
authored
Use ONOFF define (syssi#523)
1 parent 0c994c7 commit 9044e93

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

components/jk_bms_ble/jk_bms_ble.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ void JkBmsBle::decode_jk02_cell_info_(const std::vector<uint8_t> &data) {
576576

577577
if (frame_version == FRAME_VERSION_JK02_32S) {
578578
uint16_t raw_emergency_time_countdown = jk_get_16bit(186 + offset);
579-
ESP_LOGI(TAG, " Emergency switch: %s", (raw_emergency_time_countdown > 0) ? "on" : "off");
579+
ESP_LOGI(TAG, " Emergency switch: %s", ONOFF(raw_emergency_time_countdown > 0));
580580
this->publish_state_(this->emergency_switch_, raw_emergency_time_countdown > 0);
581581
this->publish_state_(this->emergency_time_countdown_sensor_, (float) raw_emergency_time_countdown * 1.0f);
582582

@@ -891,15 +891,15 @@ void JkBmsBle::decode_jk02_settings_(const std::vector<uint8_t> &data) {
891891
this->publish_state_(this->cell_count_number_, (float) data[114]);
892892

893893
// 118 4 0x01 0x00 0x00 0x00 Charge switch
894-
ESP_LOGI(TAG, " Charge switch: %s", ((bool) data[118]) ? "on" : "off");
894+
ESP_LOGI(TAG, " Charge switch: %s", ONOFF((bool) data[118]));
895895
this->publish_state_(this->charging_switch_, (bool) data[118]);
896896

897897
// 122 4 0x01 0x00 0x00 0x00 Discharge switch
898-
ESP_LOGI(TAG, " Discharge switch: %s", ((bool) data[122]) ? "on" : "off");
898+
ESP_LOGI(TAG, " Discharge switch: %s", ONOFF((bool) data[122]));
899899
this->publish_state_(this->discharging_switch_, (bool) data[122]);
900900

901901
// 126 4 0x01 0x00 0x00 0x00 Balancer switch
902-
ESP_LOGI(TAG, " Balancer switch: %s", ((bool) data[126]) ? "on" : "off");
902+
ESP_LOGI(TAG, " Balancer switch: %s", ONOFF((bool) data[126]));
903903
this->publish_state_(this->balancer_switch_, (bool) (data[126]));
904904

905905
// 130 4 0x88 0x13 0x00 0x00 Nominal battery capacity
@@ -969,7 +969,7 @@ void JkBmsBle::decode_jk02_settings_(const std::vector<uint8_t> &data) {
969969
// bit6: SMART_SLEEP_ON_SWITCH_ENABLED 64
970970
// bit7: DISABLE_PCL_MODULE_SWITCH_ENABLED 128
971971
this->publish_state_(this->heating_switch_, check_bit_(data[282], 1));
972-
ESP_LOGI(TAG, " Heating switch: %s", ((bool) check_bit_(data[282], 1)) ? "on" : "off");
972+
ESP_LOGI(TAG, " Heating switch: %s", ONOFF(check_bit_(data[282], 1)));
973973
this->publish_state_(this->disable_temperature_sensors_switch_, check_bit_(data[282], 2));
974974
ESP_LOGI(TAG, " Port switch: %s", check_bit_(data[282], 8) ? "RS485" : "CAN");
975975
this->publish_state_(this->display_always_on_switch_, check_bit_(data[282], 16));
@@ -988,12 +988,12 @@ void JkBmsBle::decode_jk02_settings_(const std::vector<uint8_t> &data) {
988988
// bit7: ? 128
989989
this->publish_state_(this->timed_stored_data_switch_, (bool) this->check_bit_(data[283], 1));
990990
this->publish_state_(this->charging_float_mode_switch_, (bool) this->check_bit_(data[283], 2));
991-
ESP_LOGI(TAG, " Switch bit2: %s", (this->check_bit_(data[283], 4)) ? "on" : "off");
992-
ESP_LOGI(TAG, " Switch bit3: %s", (this->check_bit_(data[283], 8)) ? "on" : "off");
993-
ESP_LOGI(TAG, " Switch bit4: %s", (this->check_bit_(data[283], 16)) ? "on" : "off");
994-
ESP_LOGI(TAG, " Switch bit5: %s", (this->check_bit_(data[283], 32)) ? "on" : "off");
995-
ESP_LOGI(TAG, " Switch bit6: %s", (this->check_bit_(data[283], 64)) ? "on" : "off");
996-
ESP_LOGI(TAG, " Switch bit7: %s", (this->check_bit_(data[283], 128)) ? "on" : "off");
991+
ESP_LOGI(TAG, " Switch bit2: %s", ONOFF(check_bit_(data[283], 4)));
992+
ESP_LOGI(TAG, " Switch bit3: %s", ONOFF(check_bit_(data[283], 8)));
993+
ESP_LOGI(TAG, " Switch bit4: %s", ONOFF(check_bit_(data[283], 16)));
994+
ESP_LOGI(TAG, " Switch bit5: %s", ONOFF(check_bit_(data[283], 32)));
995+
ESP_LOGI(TAG, " Switch bit6: %s", ONOFF(check_bit_(data[283], 64)));
996+
ESP_LOGI(TAG, " Switch bit7: %s", ONOFF(check_bit_(data[283], 128)));
997997
// 283 3 0x00 0x00 0x00
998998
// 286 4 0x00 0x00 0x00 0x00
999999
// 290 4 0x00 0x00 0x00 0x00

0 commit comments

Comments
 (0)