zi6lidsw.c

来自「Note book LID switch function」· C语言 代码 · 共 102 行

C
102
字号
//---------------------------------------------------------------------------
// define program revision ( Compiler: Borland C++ V3.1 )
//---------------------------------------------------------------------------

#include<stdlib.h>
#include<stdio.h>
#include<dos.h>
#include "DECLARE.H"
#include "MISC.C"
#include "KBC.C"
#include "EC.C"

#define PROGRAM_VER "1.0"  // 12182003
#define LidAddr         0xf34C
//---------------------------------------------------------------------------
// MAIN routine
//---------------------------------------------------------------------------
void main ()
{
  int	        i;
  char          ch,item;
  BYTE          wRegDataw , RegAdr, wRegData ;
  BYTE          lid_status ;
  int           x,y,wait_i;
  char wait[] = { 0x7c,0x2f,0x2d,0x5c }; // { |, / , - ,\ }

  printf("\n[ZI6LIDSW.EXE] Program Version : %s ",PROGRAM_VER);         // show program version
  printf("\n Lid Status : ");

  x=wherex();
  y=wherey();

  while(1)
  {
    gotoxy(x,y);
    if(wait_i>=4) wait_i=0;
    printf("%c",wait[wait_i++]);

    lid_status = read_MCU_register(LidAddr); //bit0 1=on 0=off
    lid_status = lid_status & 0x01 ;
//    printf("lid_status=%Xh \n",lid_status);
    delay(50);

    if( lid_status == 0x01 )  // 0x01 = close
    {
      gotoxy(x,y);
      textcolor(9);
      cprintf("Lid Switch Pressed !!\r");
      textcolor(15);

      while(1)
      {

        lid_status = read_MCU_register(LidAddr); //bit0 1=on 0=off
        lid_status = lid_status & 0x01 ;
	sound(523);
	delay(100);
	sound(1046);
	delay(120);

       if( lid_status == 0x00 )  // 0x00 = open
	{
	 textcolor(10);
	 cprintf("\nLid Switch Released !! Test PASS !!\n");
	 textcolor(15);
	 sound(523);
	 delay(50);
	 sound(587);
	 delay(100);
	 sound(659);
	 delay(100);
	 sound(523);
	 delay(200);
	 nosound();
	 delay(200);
	 exit(0);
	}
         if (!(bioskey(1) ==0))
         {
          if (getch() == 0x1B)
           {
             nosound();
             printf("\nProgram Abort - 'ESC' Key Press !! Please Check It !!\n");
             delay(500);
             exit(1);
           }
         }
      } // while(1)
    } // if
     if (!(bioskey(1) ==0))
       {
         if (getch() == 0x1B)
          {
             nosound();
             printf("\nProgram Abort - 'ESC' Key Press !! Please Check It !!\n");
             exit(1);
          }
       }
  } // while(1)

}// main

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?