Skip to content

Commit

Permalink
add colors to number indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-8 committed Nov 25, 2024
1 parent dd4dd1c commit 487a495
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RCMv3/rcmv3.h
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ class RCMv3ComponentFactory {
return false;
}
int componentIndex = data[i];
if ((componentIndex < 0 && (type != RC_TYPE_MIXER)) || componentIndex >= components.size()) { // mixer only optionally needs a component to send the value to
if ((componentIndex < 0 || componentIndex >= components.size()) && !(type == RC_TYPE_MIXER)) { // mixer only optionally needs a component to send the value to
create_component_error_msg += " invalid component index (" + String(componentIndex) + ") ";
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/ds/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ <h1>RCMv3 Driver Station</h1>
<div class="add-ds-items-button-list">
<button onclick="downloadUIData();">save UI to file</button>
<button onclick="uploadUIData();">load UI from file</button>
<button onclick="saveUI()">save UI to robot</button>
<button onclick="loadUI()">reload UI from robot</button>
<button onclick="saveUI()">save UI to robot</button>
<div><button class="add-ds-items-button clear-ds-items-button" onclick='clearDSItems()'>clear</button></div>
</div>
<div class="controls-list">
Expand Down Expand Up @@ -101,4 +101,4 @@ <h1>RCMv3 Driver Station</h1>

</body>

</html>
</html>
19 changes: 18 additions & 1 deletion docs/ds/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,27 @@ class DSItem {
const r2 = parseInt(this.colorHigh.substring(1, 3), 16);
const g2 = parseInt(this.colorHigh.substring(3, 5), 16);
const b2 = parseInt(this.colorHigh.substring(5, 7), 16);
const percent = (this.vars[0] - this.colorLowVal) / (this.colorHighVal - this.colorLowVal);
const r = Math.round(r1 + (r2 - r1) * percent);
const g = Math.round(g1 + (g2 - g1) * percent);
const b = Math.round(b1 + (b2 - b1) * percent);
ctx.fillStyle = "#" + r.toString(16) + g.toString(16) + b.toString(16);
let colorString = "#";
if (r < 16) {
colorString += "0" + r.toString(16);
} else {
colorString += r.toString(16);
}
if (g < 16) {
colorString += "0" + g.toString(16);
} else {
colorString += g.toString(16);
}
if (b < 16) {
colorString += "0" + b.toString(16);
} else {
colorString += b.toString(16);
}
ctx.fillStyle = colorString;
}
} else {
ctx.fillStyle = this.color;
Expand Down

0 comments on commit 487a495

Please sign in to comment.