Touch screen drivers control dashboard for miniature locomotive. Features meters for speed, volts, power. Switches for lights, horns. Drives multiple STM3_ESC brushless motor controllers for complete brushless loco system as used in "The Brute" - www.jons-workshop.com
Dependencies: TS_DISCO_F746NG mbed Servo LCD_DISCO_F746NG BSP_DISCO_F746NG QSPI_DISCO_F746NG AsyncSerial FastPWM
Diff: cli_TS_nortos.cpp
- Revision:
- 14:6bcec5ac21ca
- Parent:
- 12:a25bdf135348
--- a/cli_TS_nortos.cpp Mon Jan 14 16:51:16 2019 +0000
+++ b/cli_TS_nortos.cpp Mon Mar 04 17:47:27 2019 +0000
@@ -102,10 +102,10 @@
count++;
pc.printf ("Board Count = %d\r\n", count);
if (count) {
- pc.printf ("Boards found ^");
+ pc.printf ("Boards found [");
for (int i = 0; i < count; i++)
pc.printf ("%c ", boards[i]);
- pc.printf ("\r\n");
+ pc.printf ("]\r\n");
}
else
pc.printf ("No STM3_ESC boards found\r\n");
@@ -127,28 +127,52 @@
pc.printf ("ver_req_cmd not yet implemented\r\n");
}
+void queryv (struct parameters & a) { // Handle response from ESC resulting from prior TSC "n?v\r" sent request - ESC'n' system voltage
+ pc.printf ("Responding ESC id=%d, volts=%.2f\r\n", (int)a.dbl[0], a.dbl[1]);
+}
+void queryi (struct parameters & a) { // Handle response from ESC resulting from prior TSC "n?i\r" sent request - ESC'n' motor pair currents
+ pc.printf ("Responding ESC id=%d, I MotorA=%.2f, I MotorB=%.2f\r\n", (int)a.dbl[0], a.dbl[1], a.dbl[2]);
+}
+
struct kb_command {
const char * cmd_word; // points to text e.g. "menu"
const char * explan;
void (*f)(struct parameters &); // points to function
} ;
+/**
+* struct kb_command const command_list[] = {
+*
+* struct kb_command const xx_list[]
+*
+* Each line in list has 3 elements
+* e.g. "ver\r" is message we may expect to be recieved here as a command or command response sent from somewhere else
+* "waffle" is purely to inform you something about this message
+* cmd is pointer to function, the what to do in response to the incoming message
+* function type is void (*foo) (struct parameters &)
+* This gives function access to parameters recieved with the message, e.g. "?i 7.45 8.23\r"
+* User is at liberty to send using e.g. 'STM3_ESC_Interface::message' anything to any remote connected entity at any time.
+* It is up to the user to ensure whatever is out there can make sense of it !
+* The list of commands and responses the 'Brute_TS_Controller' is expected to recognise and act upon
+* One such list for commands from pc terminal, another for comms with some number of STM3_Esc boards
+*/
struct kb_command const command_list[] = {
{"ls", "Lists available commands", menucmd},
- {"?", "Lists available commands, same as ls", menucmd},
- {"ver", "report const_version_string", TSver_cmd}, // Report TS controller version
+ {"?", "Lists available commands, same as ls", menucmd}, // Send this list, a menu
+ {"ver", "report const_version_string", TSver_cmd}, // Report TS controller version
{"boards", "List STM3_ESC boards connected", boards_cmd},
- {"kd", "kick the dog", kd_cmd},
+ {"kd", "kick the dog", kd_cmd}, // Broadcast Command to STM3_ESCs, resets and enables WatchDog timeout
+ {"?v", "Ask ESC for system voltage reading", queryv}, // Makes no sense for pc to ask this of TS controller, just to test function
+ {"?i", "Ask ESC for pair of motor current readings", queryi}, // Makes no sense for pc to ask this of TS controller, just to test function
{"nu", "do nothing", null_cmd},
-};
+} ;
struct kb_command const loco_command_list[] = {
- {"ls", "Lists available commands", menucmd},
- {"?", "Lists available commands, same as ls", menucmd},
{"who", "Reads 'whon' response from STM3_ESC where 'n' is board num ascii from eeprom", who_cmd},
{"ver", "report const_version_string", ver_req_cmd}, // Request software version of one specific ESC board
{"mph", "bogie mph reading", upmph_cmd}, // 22/06/2018
- {"nu", "do nothing", null_cmd},
+ {"?v", "Ask ESC for system voltage reading", queryv},
+ {"?i", "Ask ESC for pair of motor current readings", queryi},
} ;