Skip to content

Commit 778ff17

Browse files
Gold856samfreund
authored andcommitted
Optimize UI CPU usage (PhotonVision#2168)
1 parent eeda508 commit 778ff17

File tree

5 files changed

+8
-19
lines changed

5 files changed

+8
-19
lines changed

photon-client/src/components/app/photon-sidebar.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ const renderCompact = computed<boolean>(() => compact.value || !mdAndUp.value);
2525
<template>
2626
<v-navigation-drawer permanent :rail="renderCompact" color="sidebar">
2727
<v-list nav color="primary">
28-
<!-- List item for the heading; note that there are some tricks in setting padding and image width make things look right -->
29-
<v-list-item :class="renderCompact ? 'pr-0 pl-0' : ''" style="display: flex; justify-content: center">
28+
<v-list-item class="pr-0 pl-0" style="display: flex; justify-content: center">
3029
<template #prepend>
3130
<img v-if="!renderCompact" class="logo" src="@/assets/images/logoLarge.svg" alt="large logo" />
3231
<img v-else class="logo" src="@/assets/images/logoSmallTransparent.svg" alt="small logo" />

photon-client/src/stores/settings/CameraSettingsStore.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ export const useCameraSettingsStore = defineStore("cameraSettings", {
2727
}),
2828
getters: {
2929
needsCameraConfiguration(): boolean {
30-
return (
31-
JSON.stringify(useCameraSettingsStore().cameras[PlaceholderCameraSettings.uniqueName]) ===
32-
JSON.stringify(PlaceholderCameraSettings)
33-
);
30+
return useCameraSettingsStore().cameras["Placeholder Name"] === PlaceholderCameraSettings;
3431
},
3532
// TODO update types to update this value being undefined. This would be a decently large change.
3633
currentCameraSettings(): UiCameraConfiguration {

photon-client/src/types/SettingTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export interface CameraSettingsChangeRequest {
274274
quirksToChange: Record<ValidQuirks, boolean>;
275275
}
276276

277-
export const PlaceholderCameraSettings: UiCameraConfiguration = {
277+
export const PlaceholderCameraSettings: UiCameraConfiguration = Object.freeze({
278278
cameraPath: "/dev/null",
279279

280280
nickname: "Placeholder Camera",
@@ -391,7 +391,7 @@ export const PlaceholderCameraSettings: UiCameraConfiguration = {
391391
isConnected: true,
392392
hasConnected: true,
393393
mismatch: false
394-
};
394+
});
395395

396396
export enum CalibrationBoardTypes {
397397
Chessboard = 0,

photon-client/src/views/CameraMatchingView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const unmatchedCameras = computed(() => {
8787
const activeVisionModules = computed(() =>
8888
Object.values(useCameraSettingsStore().cameras)
8989
// Ignore placeholder camera
90-
.filter((camera) => JSON.stringify(camera) !== JSON.stringify(PlaceholderCameraSettings))
90+
.filter((camera) => camera !== PlaceholderCameraSettings)
9191
// Display connected cameras first
9292
.sort(
9393
(first, second) =>

photon-client/src/views/DashboardView.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ const cameraMismatchWarningShown = computed<boolean>(() => {
6464
return (
6565
Object.values(useCameraSettingsStore().cameras)
6666
// Ignore placeholder camera
67-
.filter((camera) => JSON.stringify(camera) !== JSON.stringify(PlaceholderCameraSettings))
68-
.some((camera) => {
69-
return camera.mismatch;
70-
})
67+
.filter((camera) => camera !== PlaceholderCameraSettings)
68+
.some((camera) => camera.mismatch)
7169
);
7270
});
7371
@@ -148,12 +146,7 @@ const showCameraSetupDialog = ref(useCameraSettingsStore().needsCameraConfigurat
148146
<PipelineConfigCard />
149147

150148
<!-- TODO - not sure this belongs here -->
151-
<v-dialog
152-
v-if="useCameraSettingsStore().needsCameraConfiguration"
153-
v-model="showCameraSetupDialog"
154-
max-width="800"
155-
dark
156-
>
149+
<v-dialog v-model="showCameraSetupDialog" max-width="800" dark>
157150
<v-card flat color="surface">
158151
<v-card-title>Set up some cameras to get started!</v-card-title>
159152
<v-card-text class="pt-0">

0 commit comments

Comments
 (0)