Skip to content

Commit

Permalink
Add opt. accel times from Remote
Browse files Browse the repository at this point in the history
  • Loading branch information
realA10001986 authored Oct 23, 2024
1 parent ecdf756 commit 4968916
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 23 deletions.
4 changes: 2 additions & 2 deletions timecircuits-A10001986/tc_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
// '0'-'9', 'A'-'Z', '(', ')', '.', '_', '-' or space
#define TC_VERSION "V3.1.99" // 13 chars max
#ifndef IS_ACAR_DISPLAY
#define TC_VERSION_EXTRA "OCT152024" // 13 chars max
#define TC_VERSION_EXTRA "OCT232024" // 13 chars max
#else // A-Car
#define TC_VERSION_EXTRA "10152024" // 12 chars max
#define TC_VERSION_EXTRA "10232024" // 12 chars max
#endif

//#define TC_DBG // debug output on Serial
Expand Down
10 changes: 6 additions & 4 deletions timecircuits-A10001986/tc_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static bool read_settings(File configFile)
wd |= CopyCheckValidNumParm(json["beep"], settings.beep, sizeof(settings.beep), 0, 3, DEF_BEEP);

// Transition - now in separate file
CopyCheckValidNumParm(json["autoRotateTimes"], settings.autoRotateTimes, sizeof(settings.autoRotateTimes), 0, 5, DEF_AUTOROTTIMES);
//CopyCheckValidNumParm(json["autoRotateTimes"], settings.autoRotateTimes, sizeof(settings.autoRotateTimes), 0, 5, DEF_AUTOROTTIMES);

if(json["hostName"]) {
CopyTextParm(settings.hostName, json["hostName"], sizeof(settings.hostName));
Expand Down Expand Up @@ -523,9 +523,9 @@ static bool read_settings(File configFile)
} else wd = true;

// Transition - now separate config file
CopyCheckValidNumParm(json["destTimeBright"], settings.destTimeBright, sizeof(settings.destTimeBright), 0, 15, DEF_BRIGHT_DEST);
CopyCheckValidNumParm(json["presTimeBright"], settings.presTimeBright, sizeof(settings.presTimeBright), 0, 15, DEF_BRIGHT_PRES);
CopyCheckValidNumParm(json["lastTimeBright"], settings.lastTimeBright, sizeof(settings.lastTimeBright), 0, 15, DEF_BRIGHT_DEPA);
//CopyCheckValidNumParm(json["destTimeBright"], settings.destTimeBright, sizeof(settings.destTimeBright), 0, 15, DEF_BRIGHT_DEST);
//CopyCheckValidNumParm(json["presTimeBright"], settings.presTimeBright, sizeof(settings.presTimeBright), 0, 15, DEF_BRIGHT_PRES);
//CopyCheckValidNumParm(json["lastTimeBright"], settings.lastTimeBright, sizeof(settings.lastTimeBright), 0, 15, DEF_BRIGHT_DEPA);

wd |= CopyCheckValidNumParm(json["dtNmOff"], settings.dtNmOff, sizeof(settings.dtNmOff), 0, 1, DEF_DT_OFF);
wd |= CopyCheckValidNumParm(json["ptNmOff"], settings.ptNmOff, sizeof(settings.ptNmOff), 0, 1, DEF_PT_OFF);
Expand Down Expand Up @@ -559,6 +559,7 @@ static bool read_settings(File configFile)
}

wd |= CopyCheckValidNumParm(json["speedoBright"], settings.speedoBright, sizeof(settings.speedoBright), 0, 15, DEF_BRIGHT_SPEEDO);
wd |= CopyCheckValidNumParm(json["speedoAF"], settings.speedoAF, sizeof(settings.speedoAF), 0, 1, DEF_SPEEDO_ACCELFIG);
wd |= CopyCheckValidNumParmF(json["speedoFact"], settings.speedoFact, sizeof(settings.speedoFact), 0.5, 5.0, DEF_SPEEDO_FACT);
#ifdef TC_HAVEGPS
wd |= CopyCheckValidNumParm(json["useGPSSpeed"], settings.useGPSSpeed, sizeof(settings.useGPSSpeed), 0, 1, DEF_USE_GPS_SPEED);
Expand Down Expand Up @@ -680,6 +681,7 @@ void write_settings()
#ifdef TC_HAVESPEEDO
json["speedoType"] = (const char *)settings.speedoType;
json["speedoBright"] = (const char *)settings.speedoBright;
json["speedoAF"] = (const char *)settings.speedoAF;
json["speedoFact"] = (const char *)settings.speedoFact;
#ifdef TC_HAVEGPS
json["useGPSSpeed"] = (const char *)settings.useGPSSpeed;
Expand Down
4 changes: 3 additions & 1 deletion timecircuits-A10001986/tc_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extern uint8_t musFolderNum;
#define DEF_ETT_DELAY 0 // in ms; Default 0: ETT immediately
#define DEF_ETT_LONG 1 // [removed] 0: Ext. TT short (reentry), 1: long
#define DEF_SPEEDO_TYPE 99 // Default display type: None
#define DEF_SPEEDO_ACCELFIG 0 // Accel figures: 0: Movie (approximated), 1: Real-life
#define DEF_SPEEDO_FACT 2.0 // Speedo factor (1.0 actual DeLorean figures; >1.0 faster, <1.0 slower)
#define DEF_BRIGHT_SPEEDO 15 // Default: Max. brightness for speed
#define DEF_USE_GPS_SPEED 0 // 0: Do not show GPS speed on speedo display
Expand Down Expand Up @@ -159,6 +160,7 @@ struct Settings {
#ifdef TC_HAVESPEEDO
char speedoType[4] = MS(DEF_SPEEDO_TYPE);
char speedoBright[4] = MS(DEF_BRIGHT_SPEEDO);
char speedoAF[4] = MS(DEF_SPEEDO_ACCELFIG);
char speedoFact[6] = MS(DEF_SPEEDO_FACT);
#ifdef TC_HAVEGPS
char useGPSSpeed[4] = MS(DEF_USE_GPS_SPEED);
Expand All @@ -169,7 +171,7 @@ struct Settings {
char tempBright[4] = MS(DEF_TEMP_BRIGHT);
char tempOffNM[4] = MS(DEF_TEMP_OFF_NM);
#endif
#endif // HAVESPEEDO
#endif // HAVESPEEDO
#ifdef EXTERNAL_TIMETRAVEL_OUT
char useETTO[4] = MS(DEF_USE_ETTO);
char noETTOLead[4] = MS(DEF_NO_ETTO_LEAD);
Expand Down
30 changes: 27 additions & 3 deletions timecircuits-A10001986/tc_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ static uint64_t tdro = 5258964960;
uint8_t* e(uint8_t *d, uint32_t m, int y) { return (*r)(d, m, y); }

// Acceleraton times
#ifdef TC_HAVESPEEDO
static const int16_t tt_p0_delays[88] =
#if defined(TC_HAVESPEEDO) || defined(TC_HAVE_REMOTE)
static const int16_t tt_p0_delays_rl[88] =
{
0, 100, 100, 90, 80, 80, 80, 80, 80, 80, // 0 - 9 10mph 0.8s 0.8=800ms
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, // 10-19 20mph 1.6s 0.8
Expand All @@ -786,6 +786,19 @@ static const int16_t tt_p0_delays[88] =
320, 330, 350, 370, 370, 380, 380, 390, 400, 410, // 70-79 80mph 14.7s 3.7
410, 410, 410, 410, 410, 410, 410, 410 // 80-87 90mph 18.8s 4.1
};
static const int16_t tt_p0_delays_movie[88] =
{
0, 90, 90, 90, 90, 90, 90, 95, 95, 100, // m0 - 9 10mph 0- 9: 0.83s (m=measured, i=interpolated)
105, 110, 115, 120, 125, 130, 135, 140, 145, 150, // i10-19 20mph 10-19: 1.27s
155, 160, 165, 170, 175, 180, 185, 190, 195, 200, // i20-29 30mph 20-29: 1.77s
200, 200, 202, 203, 204, 205, 206, 207, 208, 209, // m30-39 40mph 30-39: 2s
210, 211, 212, 213, 214, 215, 216, 217, 218, 219, // i40-49 50mph 40-49: 2.1s
220, 221, 222, 223, 224, 225, 226, 227, 228, 229, // m50-59 60mph 50-59: 2.24s
230, 233, 236, 240, 243, 246, 250, 253, 256, 260, // i60-69 70mph 60-69: 2.47s
263, 266, 270, 273, 276, 280, 283, 286, 290, 293, // m70-79 80mph 70-79: 2.78s
296, 300, 300, 303, 303, 306, 310, 310 // i80-88 90mph 80-88: 2.4s total 17.6 secs
};
static const int16_t *tt_p0_delays = tt_p0_delays_movie;
static long tt_p0_totDelays[88];
#endif

Expand Down Expand Up @@ -1556,6 +1569,18 @@ void time_setup()
beepTimeout = BEEPM2_SECS*1000;

// Set up speedo display
#ifdef TC_HAVESPEEDO
if(!useSpeedo || (!atoi(settings.speedoAF))) {
//tt_p0_delays = tt_p0_delays_movie; // already initialized
ttP0TimeFactor = 1.0;
} else {
tt_p0_delays = tt_p0_delays_rl;
ttP0TimeFactor = (float)strtof(settings.speedoFact, NULL);
}
#elif defined(TC_HAVE_REMOTE)
//tt_p0_delays = tt_p0_delays_movie; // already initialized
#endif

#ifdef TC_HAVESPEEDO
if(useSpeedo) {
speedo.setBrightness(atoi(settings.speedoBright), true);
Expand All @@ -1565,7 +1590,6 @@ void time_setup()
if(!playTTsounds) havePreTTSound = false;

// Speed factor for acceleration curve
ttP0TimeFactor = (float)strtof(settings.speedoFact, NULL);
if(ttP0TimeFactor < 0.5) ttP0TimeFactor = 0.5;
if(ttP0TimeFactor > 5.0) ttP0TimeFactor = 5.0;

Expand Down
36 changes: 23 additions & 13 deletions timecircuits-A10001986/tc_wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ WiFiManagerParameter custom_tzsel("<datalist id='tz'><option value='PST8PDT,M3.2

#ifdef TC_NOCHECKBOXES // --- Standard text boxes: -------
WiFiManagerParameter custom_playIntro("plIn", "Play intro (0=off, 1=on)", settings.playIntro, 1, aco);
WiFiManagerParameter custom_mode24("md24", "24-hour clock mode: (0=12hr, 1=24hr)", settings.mode24, 1, aco);
WiFiManagerParameter custom_mode24("md24", "Clock mode (0=12hr, 1=24hr)", settings.mode24, 1, aco);
#else // -------------------- Checkbox hack: --------------
WiFiManagerParameter custom_playIntro("plIn", "Play intro", settings.playIntro, 1, "type='checkbox' style='margin-top:3px'", WFM_LABEL_AFTER);
WiFiManagerParameter custom_mode24("md24", "24-hour clock mode", settings.mode24, 1, "type='checkbox'", WFM_LABEL_AFTER);
WiFiManagerParameter custom_mode24("md24", "24-hour clock", settings.mode24, 1, "type='checkbox'", WFM_LABEL_AFTER);
#endif // -------------------------------------------------
WiFiManagerParameter custom_beep_aint(beepaintCustHTML); // beep + aint
#ifdef TC_NOCHECKBOXES // --- Standard text boxes: -------
Expand All @@ -197,19 +197,19 @@ WiFiManagerParameter custom_alarmRTC("artc", "Alarm base is RTC (1) or displayed
WiFiManagerParameter custom_ttrp("ttrp", "Make time travels persistent (0=no, 1=yes)", settings.timesPers, 1, "autocomplete='off'");
#endif
#else // -------------------- Checkbox hack: --------------
WiFiManagerParameter custom_alarmRTC("artc", "Alarm base is real present time", settings.alarmRTC, 1, "title='If unchecked, the alarm base is the displayed \"present\" time' type='checkbox'", WFM_LABEL_AFTER);
WiFiManagerParameter custom_alarmRTC("artc", "Alarm base is real present time", settings.alarmRTC, 1, "title='If unchecked, alarm base is the displayed \"present\" time' type='checkbox'", WFM_LABEL_AFTER);
#ifndef PERSISTENT_SD_ONLY
WiFiManagerParameter custom_ttrp("ttrp", "Make time travels persistent", settings.timesPers, 1, "type='checkbox'", WFM_LABEL_AFTER);
#endif
#endif // -------------------------------------------------

#if defined(TC_MDNS) || defined(TC_WM_HAS_MDNS)
#define HNTEXT "Hostname<br><span style='font-size:80%'>The Config Portal is accessible at http://<i>hostname</i>.local<br>(Valid characters: a-z/0-9/-)</span>"
#define HNTEXT "Hostname<br><span style='font-size:80%'>The Config Portal is accessible at http://<i>hostname</i>.local<br>[Valid characters: a-z/0-9/-]</span>"
#else
#define HNTEXT "Hostname<br><span style='font-size:80%'>(Valid characters: a-z/0-9/-)</span>"
#endif
WiFiManagerParameter custom_hostName("hostname", HNTEXT, settings.hostName, 31, "pattern='[A-Za-z0-9\\-]+' placeholder='Example: timecircuits'");
WiFiManagerParameter custom_sysID("sysID", "AP Mode: Network name appendix<br><span style='font-size:80%'>Will be appended to \"TCD-AP\" to create a unique name if multiple TCDs in range. [a-z/0-9/-]</span>", settings.systemID, 7, "pattern='[A-Za-z0-9\\-]+'");
WiFiManagerParameter custom_sysID("sysID", "AP Mode: Network name appendix<br><span style='font-size:80%'>Will be appended to \"TCD-AP\" [a-z/0-9/-]</span>", settings.systemID, 7, "pattern='[A-Za-z0-9\\-]+'");
WiFiManagerParameter custom_appw("appw", "AP Mode: WiFi password<br><span style='font-size:80%'>Password to protect TCD-AP. Empty or 8 characters [a-z/0-9/-]<br><b>Write this down, you might lock yourself out!</b></span>", settings.appw, 8, "minlength='8' pattern='[A-Za-z0-9\\-]+'");
WiFiManagerParameter custom_wifiConRetries("wifiret", "WiFi connection attempts (1-10)", settings.wifiConRetries, 2, "type='number' min='1' max='10' autocomplete='off'", WFM_LABEL_BEFORE);
WiFiManagerParameter custom_wifiConTimeout("wificon", "WiFi connection timeout (7-25[seconds])", settings.wifiConTimeout, 2, "type='number' min='7' max='25'");
Expand Down Expand Up @@ -254,28 +254,33 @@ WiFiManagerParameter custom_lxLim("lxLim", "<br>Lux threshold (0-50000)", settin
#ifdef TC_NOCHECKBOXES // --- Standard text boxes: -------
WiFiManagerParameter custom_tempUnit("uTem", "Temperature unit (0=°F, 1=°C)", settings.tempUnit, 1, "autocomplete='off' title='Select unit for temperature'");
#else // -------------------- Checkbox hack: --------------
WiFiManagerParameter custom_tempUnit("temUnt", "Show temperature in °Celsius", settings.tempUnit, 1, "title='Fahrenheit if unchecked' type='checkbox' class='mt5'", WFM_LABEL_AFTER);
WiFiManagerParameter custom_tempUnit("temUnt", "Show temperature in Celsius", settings.tempUnit, 1, "title='Fahrenheit if unchecked' type='checkbox' class='mt5'", WFM_LABEL_AFTER);
#endif // -------------------------------------------------
WiFiManagerParameter custom_tempOffs("tOffs", "<br>Temperature offset (-3.0-3.0)", settings.tempOffs, 4, "type='number' min='-3.0' max='3.0' step='0.1' title='Correction value to add to temperature' autocomplete='off'");
#endif // TC_HAVETEMP

#ifdef TC_HAVESPEEDO
WiFiManagerParameter custom_speedoType(spTyCustHTML);
WiFiManagerParameter custom_speedoBright("speBri", "<br>Speedo brightness (0-15)", settings.speedoBright, 2, "type='number' min='0' max='15' autocomplete='off'");
WiFiManagerParameter custom_speedoFact("speFac", "Speedo sequence speed factor (0.5-5.0)", settings.speedoFact, 3, "type='number' min='0.5' max='5.0' step='0.5' title='1.0 means real-world DMC-12 acceleration time.' autocomplete='off'");
WiFiManagerParameter custom_speedoBright("speBri", "<br>Speed brightness (0-15)", settings.speedoBright, 2, "type='number' min='0' max='15' autocomplete='off'");
#ifdef TC_NOCHECKBOXES // --- Standard text boxes: -------
WiFiManagerParameter custom_sAF("sAF", "Acceleration times (0=real, 1=movie)", settings.speedoAF, 1, "autocomplete='off'");
#else // -------------------- Checkbox hack: --------------
WiFiManagerParameter custom_sAF("sAF", "Real-life acceleration figures", settings.speedoAF, 1, "autocomplete='off' title='If unchecked, movie-like times are used' type='checkbox' style='margin-top:12px'", WFM_LABEL_AFTER);
#endif // -------------------------------------------------
WiFiManagerParameter custom_speedoFact("speFac", "<br>Factor for real-life figures (0.5-5.0)", settings.speedoFact, 3, "type='number' min='0.5' max='5.0' step='0.5' title='1.0 means real-world DMC-12 acceleration time.' autocomplete='off'");
#ifdef TC_HAVEGPS
#ifdef TC_NOCHECKBOXES // --- Standard text boxes: -------
WiFiManagerParameter custom_useGPSS("uGPSS", "Display GPS speed (0=no, 1=yes)", settings.useGPSSpeed, 1, "autocomplete='off' title='Enable to use a GPS receiver to display actual speed on speedo display'");
WiFiManagerParameter custom_useGPSS("uGPSS", "Display GPS speed (0=no, 1=yes)", settings.useGPSSpeed, 1, "autocomplete='off' title='Enable to display actual GPS speed on speedo'");
#else // -------------------- Checkbox hack: --------------
WiFiManagerParameter custom_useGPSS("uGPSS", "Display GPS speed", settings.useGPSSpeed, 1, "autocomplete='off' title='Check to use a GPS receiver to display actual speed on speedo display' type='checkbox' style='margin-top:12px'", WFM_LABEL_AFTER);
WiFiManagerParameter custom_useGPSS("uGPSS", "Display GPS speed", settings.useGPSSpeed, 1, "autocomplete='off' title='Check to display actual GPS speed on speedo' type='checkbox' style='margin-top:12px'", WFM_LABEL_AFTER);
#endif // -------------------------------------------------
WiFiManagerParameter custom_updrt(spdRateCustHTML); // speed update rate
#endif // TC_HAVEGPS
#ifdef TC_HAVETEMP
#ifdef TC_NOCHECKBOXES // --- Standard text boxes: -------
WiFiManagerParameter custom_useDpTemp("dpTemp", "Display temperature (0=no, 1=yes)", settings.dispTemp, 1, "autocomplete='off' title='Enable to display temperature on speedo display when idle'");
WiFiManagerParameter custom_useDpTemp("dpTemp", "Display temperature (0=no, 1=yes)", settings.dispTemp, 1, "autocomplete='off' title='Enable to display temperature on speedo when idle'");
#else // -------------------- Checkbox hack: --------------
WiFiManagerParameter custom_useDpTemp("dpTemp", "Display temperature", settings.dispTemp, 1, "autocomplete='off' title='Check to display temperature on speedo display when idle' type='checkbox' style='margin-top:12px'", WFM_LABEL_AFTER);
WiFiManagerParameter custom_useDpTemp("dpTemp", "Display temperature", settings.dispTemp, 1, "autocomplete='off' title='Check to display temperature on speedo when idle' type='checkbox' style='margin-top:12px'", WFM_LABEL_AFTER);
#endif // -------------------------------------------------
WiFiManagerParameter custom_tempBright("temBri", "<br>Temperature brightness (0-15)", settings.tempBright, 2, "type='number' min='0' max='15' autocomplete='off'");
#ifdef TC_NOCHECKBOXES // --- Standard text boxes: -------
Expand Down Expand Up @@ -537,7 +542,8 @@ void wifi_setup()
#ifdef TC_HAVESPEEDO
&custom_sectstart,
&custom_speedoType,
&custom_speedoBright,
&custom_speedoBright,
&custom_sAF,
&custom_speedoFact,
#ifdef TC_HAVEGPS
&custom_useGPSS,
Expand Down Expand Up @@ -957,6 +963,7 @@ void wifi_loop()
#endif

#ifdef TC_HAVESPEEDO
mystrcpy(settings.speedoAF, &custom_sAF);
#ifdef TC_HAVEGPS
mystrcpy(settings.useGPSSpeed, &custom_useGPSS);
#endif
Expand Down Expand Up @@ -1017,6 +1024,7 @@ void wifi_loop()
#endif

#ifdef TC_HAVESPEEDO
strcpyCB(settings.speedoAF, &custom_sAF);
#ifdef TC_HAVEGPS
strcpyCB(settings.useGPSSpeed, &custom_useGPSS);
#endif
Expand Down Expand Up @@ -1662,6 +1670,7 @@ void updateConfigPortalValues()
custom_tempUnit.setValue(settings.tempUnit, 1);
#endif
#ifdef TC_HAVESPEEDO
custom_sAF.setValue(settings.speedoAF, 1);
#ifdef TC_HAVEGPS
custom_useGPSS.setValue(settings.useGPSSpeed, 1);
#endif
Expand Down Expand Up @@ -1711,6 +1720,7 @@ void updateConfigPortalValues()
setCBVal(&custom_tempUnit, settings.tempUnit);
#endif
#ifdef TC_HAVESPEEDO
setCBVal(&custom_sAF, settings.speedoAF);
#ifdef TC_HAVEGPS
setCBVal(&custom_useGPSS, settings.useGPSSpeed);
#endif
Expand Down
7 changes: 7 additions & 0 deletions timecircuits-A10001986/timecircuits-A10001986.ino
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@

/* Changelog
*
* 2024/10/23 (A10001986)
* - Speedo/acceleration: Implement option to use either real-life figures
* (as before), or movie-like figures (matching the Futaba Remote's times).
* Accel factor only applies to real-life times.
* "Movie-like" is measured/interpolated from mph incrementing times on the
* Remote control's display.
* If speedo is not found or disabled, movie-like times are used.
* 2024/10/15 (A10001986)
* - Add support for HDC302X temperature/humidity sensor (yet untested)
* 2024/10/03 (A10001986)
Expand Down

0 comments on commit 4968916

Please sign in to comment.