This commit is contained in:
机械小鸽 2025-03-03 19:40:48 +08:00 committed by GitHub
parent c523c80cfb
commit 9049547097
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2208,8 +2208,10 @@ public:
dx = bx + 220; dx = bx + 220;
dy = by + 77; dy = by + 77;
// 获取carState数据
auto carState = sm["carState"].getCarState();
// 显示巡航设定速度km/h // 显示巡航设定速度km/h
auto carState = sm["carState"].getCarState(); // 重新获取carState
float setSpeed = carState.getCruiseState().getSpeed() * 3.6; // 转换为 km/h float setSpeed = carState.getCruiseState().getSpeed() * 3.6; // 转换为 km/h
sprintf(gap_str, "%.0f", setSpeed); sprintf(gap_str, "%.0f", setSpeed);
ui_draw_text(s, dx, dy, gap_str, 40, COLOR_WHITE, BOLD); ui_draw_text(s, dx, dy, gap_str, 40, COLOR_WHITE, BOLD);
@ -2230,15 +2232,15 @@ public:
char gear_str[32] = "R"; char gear_str[32] = "R";
dx = bx + 305; dx = bx + 305;
dy = by + 60; dy = by + 60;
//const SubMaster& sm = *(s->sm);
auto carState = sm["carState"].getCarState(); // 使用之前获取的carState
if (carState.getGearShifter() == cereal::CarState::GearShifter::UNKNOWN) strcpy(gear_str, "U"); if (carState.getGearShifter() == cereal::CarState::GearShifter::UNKNOWN) strcpy(gear_str, "U");
else if (carState.getGearShifter() == cereal::CarState::GearShifter::PARK) strcpy(gear_str, "P"); else if (carState.getGearShifter() == cereal::CarState::GearShifter::PARK) strcpy(gear_str, "P");
else if (carState.getGearShifter() == cereal::CarState::GearShifter::DRIVE) { else if (carState.getGearShifter() == cereal::CarState::GearShifter::DRIVE) {
if (carState.getGearStep() > 0) if (carState.getGearStep() > 0)
sprintf(gear_str, "%d", carState.getGearStep()); sprintf(gear_str, "%d", carState.getGearStep());
else else
strcpy(gear_str, "D"); strcpy(gear_str, "D");
} }
else if(carState.getGearShifter() == cereal::CarState::GearShifter::NEUTRAL) strcpy(gear_str, "N"); else if(carState.getGearShifter() == cereal::CarState::GearShifter::NEUTRAL) strcpy(gear_str, "N");
else if (carState.getGearShifter() == cereal::CarState::GearShifter::REVERSE) strcpy(gear_str, "R"); else if (carState.getGearShifter() == cereal::CarState::GearShifter::REVERSE) strcpy(gear_str, "R");