Use integer type for item count instead of char

This commit is contained in:
Christian Göttsche 2020-10-29 23:17:12 +01:00 committed by cgzones
parent 59ef15b2ad
commit 43d274a617
3 changed files with 6 additions and 9 deletions

View File

@ -51,8 +51,7 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) {
int cpu = this->param;
if (cpu > this->pl->cpuCount) {
xSnprintf(buffer, size, "absent");
int items = this->curItems;
for (int i = 0; i < items; i++)
for (uint8_t i = 0; i < this->curItems; i++)
this->values[i] = 0;
return;
}

View File

@ -195,8 +195,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
// First draw in the bar[] buffer...
int offset = 0;
int items = this->curItems;
for (int i = 0; i < items; i++) {
for (uint8_t i = 0; i < this->curItems; i++) {
double value = this->values[i];
value = CLAMP(value, 0.0, this->total);
if (value > 0) {
@ -220,7 +219,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
// ...then print the buffer.
offset = 0;
for (int i = 0; i < items; i++) {
for (uint8_t i = 0; i < this->curItems; i++) {
attrset(CRT_colors[Meter_attributes(this)[i]]);
mvaddnstr(y, x + offset, bar + offset, blockSizes[i]);
offset += blockSizes[i];
@ -296,8 +295,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
Meter_updateValues(this, buffer, nValues - 1);
double value = 0.0;
int items = this->curItems;
for (int i = 0; i < items; i++)
for (uint8_t i = 0; i < this->curItems; i++)
value += this->values[i];
value /= this->total;
data->values[nValues - 1] = value;

View File

@ -42,7 +42,7 @@ typedef struct MeterClass_ {
const char* const uiName;
const char* const caption;
const char* const description;
const char maxItems;
const uint8_t maxItems;
} MeterClass;
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
@ -75,7 +75,7 @@ struct Meter_ {
GraphData* drawData;
int h;
const ProcessList* pl;
char curItems;
uint8_t curItems;
double* values;
double total;
void* meterData;