Permalink
Browse files

adjust units of amps, power factor, and duty cycle to match field des…

…criptions
  • Loading branch information...
pyrovski committed May 9, 2012
1 parent ef4685e commit 29aa604f3a2bdc1eba398bf09b2a76480213b3bc
Showing with 19 additions and 1 deletion.
  1. +19 −1 wattsup.c
View
@@ -839,8 +839,26 @@ static int filter_data(struct wu_packet * p, int i, char * buf)
{
if (i < wu_num_fields) {
if (wu_fields[i].enable) {
double scale;
int digits;
switch(i){
case wu_field_min_amps:
case wu_field_max_amps:
case wu_field_amps:
scale = 1000.0;
digits = 3;
break;
case wu_field_power_factor:
case wu_field_duty_cycle:
scale = 1.0;
digits = 1;
break;
default:
scale = 10.0;
digits = 1;
}
double val = strtod(p->field[i], NULL);
snprintf(buf, 256, "%.1f", val / 10.0);
snprintf(buf, 256, "%.*lf", digits, val / scale);
return 1;
}
}

0 comments on commit 29aa604

Please sign in to comment.