diff options
author | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2011-03-16 21:31:25 +0000 |
---|---|---|
committer | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2011-03-16 21:31:25 +0000 |
commit | 7fb7b36002cd59d47e70222773bb1eb6aa37e340 (patch) | |
tree | 401a180359243543ea3c4a178f7c651c5bc3db6a | |
parent | 4becb5f4c574ef22e6759b0cfdec29966a638a4b (diff) | |
download | lm-sensors-7fb7b36002cd59d47e70222773bb1eb6aa37e340.tar.gz |
Ensure that hysteresis and the limit it relates to are always
printed on the same line.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5944 7894878c-1315-0410-8ee3-d5d059ff63e0
-rw-r--r-- | prog/sensors/chips.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index ba38ba82..d1d2a176 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -67,6 +67,8 @@ void print_chip_raw(const sensors_chip_name *name) } } +static const char hyst_str[] = "hyst"; + static inline double deg_ctof(double cel) { return cel * (9.0F / 5.0F) + 32.0F; @@ -154,12 +156,17 @@ static void print_limits(struct sensor_subfeature_data *limits, int alarm_count, int label_size, const char *fmt) { - int i; + int i, slot, skip; int alarms_printed = 0; - for (i = 0; i < limit_count; i++) { - if (!(i & 1)) { - if (i) + /* + * We print limits on two columns, filling lines first, except for + * hysteresis which must always go on the right column, with the + * limit it relates to being in the left column on the same line. + */ + for (i = slot = 0; i < limit_count; i++, slot++) { + if (!(slot & 1)) { + if (slot) printf("\n%*s", label_size + 10, ""); printf("("); } else { @@ -167,14 +174,20 @@ static void print_limits(struct sensor_subfeature_data *limits, } printf(fmt, limits[i].name, limits[i].value, limits[i].unit); - if ((i & 1) || i == limit_count - 1) { + + /* If needed, skip one slot to avoid hyst on first column */ + skip = i + 2 < limit_count && limits[i + 2].name == hyst_str && + !(slot & 1); + + if (((slot + skip) & 1) || i == limit_count - 1) { printf(")"); if (alarm_count && !alarms_printed) { print_alarms(alarms, alarm_count, - (i & 1) ? 0 : 16); + (slot & 1) ? 0 : 16); alarms_printed = 1; } } + slot += skip; } if (alarm_count && !alarms_printed) print_alarms(alarms, alarm_count, 32); @@ -239,18 +252,18 @@ static void get_sensor_limit_data(const sensors_chip_name *name, } static const struct sensor_subfeature_list temp_max_sensors[] = { - { SENSORS_SUBFEATURE_TEMP_MAX_HYST, NULL, 0, "hyst" }, + { SENSORS_SUBFEATURE_TEMP_MAX_HYST, NULL, 0, hyst_str }, { -1, NULL, 0, NULL } }; static const struct sensor_subfeature_list temp_crit_sensors[] = { - { SENSORS_SUBFEATURE_TEMP_CRIT_HYST, NULL, 0, "crit hyst" }, + { SENSORS_SUBFEATURE_TEMP_CRIT_HYST, NULL, 0, hyst_str }, { -1, NULL, 0, NULL } }; static const struct sensor_subfeature_list temp_emergency_sensors[] = { { SENSORS_SUBFEATURE_TEMP_EMERGENCY_HYST, NULL, 0, - "emerg hyst" }, + hyst_str }, { -1, NULL, 0, NULL } }; |