Corregir CpuMon para obtener barras consistentes
Signed-off-by: somebody_master <somebody_master@somebodyserver.mooo.com>
This commit is contained in:
parent
c505350e6d
commit
a3b6ea0cab
@ -147,7 +147,15 @@ std::string CpuMon::obtenerBarra(float *porcentaje, uint8_t *cpu) {
|
|||||||
}
|
}
|
||||||
std::string cierre = "] ";
|
std::string cierre = "] ";
|
||||||
|
|
||||||
cierre.append(std::to_string((int)(100 * *porcentaje)));
|
int ent_por = (int)(100 * *porcentaje);
|
||||||
|
|
||||||
|
if (ent_por < 10) {
|
||||||
|
cierre.append(" ");
|
||||||
|
} else if (ent_por < 100) {
|
||||||
|
cierre.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
cierre.append(std::to_string(ent_por));
|
||||||
cierre.append(" %% ");
|
cierre.append(" %% ");
|
||||||
|
|
||||||
// El ancho se calcula con el ancho máximo menos la longitud de los caracteres
|
// El ancho se calcula con el ancho máximo menos la longitud de los caracteres
|
||||||
@ -155,15 +163,13 @@ std::string CpuMon::obtenerBarra(float *porcentaje, uint8_t *cpu) {
|
|||||||
int ancho = CpuMon::columnas - barra.length() - cierre.length() - 3;
|
int ancho = CpuMon::columnas - barra.length() - cierre.length() - 3;
|
||||||
|
|
||||||
// Bucle para almohadillas
|
// Bucle para almohadillas
|
||||||
|
int num_veces = (int)(ancho * *porcentaje);
|
||||||
for (uint16_t i = 0; i < (int)(ancho * *porcentaje); i++) {
|
for (uint16_t i = 0; i < (int)(ancho * *porcentaje); i++) {
|
||||||
barra.append("#");
|
barra.append("#");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para guiones
|
// Bucle para guiones
|
||||||
int num_veces = (int)(ancho - (ancho * *porcentaje));
|
num_veces = ancho - num_veces;
|
||||||
if (*porcentaje == 0) {
|
|
||||||
num_veces--;
|
|
||||||
}
|
|
||||||
for (uint16_t i = 0; i < num_veces; i++) {
|
for (uint16_t i = 0; i < num_veces; i++) {
|
||||||
barra.append("-");
|
barra.append("-");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user