mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-15 06:12:11 +08:00
UI: reducing CPU usage from 13% to 4% when offroad (#19575)
* Accurately control the UI frequency * helper function sleep_for old-commit-hash: a4afc03a732ab6438a72bda22911bf4532e9e4cd
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
namespace util {
|
||||
|
||||
@@ -69,7 +71,9 @@ inline std::string getenv_default(const char* env_var, const char * suffix, cons
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void sleep_for(const int milliseconds) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
||||
}
|
||||
}
|
||||
|
||||
struct unique_fd {
|
||||
|
||||
@@ -148,7 +148,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
while (!do_exit) {
|
||||
if (!s->started) {
|
||||
usleep(50 * 1000);
|
||||
util::sleep_for(50);
|
||||
}
|
||||
double u1 = millis_since_boot();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user