diff --git a/src/cpu_mon.cpp b/src/cpu_mon.cpp index cd48c4e..bcd1b39 100644 --- a/src/cpu_mon.cpp +++ b/src/cpu_mon.cpp @@ -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("-"); }