Skip to content

Commit

Permalink
Sat nav improvements:
Browse files Browse the repository at this point in the history
* List menus: gray out as long as data is not received
* Turn off MFD info during and just after download, similar to original MFD
  • Loading branch information
0xCAFEDECAF committed Nov 12, 2024
1 parent dd4c932 commit a2b3969
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 61 deletions.
33 changes: 17 additions & 16 deletions VanLiveConnect/MFD.html.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ char mfd_html[] PROGMEM = R"=====(
<!-- Our own stuff. Added '?foo=1' to force Chrome reload; see also https://stackoverflow.com/a/70410178 -->
<script src="MFD.js?foo=1" async></script>
</head>
<body id="body" translate="no" onload="htmlBodyOnLoad();" onresize="resizeScreenToFit();">
<!-- "Small" information panel -->
<div style="position:absolute; left:0px; top:0px; width:390px; height:550px;">
<div id="small_panel" style="position:absolute; left:0px; top:0px; width:390px; height:550px;">
<!-- Trip info -->
Expand Down Expand Up @@ -162,7 +163,7 @@ char mfd_html[] PROGMEM = R"=====(
<!-- "Large" information panel -->
<div style="position:absolute; left:390px; top:0px; width:960px; height:550px;">
<div id="large_panel" style="position:absolute; left:390px; top:0px; width:960px; height:550px;">
<!-- Large clock (nothing better to show) -->
Expand Down Expand Up @@ -1148,7 +1149,7 @@ char mfd_html[] PROGMEM = R"=====(
<!-- Show spinning disc as long as no data has come in -->
<div id="satnav_to_mfd_show_characters_spinning_disc"
style="display:none; position:absolute; left:400px; top:320px; transform:scaleX(2);">
style="display:none; position:absolute; left:400px; top:300px; transform:scaleX(2);">
<div class="fas fa-compact-disc" style="font-size:100px;"></div>
</div>
Expand Down Expand Up @@ -1270,7 +1271,7 @@ char mfd_html[] PROGMEM = R"=====(
<!-- Show spinning disk while text area is still empty, i.e. data is being retrieved -->
<div id="satnav_choose_from_list_spinning_disc"
style="display:none; position:absolute; left:400px; top:320px; transform:scaleX(2);">
style="display:none; position:absolute; left:400px; top:300px; transform:scaleX(2);">
<div class="fas fa-compact-disc" style="font-size:100px;"></div>
</div>
Expand Down Expand Up @@ -1348,7 +1349,7 @@ char mfd_html[] PROGMEM = R"=====(
<div id="satnav_personal_address_validate_buttons" style="display:block">
<div id="satnav_show_personal_address_validate_button"
on_click="showPopup('satnav_guidance_preference_popup', 8000);"
class="icon button validateButton" style="left:25px; top:460px;">
class="icon button buttonDisabled validateButton" style="left:25px; top:460px;">
Validate
</div>
</div>
Expand Down Expand Up @@ -1388,7 +1389,7 @@ char mfd_html[] PROGMEM = R"=====(
<div id="satnav_professional_address_validate_buttons" style="display:block">
<div id="satnav_show_professional_address_validate_button"
on_click="showPopup('satnav_guidance_preference_popup', 8000);"
class="icon button validateButton" style="left:25px; top:460px;">
class="icon button buttonDisabled validateButton" style="left:25px; top:460px;">
Validate
</div>
</div>
Expand Down Expand Up @@ -2422,16 +2423,6 @@ char mfd_html[] PROGMEM = R"=====(
</div>
</div> <!-- "satnav_initializing_popup" -->
<!-- Sat nav downloading popup -->
<div id="satnav_downloading_popup"
on_enter="satnavDownloading = true;"
class="icon notificationPopup">
<div class="centerAligned messagePopupArea">
DOWNLOAD IN PROGRESS... <span id="satnav_download_progress"></span>
</div>
</div> <!-- "satnav_downloading_popup" -->
<!-- Sat nav popup "Input has been stored in personal directory" -->
<div id="satnav_input_stored_in_personal_dir_popup"
Expand Down Expand Up @@ -2699,6 +2690,16 @@ char mfd_html[] PROGMEM = R"=====(
</div>
</div>
<!-- Sat nav downloading popup -->
<div id="satnav_downloading_popup" style="left:445px;"
on_enter="satnavDownloading = true;"
class="icon notificationPopup">
<div class="centerAligned messagePopupArea">
DOWNLOAD IN PROGRESS... <span id="satnav_download_progress"></span>
</div>
</div> <!-- "satnav_downloading_popup" -->
<!-- Full-screen panels -->
<!-- System -->
Expand Down
100 changes: 55 additions & 45 deletions VanLiveConnect/MFD.js.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,9 @@ function keyPressed(key)
var currentButton = selected.button;
// Ignore if grayed out
if (currentButton.attr("grayed-out") === "true") return;
// Retrieve the specified action, like e.g. on_left_button="doSomething();"
var action = currentButton.attr("on_" + key.toLowerCase());
if (action) return eval(action);
Expand Down Expand Up @@ -1412,6 +1415,8 @@ function highlightLine(id)
id = getFocusId(id);
if (id === undefined) return;
if ($("#" + id).attr("grayed-out") === "true") return;
var lines = splitIntoLines(id);
if (lines.length === 0) return; // Nothing to highlight?
Expand Down Expand Up @@ -2187,6 +2192,22 @@ function satnavGotoMainMenu()
satnavShowDisclaimer();
}
// The list is kept grayed-out until the actual data is received from the sat nav unit
function satnavGrayOutList()
{
unhighlightLine("satnav_choice_list");
$("#satnav_choice_list").css("color", "var(--disabled-element-color)");
$('#satnav_choice_list').attr("grayed-out", "true");
// Show the spinning disc after a while
clearTimeout(satnavGotoListScreen.showSpinningDiscTimer);
satnavGotoListScreen.showSpinningDiscTimer = setTimeout
(
function() { $("#satnav_choose_from_list_spinning_disc").show(); },
2500
);
}
function satnavGotoListScreen()
{
// In the menu stack, there is never more than one "list screen" stacked. So check if there is an existing list
Expand Down Expand Up @@ -2227,19 +2248,7 @@ function satnavGotoListScreen()
} // switch
} // if
if ($("#satnav_choice_list").text() === "")
{
// Show the spinning disc after a while
clearTimeout(satnavGotoListScreen.showSpinningDiscTimer);
satnavGotoListScreen.showSpinningDiscTimer = setTimeout
(
function() { $("#satnav_choose_from_list_spinning_disc").show(); },
3500
);
} // if
// We could get here via "Esc" and then the currently selected line must be highlighted
highlightLine("satnav_choice_list");
satnavGrayOutList();
}
function satnavGotoListScreenEmpty()
Expand Down Expand Up @@ -3353,6 +3362,19 @@ function satnavStopOrResumeGuidance()
if (satnavMode === "IN_GUIDANCE_MODE") satnavStopGuidance(); else satnavSwitchToGuidanceScreen();
}
// Enable or disable the "Navigation/Guidance" button in the main menu
function toggleNavigationButtonInMainMenu(enable)
{
$("#main_menu_goto_satnav_button").toggleClass("buttonDisabled", ! enable);
if (! enable)
{
// Select the 'Configure display' (bottom) button
$("#main_menu_goto_satnav_button").removeClass("buttonSelected");
$("#main_menu_goto_screen_configuration_button").addClass("buttonSelected");
} // if
}
var nSatNavDiscUnreadable = 0;
function satnavPoweringOff(satnavMode)
Expand All @@ -3365,8 +3387,10 @@ function satnavPoweringOff(satnavMode)
webSocket.send("ask_for_guidance_continuation:YES");
} // if
toggleNavigationButtonInMainMenu(false);
satnavInitialized = false;
nSatNavDiscUnreadable = 1;
nSatNavDiscUnreadable = 0;
satnavDisclaimerAccepted = false;
satnavServiceListSize = -1;
satnavDestinationNotAccessibleByRoadPopupShown = false;
Expand Down Expand Up @@ -4766,10 +4790,12 @@ function handleItemChange(item, value, changed)
{
hidePopup("satnav_initializing_popup");
// TODO - show popup not directly, but only after a few times this status
showStatusPopup(satnavDiscUnreadbleText, 5000);
if (inSatnavMenuOrGuidanceScreen()) selectDefaultScreen();
// Show popup not directly
if (nSatNavDiscUnreadable >= 1)
{
showStatusPopup(satnavDiscUnreadbleText, 5000);
if (inSatnavMenuOrGuidanceScreen()) selectDefaultScreen();
}
}
else if (value.match(/READY/))
{
Expand Down Expand Up @@ -4834,12 +4860,7 @@ function handleItemChange(item, value, changed)
let driving = satnavVehicleMoving();
// While driving, disable "Navigation / Guidance" button in main menu
$("#main_menu_goto_satnav_button").toggleClass("buttonDisabled", driving);
if (driving)
{
$("#main_menu_goto_satnav_button").removeClass("buttonSelected");
$("#main_menu_goto_screen_configuration_button").addClass("buttonSelected");
} // if
toggleNavigationButtonInMainMenu(! driving);
} // case
break;
Expand Down Expand Up @@ -4903,6 +4924,7 @@ function handleItemChange(item, value, changed)
$("#satnav_download_progress").text(value);
if (value === "0") break;
selectDefaultScreen(); // Original MFD no longer responds, showing "WAITING FOR DOWNLOADING"
$("#large_panel").hide();
showPopup("satnav_downloading_popup", 120000);
} // case
break;
Expand All @@ -4919,7 +4941,7 @@ function handleItemChange(item, value, changed)
if (nSatNavDiscUnreadable == 6 || nSatNavDiscUnreadable == 14)
{
hidePopup("satnav_initializing_popup");
showStatusPopup(satnavDiscUnreadbleText, 4000);
showStatusPopup(satnavDiscUnreadbleText, 5000);
} // if
} // case
break;
Expand All @@ -4931,14 +4953,7 @@ function handleItemChange(item, value, changed)
if (! satnavEquipmentPresent) nSatNavDiscUnreadable = 0;
// Enable or disable the "Navigation/Guidance" button in the main menu
$("#main_menu_goto_satnav_button").toggleClass("buttonDisabled", value === "NO");
if (value === "NO")
{
// Select the 'Configure display' (bottom) button
$("#main_menu_goto_satnav_button").removeClass("buttonSelected");
$("#main_menu_goto_screen_configuration_button").addClass("buttonSelected");
} // if
toggleNavigationButtonInMainMenu(satnavEquipmentPresent);
} // case
break;
Expand Down Expand Up @@ -5205,18 +5220,9 @@ function handleItemChange(item, value, changed)
case "mfd_to_satnav_request_type":
{
satnavMfdRequestType = value;
if (value === "REQ_ITEMS") satnavGrayOutList();
if (value !== "REQ_N_ITEMS") break;
switch (mfdToSatnavRequest)
{
case "enter_city":
case "enter_street":
{
satnavPrepareEntryScreen();
} // case
break;
} // switch
if(mfdToSatnavRequest === "enter_city" || mfdToSatnavRequest === "enter_street") satnavPrepareEntryScreen();
} // case
break;
Expand Down Expand Up @@ -5346,10 +5352,12 @@ function handleItemChange(item, value, changed)
case "satnav_list":
{
// Hide the spinning disc
clearTimeout(satnavGotoListScreen.showSpinningDiscTimer);
$("#satnav_choose_from_list_spinning_disc").hide();
$("#satnav_choice_list").css("color", "var(--main-color)");
$('#satnav_choice_list').removeAttr("grayed-out");
switch(mfdToSatnavRequest)
{
case "enter_city":
Expand Down Expand Up @@ -5837,6 +5845,7 @@ function handleItemChange(item, value, changed)
{
if (value === "MFD_SCREEN_ON")
{
$("#small_panel,#large_panel").show();
if (economyMode === "ON" && currentLargeScreenId !== "pre_flight" && engineRpm <= 0) showPowerSavePopup();
satnavDownloading = false;
$("#main_menu_goto_satnav_button").removeClass("buttonDisabled");
Expand All @@ -5847,6 +5856,7 @@ function handleItemChange(item, value, changed)
else if (value === "MFD_SCREEN_OFF")
{
hidePopup();
if (satnavDownloading) $("#small_panel,#large_panel").hide();
} // if
} // case
break;
Expand Down
Binary file modified VanLiveConnect/data/MFD.html.gz
Binary file not shown.
Binary file modified VanLiveConnect/data/MFD.js.gz
Binary file not shown.

0 comments on commit a2b3969

Please sign in to comment.