application: remove now automatic find lcd action
This commit is contained in:
parent
9339db28b5
commit
e1a4a71c90
|
@ -70,9 +70,6 @@ static time_t time_start = 0;
|
|||
volatile bool rtc_internal_tick_flag = false; /**< flag set when internal RTC ticked */
|
||||
/** @} */
|
||||
|
||||
/** to disable the console print */
|
||||
bool disable_print = false;
|
||||
|
||||
/** activity timeout before switching off (in seconds) */
|
||||
#define SHUTDOWN_TIMEOUT 10
|
||||
|
||||
|
@ -82,9 +79,6 @@ bool disable_print = false;
|
|||
|
||||
size_t putc(char c)
|
||||
{
|
||||
if (disable_print) {
|
||||
return 0;
|
||||
}
|
||||
size_t length = 0; // number of characters printed
|
||||
static char last_c = 0; // to remember on which character we last sent
|
||||
if ('\n' == c) { // send carriage return (CR) + line feed (LF) newline for each LF
|
||||
|
@ -582,22 +576,11 @@ static void command_cables(void* argument)
|
|||
}
|
||||
|
||||
/** find out which USB cable is connected
|
||||
* @param[in] argument NULL to print on console, "lcd" to print on LCD
|
||||
* @param[in] argument no argument required
|
||||
*/
|
||||
static void command_find(void* argument)
|
||||
{
|
||||
char* arg = (char*)argument; // we won't use the argument
|
||||
bool print_lcd = false;
|
||||
|
||||
if (arg) {
|
||||
if (0 == strcmp(arg, "lcd")) {
|
||||
print_lcd = true;
|
||||
disable_print = true;
|
||||
} else {
|
||||
printf("unknown argument %s\n", arg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
(void)argument; // we won't use the argument
|
||||
|
||||
printf("= finding cable =\n");
|
||||
|
||||
|
@ -610,15 +593,6 @@ static void command_find(void* argument)
|
|||
if (NULL == cable.connections) {
|
||||
if (cable.connections_nb) {
|
||||
printf("no memory available\n");
|
||||
if (print_lcd) {
|
||||
lcd_hd44780_clear_display();
|
||||
char lcd_str[] = "testing error";
|
||||
lcd_hd44780_write_line(false, lcd_str, strlen(lcd_str));
|
||||
}
|
||||
} else {
|
||||
if (!print_lcd) {
|
||||
printf("no ground connections between connectors found\n");
|
||||
}
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
@ -640,11 +614,6 @@ static void command_find(void* argument)
|
|||
cable_cables(&cable);
|
||||
if (0 == cable.cables_nb) {
|
||||
printf("found no cable with matching connector set\n");
|
||||
if (print_lcd) {
|
||||
lcd_hd44780_clear_display();
|
||||
char lcd_str[] = "unknown cable";
|
||||
lcd_hd44780_write_line(false, lcd_str, strlen(lcd_str));
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
printf("found %u cable(s) with matching connectors:\n", cable.cables_nb);
|
||||
|
@ -660,38 +629,13 @@ static void command_find(void* argument)
|
|||
|
||||
// calculate score for cables
|
||||
cable_issues_nb(&cable);
|
||||
if (!print_lcd) {
|
||||
printf("cable connection issue(s):\n");
|
||||
for (uint8_t cable_i = 0; cable_i < LENGTH(usb_cables) && cable_i < LENGTH(cable.cables) && cable_i < LENGTH(cable.unconnected_nb) && cable_i < LENGTH(cable.unspecified_nb); cable_i++) {
|
||||
if (!cable.cables[cable_i]) { // skip if the cable connectors do not match
|
||||
continue;
|
||||
}
|
||||
uint16_t issues = cable.unconnected_nb[cable_i] + cable.unspecified_nb[cable_i];
|
||||
printf("- %02u %s: %u (unconnected=%u/%u, undefined=%u)\n", cable_i, usb_cables[cable_i].name, issues, cable.unconnected_nb[cable_i], usb_cables[cable_i].pin_pairs_nb, cable.unspecified_nb[cable_i]);
|
||||
printf("cable connection issue(s):\n");
|
||||
for (uint8_t cable_i = 0; cable_i < LENGTH(usb_cables) && cable_i < LENGTH(cable.cables) && cable_i < LENGTH(cable.unconnected_nb) && cable_i < LENGTH(cable.unspecified_nb); cable_i++) {
|
||||
if (!cable.cables[cable_i]) { // skip if the cable connectors do not match
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// print result to LCD
|
||||
if (print_lcd) {
|
||||
lcd_hd44780_clear_display();
|
||||
if (cable.cable_best < LENGTH(usb_cables) && cable.cable_best < LENGTH(cable.unconnected_nb) && cable.cable_best < LENGTH(cable.unspecified_nb)) {
|
||||
const struct usb_cable_t* usb_cable = &usb_cables[cable.cable_best];
|
||||
lcd_hd44780_write_line(false, usb_cable->name, strlen(usb_cable->name));
|
||||
uint16_t issues = cable.unconnected_nb[cable.cable_best] + cable.unspecified_nb[cable.cable_best];
|
||||
if (0 == issues) {
|
||||
lcd_hd44780_write_line(true, "perfect match", 13);
|
||||
} else {
|
||||
char score_str[17];
|
||||
uint8_t str_len = snprintf(score_str, LENGTH(score_str), "issues: %u", issues);
|
||||
if (str_len) {
|
||||
lcd_hd44780_write_line(true, score_str, str_len);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lcd_hd44780_write_line(false, "no matching", 11);
|
||||
lcd_hd44780_write_line(true, "cable found", 11);
|
||||
}
|
||||
goto end;
|
||||
uint16_t issues = cable.unconnected_nb[cable_i] + cable.unspecified_nb[cable_i];
|
||||
printf("- %02u %s: %u (unconnected=%u/%u, undefined=%u)\n", cable_i, usb_cables[cable_i].name, issues, cable.unconnected_nb[cable_i], usb_cables[cable_i].pin_pairs_nb, cable.unspecified_nb[cable_i]);
|
||||
}
|
||||
|
||||
// print connection details
|
||||
|
@ -708,7 +652,7 @@ static void command_find(void* argument)
|
|||
printf("perfect matching cable: %s\n", usb_cable->name);
|
||||
goto end;
|
||||
}
|
||||
printf("closes matching cable: %s\n", usb_cable->name);
|
||||
printf("closest matching cable: %s\n", usb_cable->name);
|
||||
printf("%u connection issue(s) (%u unconnected, %u unspecified)\n", issues, cable.unconnected_nb[cable.cable_best], cable.unspecified_nb[cable.cable_best]);
|
||||
if (cable.unconnected_nb[cable.cable_best] > 0) {
|
||||
printf("unconnected pins:\n");
|
||||
|
@ -753,7 +697,6 @@ static void command_find(void* argument)
|
|||
end:
|
||||
usb_pins_float(); // put all pins back in safe floating state
|
||||
cable_clear(&cable); // free allocated memory
|
||||
disable_print = false; // enable serial print again
|
||||
}
|
||||
|
||||
/** set or show pin value
|
||||
|
@ -1113,8 +1056,8 @@ static const struct menu_command_t menu_commands[] = {
|
|||
.shortcut = 'f',
|
||||
.name = "find",
|
||||
.command_description = "find cable",
|
||||
.argument = MENU_ARGUMENT_STRING,
|
||||
.argument_description = "[lcd]",
|
||||
.argument = MENU_ARGUMENT_NONE,
|
||||
.argument_description = NULL,
|
||||
.command_handler = &command_find,
|
||||
},
|
||||
{
|
||||
|
@ -1389,9 +1332,6 @@ void main(void)
|
|||
rcc_periph_clock_enable(RCC_GPIOG); // enable clock to all GPIO port domains since we use them all
|
||||
usb_pins_float(); // pull all pins to floating
|
||||
|
||||
// find cable after power up
|
||||
command_find("lcd");
|
||||
|
||||
// setup terminal
|
||||
terminal_prefix = ""; // set default prefix
|
||||
terminal_process = &process_command; // set central function to process commands
|
||||
|
|
Loading…
Reference in New Issue