Skip to content

Commit

Permalink
made acu colors better
Browse files Browse the repository at this point in the history
  • Loading branch information
BK1031 committed Jun 15, 2024
1 parent c8a75b4 commit 263d4a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 36 deletions.
26 changes: 8 additions & 18 deletions dashboard/src/pages/gr24/acu/widgets/CellLiveWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,10 @@ function CellLiveWidget() {
}}
>
<div
className={`absolute ${getVoltageBackgroundColor(data.voltage)} bottom-0 opacity-25`}
style={{
position: "absolute",
bottom: 0,
width: 125,
height: `${(data.voltage / maxVoltage) * 100}%`,
backgroundColor: getVoltageBackgroundColor(data.voltage),
// backgroundColor: getVoltageBackgroundColor(maxVoltage),
transition: "height 0.3s ease",
zIndex: 0,
}}
Expand All @@ -85,20 +82,13 @@ function CellLiveWidget() {

const getVoltageBackgroundColor = (voltage) => {
const fraction = voltage / maxVoltage;
const brightnessFactor = 0.25;
const red = Math.min(
255,
Math.max(0, Math.floor((1 - fraction) * 255 * brightnessFactor)),
);
const green = Math.min(
255,
Math.max(0, Math.floor(fraction * 255 * brightnessFactor)),
);
return `rgb(${red}, ${green}, 0)`;
};

const getVoltageColor = (voltage: number) => {
return "text-white";
if (fraction < 0.2) {
return "bg-red-400";
} else if (fraction < 0.4) {
return "bg-yellow-400";
} else {
return "bg-green-400";
}
};

const getTempColor = (temp: number) => {
Expand Down
26 changes: 8 additions & 18 deletions dashboard/src/pages/gr24/acu/widgets/SegmentLiveWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,10 @@ function SegmentLiveWidget() {
}}
>
<div
className={`absolute ${getVoltageBackgroundColor(data.voltage)} bottom-0 opacity-25`}
style={{
position: "absolute",
bottom: 0,
width: 125,
height: `${(data.voltage / maxVoltage) * 100}%`,
backgroundColor: getVoltageBackgroundColor(data.voltage),
// backgroundColor: getVoltageBackgroundColor(maxVoltage),
transition: "height 0.3s ease",
zIndex: 0,
}}
Expand All @@ -85,20 +82,13 @@ function SegmentLiveWidget() {

const getVoltageBackgroundColor = (voltage) => {
const fraction = voltage / maxVoltage;
const brightnessFactor = 0.25;
const red = Math.min(
255,
Math.max(0, Math.floor((1 - fraction) * 255 * brightnessFactor)),
);
const green = Math.min(
255,
Math.max(0, Math.floor(fraction * 255 * brightnessFactor)),
);
return `rgb(${red}, ${green}, 0)`;
};

const getVoltageColor = (voltage: number) => {
return "text-white";
if (fraction < 0.2) {
return "bg-red-400";
} else if (fraction < 0.4) {
return "bg-yellow-400";
} else {
return "bg-green-400";
}
};

const getTempColor = (temp: number) => {
Expand Down

0 comments on commit 263d4a4

Please sign in to comment.