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 = "] ";
|
||||
|
||||
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(" %% ");
|
||||
|
||||
// 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;
|
||||
|
||||
// Bucle para almohadillas
|
||||
int num_veces = (int)(ancho * *porcentaje);
|
||||
for (uint16_t i = 0; i < (int)(ancho * *porcentaje); i++) {
|
||||
barra.append("#");
|
||||
}
|
||||
|
||||
// Bucle para guiones
|
||||
int num_veces = (int)(ancho - (ancho * *porcentaje));
|
||||
if (*porcentaje == 0) {
|
||||
num_veces--;
|
||||
}
|
||||
num_veces = ancho - num_veces;
|
||||
for (uint16_t i = 0; i < num_veces; i++) {
|
||||
barra.append("-");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user