Changeset 928

Show
Ignore:
Timestamp:
11/13/00 19:31:48 (13 years ago)
Author:
frodo
Message:

Display stuff as Fahrenheits; patch of Kelsey Hudson

<khudson@… >

Location:
lm-sensors/trunk/prog/sensors
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/sensors/chips.c

    r909 r928  
    2929static void print_label(const char *label, int space); 
    3030static void free_the_label(char **label); 
     31static void print_temp_info( float, float, float ); 
     32static inline float deg_ctof( float ); 
     33 
     34extern int fahrenheit; 
    3135 
    3236char *spacestr(int n) 
     
    3842  buf[n] = '\0'; 
    3943  return buf; 
     44} 
     45 
     46inline float deg_ctof( float cel ) 
     47{ 
     48   return ( cel * ( 9.0F / 5.0F ) + 32.0F ); 
     49} 
     50 
     51void print_temp_info( float cur, float over, float hyst ) 
     52{ 
     53   char degv[5]; 
     54 
     55   float n_cur,  
     56         n_over,  
     57         n_hyst; 
     58 
     59   if ( fahrenheit ) 
     60   { 
     61      sprintf( degv, "%cF", 176 ); 
     62      n_cur  = deg_ctof( cur  ); 
     63      n_over = deg_ctof( over ); 
     64      n_hyst = deg_ctof( hyst ); 
     65   } 
     66   else 
     67   { 
     68      sprintf( degv, "%cC", 176 ); 
     69      n_cur  = cur; 
     70      n_over = over; 
     71      n_hyst = hyst; 
     72   } 
     73 
     74   printf( "%+3.0f%s     (limit = %+3.0f%s,  hysteresis = %+3.0f%s)", 
     75           n_cur, degv, n_over, degv, n_hyst, degv ); 
    4076} 
    4177 
     
    82118    if (valid) { 
    83119      print_label(label,10); 
    84       printf("%6.1f C (limit: %6.1f C, hysteresis: %6.1f C)\n", 
    85              cur,over,hyst); 
     120      print_temp_info( cur, over, hyst ); 
     121      printf( "\n" ); 
    86122    } 
    87123  } else 
     
    109145    if (valid) { 
    110146      print_label(label,10); 
    111       printf("%4.0f C (limit: %4.0f C, hysteresis: %4.0f C)    ", 
    112              cur,over,hyst); 
     147      print_temp_info( cur, over, hyst ); 
    113148      if (alarms & (ADM1021_ALARM_TEMP_HIGH | ADM1021_ALARM_TEMP_LOW)) { 
    114149        printf("ALARM ("); 
     
    135170    if (valid) { 
    136171      print_label(label,10); 
    137       printf("%4.0f C (limit: %4.0f C, hysteresis: %4.0f C)    ", 
    138              cur,over,hyst); 
     172      print_temp_info( cur, over, hyst ); 
    139173      if (alarms & (ADM1021_ALARM_RTEMP_HIGH | ADM1021_ALARM_RTEMP_LOW | 
    140174                    ADM1021_ALARM_RTEMP_NA)) { 
     
    192226    if (valid) { 
    193227      print_label(label,10); 
    194       printf("%+6.2f V  (min = %+6.2f V, max = %+6.2f V)   %s\n", 
     228      printf( "%+6.2f V  (min = %+6.2f V, max = %+6.2f V)   %s\n", 
    195229             cur,min,max,alarms&ADM9240_ALARM_IN0?"ALARM":""); 
    196230    } 
     
    290324    if (valid) { 
    291325      print_label(label,10); 
    292       printf("%+3.0f C     (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    293              cur,max,min, alarms&ADM9240_ALARM_TEMP?"ALARM":""); 
     326      print_temp_info( cur, min, max ); 
     327      printf( " %s\n", alarms & ADM9240_ALARM_TEMP ? "ALARM" : "" ); 
    294328    } 
    295329  } else 
     
    409443    if (valid) { 
    410444      print_label(label,10); 
    411       printf("%+3.0f C     (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    412              cur,max,min, alarms&SIS5595_ALARM_TEMP?"ALARM":""); 
     445      print_temp_info( cur, min, max ); 
     446      printf( " %s\n", alarms & SIS5595_ALARM_TEMP ? "ALARM" : "" ); 
    413447    } 
    414448  } else 
     
    531565    if (valid) { 
    532566      print_label(label,10); 
    533       printf("%+3.1f C     (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    534              cur,max,min, alarms&VIA686A_ALARM_TEMP?"ALARM":""); 
     567      print_temp_info( cur, min, max ); 
     568      printf(" %s\n", alarms & VIA686A_ALARM_TEMP ? "ALARM" : "" ); 
    535569    } 
    536570  } else 
     
    543577    if (valid) { 
    544578      print_label(label,10); 
    545       printf("%+3.1f C     (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    546              cur,max,min, alarms&VIA686A_ALARM_TEMP2?"ALARM":""); 
     579      print_temp_info( cur, min, max ); 
     580      printf(" %s\n", alarms & VIA686A_ALARM_TEMP2 ? "ALARM" : "" ); 
    547581    } 
    548582  } else 
     
    555589    if (valid) { 
    556590      print_label(label,10); 
    557       printf("%+3.1f C     (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    558              cur,max,min, alarms&VIA686A_ALARM_TEMP3?"ALARM":""); 
     591      print_temp_info( cur, min, max ); 
     592      printf(" %s\n", alarms & VIA686A_ALARM_TEMP3 ? "ALARM" : "" ); 
    559593    } 
    560594  } else 
     
    706740    if (valid) { 
    707741      print_label(label,10); 
    708       printf("%+3.0f C     (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    709              cur,max,min, alarms&LM78_ALARM_TEMP?"ALARM":""); 
     742      print_temp_info( cur, max, min ); 
     743      printf( " %s\n", alarms & LM78_ALARM_TEMP ? "ALARM" : "" ); 
    710744    } 
    711745  } else 
     
    899933    if (valid) { 
    900934      print_label(label,10); 
    901       printf("%+3.0f C     (limit = %+3.0f C,  hysteresis = %+3.0f C) %s  %s\n", 
    902              cur,max,min, alarms&GL518_ALARM_TEMP?"ALARM":"     ", 
     935      print_temp_info( cur, max, min ); 
     936      printf("%s  %s\n", alarms&GL518_ALARM_TEMP?"ALARM":"     ", 
    903937             beeps&GL518_ALARM_TEMP?"(beep)":""); 
    904938    } 
     
    10131047    if (valid) { 
    10141048      print_label(label,10); 
    1015       printf("%+3.0f C   (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n", 
    1016            cur,max,min, alarms&ADM1025_ALARM_TEMP?"ALARM":""); 
     1049      print_temp_info( cur, max, min ); 
     1050      printf(" %s\n", alarms&ADM1025_ALARM_TEMP?"ALARM":""); 
    10171051    } 
    10181052  } else 
     
    11531187    if (valid) { 
    11541188      print_label(label,10); 
    1155       printf("%+3.2f C (hot:limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
     1189 
     1190      if ( fahrenheit ) 
     1191      { 
     1192      printf("%+3.2f°C (hot:limit = %+3.0f°F,  hysteresis = %+3.0f°F) %s\n", 
     1193           deg_ctof(cur),deg_ctof(max),deg_ctof(min), alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
     1194    printf("         (os: limit = %+3.0f°F,  hysteresis = %+3.0f°F) %s\n", 
     1195           deg_ctof(max2),deg_ctof(min2), alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
     1196      } 
     1197      else 
     1198      { 
     1199      printf("%+3.2f °C (hot:limit = %+3.0f°C,  hysteresis = %+3.0f°C) %s\n", 
    11561200           cur,max,min, alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
    1157     printf("         (os: limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
     1201    printf("         (os: limit = %+3.0f°C,  hysteresis = %+3.0f°C) %s\n", 
    11581202           max2,min2, alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
     1203      } 
    11591204    } 
    11601205  } else 
     
    13181363    if (valid) { 
    13191364      print_label(label,10); 
    1320       printf("%+6.0f C  (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    1321              cur,max,min, alarms&MTP008_ALARM_TEMP1?"ALARM":""); 
     1365      print_temp_info( cur, max, min ); 
     1366      printf(" %s\n", alarms&MTP008_ALARM_TEMP1?"ALARM":""); 
    13221367    } 
    13231368  } else 
     
    13311376    if (valid) { 
    13321377      print_label(label,10); 
    1333       printf("%+6.0f C  (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    1334              cur,max,min, alarms&MTP008_ALARM_TEMP2?"ALARM":""); 
     1378      print_temp_info( cur, max, min ); 
     1379      printf(" %s\n", alarms&MTP008_ALARM_TEMP2?"ALARM":""); 
    13351380    } 
    13361381  } else 
     
    13441389    if (valid) { 
    13451390      print_label(label,10); 
    1346       printf("%+6.0f C  (limit = %+3.0f C,  hysteresis = %+3.0f C) %s\n", 
    1347              cur,max,min, alarms&MTP008_ALARM_TEMP3?"ALARM":""); 
     1391      print_temp_info( cur, max, min ); 
     1392      printf(" %s\n", alarms&MTP008_ALARM_TEMP3?"ALARM":""); 
    13481393    } 
    13491394  } else 
     
    15081553      } 
    15091554    } else 
    1510       printf("ERROR: Can't get IN6 data!\n"); 
     1555      printf("ERROR: Can't get IN8 data!\n"); 
    15111556    free_the_label(&label); 
    15121557  } 
     
    15591604      if((!is82d) && (!is83s)) { 
    15601605        print_label(label,10); 
    1561         printf("%+3.0f C   (limit = %+3.0f C, hysteresis = %+3.0f C) %s  %s\n", 
    1562                cur,max,min, alarms&W83781D_ALARM_TEMP1 ?"ALARM":"     ", 
     1606        print_temp_info( cur, max, min ); 
     1607        printf(" %s  %s\n", alarms&W83781D_ALARM_TEMP1 ?"ALARM":"     ", 
    15631608               beeps&W83781D_ALARM_TEMP1?"(beep)":""); 
    15641609      } else { 
    15651610        if(!sensors_get_feature(*name,SENSORS_W83781D_SENS1,&sens)) { 
    15661611          print_label(label,10); 
    1567           printf( 
    1568   "%+3.0f C  (limit = %+3.0f C, hysteresis = %+3.0f C, sensor = %s) %s  %s\n", 
    1569                  cur,max,min, 
     1612          print_temp_info( cur, max, min ); 
     1613          printf( " sensor = %s   %s   %s\n", 
    15701614                 (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? 
    15711615                 "3904 transistor":"thermistor", 
     
    15881632      if((!is82d) && (!is83s)) { 
    15891633        print_label(label,10); 
    1590         printf("%+3.1f C   (limit = %+3.1f C, hysteresis = %+3.1f C) %s  %s\n", 
    1591                cur,max,min, alarms&W83781D_ALARM_TEMP23 ?"ALARM":"     ", 
    1592                beeps&W83781D_ALARM_TEMP23?"(beep)":""); 
     1634        print_temp_info( cur, max, min ); 
     1635        printf(" %s  %s\n", alarms&W83781D_ALARM_TEMP2 ?"ALARM":"     ", 
     1636               beeps&W83781D_ALARM_TEMP2?"(beep)":""); 
    15931637      } else { 
    15941638        if(!sensors_get_feature(*name,SENSORS_W83781D_SENS2,&sens)) { 
    15951639          print_label(label,10); 
    1596           printf( 
    1597   "%+3.1f C  (limit = %+3.1f C, hysteresis = %+3.1f C, sensor = %s) %s  %s\n", 
    1598                  cur,max,min, 
     1640          print_temp_info( cur, max, min ); 
     1641          printf( " sensor = %s   %s   %s\n", 
    15991642                 (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? 
    16001643                 "3904 transistor":"thermistor", 
     
    16181661        if(!is82d) { 
    16191662          print_label(label,10); 
    1620           printf("%+3.1f C   (limit = %+3.1f C, hysteresis = %+3.1f C) %s  %s\n", 
    1621                  cur,max,min, alarms&W83781D_ALARM_TEMP23 ?"ALARM":"     ", 
    1622                  beeps&W83781D_ALARM_TEMP23?"(beep)":""); 
     1663          print_temp_info( cur, max, min ); 
     1664          printf(" %s  %s\n", alarms&W83781D_ALARM_TEMP2 ?"ALARM":"     ", 
     1665                 beeps&W83781D_ALARM_TEMP3?"(beep)":""); 
    16231666        } else { 
    16241667          if(!sensors_get_feature(*name,SENSORS_W83781D_SENS3,&sens)) { 
    16251668            print_label(label,10); 
    1626             printf( 
    1627   "%+3.1f C  (limit = %+3.1f C, hysteresis = %+3.1f C, sensor = %s) %s  %s\n", 
    1628                    cur,max,min, 
     1669            print_temp_info( cur, max, min ); 
     1670            printf( " sensor = %s   %s   %s\n", 
    16291671                   (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? 
    16301672                   "3904 transistor":"thermistor", 
     
    16921734      if (valid && (cur || max || min)) { 
    16931735         print_label(label, 12); 
    1694          printf("%+3.1f C     (limit = %+3.1f C, hysteresis = %+3.1f C)\n", 
    1695                 cur, max, min); 
     1736         print_temp_info( cur, max, min ); 
     1737         printf("\n"); 
    16961738      } 
    16971739   } else 
     
    17051747      if (valid && (cur || max || min)) { 
    17061748         print_label(label, 12); 
    1707          printf("%+3.1f C     (limit = %+3.1f C, hysteresis = %+3.1f C) %s\n", 
    1708                 cur, max, min, alarms&MAXI_ALARM_TEMP2 ? "ALARM" : ""); 
     1749         print_temp_info( cur, max, min ); 
     1750         printf(" %s\n", alarms&MAXI_ALARM_TEMP2 ? "ALARM" : ""); 
    17091751      } 
    17101752   } else 
     
    17181760      if (valid && (cur || max || min)) { 
    17191761         print_label(label, 12); 
    1720          printf("%+3.1f C     (limit = %+3.1f C, hysteresis = %+3.1f C)\n", 
    1721                 cur, max, min); 
     1762         print_temp_info( cur, max, min ); 
     1763         printf("\n"); 
    17221764      } 
    17231765   } else 
     
    17311773      if (valid && (cur || max || min)) { 
    17321774         print_label(label, 12); 
    1733          printf("%+3.1f C     (limit = %+3.1f C, hysteresis = %+3.1f C) %s\n", 
    1734                 cur, max, min, alarms&MAXI_ALARM_TEMP4 ? "ALARM" : ""); 
     1775         print_temp_info( cur, max, min ); 
     1776         printf(" %s\n", alarms&MAXI_ALARM_TEMP4 ? "ALARM" : ""); 
    17351777      } 
    17361778   } else 
     
    17441786      if (valid && (cur || max || min)) { 
    17451787         print_label(label, 12); 
    1746          printf("%+3.1f C     (limit = %+3.1f C, hysteresis = %+3.1f C) %s\n", 
    1747                 cur, max, min, alarms&MAXI_ALARM_TEMP5 ? "ALARM" : ""); 
     1788         print_temp_info( cur, max, min ); 
     1789         printf(" %s\n", alarms&MAXI_ALARM_TEMP5 ? "ALARM" : ""); 
    17481790      } 
    17491791   } else 
  • lm-sensors/trunk/prog/sensors/main.c

    r909 r928  
    5252sensors_chip_name chips[CHIPS_MAX]; 
    5353int chips_count=0; 
    54 int do_sets, do_unknown; 
     54int do_sets, do_unknown, fahrenheit; 
    5555 
    5656void print_short_help(void) 
     
    6565  printf("  -h, --help            Display this help text\n"); 
    6666  printf("  -s, --set             Execute `set' statements too (root only)\n"); 
     67  printf("  -f, --fahrenheit      Show temperatures in degrees fahrenheit\n" ); 
    6768  printf("  -u, --unknown         Treat chips as unknown ones (testing only)\n"); 
    6869  printf("  -v, --version         Display the program version\n"); 
     
    137138    { "set", no_argument, NULL, 's' }, 
    138139    { "version", no_argument, NULL, 'v'}, 
     140    { "fahrenheit", no_argument, NULL, 'f' }, 
    139141    { "config-file", required_argument, NULL, 'c' }, 
    140142    { "unknown", required_argument, NULL, 'u' }, 
     
    145147  do_sets = 0; 
    146148  while (1) { 
    147     c = getopt_long(argc,argv,"hvusc:",long_opts,NULL); 
     149    c = getopt_long(argc,argv,"hvufsc:",long_opts,NULL); 
    148150    if (c == EOF) 
    149151      break; 
     
    164166    case 's': 
    165167      do_sets = 1; 
     168      break; 
     169    case 'f': 
     170      fahrenheit = 1; 
    166171      break; 
    167172    case 'u': 
  • lm-sensors/trunk/prog/sensors/sensors.1

    r848 r928  
    6565.IP -v 
    6666Returns the program version. 
     67.IP -f 
     68Prints the temperatures in degrees Fahrenheit instead of Celsius. 
    6769.SH FILES 
    6870.I /etc/sensors.conf