Fixed back button in some areas, fixed rounding of byte values

main
xad1 3 years ago
parent 3217a8d785
commit 73e770da1c

@ -1,7 +1,7 @@
#ifndef PIN_H
#define PIN_H
#include <Arduino.h>
const String LOCK_PIN = "454";
const String LOCK_PIN = "";
/**
* 0 = A Button
* 1 = B Button

@ -281,7 +281,13 @@ void poolMenuPrint(void *pool)
* @param backEnabled Whether the back button should be enabled for this menu.
* @param printMachine The callback function to print the name of the item.
*/
void listItems(void *items, void **item, const String title, const int &numItems, const int &itemSize, const bool &backEnabled, MenuPrintCallback printMachine)
void listItems(
void *items, void **item,
const String title,
const int &numItems,
const int &itemSize,
const bool &backEnabled,
MenuPrintCallback printMachine)
{
GO.lcd.clearDisplay();
GO.lcd.setCursor(0, 0);
@ -337,6 +343,7 @@ void listItems(void *items, void **item, const String title, const int &numItems
*/
void listNodes(Node *nodes, const int &numItems)
{
selectedItem = 0;
void *item;
listItems(nodes, &item, "Select Node", numItems, sizeof(Node), false, nodeMenuPrint);
@ -361,6 +368,7 @@ void listNodes(Node *nodes, const int &numItems)
*/
void listContainers(Container *containers, const int &numItems)
{
selectedItem = 0;
void *item;
listItems(containers, &item, "Select Container", numItems, sizeof(Container), true, containerMenuPrint);
@ -385,6 +393,7 @@ void listContainers(Container *containers, const int &numItems)
*/
void listVMs(VM *vms, const int &numItems)
{
selectedItem = 0;
void *item;
listItems(vms, &item, "Select VM", numItems, sizeof(VM), true, vmMenuPrint);
if (item != nullptr)
@ -408,6 +417,7 @@ void listVMs(VM *vms, const int &numItems)
*/
void listDisks(Disk *disks, const int &numItems)
{
selectedItem = 0;
void *item;
listItems(disks, &item, "Select Disk", numItems, sizeof(Disk), true, diskMenuPrint);
@ -432,6 +442,7 @@ void listDisks(Disk *disks, const int &numItems)
*/
void listPools(Pool *pools, const int &numItems)
{
selectedItem = 0;
void *item;
listItems(pools, &item, "Select Pool", numItems, sizeof(Pool), true, poolMenuPrint);
if (item != nullptr)

@ -15,6 +15,7 @@ const int UPDATE_INTERVAL = 3000;
/**
* @brief Function to convert bytes to more human readable formats. Works by checking if the value is over a certain size before dividing it and adding the appropriate label.
* Casts the value to a double before dividing so that the value can be displayed more accurately.
*
* @param value The value in bytes to convert.
* @return String The converted value in a human readable string.
@ -23,19 +24,23 @@ String convertBytes(const long long &value)
{
if (value > 1099511627776)
{
return String(value / 1099511627776) + " TiB";
double result = static_cast<double>(value) / 1099511627776.0;
return String(result, 2) + " TiB";
}
if (value > 1073741824)
{
return String(value / 1073741824) + " GiB";
double result = static_cast<double>(value) / 1073741824.0;
return String(result, 2) + " GiB";
}
if (value > 1048576)
{
return String(value / 1048576) + " MiB";
double result = static_cast<double>(value) / 1048576.0;
return String(result, 2) + " MiB";
}
if (value > 1024)
{
return String(value / 1024) + " KiB";
double result = static_cast<double>(value) / 1024.0;
return String(result, 2) + " KiB";
}
return String(value) + " Bytes";
}
@ -230,6 +235,8 @@ void containerInfo()
break;
}
}
mainMenu();
}
/**
@ -265,6 +272,7 @@ void vmInfo()
break;
}
}
mainMenu();
}
/**
@ -298,7 +306,9 @@ void diskInfo()
break;
}
}
}
mainMenu();
}
/**
@ -328,9 +338,10 @@ void poolInfo()
GO.update();
if (GO.BtnB.isPressed())
{
mainMenu();
poolInfo();
break;
}
}
}
mainMenu();
}
Loading…
Cancel
Save