home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / veridata.zip / vwatch.c < prev    next >
Text File  |  1995-02-19  |  1KB  |  55 lines

  1. /*
  2.  * vwatch.c (monitor the power status of the Veridata EL-486S/25e notebook)
  3.  */
  4.  
  5. #include "veridata.h"
  6. #include "sound.h"
  7.  
  8. main()
  9. {
  10.    unsigned int status,
  11.                 level1_cnt, /* beep in level1 if this becomes 0 */
  12.                 led_on;     /* true if "Bat. Low" led is on */
  13.  
  14.    /* make sure we are in a known state */
  15.    status=_inp8(VERIDATA_PORT) & SAFETY_MASK | BAT_LOW_OFF;
  16.    _outp8(VERIDATA_PORT,status);
  17.    led_on=FALSE;
  18.    level1_cnt=0;
  19.   
  20.    while (TRUE) {
  21.       status=_inp8(VERIDATA_PORT);
  22.       switch (status & POWER_MASK) {
  23.       case POWER_OK:
  24.          if (led_on) {
  25.             _outp8(VERIDATA_PORT,status | BAT_LOW_OFF & SAFETY_MASK);
  26.             led_on=FALSE;
  27.          } 
  28.          break;
  29.       case POWER_LVL1:
  30.          if (level1_cnt == 0) {
  31.             level1_cnt=4;
  32.             beep(0xc8,0x02,50);
  33.          } else {
  34.             level1_cnt--;
  35.          }
  36.          if (led_on) {
  37.             _outp8(VERIDATA_PORT,status | BAT_LOW_OFF & SAFETY_MASK);
  38.             led_on=FALSE;
  39.          } else {
  40.             led_on=TRUE;
  41.             _outp8(VERIDATA_PORT,status & ~BAT_LOW_OFF & SAFETY_MASK);
  42.          }
  43.          break;
  44.       case POWER_LVL2:
  45.          beep(0x50,0x02,50);
  46.          if (!led_on) {
  47.             led_on=TRUE;
  48.             _outp8(VERIDATA_PORT,status & ~BAT_LOW_OFF & SAFETY_MASK);
  49.          }
  50.          break;
  51.       }
  52.     sleep(1);
  53.   }
  54. }
  55.