mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
cabana: stable FPS (#26120)
* stable FPS * fix old-commit-hash: 686506f4003964e230550e100d6a841c2ff5d3ac
This commit is contained in:
@@ -87,7 +87,7 @@ void CANMessages::process(QHash<QString, std::deque<CanData>> *messages) {
|
||||
}
|
||||
|
||||
bool CANMessages::eventFilter(const Event *event) {
|
||||
static double prev_update_sec = 0;
|
||||
static double prev_update_ts = 0;
|
||||
// drop packets when the GUI thread is calling seekTo. to make sure the current_sec is accurate.
|
||||
if (!seeking && event->which == cereal::Event::Which::CAN) {
|
||||
if (!received_msgs) {
|
||||
@@ -121,8 +121,9 @@ bool CANMessages::eventFilter(const Event *event) {
|
||||
}
|
||||
}
|
||||
|
||||
if (current_sec < prev_update_sec || (current_sec - prev_update_sec) > 1.0 / settings.fps) {
|
||||
prev_update_sec = current_sec;
|
||||
double ts = millis_since_boot();
|
||||
if ((ts - prev_update_ts) > (1000.0 / settings.fps)) {
|
||||
prev_update_ts = ts;
|
||||
// use pointer to avoid data copy in queued connection.
|
||||
emit received(received_msgs.release());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user