Implement PID and telemetry
This commit is contained in:
@@ -13,19 +13,28 @@ static const char *TAG = "spincoat-plater-firmware/ui";
|
||||
|
||||
static lv_obj_t * rpm_label = NULL;
|
||||
|
||||
/**
|
||||
* Callback for pressing the top button
|
||||
*/
|
||||
void top_cb(lv_event_t * e) {
|
||||
update_throttle(get_throttle() + BTN_INCREMENT);
|
||||
lv_label_set_text_fmt(rpm_label, "RPM: %d", get_throttle());
|
||||
//lv_label_set_text_fmt(rpm_label, "RPM: %d", get_throttle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for pressing the bottom button
|
||||
*/
|
||||
void bottom_cb(lv_event_t * e) {
|
||||
uint16_t throttle = get_throttle();
|
||||
if(throttle >= BTN_INCREMENT) {
|
||||
update_throttle(get_throttle() - BTN_INCREMENT);
|
||||
lv_label_set_text_fmt(rpm_label, "RPM: %d", get_throttle());
|
||||
//lv_label_set_text_fmt(rpm_label, "RPM: %d", get_throttle());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory function that creates a "numberstack" widget and returns the label for it
|
||||
*/
|
||||
void build_numberstack(lv_obj_t * parent,
|
||||
const char * label_text,
|
||||
lv_obj_t ** label_value,
|
||||
@@ -90,9 +99,14 @@ void build_numberstack(lv_obj_t * parent,
|
||||
lv_obj_center(lbl_bottom);
|
||||
}
|
||||
|
||||
void update_rpm_readout(uint16_t rpm) {
|
||||
if(rpm_label != NULL) {
|
||||
lv_label_set_text_fmt(rpm_label, "RPM: %d", rpm);
|
||||
}
|
||||
};
|
||||
|
||||
void build_ui(void) {
|
||||
rpm_label = NULL;
|
||||
build_numberstack(lv_screen_active(), "RPM", &rpm_label, top_cb, bottom_cb);
|
||||
lv_label_set_text_fmt(rpm_label, "RPM: %d", get_throttle());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user