mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 18:12:05 +08:00
remove read_param_timeout (#2095)
* remove read_param_timeout * missed that old-commit-hash: 9cd5180b43e03f84adb870fa25c91428a18394e0
This commit is contained in:
@@ -308,9 +308,11 @@ int main(int argc, char* argv[]) {
|
||||
ui_draw_vision_alert(s, s->scene.alert_size, s->status, s->scene.alert_text1.c_str(), s->scene.alert_text2.c_str());
|
||||
}
|
||||
|
||||
read_param_timeout(&s->is_metric, "IsMetric", &s->is_metric_timeout);
|
||||
int param_read = read_param_timeout(&s->last_athena_ping, "LastAthenaPingTime", &s->last_athena_ping_timeout);
|
||||
if (param_read != -1) { // Param was updated this loop
|
||||
|
||||
if (s->sm->frame % (2*UI_FREQ) == 0) {
|
||||
read_param(&s->is_metric, "IsMetric");
|
||||
} else if (s->sm->frame % (3*UI_FREQ) == 0) {
|
||||
int param_read = read_param(&s->last_athena_ping, "LastAthenaPingTime");
|
||||
if (param_read != 0) { // Failed to read param
|
||||
s->scene.athenaStatus = NET_DISCONNECTED;
|
||||
} else if (nanos_since_boot() - s->last_athena_ping < 70e9) {
|
||||
|
||||
@@ -68,7 +68,6 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
|
||||
|
||||
read_param(&s->is_metric, "IsMetric");
|
||||
read_param(&s->longitudinal_control, "LongitudinalControl");
|
||||
s->is_metric_timeout = UI_FREQ;
|
||||
}
|
||||
|
||||
void update_status(UIState *s, int status) {
|
||||
|
||||
@@ -211,11 +211,7 @@ typedef struct UIState {
|
||||
UIScene scene;
|
||||
bool awake;
|
||||
|
||||
// timeouts
|
||||
int awake_timeout;
|
||||
int is_metric_timeout;
|
||||
int last_athena_ping_timeout;
|
||||
|
||||
bool controls_seen;
|
||||
|
||||
uint64_t last_athena_ping;
|
||||
@@ -276,15 +272,3 @@ int read_param(T* param, const char *param_name, bool persistent_param = false){
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int read_param_timeout(T* param, const char* param_name, int* timeout, bool persistent_param = false) {
|
||||
int result = -1;
|
||||
if (*timeout > 0){
|
||||
(*timeout)--;
|
||||
} else {
|
||||
*timeout = 2 * UI_FREQ; // 0.5Hz
|
||||
result = read_param(param, param_name, persistent_param);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user