Add hwInfo in Info menu

This commit is contained in:
Federico Amedeo Izzo 2021-02-02 21:45:10 +01:00
parent 65b5c0b002
commit 83d91b555d
3 changed files with 34 additions and 9 deletions

View File

@ -112,38 +112,42 @@ const char *menu_items[8] =
};
#ifdef HAS_RTC
const char *settings_items[2] =
const char *settings_items[] =
{
"Time & Date",
"Display"
};
#else
const char *settings_items[1] =
const char *settings_items[] =
{
"Display"
};
#endif
#ifdef SCREEN_CONTRAST
const char *display_items[2] =
const char *display_items[] =
{
"Brightness",
"Contrast"
};
#else
const char *display_items[1] =
const char *display_items[] =
{
"Brightness",
};
#endif
const char *info_items[4] =
const char *info_items[] =
{
"Model",
"Bat. Voltage",
"Bat. Charge",
"RSSI",
"Model",
"Band",
"VHF",
"UHF",
"LCD Type"
};
const char *authors[4] =
const char *authors[] =
{
"Niccolo' IU2KIN",
"Silvano IU2KWO",

View File

@ -23,6 +23,7 @@
#include <string.h>
#include <ui.h>
#include <interfaces/nvmem.h>
#include <interfaces/platform.h>
void _ui_drawMenuList(point_t pos, uint8_t selected, int (*getCurrentEntry)(char *buf, uint8_t max_len, uint8_t index))
{
@ -132,15 +133,24 @@ int _ui_getInfoEntryName(char *buf, uint8_t max_len, uint8_t index)
int _ui_getInfoValueName(char *buf, uint8_t max_len, uint8_t index)
{
const hwInfo_t* hwinfo = platform_getHwInfo();
if(index >= info_num) return -1;
if(strcmp(info_items[index], "Model") == 0)
snprintf(buf, max_len, "%s", "");
else if(strcmp(info_items[index], "Bat. Voltage") == 0)
snprintf(buf, max_len, "%.1fV", last_state.v_bat);
else if(strcmp(info_items[index], "Bat. Charge") == 0)
snprintf(buf, max_len, "%.1f%%", last_state.charge * 100);
else if(strcmp(info_items[index], "RSSI") == 0)
snprintf(buf, max_len, "%.1fdBm", last_state.rssi);
if(strcmp(info_items[index], "Model") == 0)
snprintf(buf, max_len, "%s", hwinfo->name);
if(strcmp(info_items[index], "Band") == 0)
snprintf(buf, max_len, "%s %s", hwinfo->vhf_band ? "VHF" : "", hwinfo->uhf_band ? "UHF" : "");
else if(strcmp(info_items[index], "VHF") == 0)
snprintf(buf, max_len, "%d - %d", hwinfo->vhf_minFreq, hwinfo->vhf_maxFreq);
else if(strcmp(info_items[index], "UHF") == 0)
snprintf(buf, max_len, "%d - %d", hwinfo->uhf_minFreq, hwinfo->uhf_maxFreq);
else if(strcmp(info_items[index], "LCD Type") == 0)
snprintf(buf, max_len, "%d", hwinfo->lcd_type);
return 0;
}

View File

@ -20,9 +20,15 @@
#include <stdio.h>
#include "emulator.h"
hwInfo_t hwInfo;
void platform_init()
{
//printf("Platform init\n");
// Fill hwinfo struct
snprintf(hwInfo.name, 10, "Linux");
hwInfo.vhf_band = 1;
hwInfo.uhf_band = 1;
}
void platform_terminate()
@ -111,3 +117,8 @@ const void *platform_getCalibrationData()
{
return NULL;
}
const hwInfo_t *platform_getHwInfo()
{
return &hwInfo;
}