|
| 1 | +# Display Track Status on OLED |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +To display track status, add a line in myAutomation.h |
| 6 | +```cpp |
| 7 | +#include "myTrackStatus.example.h" |
| 8 | +``` |
| 9 | + |
| 10 | +If using Mega, a line will be needed in config.h to allocate memory for additional lines on the first display. |
| 11 | +```cpp |
| 12 | +#define MAX_CHARACTER_ROWS 17 |
| 13 | +``` |
| 14 | +
|
| 15 | +9 plus number of tracks; 17 for 8 tracks. |
| 16 | +CSB1, ESP32-WROOM and Nucleo-F4 have this setting as default. |
| 17 | +
|
| 18 | +In addition to displaying track status, myTrackStatus.example.h will update the second line on the display, to show the motor shield type after 10 seconds. |
| 19 | +
|
| 20 | +myTrackStatus.example.h can be used by adding the `#include` line in myAutomation.h, or you can copy/rename the file in your backup folder and customize it so that the information is displayed on a different screen. |
| 21 | +
|
| 22 | +``` |
| 23 | +// myAutomation.h - as used in the above example |
| 24 | + |
| 25 | +#include "myTrackStatus.example.h" |
| 26 | + |
| 27 | +AUTOSTART |
| 28 | +SET_TRACK(A,MAIN) |
| 29 | +SET_TRACK(B,PROG) |
| 30 | +POWEROFF // power command follows change in track mode |
| 31 | + DELAYMINS(2) // do not change defaults for 2 minutes |
| 32 | + SCREEN(0, 0, "") // clear two static rows |
| 33 | + SCREEN(0, 1, "") // to avoid scrolling |
| 34 | +DONE |
| 35 | +``` |
| 36 | +
|
| 37 | +
|
| 38 | +Contents of the example file -- suggested for review/reference on how various EXRAIL commands have been used. |
| 39 | +```cpp |
| 40 | +// myTrackStatus.example.h |
| 41 | +
|
| 42 | +// Reporting power status and mA for each track on the LCD |
| 43 | +HAL(Bitmap,8236,1) // create flag 8236 |
| 44 | +AUTOSTART DELAY(5000) |
| 45 | + ROUTE("TRACKSTATUS"_hk, "Resume/Pause JL Display") |
| 46 | + IF(8236) |
| 47 | + RESET(8236) |
| 48 | + ROUTE_CAPTION("TRACKSTATUS"_hk, "Paused") ROUTE_INACTIVE("TRACKSTATUS"_hk) |
| 49 | + SCREEN(0, 8, "Track status paused") |
| 50 | + SCREEN(0, 9, "") |
| 51 | + SCREEN(0,10, "") // several blank lines as needed |
| 52 | + SCREEN(0,11, "") |
| 53 | + SCREEN(0,12, "") |
| 54 | + SCREEN(0,13, "") |
| 55 | + SCREEN(0,14, "") |
| 56 | + SCREEN(0,15, "") |
| 57 | + SCREEN(0,16, "") |
| 58 | + PRINT("to pause/resume: </START TRACKSTATUS> \n") |
| 59 | + DONE ENDIF |
| 60 | + SET(8236) |
| 61 | + ROUTE_CAPTION("TRACKSTATUS"_hk, "Running") ROUTE_ACTIVE("TRACKSTATUS"_hk) |
| 62 | + PRINT("Resume JL Display") |
| 63 | + FOLLOW("PAUSETRACKSTATUS"_hk) |
| 64 | + SEQUENCE("PAUSETRACKSTATUS"_hk) |
| 65 | + PARSE("<JL 0 8>") // screen 0 start on line 8 |
| 66 | + PRINT("to pause/resume: </START TRACKSTATUS> \n") |
| 67 | + DELAY(3000) |
| 68 | + IF(8236) FOLLOW("PAUSETRACKSTATUS"_hk) ENDIF |
| 69 | + DONE |
| 70 | +// ************ End OLED JL Display Track mA Amperage ************** // |
| 71 | +
|
| 72 | +// Display motor shield after 10 seconds |
| 73 | +AUTOSTART |
| 74 | + DELAY(10000) |
| 75 | + STEALTH(StringFormatter::lcd(1, F("MS: %S"), DCC::getMotorShieldName());) |
| 76 | +DONE |
| 77 | +``` |
0 commit comments