1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-04-24 19:50:31 +00:00

System status page

This commit is contained in:
Gerald Schnabel
2023-02-12 14:43:54 +01:00
parent 8a4a1ce21e
commit 259c2f6cde
7 changed files with 94 additions and 10 deletions

63
menu.c
View File

@@ -49,6 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "menu-minimig.h"
#include "menu-8bit.h"
#include "settings.h"
#include "usb.h"
// test features (not used right now)
// #define ALLOW_TEST_MENU 0 //remove to disable in prod version
@@ -461,6 +462,10 @@ static char GetMenuPage_System(uint8_t idx, char action, menu_page_t *page) {
page->title = "USB";
page->timer = 10;
break;
case 10:
page->title = "Status";
page->timer = 10;
break;
}
return 0;
}
@@ -484,6 +489,7 @@ static char GetMenuItem_System(uint8_t idx, char action, menu_item_t *item) {
else if (idx<=33) {item->page = (page_idx>=4 && page_idx<=7) ? page_idx : 4; item->active = 0;}
else if (idx<=37) {item->page = 8; item->active = 0;}
else if (idx<=43) {item->page = 9; item->active = 0;}
else if (idx<=49) {item->page = 10; item->active = 0;}
else return 0;
if (item->page != page_idx) return 1; // shortcut
@@ -522,13 +528,11 @@ static char GetMenuItem_System(uint8_t idx, char action, menu_item_t *item) {
item->item = " Save settings";
break;
case 5:
item->item = " About";
item->item = " Status";
item->newpage = 10;
break;
case 6:
siprintf(s, " %-3s / %9luMB / %-7s", fat_uses_mmc() ? "SD" : "USB", storage_size, fs_type_to_string());
item->item = s;
item->active = 0;
item->item = " About";
break;
// page 1 - firmware & core
@@ -722,6 +726,50 @@ static char GetMenuItem_System(uint8_t idx, char action, menu_item_t *item) {
item->item = s;
break;
}
// page 10 - System status
case 44:
siprintf(s, " Boot device: %11s", fat_uses_mmc() ? " SD card" : "USB storage");
item->item = s;
break;
case 45:
siprintf(s, " Medium: %7s / %7luMB", fs_type_to_string(), storage_size);
item->item = s;
break;
case 46:
unsigned char keyboard_count = get_keyboards();
siprintf(s, " Keyboard:");
keyboard_count ? siprintf(s + 10, " %8u", keyboard_count) : siprintf(s + 10, " none");
siprintf(s + 19, " detected");
item->item = s;
break;
case 47:
unsigned char mouse_count = get_mice();
siprintf(s, " Mouse:");
mouse_count ? siprintf(s + 7, " %11u", mouse_count) : siprintf(s + 7, " none");
siprintf(s + 19, " detected");
item->item = s;
break;
case 48:
uint8_t *mac = get_mac();
siprintf(s, " Network:");
if (mac) {
siprintf(s + 9, " %02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2],
mac[3], mac[4], mac[5]);
} else {
siprintf(s + 9, " none detected");
}
item->item = s;
break;
case 49:
uint8_t pl2303_count = get_pl2303s();
siprintf(s, " Serial:");
pl2303_count ? siprintf(s + 8, " %10u", pl2303_count) : siprintf(s + 8, " none");
siprintf(s + 19, " detected");
item->item = s;
break;
default:
item->active = 0;
}
@@ -756,6 +804,9 @@ static char GetMenuItem_System(uint8_t idx, char action, menu_item_t *item) {
ErrorMessage("\n Error writing settings!\n", 0);
break;
case 5:
item->newpage = 10;
break;
case 6:
parentstate = MENU_8BIT_ABOUT1;
menusub = 0;
break;
@@ -1350,7 +1401,7 @@ void HandleUI(void)
// menu key closes menu
if (menu || select || left) {
menustate = MENU_NG;
menusub = 5;
menusub = 6;
}
break;
/*

View File

@@ -27,6 +27,15 @@ static uint16_t tx_cnt, tx_offset;
bool eth_present = 0;
usb_asix_info_t *eth_info;
uint8_t *get_mac(void) {
if (eth_present) {
return eth_info->mac;
}
return NULL;
}
// currently only AX88772 is supported as that's the only
// device i have
#define ASIX_TYPE_AX88772 0x01
@@ -505,6 +514,7 @@ static uint8_t usb_asix_init(usb_device_t *dev, usb_device_descriptor_t *dev_des
// finally inform core about ethernet support
tos_update_sysctrl(tos_system_ctrl() | TOS_CONTROL_ETHERNET);
eth_info = info;
eth_present = 1;
return 0;

View File

@@ -21,5 +21,6 @@ typedef struct {
// interface to usb core
extern const usb_device_class_config_t usb_asix_class;
void usb_asix_xmit(uint16_t len);
uint8_t *get_mac(void);
#endif // ASIX_H

View File

@@ -18,8 +18,17 @@
static unsigned char kbd_led_state = 0; // default: all leds off
static unsigned char keyboards = 0; // number of detected usb keyboards
static unsigned char mice = 0; // number of detected usb mice
unsigned char get_keyboards(void) {
return keyboards;
}
unsigned char get_mice(void) {
return mice;
}
// up to 8 buttons can be remapped
#define MAX_JOYSTICK_BUTTON_REMAP 8
@@ -206,6 +215,7 @@ static uint8_t usb_hid_parse_conf(usb_device_t *dev, uint8_t conf, uint16_t len)
case HID_PROTOCOL_KEYBOARD:
hid_debugf("HID protocol is KEYBOARD");
info->iface[info->bNumIfaces].device_type = HID_DEVICE_KEYBOARD;
keyboards++;
break;
case HID_PROTOCOL_MOUSE:
@@ -345,7 +355,7 @@ static uint8_t usb_hid_init(usb_device_t *dev, usb_device_descriptor_t *dev_desc
return rcode;
}
if(info->iface[i].device_type == REPORT_TYPE_NONE) {
if(info->iface[i].device_type == HID_DEVICE_UNKNOWN) {
// bInterfaceProtocol was 0 ("none") -> try to parse anyway
iprintf("HID NONE: report type = %d, size = %d\n",
info->iface[i].conf.type, info->iface[i].conf.report_size);
@@ -355,19 +365,19 @@ static uint8_t usb_hid_init(usb_device_t *dev, usb_device_descriptor_t *dev_desc
if((info->iface[i].conf.type == REPORT_TYPE_KEYBOARD) &&
(info->iface[i].conf.report_size == 8)) {
iprintf("HID NONE: is keyboard (arduino?)\n");
info->iface[i].device_type = REPORT_TYPE_KEYBOARD;
info->iface[i].device_type = HID_DEVICE_KEYBOARD;
info->iface[i].has_boot_mode = true; // assume that the report is boot mode style as it's 8 bytes in size
}
}
if(info->iface[i].device_type == REPORT_TYPE_MOUSE) {
if(info->iface[i].device_type == HID_DEVICE_MOUSE) {
iprintf("MOUSE: report type = %d, id = %d, size = %d\n",
info->iface[i].conf.type,
info->iface[i].conf.report_id,
info->iface[i].conf.report_size);
}
if(info->iface[i].device_type == REPORT_TYPE_JOYSTICK) {
if(info->iface[i].device_type == HID_DEVICE_JOYSTICK) {
char k;
iprintf("JOYSTICK: report type = %d, id = %d, size = %d\n",
@@ -456,6 +466,11 @@ static uint8_t usb_hid_release(usb_device_t *dev) {
joystick_release(c_jindex);
}
// check if a keyboard is released
if(info->iface[i].device_type == HID_DEVICE_KEYBOARD) {
keyboards--;
}
// check if a mouse is released
if(info->iface[i].device_type == HID_DEVICE_MOUSE) {
uint8_t c_jindex = info->iface[i].jindex;

View File

@@ -100,6 +100,8 @@ extern const usb_device_class_config_t usb_hid_class;
void hid_set_kbd_led(unsigned char led, bool on);
uint8_t hid_get_joysticks(void);
int8_t hid_keyboard_present(void);
unsigned char get_keyboards(void);
unsigned char get_mice(void);
// HID low-level remapping - do not confuse with virtual joystick in joymapping.h
void hid_joystick_button_remap_init(void);

View File

@@ -47,6 +47,10 @@ static uint8_t tx_buf_fill;
static uint8_t adapter_count = 0;
uint8_t get_pl2303s(void) {
return adapter_count;
}
// return true if there's a pl2303 present and if that has
// its tx buffer full. This will then stop reading data from the
// core so it can throttle

View File

@@ -76,5 +76,6 @@ void pl2303_tx_byte(uint8_t byte);
uint8_t pl2303_rx_available(void);
uint8_t pl2303_rx(void);
int8_t pl2303_is_blocked(void);
uint8_t get_pl2303s(void);
#endif // PL2303_H