added command for setting specific height

This commit is contained in:
Rocka84
2024-06-01 14:00:53 +02:00
parent 31d70b3746
commit c10ab706a3
3 changed files with 21 additions and 9 deletions

View File

@@ -127,7 +127,7 @@ position4 | 4th stored height
### Available buttons and methods
button | lambda method | description
-----------|--------------------------------|---------------------------
-----------|-----------------------------------|---------------------------
raise | `id(my_desk).raise()` | raise desk by one step (~14mm)
lower | `id(my_desk).raise()` | lower desk by one step (~14mm)
stop | `id(my_desk).stop()` | stop movement of desk
@@ -135,6 +135,7 @@ position1 | `id(my_desk).goto_position(1)` | move to 1st stored height
position2 | `id(my_desk).goto_position(2)` | move to 2nd stored height
position3 | `id(my_desk).goto_position(3)` | move to 3rd stored height
position4 | `id(my_desk).goto_position(4)` | move to 4th stored height
[n/a] | `id(my_desk).goto_height(height)` | move to specified height
## Case

View File

@@ -167,6 +167,16 @@ namespace esphome {
}
}
void JiecangDeskController::goto_height(float height) {
unsigned char cmd = 0x01B;
unsigned char high_byte = ((int) height * 10) >> 8;
unsigned char low_byte = ((int) height * 10) & 0xFF;
unsigned char checksum = cmd + 2 + high_byte + low_byte;
write_array({ 0xF1, 0xF1, cmd, 0x02, high_byte, low_byte, checksum, 0x7E });
}
void JiecangDeskController::request_physical_limits() {
send_simple_command(0x0C);
}

View File

@@ -51,6 +51,7 @@ namespace esphome {
void lower();
void stop();
void goto_position(int pos);
void goto_height(float height);
void request_physical_limits();
void request_limits();