Skip to content

Commit

Permalink
HDZero OSD support in configurator (#449)
Browse files Browse the repository at this point in the history
* Partial port of iNav HDZero OSD
* css changes to fit hdzero osd
* osd positioning fix
* Rename Sharkbyte -> HDZero
* bump max msp version: 1.52.0
* Handle 32bits function mask for msp 1.52.0 and above
* only display HDZero OSD under port peripherals, and HD (HDZero) in OSD Tab if >= MSP 1.52.0
* OSD Preview style fix (no longer sticky)
* repair OSD HD layout
* set min-width on osd preview pane
* Handle OSD size and positions based on whether HDZero is selected, and MSP ver gte 1.52.0
* fix some codacy warnings
* WIP - preliminary HDzero and Backward compatibility
* HD & backwardCompat code cleanup; default positioning still needs work
* revert to HD/HDZero verbiage rather than HD720
* cleaner MSPHelper.js
* force gps_baudratep=115200 for HDZero peripheral
* HDZero - fix osd-tab floaty center and third columns
* hdzero - force msp toggle off for HDZero peripheral
* hdzero - codacy cleanup

Co-authored-by: mricho <[email protected]>
  • Loading branch information
nerdCopter and mricho authored Feb 7, 2024
1 parent 605ad09 commit 67ecb6b
Show file tree
Hide file tree
Showing 9 changed files with 770 additions and 530 deletions.
6 changes: 6 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,12 @@
"portsFunction_RUNCAM_DEVICE_CONTROL": {
"message": "Camera (RunCam Protocol)"
},
"portsFunction_HDZERO_OSD": {
"message": "HDZero OSD"
},
"osdSetupVideoFormatOptionHd": {
"message": "HD (HDZero)"
},
"pidTuningProfileOption": {
"message": "Profile $1"
},
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"minimum_chrome_version": "49",
"version": "0.4.1",
"max_msp": "1.51.0",
"max_msp": "1.52.0",
"COMMENT": "MAX_MSP required!!!!",
"author": "Emuflight Team",
"name": "Emuflight Configurator",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "emuflight-configurator",
"description": "Crossplatform configuration tool for Emuflight flight control system.",
"version": "0.4.1",
"max_msp": "1.51.0",
"max_msp": "1.52.0",
"COMMENT": "MAX_MSP required!!!!",
"main": "main.html",
"chromium-args": "--disable-features=nw2",
Expand Down
15 changes: 15 additions & 0 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,12 @@ dialog {
width: 33%;
}

.third_left_osd {
float: left;
width: calc(50% - 360px);
min-width: 23%;
}

.third_center {
display: inline-block;
width: 34%;
Expand All @@ -1227,6 +1233,10 @@ dialog {
width: 33%;
}

.third_right_osd {
min-width: 68%;
}

.fourth {
float: left;
width: 25%;
Expand All @@ -1247,6 +1257,11 @@ dialog {
width: 67%;
}

.twothird_osd {
float: left;
width: 60%;
}

/* Columns END> */

/* Spacers */
Expand Down
61 changes: 47 additions & 14 deletions src/css/tabs/osd.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
line-height: 24px;
color: white;
font-weight: bold;

/* text-shadow: 1px 0px 2px rgba(0, 0, 0, 0.9);*/
}

Expand Down Expand Up @@ -256,20 +255,20 @@
}

.tab-osd .preview .gui_box_titlebar label {
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
white-space: nowrap;
vertical-align: text-bottom;
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
white-space: nowrap;
vertical-align: text-bottom;
}

.tab-osd .preview .gui_box_titlebar select {
max-width: 100px;
border-radius: 2px;
font-size: 11px;
font-weight: normal;
font-family: 'open_sansregular', 'Segoe UI', Tahoma, sans-serif;
max-width: 100px;
border-radius: 2px;
font-size: 11px;
font-weight: normal;
font-family: 'open_sansregular', 'Segoe UI', Tahoma, sans-serif;
}

.tab-osd .preview .gui_box_bottombar {
Expand Down Expand Up @@ -445,19 +444,53 @@ button {
border: 1px solid var(--subtleAccent);
}

.tab-osd .third_left {
float: left;
/* width: calc(50% - 197px); */
width: 32%;
max-width: 300px;
margin-right: 5px;
}

.tab-osd .third_center {
float: left;
/* width: 32%; */
width: unset;
min-width: 350px;
margin-left: 5px;
margin-right: 5px;
}

.tab-osd .third_right {
float: left;
/* width: calc(50% - 197px); */
width: 32%;
max-width: 300px;
margin-left: 20px;
}

.tab-osd .preview {
width: 360px;
float: left;
position: sticky;
/* position: sticky; */
top: 0px;

/* please don't copy the generic background image from another project
* and replace the one that @nathantsoi took :)
*/
background: url(../../images/osd-bg-1.jpg);
background-size: cover;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
/* left: calc(50% - 197px); */
}

.tab-osd .preview_hd {
width: 600px !important;
/* left: calc(50% - 317px) !important; */
}

.tab-osd .preview_hd_side {
/* width: calc(50% - 317px) !important; */
}

.tab-osd .alarms label {
Expand Down
36 changes: 27 additions & 9 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ function MspHelper () {
'TELEMETRY_IBUS': 12,
'IRC_TRAMP': 13,
'RUNCAM_DEVICE_CONTROL': 14, // support communitate with RunCam Device
'LIDAR_TF': 15
'LIDAR_TF': 15,
'HDZERO_OSD': 16, // matches: FUNCTION_HDZERO_OSD = (1 << 16), // 65536 in saidinesh5/Emuflight: src/main/io/serial.h
};

self.REBOOT_TYPES = {
Expand Down Expand Up @@ -818,19 +819,32 @@ MspHelper.prototype.process_data = function(dataHandler) {
SERIAL_CONFIG.cliBaudRate = data.readU32();
SERIAL_CONFIG.gpsBaudRate = data.readU32();
SERIAL_CONFIG.gpsPassthroughBaudRate = data.readU32();
} else {
} else {
SERIAL_CONFIG.ports = [];
var bytesPerPort = 1 + 2 + (1 * 4);

var bytesPerPort;
if (semver.lt(CONFIG.apiVersion, "1.52.0")) {
bytesPerPort = 1 + 2 + (1 * 4);
} else { //MSP gte 1.52
bytesPerPort = 1 + 4 + (1 * 4);
}

var serialPortCount = data.byteLength / bytesPerPort;
for (var i = 0; i < serialPortCount; i++) {
var serialPort = {
identifier: data.readU8(),
functions: self.serialPortFunctionMaskToFunctions(data.readU16()),
var serialPort = { identifier: data.readU8() };

if (semver.lt(CONFIG.apiVersion, "1.52.0")) {
serialPort = Object.assign(serialPort, {functions: self.serialPortFunctionMaskToFunctions(data.readU16())});
} else { //MSP gte 1.52
serialPort = Object.assign(serialPort, {functions: self.serialPortFunctionMaskToFunctions(data.readU32())});
}

serialPort = Object.assign(serialPort, {
msp_baudrate: self.BAUD_RATES[data.readU8()],
gps_baudrate: self.BAUD_RATES[data.readU8()],
telemetry_baudrate: self.BAUD_RATES[data.readU8()],
blackbox_baudrate: self.BAUD_RATES[data.readU8()]
}
});
SERIAL_CONFIG.ports.push(serialPort);
}
}
Expand Down Expand Up @@ -1923,8 +1937,12 @@ MspHelper.prototype.crunch = function(code) {
var serialPort = SERIAL_CONFIG.ports[i];
buffer.push8(serialPort.identifier);
var functionMask = self.serialPortFunctionsToMask(serialPort.functions);
buffer.push16(functionMask)
.push8(self.BAUD_RATES.indexOf(serialPort.msp_baudrate))
if (semver.lt(CONFIG.apiVersion, "1.52.0")) {
buffer.push16(functionMask);
} else { //MSP gte 1.52
buffer.push32(functionMask);
}
buffer.push8(self.BAUD_RATES.indexOf(serialPort.msp_baudrate))
.push8(self.BAUD_RATES.indexOf(serialPort.gps_baudrate))
.push8(self.BAUD_RATES.indexOf(serialPort.telemetry_baudrate))
.push8(self.BAUD_RATES.indexOf(serialPort.blackbox_baudrate));
Expand Down
Loading

0 comments on commit 67ecb6b

Please sign in to comment.