Skip to content

Commit 7f14e15

Browse files
Merge pull request #7250 from smlng/sys/phydat/enh_scale2str
sys, phydat: omit scale to string conversion if not applicable
2 parents db65120 + e4382ae commit 7f14e15

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

sys/phydat/phydat_str.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,22 @@ void phydat_dump(phydat_t *data, uint8_t dim)
3232
}
3333
printf("Data:");
3434
for (uint8_t i = 0; i < dim; i++) {
35-
char scale_str = phydat_scale_to_str(data->scale);
35+
char scale_str;
36+
37+
switch (data->unit) {
38+
case UNIT_UNDEF:
39+
case UNIT_NONE:
40+
case UNIT_M2:
41+
case UNIT_M3:
42+
case UNIT_PERCENT:
43+
case UNIT_TEMP_C:
44+
case UNIT_TEMP_F:
45+
/* no string conversion */
46+
scale_str = '\0';
47+
break;
48+
default:
49+
scale_str = phydat_scale_to_str(data->scale);
50+
}
3651

3752
printf("\t[%i] ", (int)i);
3853

0 commit comments

Comments
 (0)