1 /* Slot Configuration */
5 #include <avr/pgmspace.h>
8 #include "../monitor.h"
10 static char* boards[] = {
17 static uint8_t num_boards = sizeof(boards) / sizeof(boards[0]);
19 static uint8_t change_slot(uint8_t slot)
21 if(slot > 8) return(0);
24 uint8_t old_id = slots[slot];
27 printf_P(PSTR("CHANGING SLOT\n============\n"), slot);
28 for(uint8_t i = 0; i < num_boards; i++) {
29 printf_P(PSTR("\t(%2u) %s\n"), i, boards[i]);
33 /* TODO: fix this for IDs greater 9 */
34 printf_P(PSTR("Select new board for slot %u: "), slot);
35 sel = uart_getc(NULL);
38 if((unsigned)(sel - '0') < num_boards) {
39 slots[slot] = (sel - '0');
40 if(slots[slot] != old_id) changed = 1;
41 printf_P(PSTR("Set to ID 0x%02x ['%s']\n"),
42 (sel - '0'), boards[slots[slot]]);
44 printf_P(PSTR("ID was NOT not changed.\n"));
52 uint8_t menu_slots(void)
54 int slots_changed = 0;
58 printf_P(PSTR("\nSLOT CONFIGURATION\n==================\n"));
59 for(uint8_t i = 1; i <= 8; i++) {
60 char *name = "Invalid Entry";
62 if(slots[i] != 0xFF) name = boards[slots[i]];
63 printf_P(PSTR("\t(%u) Change Slot %u: 0x%02x [%s]\n"),
64 i, (i-1), slots[i], name);
66 printf_P(PSTR("\t(9) Exit\n"));
67 printf_P(PSTR("Select: "));
68 sel = uart_getc(NULL);
69 printf_P(PSTR("\n\n"));
72 case '1': case '2': case '3': case '4':
73 case '5': case '6': case '7': case '8':
74 printf_P(PSTR("Changing Slot %i\n"), (sel - '0'));
75 if(change_slot(sel - '0')) slots_changed = 1;
80 printf_P(PSTR("Invalid Entry!\n")); break;
83 return(slots_changed);