Skip to content

Commit

Permalink
New led functions gps bar battery bar altitude (#3823)
Browse files Browse the repository at this point in the history
* new led basefunctions: gps bar, battery bar, altitude

* removed trailing spaces

removed trailing spaces

* Update led_strip.js

* Reorder index to follow firmware

---------

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
  • Loading branch information
jonas-becker and haslinghuis authored May 5, 2024
1 parent 461e2db commit 4d46da2
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 6 deletions.
20 changes: 20 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3799,6 +3799,18 @@
"message": "GPS",
"description": "One of the modes of the Led Strip"
},
"ledStripFunctionGPSBarOption": {
"message": "GPS Bar",
"description": "One of the modes of the Led Strip"
},
"ledStripFunctionBatteryBarOption": {
"message": "Battery Bar",
"description": "One of the modes of the Led Strip"
},
"ledStripFunctionAltitudeOption": {
"message": "Altitude",
"description": "One of the modes of the Led Strip"
},
"ledStripFunctionRingOption": {
"message": "Ring",
"description": "One of the modes of the Led Strip"
Expand Down Expand Up @@ -3893,6 +3905,14 @@
"message": "GPS: locked",
"description": "One of the modes in Color Mode in Led Strip"
},
"ledStripModeGpsDefault": {
"message": "Default",
"description": "One of the modes in GPS Mode in Led Strip"
},
"ledStripModeGpsBar": {
"message": "Bar",
"description": "One of the modes in GPS Mode in Led Strip"
},
"ledStripWiring": {
"message": "LED Strip Wiring",
"description": "One of the modes in Led Strip"
Expand Down
26 changes: 26 additions & 0 deletions src/css/tabs/led_strip.less
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,29 @@
margin-left: 4px;
}
}
.gPoint.function-p {
background: rgb(0, 128, 85);
box-shadow: inset 0 0 30px rgba(0, 0, 0, .7);
border-color: rgb(52, 155, 255);
}
.gPoint.function-e {
background: rgb(0, 0, 128);
box-shadow: inset 0 0 30px rgba(0, 0, 0, .7);
border-color: rgb(52, 155, 255);
}
.gPoint.function-u {
background: linear-gradient( to bottom right, rgba(191, 0, 255, 0.5) 0%, rgba(0, 179, 255, 0.5) 33%, rgba(0, 4, 255, 0.5) 66%, rgba(191, 0, 255, 0.5) 100%);
box-shadow: inset 0 0 30px rgba(0, 0, 0, .7);
border-color: grey;
.overlay-color {
float: left;
height: 15px;
width: 15px;
margin-top: -23px;
margin-left: 4px;
border-radius: 4px;
}
}
.gPoint {
select {
background: #000;
Expand Down Expand Up @@ -210,6 +233,9 @@
.function-a {
background: rgb(52, 155, 255);
}
.function-u {
background: linear-gradient( to bottom right, rgba(191, 0, 255, 0.5) 0%, rgba(0, 179, 255, 0.5) 33%, rgba(0, 4, 255, 0.5) 66%, rgba(191, 0, 255, 0.5) 100%);
}
.function-l {
background: magenta;
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { reinitializeConnection } from "../serial_backend";

// Used for LED_STRIP
const ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
const ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r']; // in LSB bit
const ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r', 'p', 'e', 'u']; // in LSB bit
let ledOverlayLetters = ['t', 'y', 'o', 'b', 'v', 'i', 'w']; // in LSB bit

function MspHelper() {
Expand Down
17 changes: 13 additions & 4 deletions src/js/tabs/led_strip.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ led_strip.initialize = function (callback, scrollPosition) {
const functionTag = '.function-';

TABS.led_strip.functions = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l', 'o', 'y'];
TABS.led_strip.baseFuncs = ['c', 'f', 'a', 'l', 's', 'g', 'r'];
TABS.led_strip.baseFuncs = ['c', 'f', 'a', 'l', 's', 'g', 'r', 'p', 'e', 'u'];
TABS.led_strip.overlays = ['t', 'y', 'o', 'b', 'v', 'i', 'w'];

if (semver.lt(FC.CONFIG.apiVersion,API_VERSION_1_46)) {
Expand Down Expand Up @@ -427,8 +427,8 @@ led_strip.initialize = function (callback, scrollPosition) {
$('.modeSelect').on('change', function() {

const that = this;

const mode = Number($(that).val());

$('.mode_colors').find('button').each(function() {
for (let i = 0; i < 6; i++) {
for (let j = 0; j < 6; j++) {
Expand All @@ -439,7 +439,6 @@ led_strip.initialize = function (callback, scrollPosition) {
}
}
});

$('.mode_colors').each(function() { setModeBackgroundColor($(this)); });
});

Expand All @@ -463,6 +462,9 @@ led_strip.initialize = function (callback, scrollPosition) {
break;
case 'b':
case 'i':
case 'p':
case 'e':
case 'u':
if (areOverlaysActive(`function-${f}`))
p.addClass(`function-${letter}`);
break;
Expand Down Expand Up @@ -817,6 +819,9 @@ led_strip.initialize = function (callback, scrollPosition) {
case "function-c":
case "function-a":
case "function-f":
case "function-p":
case "function-e":
case "function-u":
case "function-s":
case "function-l":
case "function-r":
Expand Down Expand Up @@ -910,11 +915,14 @@ led_strip.initialize = function (callback, scrollPosition) {
switch (activeFunction) {
case "": // none
case "function-f": // Modes & Orientation
$('.modeSelect').show();
$('.special_colors').hide();
case "function-l": // Battery
// $('.mode_color-6-3').show(); // background
$('.special_colors').hide();
break;
case "function-g": // GPS
$('.modeSelect').show();
$('.mode_color-6-5').show(); // no sats
$('.mode_color-6-6').show(); // no lock
$('.mode_color-6-7').show(); // locked
Expand All @@ -924,6 +932,7 @@ led_strip.initialize = function (callback, scrollPosition) {
$('.mode_color-6-4').show(); // blink background
break;
case "function-a": // Arm state
$('.modeSelect').hide();
$('.mode_color-6-0').show(); // disarmed
$('.mode_color-6-1').show(); // armed
break;
Expand Down Expand Up @@ -1034,7 +1043,7 @@ led_strip.initialize = function (callback, scrollPosition) {

function drawColorBoxesInColorLedPoints() {
$('.gPoint').each(function() {
if ($(this).is('.function-c') || $(this).is('.function-r') || $(this).is('.function-b')) {
if ($(this).is('.function-c') || $(this).is('.function-r') || $(this).is('.function-b') || $(this).is('.function-u')) {
$(this).find('.overlay-color').show();

for (let colorIndex = 0; colorIndex < 16; colorIndex++) {
Expand Down
11 changes: 10 additions & 1 deletion src/tabs/led_strip.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<option value="function-s" i18n="ledStripFunctionRSSIOption"></option>
<option value="function-g" i18n="ledStripFunctionGPSOption"></option>
<option value="function-r" i18n="ledStripFunctionRingOption"></option>
<option value="function-p" i18n="ledStripFunctionGPSBarOption"></option>
<option value="function-e" i18n="ledStripFunctionBatteryBarOption"></option>
<option value="function-u" i18n="ledStripFunctionAltitudeOption"></option>
</select>
</div>

Expand Down Expand Up @@ -124,7 +127,7 @@
<div class="mode_colors">
<div class="section" i18n="ledStripModeColorsTitle"></div>

<select id="ledStripModeColorsModeSelect" class="modeSelect">
<select id="ledStripModeColorsModeSelect" class="modeSelect gps">
<option value="0" i18n="ledStripModeColorsModeOrientation"></option>
<option value="1" i18n="ledStripModeColorsModeHeadfree"></option>
<option value="2" i18n="ledStripModeColorsModeHorizon"></option>
Expand Down Expand Up @@ -190,6 +193,12 @@

<div class="special_colors mode_colors">
<div class="section" i18n="ledStripModesSpecialColorsTitle"></div>

<select id="ledStripModeGpsModeSelect" class="modeSelect flightmode">
<option value="0" i18n="ledStripModeGpsDefault"></option>
<option value="1" i18n="ledStripModeGpsBar"></option>
</select>

<button class="mode_color-6-0" i18n_title="colorGreen" i18n="ledStripModeColorsModeDisarmed"></button>
<button class="mode_color-6-1" i18n_title="colorBlue" i18n="ledStripModeColorsModeArmed"></button>
<button class="mode_color-6-2" i18n_title="colorWhite" i18n="ledStripModeColorsModeAnimation"></button>
Expand Down

0 comments on commit 4d46da2

Please sign in to comment.