Speed/Config and VFD added
This commit is contained in:
@@ -20,6 +20,8 @@ substitutions:
|
|||||||
gauge0_max_steps: "4000"
|
gauge0_max_steps: "4000"
|
||||||
gauge0_unit: W
|
gauge0_unit: W
|
||||||
gauge0_step: "1.0"
|
gauge0_step: "1.0"
|
||||||
|
gauge0_speed_step: "100"
|
||||||
|
gauge0_accel_step: "100"
|
||||||
gauge0_default_speed: "5000"
|
gauge0_default_speed: "5000"
|
||||||
gauge0_default_accel: "6000"
|
gauge0_default_accel: "6000"
|
||||||
|
|
||||||
@@ -30,6 +32,8 @@ substitutions:
|
|||||||
gauge1_max_steps: "4000"
|
gauge1_max_steps: "4000"
|
||||||
gauge1_unit: W
|
gauge1_unit: W
|
||||||
gauge1_step: "1.0"
|
gauge1_step: "1.0"
|
||||||
|
gauge1_speed_step: "100"
|
||||||
|
gauge1_accel_step: "100"
|
||||||
gauge1_default_speed: "5000"
|
gauge1_default_speed: "5000"
|
||||||
gauge1_default_accel: "6000"
|
gauge1_default_accel: "6000"
|
||||||
|
|
||||||
@@ -134,6 +138,42 @@ sensor:
|
|||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
update_interval: 5s
|
update_interval: 5s
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "${gauge0_entity_name} Speed"
|
||||||
|
lambda: |-
|
||||||
|
return id(gauge0_speed_value);
|
||||||
|
unit_of_measurement: "steps/s"
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: 5s
|
||||||
|
entity_category: config
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "${gauge0_entity_name} Acceleration"
|
||||||
|
lambda: |-
|
||||||
|
return id(gauge0_accel_value);
|
||||||
|
unit_of_measurement: "steps/s^2"
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: 5s
|
||||||
|
entity_category: config
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "${gauge1_entity_name} Speed"
|
||||||
|
lambda: |-
|
||||||
|
return id(gauge1_speed_value);
|
||||||
|
unit_of_measurement: "steps/s"
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: 5s
|
||||||
|
entity_category: config
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "${gauge1_entity_name} Acceleration"
|
||||||
|
lambda: |-
|
||||||
|
return id(gauge1_accel_value);
|
||||||
|
unit_of_measurement: "steps/s^2"
|
||||||
|
accuracy_decimals: 0
|
||||||
|
update_interval: 5s
|
||||||
|
entity_category: config
|
||||||
|
|
||||||
text_sensor:
|
text_sensor:
|
||||||
- platform: wifi_info
|
- platform: wifi_info
|
||||||
ip_address:
|
ip_address:
|
||||||
@@ -202,11 +242,228 @@ number:
|
|||||||
snprintf(cmd, sizeof(cmd), "SET 1 %d\n", steps);
|
snprintf(cmd, sizeof(cmd), "SET 1 %d\n", steps);
|
||||||
id(arduino_uart).write_str(cmd);
|
id(arduino_uart).write_str(cmd);
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: gauge0_speed_number
|
||||||
|
name: "${gauge0_entity_name} Speed"
|
||||||
|
entity_category: config
|
||||||
|
unit_of_measurement: "steps/s"
|
||||||
|
min_value: 1
|
||||||
|
max_value: 20000
|
||||||
|
step: ${gauge0_speed_step}
|
||||||
|
mode: box
|
||||||
|
optimistic: true
|
||||||
|
restore_value: false
|
||||||
|
initial_value: ${gauge0_default_speed}
|
||||||
|
set_action:
|
||||||
|
- lambda: |-
|
||||||
|
const int clamped = std::max(1, static_cast<int>(lroundf(x)));
|
||||||
|
id(gauge0_speed_value) = clamped;
|
||||||
|
char cmd[24];
|
||||||
|
snprintf(cmd, sizeof(cmd), "SPEED 0 %d\n", clamped);
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: gauge0_accel_number
|
||||||
|
name: "${gauge0_entity_name} Acceleration"
|
||||||
|
entity_category: config
|
||||||
|
unit_of_measurement: "steps/s^2"
|
||||||
|
min_value: 1
|
||||||
|
max_value: 50000
|
||||||
|
step: ${gauge0_accel_step}
|
||||||
|
mode: box
|
||||||
|
optimistic: true
|
||||||
|
restore_value: false
|
||||||
|
initial_value: ${gauge0_default_accel}
|
||||||
|
set_action:
|
||||||
|
- lambda: |-
|
||||||
|
const int clamped = std::max(1, static_cast<int>(lroundf(x)));
|
||||||
|
id(gauge0_accel_value) = clamped;
|
||||||
|
char cmd[24];
|
||||||
|
snprintf(cmd, sizeof(cmd), "ACCEL 0 %d\n", clamped);
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: gauge1_speed_number
|
||||||
|
name: "${gauge1_entity_name} Speed"
|
||||||
|
entity_category: config
|
||||||
|
unit_of_measurement: "steps/s"
|
||||||
|
min_value: 1
|
||||||
|
max_value: 20000
|
||||||
|
step: ${gauge1_speed_step}
|
||||||
|
mode: box
|
||||||
|
optimistic: true
|
||||||
|
restore_value: false
|
||||||
|
initial_value: ${gauge1_default_speed}
|
||||||
|
set_action:
|
||||||
|
- lambda: |-
|
||||||
|
const int clamped = std::max(1, static_cast<int>(lroundf(x)));
|
||||||
|
id(gauge1_speed_value) = clamped;
|
||||||
|
char cmd[24];
|
||||||
|
snprintf(cmd, sizeof(cmd), "SPEED 1 %d\n", clamped);
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: gauge1_accel_number
|
||||||
|
name: "${gauge1_entity_name} Acceleration"
|
||||||
|
entity_category: config
|
||||||
|
unit_of_measurement: "steps/s^2"
|
||||||
|
min_value: 1
|
||||||
|
max_value: 50000
|
||||||
|
step: ${gauge1_accel_step}
|
||||||
|
mode: box
|
||||||
|
optimistic: true
|
||||||
|
restore_value: false
|
||||||
|
initial_value: ${gauge1_default_accel}
|
||||||
|
set_action:
|
||||||
|
- lambda: |-
|
||||||
|
const int clamped = std::max(1, static_cast<int>(lroundf(x)));
|
||||||
|
id(gauge1_accel_value) = clamped;
|
||||||
|
char cmd[24];
|
||||||
|
snprintf(cmd, sizeof(cmd), "ACCEL 1 %d\n", clamped);
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# VFD controls
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
text:
|
||||||
|
- platform: template
|
||||||
|
id: vfd_display
|
||||||
|
name: VFD Display
|
||||||
|
mode: text
|
||||||
|
optimistic: true
|
||||||
|
restore_value: false
|
||||||
|
min_length: 0
|
||||||
|
max_length: 4
|
||||||
|
initial_value: ""
|
||||||
|
set_action:
|
||||||
|
- lambda: |-
|
||||||
|
std::string sanitized;
|
||||||
|
sanitized.reserve(4);
|
||||||
|
for (char c : x) {
|
||||||
|
const char uc = static_cast<char>(toupper(static_cast<unsigned char>(c)));
|
||||||
|
if ((uc >= '0' && uc <= '9') || (uc >= 'A' && uc <= 'F') || uc == '-') {
|
||||||
|
sanitized.push_back(uc);
|
||||||
|
if (sanitized.size() >= 4) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
id(vfd_text_value) = sanitized;
|
||||||
|
|
||||||
|
std::string cmd = "VFD";
|
||||||
|
std::string suffix;
|
||||||
|
if (id(vfd_decimal_point_on)) {
|
||||||
|
suffix += ".";
|
||||||
|
}
|
||||||
|
if (id(vfd_alarm_on)) {
|
||||||
|
suffix += "!";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sanitized.empty()) {
|
||||||
|
cmd += " " + sanitized + suffix;
|
||||||
|
} else if (!suffix.empty()) {
|
||||||
|
cmd += " 0" + suffix;
|
||||||
|
}
|
||||||
|
cmd += "\n";
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: template
|
||||||
|
id: vfd_decimal_point
|
||||||
|
name: VFD Decimal Point
|
||||||
|
optimistic: true
|
||||||
|
restore_mode: ALWAYS_OFF
|
||||||
|
lambda: |-
|
||||||
|
return id(vfd_decimal_point_on);
|
||||||
|
turn_on_action:
|
||||||
|
- lambda: |-
|
||||||
|
id(vfd_decimal_point_on) = true;
|
||||||
|
std::string cmd = "VFD";
|
||||||
|
std::string suffix = ".";
|
||||||
|
if (id(vfd_alarm_on)) {
|
||||||
|
suffix += "!";
|
||||||
|
}
|
||||||
|
if (!id(vfd_text_value).empty()) {
|
||||||
|
cmd += " " + id(vfd_text_value) + suffix;
|
||||||
|
} else {
|
||||||
|
cmd += " 0" + suffix;
|
||||||
|
}
|
||||||
|
cmd += "\n";
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
turn_off_action:
|
||||||
|
- lambda: |-
|
||||||
|
id(vfd_decimal_point_on) = false;
|
||||||
|
std::string cmd = "VFD";
|
||||||
|
std::string suffix;
|
||||||
|
if (id(vfd_alarm_on)) {
|
||||||
|
suffix += "!";
|
||||||
|
}
|
||||||
|
if (!id(vfd_text_value).empty()) {
|
||||||
|
cmd += " " + id(vfd_text_value) + suffix;
|
||||||
|
} else if (!suffix.empty()) {
|
||||||
|
cmd += " 0" + suffix;
|
||||||
|
}
|
||||||
|
cmd += "\n";
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: vfd_alarm
|
||||||
|
name: VFD Alarm
|
||||||
|
optimistic: true
|
||||||
|
restore_mode: ALWAYS_OFF
|
||||||
|
lambda: |-
|
||||||
|
return id(vfd_alarm_on);
|
||||||
|
turn_on_action:
|
||||||
|
- lambda: |-
|
||||||
|
id(vfd_alarm_on) = true;
|
||||||
|
std::string cmd = "VFD";
|
||||||
|
std::string suffix;
|
||||||
|
if (id(vfd_decimal_point_on)) {
|
||||||
|
suffix += ".";
|
||||||
|
}
|
||||||
|
suffix += "!";
|
||||||
|
if (!id(vfd_text_value).empty()) {
|
||||||
|
cmd += " " + id(vfd_text_value) + suffix;
|
||||||
|
} else {
|
||||||
|
cmd += " 0" + suffix;
|
||||||
|
}
|
||||||
|
cmd += "\n";
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
turn_off_action:
|
||||||
|
- lambda: |-
|
||||||
|
id(vfd_alarm_on) = false;
|
||||||
|
std::string cmd = "VFD";
|
||||||
|
std::string suffix;
|
||||||
|
if (id(vfd_decimal_point_on)) {
|
||||||
|
suffix += ".";
|
||||||
|
}
|
||||||
|
if (!id(vfd_text_value).empty()) {
|
||||||
|
cmd += " " + id(vfd_text_value) + suffix;
|
||||||
|
} else if (!suffix.empty()) {
|
||||||
|
cmd += " 0" + suffix;
|
||||||
|
}
|
||||||
|
cmd += "\n";
|
||||||
|
id(arduino_uart).write_str(cmd);
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Gauge light state cache
|
# Gauge light state cache
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
|
- id: vfd_text_value
|
||||||
|
type: std::string
|
||||||
|
restore_value: no
|
||||||
|
initial_value: '""'
|
||||||
|
- id: vfd_decimal_point_on
|
||||||
|
type: bool
|
||||||
|
restore_value: no
|
||||||
|
initial_value: "false"
|
||||||
|
- id: vfd_alarm_on
|
||||||
|
type: bool
|
||||||
|
restore_value: no
|
||||||
|
initial_value: "false"
|
||||||
- id: gauge0_target_value
|
- id: gauge0_target_value
|
||||||
type: float
|
type: float
|
||||||
restore_value: no
|
restore_value: no
|
||||||
@@ -215,6 +472,22 @@ globals:
|
|||||||
type: float
|
type: float
|
||||||
restore_value: no
|
restore_value: no
|
||||||
initial_value: ${gauge1_min}
|
initial_value: ${gauge1_min}
|
||||||
|
- id: gauge0_speed_value
|
||||||
|
type: float
|
||||||
|
restore_value: no
|
||||||
|
initial_value: ${gauge0_default_speed}
|
||||||
|
- id: gauge0_accel_value
|
||||||
|
type: float
|
||||||
|
restore_value: no
|
||||||
|
initial_value: ${gauge0_default_accel}
|
||||||
|
- id: gauge1_speed_value
|
||||||
|
type: float
|
||||||
|
restore_value: no
|
||||||
|
initial_value: ${gauge1_default_speed}
|
||||||
|
- id: gauge1_accel_value
|
||||||
|
type: float
|
||||||
|
restore_value: no
|
||||||
|
initial_value: ${gauge1_default_accel}
|
||||||
- id: gauge0_bl_r
|
- id: gauge0_bl_r
|
||||||
type: int
|
type: int
|
||||||
restore_value: no
|
restore_value: no
|
||||||
|
|||||||
Reference in New Issue
Block a user