


Source code
/*FAN.H header file*/
#include
#include
unsigned char bit_manipulation(unsigned char value)
{
unsigned char bit_value;
bit_value=inportb(0x378);
//printf("Before manipulation %d",bit_value);
bit_value=bit_value value;
//printf("after manipulation %d",bit_value);
return bit_value;
}
void switch_on_fan()
{
unsigned char port_value;
port_value=bit_manipulation(64);
outportb(0x378,port_value);
}
void fan_speed_0()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&120;
//port_value=bit_manipulation(0);
outportb(0x378,port_value);
}
void fan_speed_1()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&120;
port_value=port_value0;
outportb(0x378,port_value);
}
void fan_speed_2()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&120;
port_value=port_value1;
outportb(0x378,port_value);
}
void fan_speed_3()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&120;
port_value=port_value3;
outportb(0x378,port_value);
}
void fan_speed_4()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&120;
port_value=port_value4;
outportb(0x378,port_value);
}
void fan_speed_5()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&120;
port_value=port_value5;
outportb(0x378,port_value);
}
void fan_speed_6()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&120;
port_value=port_value6;
outportb(0x378,port_value);
}
void fan_speed_7()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&120;
port_value=port_value7;
outportb(0x378,port_value);
}
/*void switch_on_second()
{
unsigned char port_value;
port_value=bit_manipulation(16);
outportb(0x378,port_value);
}
void switch_on_third()
{
unsigned char port_value;
port_value=bit_manipulation(8);
outportb(0x378,port_value);
} */
void switch_off_fan()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value&63;
outportb(0x378,port_value);
}
void fan_home_page()
{
mainScreen();
depressedButton(20,200,100,230);
setcolor(BLACK);
outtextxy(26,210," O F F ");
rectbox(20,250,620,400,BLUE);
setfillstyle(SOLID_FILL,LIGHTBLUE);
bar(24,254,618,398);
settextstyle(0,0,2);
setcolor(YELLOW);
outtextxy(200,50,"FAN CONTROLLING");
settextstyle(0,0,1);
}
void speed_control_page()
{
pressedButton(25,300,100,340);
setcolor(BLUE);
outtextxy(28,315,"Low Speed");
setcolor(BLACK);
outtextxy(30,332," OFF ");
pressedButton(150,255,225,295);
setcolor(BLUE);
outtextxy(153,265," 1 ");
setcolor(BLACK);
outtextxy(155,280," OFF ");
pressedButton(280,255,355,295);
setcolor(BLUE);
outtextxy(283,265," 2 ");
setcolor(BLACK);
outtextxy(285,280," OFF ");
pressedButton(415,255,490,295);
setcolor(BLUE);
outtextxy(418,265," 3 ");
setcolor(BLACK);
outtextxy(420,280," OFF ");
pressedButton(540,300,615,340);
setcolor(BLUE);
outtextxy(543,310,"High Fast");
setcolor(BLACK);
outtextxy(545,325," OFF ");
pressedButton(150,350,225,390);
setcolor(BLUE);
outtextxy(153,360," 4 ");
setcolor(BLACK);
outtextxy(155,375," OFF ");
pressedButton(280,350,355,390);
setcolor(BLUE);
outtextxy(283,360," 5 ");
setcolor(BLACK);
outtextxy(285,375," OFF ");
pressedButton(415,350,490,390);
setcolor(BLUE);
outtextxy(418,360," 6 ");
setcolor(BLACK);
outtextxy(420,375," OFF ");
}
/*LIGHT.H header file*/
#include
#include
int light1,light2,light3;
void switch_on_all_light()
{
unsigned char port_value;
port_value=bit_manipulation(56);
outportb(0x378,port_value);
}
void switch_on_first_light()
{
unsigned char port_value;
port_value=bit_manipulation(8);
outportb(0x378,port_value);
}
void switch_on_second_light()
{
unsigned char port_value;
port_value=bit_manipulation(16);
outportb(0x378,port_value);
}
void switch_on_third_light()
{
unsigned char port_value;
port_value=bit_manipulation(32);
outportb(0x378,port_value);
}
void switch_off_first_light()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value = port_value & 119;
outportb(0x378,port_value);
}
void switch_off_second_light()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value & 111;
outportb(0x378,port_value);
}
void switch_off_third_light()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value & 95;
outportb(0x378,port_value);
}
void switch_off_all_light()
{
unsigned char port_value;
port_value=inportb(0x378);
port_value=port_value & 71;
outportb(0x378,port_value);
}
void light_home_page()
{
mainScreen();
settextstyle(0,0,2);
setcolor(YELLOW);
outtextxy(150,40," CONTROLLING LIGHTS");
settextstyle(0,0,1);
depressedButton(50,80,150,110);
setcolor(GREEN);
outtextxy(56,88," O N ");
setcolor(LIGHTBLUE);
outtextxy(200,85," First Light");
depressedButton(50,150,150,180);
setcolor(GREEN);
outtextxy(56,158," O N ");
setcolor(LIGHTBLUE);
outtextxy(200,160," Second Light");
depressedButton(50,220,150,250);
setcolor(GREEN);
outtextxy(56,228," O N ");
setcolor(LIGHTBLUE);
outtextxy(200,230," Third Light");
depressedButton(50,290,150,320);
setcolor(GREEN);
outtextxy(56,298," ALL ON ");
setcolor(LIGHTBLUE);
outtextxy(200,300," All Light controlling");
}
/*TIMING.H header file*/
#include
#include
int hour_bar_left,hour_bar_right,HOUR,MINU;
int set_light1,l1_hour,l1_min,set_light2,l2_hour,l2_min,set_light3,l3_hour,l3_min;
int set_low,set_normal,set_high,set_ON_OFF,low_fan_hour,low_fan_min,normal_fan_hour,normal_fan_min,high_fan_hour,high_fan_min;
int ON_OFF_hour,ON_OFF_min;
int check_time(int hour,int min)
{
struct time t;
gettime(&t);
if (t.ti_hour==hour && t.ti_min==min)
return 1;
else
return 0;
}
void display_time()
{
char str[20];
int prev,cur;
struct time t;
gettime(&t);
setfillstyle(SOLID_FILL,BLACK);
bar(510,20,620,40);
sprintf(str,"TIME:%2d:%2d",t.ti_hour,t.ti_min);
rectbox(510,20,620,40,3);
setcolor(9);
outtextxy(520,30,str);
delay(100);
}
void time_setting_bar(int x1,int y1,int x2,int y2)
{
int val;
setfillstyle(SOLID_FILL,WHITE);
bar(x1,y1,x2,y2);
val=(x2-x1)/3;
switch_pressedButton(x1-val,y1,x1-2,y2);
switch_pressedButton(x2+3,y1,x2+val,y2);
}
void time_setting_bar_left_click(int x1,int y1,int x2,int y2)
{
int val;
setfillstyle(SOLID_FILL,WHITE);
bar(x1,y1,x2,y2);
val=(x2-x1)/3;
switch_depressedButton(x1-val,y1,x1-2,y2);
}
void time_setting_bar_left_release(int x1,int y1,int x2,int y2)
{
int val;
setfillstyle(SOLID_FILL,WHITE);
bar(x1,y1,x2,y2);
val=(x2-x1)/3;
switch_pressedButton(x1-val,y1,x1-2,y2);
}
void time_setting_bar_right_click(int x1,int y1,int x2,int y2)
{
int val;
setfillstyle(SOLID_FILL,WHITE);
bar(x1,y1,x2,y2);
val=(x2-x1)/3;
switch_depressedButton(x2+3,y1,x2+val,y2);
}
void time_setting_bar_right_release(int x1,int y1,int x2,int y2)
{
int val;
setfillstyle(SOLID_FILL,WHITE);
bar(x1,y1,x2,y2);
val=(x2-x1)/3;
switch_pressedButton(x2+3,y1,x2+val,y2);
}
void time_home_page()
{
mainScreen();
rectbox(10,10,630,440,WHITE);
settextstyle(0,0,2);
setcolor(YELLOW);
outtextxy(140,50,"TIME SETTING FOR DEVICES");
settextstyle(0,0,1);
setcolor(12);
outtextxy(20,110,"Hour :");
outtextxy(20,160,"Minute :");
time_setting_bar(150,100,250,130);
time_setting_bar(150,150,250,180);
setcolor(12);
rectbox(50,200,480,300,LIGHTBLUE);
outtextxy(60,220,"LIGHT SETTING");
depressedButton(70,250,150,280);
setcolor(BLACK);
outtextxy(80,260,"L_1 OFF");
depressedButton(170,250,250,280);
setcolor(BLACK);
outtextxy(180,260,"L_2 OFF");
depressedButton(270,250,350,280);
setcolor(BLACK);
outtextxy(280,260,"L_3 OFF");
depressedButton(370,250,450,280);
setcolor(BLACK);
outtextxy(380,260,"CLEAR");
setcolor(12);
rectbox(50,300,480,400,LIGHTBLUE);
outtextxy(60,320,"FAN SETTING");
depressedButton(70,340,150,370);
setcolor(BLACK);
outtextxy(80,350," LOW");
depressedButton(170,340,250,370);
setcolor(BLACK);
outtextxy(180,350," NORMAL");
depressedButton(270,340,350,370);
setcolor(BLACK);
outtextxy(280,350," HIGH");
depressedButton(370,340,450,370);
setcolor(BLACK);
outtextxy(380,350," CLEAR ");
depressedButton(460,100,620,130);
setcolor(17);
outtextxy(470,110,"Clear All Timeing");
}
/*MOUSE.H Header file*/
#include
union REGS i,o;
void initMouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
}
void showMouse()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void hideMouseptr()
{
i.x.ax=2;
int86(0x33,&i,&o);
}
void getMousePosition(int *b,int *x,int *y)
{
i.x.ax=3;
int86(0x33,&i,&o);
*b=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
}
void restrictMousePtr(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
int86(0x33,&i,&o);
}
/* void mouseLeftPressed(void far *)
{
int x,y,b;
getMousePos(&x,&y,&b);
while(b!=0);
buttonDepressed(
}*/
/* MAININTERFACE.C */
#include
#include
#include
#include "mouse.h"
#define OFF 0
#define ON 1
char str[2];
int SPECIAL_STATUS=OFF;
int all_light=0,light_property=0,fan_property=0,time_property=0;
int fan_on_off_property,FAN_ON_OFF=OFF,fan_speed=0;
void rectbox(int,int,int,int,int);
/*
void depressedButton(int,int,int,int);
void pressedButton(int,int,int,int);
void mainScreen();*/
unsigned char bit_manipulation(unsigned char value);
unsigned char status,status1,status2,status3;
union REGS i,o;
void digitDisplay()
{
int i;
settextstyle(0,0,1);
setcolor(BLACK);
for(i=2;i<620;i+=16) x="5;" y="430;">100)
{
x=5;
y=430;
break;
}
}
}
void pressedButton(int x1,int y1,int x2,int y2)
{
hideMouseptr();
setfillstyle(SOLID_FILL,WHITE);
bar(x1,y1,x2,y2);
setcolor(DARKGRAY);
line(x2,y2,x2,y1);
line(x2+1,y2,x2+1,y1);
line(x2,y2,x1,y2);
line(x2,y2+1,x1,y2+1);
showMouse();
}
void depressedButton(int x1,int y1,int x2,int y2)
{
hideMouseptr();
setfillstyle(SOLID_FILL,WHITE);
bar(x1,y1,x2,y2);
setcolor(DARKGRAY);
line(x1,y1,x1,y2);
line(x1+1,y1,x1+1,y2);
line(x1,y1,x2,y1);
line(x1,y1+1,x2,y1+1);
showMouse();
}
void switch_pressedButton(int x1,int y1,int x2,int y2)
{
hideMouseptr();
setfillstyle(SOLID_FILL,LIGHTBLUE);
bar(x1,y1,x2,y2);
setcolor(BLUE);
line(x2,y2,x2,y1);
line(x2+1,y2,x2+1,y1);
line(x2,y2,x1,y2);
line(x2,y2+1,x1,y2+1);
showMouse();
}
void switch_depressedButton(int x1,int y1,int x2,int y2)
{
hideMouseptr();
setfillstyle(SOLID_FILL,LIGHTBLUE);
bar(x1,y1,x2,y2);
setcolor(BLUE);
line(x1,y1,x1,y2);
line(x1+1,y1,x1+1,y2);
line(x1,y1,x2,y1);
line(x1,y1+1,x2,y1+1);
showMouse();
}
void mainScreen()
{
rectbox(10,10,630,440,WHITE);
setfillstyle(SOLID_FILL,BLACK);
bar(18,18,624,434);
setfillstyle(SOLID_FILL,LIGHTBLUE);
bar(10,443,632,480);
depressedButton(20,445,100,470);
setcolor(RED);
outtextxy(28,452,"L I G H T");
depressedButton(200,445,280,470);
setcolor(RED);
outtextxy(210,452,"F A N");
depressedButton(380,445,460,470);
setcolor(RED);
outtextxy(390,452,"TIMING");
depressedButton(560,445,620,470);
setcolor(RED);
outtextxy(566,452," EXIT");
settextstyle(0,0,2);
// setcolor(13);
// outtextxy(190,50,"BISHOP HEBER COLLEGE");
settextstyle(0,0,1);
showMouse();
}
void rectbox(int x1,int y1,int x2,int y2,int color)
{
setfillstyle(SOLID_FILL,color);
bar(x1,y1,x2,y1+2);
bar(x1,y1,x1+2,y2);
bar(x2,y1,x2+2,y2);
bar(x1,y2,x2+2,y2+2);
}
#include "light.h"
#include "fan.h"
#include "timing.h"
void speed_zero()
{
hideMouseptr();
speed_control_page();
depressedButton(25,300,100,340);
setcolor(BLUE);
outtextxy(28,315,"Low Speed");
setcolor(RED);
outtextxy(30,332," ON ");
showMouse();
fan_speed=0;
fan_speed_0();
}
void speed_one()
{
hideMouseptr();
speed_control_page();
depressedButton(150,255,225,295);
setcolor(BLUE);
outtextxy(153,265," 1 ");
setcolor(RED);
outtextxy(155,280," ON ");
fan_speed=1;
showMouse();
fan_speed_1();
}
void speed_two()
{
hideMouseptr();
speed_control_page();
depressedButton(280,255,355,295);
setcolor(BLUE);
outtextxy(283,265," 2 ");
setcolor(RED);
outtextxy(285,280," ON ");
fan_speed=2;
showMouse();
fan_speed_2();
}
void speed_three()
{
hideMouseptr();
speed_control_page();
depressedButton(415,255,490,295);
setcolor(BLUE);
outtextxy(418,265," 3 ");
setcolor(RED);
outtextxy(420,280," ON ");
fan_speed=3;
showMouse();
fan_speed_3();
}
void speed_four()
{
hideMouseptr();
speed_control_page();
depressedButton(150,350,225,390);
setcolor(BLUE);
outtextxy(153,360," 4 ");
setcolor(RED);
outtextxy(155,375," ON ");
fan_speed=4;
showMouse();
fan_speed_4();
}
void speed_five()
{
hideMouseptr();
speed_control_page();
depressedButton(280,350,355,390);
setcolor(BLUE);
outtextxy(283,360," 5 ");
setcolor(RED);
outtextxy(285,375," ON ");
fan_speed=5;
showMouse();
fan_speed_5();
}
void speed_six()
{
hideMouseptr();
speed_control_page();
depressedButton(415,350,490,390);
setcolor(BLUE);
outtextxy(418,360," 6 ");
setcolor(RED);
outtextxy(420,375," ON ");
fan_speed=6;
showMouse();
fan_speed_6();
}
void speed_seven()
{
hideMouseptr();
speed_control_page();
depressedButton(540,300,615,340);
setcolor(BLUE);
outtextxy(543,310,"High Fast");
setcolor(RED);
outtextxy(545,325," ON ");
fan_speed=7;
showMouse();
fan_speed_7();
}
void light1_on_logic()
{
hideMouseptr();
pressedButton(50,80,150,110);
setcolor(BLACK);
outtextxy(56,88," O F F ");
showMouse();
switch_on_first_light();
light1=ON;
}
void main()
{
int b,x,y;
int status=1;
int gd=DETECT,gm;
initgraph(&gd,&gm,"");//"d:\cpp\bgi\cgi.bgi");
initMouse();
hideMouseptr();
welComeScreen();
cleardevice();
mainScreen();
outportb(0x378,0);
showMouse();
while(1)
{
getMousePosition(&b,&x,&y);
gotoxy(10,10);
if(x>=560 && x<=620 && y>=445 && y<=470 && b==1 && status3==0) { hideMouseptr(); pressedButton(560,445,620,470); setcolor(BLACK); outtextxy(566,452," EXIT"); outportb(0x378,0); showMouse(); delay(300); exit(0); } if (x>=380 && x<=460 && y>=445 && y<=470 && b==1 && status2==0) { pressedButton(380,445,460,470); hideMouseptr(); setcolor(BLACK); light_property=OFF; fan_property=OFF; time_property=ON; outtextxy(388,452,"TIMING"); time_home_page(); sprintf(str,"%d",HOUR); outtextxy(200,110,str); sprintf(str,"%d",MINU); outtextxy(200,160,str); if(set_light1==ON) { pressedButton(70,250,150,280); setcolor(GREEN); outtextxy(80,260,"L_1 ON"); } if(set_light2==ON) { pressedButton(170,250,250,280); setcolor(GREEN); outtextxy(180,260,"L_2 ON"); } if(set_light3==ON) { pressedButton(270,250,350,280); setcolor(GREEN); outtextxy(280,260,"L_3 ON"); } if(set_low==ON) { pressedButton(70,340,150,370); setcolor(GREEN); outtextxy(80,350," LOW"); } if(set_normal==ON) { pressedButton(170,340,250,370); setcolor(GREEN); outtextxy(180,350," NORMAL "); } if(set_high==ON) { pressedButton(270,340,350,370); setcolor(GREEN); outtextxy(280,350," HIGH"); } if(set_ON_OFF==ON) { } showMouse(); status2=1; } if (x>=380 && x<=460 && y>=445 && y<=470 && b==0 && status2==1) { depressedButton(380,445,460,470); hideMouseptr(); setcolor(RED); outtextxy(390,452,"TIMING"); showMouse(); status2=0; } if(x>=200 && x<=280 && y>=445 && y<=470 && b==1 && status1==0) { pressedButton(200,445,280,470); hideMouseptr(); setcolor(BLACK); outtextxy(210,452,"F A N"); light_property=OFF; fan_property=ON; time_property=OFF; fan_home_page(); if(FAN_ON_OFF==ON) { pressedButton(20,200,100,230); setcolor(GREEN); outtextxy(26,210," O N "); showMouse(); speed_control_page(); switch(fan_speed) { case 0:speed_zero();break; case 1:speed_one();break; case 2:speed_two();break; case 3:speed_three();break; case 4:speed_four();break; case 5:speed_five();break; case 6:speed_six();break; case 7:speed_seven();break; } } status1=1; showMouse(); } if(x>=200 && x<=280 && y>=445 && y<=470 && b==0 && status1==1) { depressedButton(200,445,280,470); hideMouseptr(); setcolor(RED); outtextxy(213,452,"F A N"); showMouse(); status1=0; } getMousePosition(&b,&x,&y); if(x>=20 && x<=100 && y>=445 && y<=470 && b==1 && status==0) { pressedButton(20,445,100,470); hideMouseptr(); setcolor(BLACK); outtextxy(28,452,"L I G H T"); light_property=ON; fan_property=OFF; time_property=OFF; light_home_page(); if(light1==ON) { pressedButton(50,80,150,110); setcolor(BLACK); outtextxy(56,88," O F F "); switch_on_first_light(); light1=ON; } if(light2==ON) { pressedButton(50,150,150,180); setcolor(BLACK); outtextxy(56,158," O F F "); switch_on_second_light(); light2=ON; } if(light3==ON) { pressedButton(50,220,150,250); setcolor(BLACK); outtextxy(56,228," O F F "); switch_on_third_light(); } if(light1==ON && light2==ON && light3==ON) { hideMouseptr(); pressedButton(50,290,150,320); setcolor(BLACK); outtextxy(56,298," ALL OFF"); showMouse(); } status=1; } if(x>=20 && x<=100 && y>=445 && y<=470 && b==0 && status==1) { depressedButton(20,445,100,470); hideMouseptr(); setcolor(RED); outtextxy(30,452,"L I G H T"); showMouse(); status=0; } getMousePosition(&b,&x,&y); if(x>=50 && x<=150 && y>=80 && y<=110 && light1==OFF && b==1 && light_property==ON) { /* hideMouseptr(); pressedButton(50,80,150,110); setcolor(BLACK); outtextxy(56,88," O F F "); showMouse(); switch_on_first_light(); light1=ON;*/ light1_on_logic(); } if(x>=50 && x<=150 && y>=80 && y<=110 && light1==ON && b==2 && light_property==ON) { hideMouseptr(); depressedButton(50,80,150,110); pressedButton(50,290,150,320); setcolor(GREEN); outtextxy(56,88," O N "); setcolor(GREEN); outtextxy(56,298," ALL ON "); all_light=OFF; showMouse(); switch_off_first_light(); light1=OFF; } if(x>=50 && x<=150 && y>=150 && y<=180 && light2==OFF && b==1 && light_property==ON) { hideMouseptr(); pressedButton(50,150,150,180); setcolor(BLACK); outtextxy(56,158," O F F "); showMouse(); switch_on_second_light(); light2=ON; } if(x>=50 && x<=150 && y>=150 && y<=180 && light2==ON && b==2 && light_property==ON) { hideMouseptr(); depressedButton(50,150,150,180); setcolor(GREEN); outtextxy(56,158," O N "); pressedButton(50,290,150,320); setcolor(GREEN); outtextxy(56,298," ALL ON "); showMouse(); switch_off_second_light(); light2=OFF; all_light=OFF; } if(x>=50 && x<=150 && y>=220 && y<=250 && light3==OFF && b==1 && light_property==ON) { hideMouseptr(); pressedButton(50,220,150,250); setcolor(BLACK); outtextxy(56,228," O F F "); showMouse(); switch_on_third_light(); light3=ON; } if(x>=50 && x<=150 && y>=220 && y<=250 && light3==ON && b==2 && light_property==ON) { hideMouseptr(); depressedButton(50,220,150,250); setcolor(GREEN); outtextxy(56,228," O N "); pressedButton(50,290,150,320); setcolor(GREEN); outtextxy(56,298," ALL ON "); all_light=OFF; showMouse(); switch_off_third_light(); light3=OFF; } if(light1==ON &&light2==ON && light3==ON && all_light==OFF && light_property==ON) { hideMouseptr(); pressedButton(50,80,150,110); setcolor(BLACK); outtextxy(56,88," O F F "); pressedButton(50,150,150,180); setcolor(BLACK); outtextxy(56,158," O F F "); pressedButton(50,220,150,250); setcolor(BLACK); outtextxy(56,228," O F F "); pressedButton(50,290,150,320); setcolor(BLACK); outtextxy(56,298," ALL OFF"); showMouse(); switch_on_all_light(); light1=light2=light3=ON; all_light=ON; } if(x>=50 && x<=150 && y>=290 && y<=320 && all_light==0 && b==1 && light_property==ON) { hideMouseptr(); pressedButton(50,80,150,110); setcolor(BLACK); outtextxy(56,88," O F F "); pressedButton(50,150,150,180); setcolor(BLACK); outtextxy(56,158," O F F "); pressedButton(50,220,150,250); setcolor(BLACK); outtextxy(56,228," O F F "); pressedButton(50,290,150,320); setcolor(BLACK); outtextxy(56,298," ALL OFF"); showMouse(); switch_on_all_light(); light1=light2=light3=ON; all_light=ON; } if(x>=50 && x<=150 && y>=290 && y<=320 &&all_light==1 && b==2 && light_property==ON) { hideMouseptr(); depressedButton(50,80,150,110); setcolor(GREEN); outtextxy(56,88," O N "); depressedButton(50,150,150,180); setcolor(GREEN); outtextxy(56,158," O N "); depressedButton(50,220,150,250); setcolor(GREEN); outtextxy(56,228," O N "); depressedButton(50,290,150,320); setcolor(GREEN); outtextxy(56,298," ALL ON "); showMouse(); switch_off_all_light(); light1=light2=light3=OFF; all_light=OFF; } if(x>=20 && x<=100 && y>=200 && y<=230 && fan_property==ON && (b==1 SPECIAL_STATUS==ON) && FAN_ON_OFF==OFF) { hideMouseptr(); pressedButton(20,200,100,230); setcolor(GREEN); outtextxy(26,210," O N "); showMouse(); speed_control_page(); switch_on_fan(); FAN_ON_OFF=ON; switch(fan_speed) { case 0:speed_zero(); pressedButton(25,300,100,340); setcolor(BLUE); outtextxy(28,315,"Low Speed"); setcolor(GREEN); outtextxy(30,332," ON "); break; case 1:speed_one(); depressedButton(150,255,225,295); setcolor(BLUE); outtextxy(153,265," 1 "); setcolor(GREEN); outtextxy(155,280," ON "); break; case 2:speed_two(); depressedButton(280,255,355,295); setcolor(BLUE); outtextxy(283,265," 2 "); setcolor(GREEN); outtextxy(285,280," ON "); break; case 3:speed_three(); pressedButton(415,255,490,295); setcolor(BLUE); outtextxy(418,265," 3 "); setcolor(GREEN); outtextxy(420,280," OFF "); break; case 4:speed_four(); depressedButton(150,350,225,390); setcolor(BLUE); outtextxy(153,360," 4 "); setcolor(GREEN); outtextxy(155,375," ON "); break; case 5:speed_five(); depressedButton(280,350,355,390); setcolor(BLUE); outtextxy(283,360," 5 "); setcolor(GREEN); outtextxy(285,375," ON "); break; case 6:speed_six(); depressedButton(415,350,490,390); setcolor(BLUE); outtextxy(418,360," 6 "); setcolor(GREEN); outtextxy(420,375," ON "); break; case 7:speed_seven(); depressedButton(540,300,615,340); setcolor(BLUE); outtextxy(543,310,"High Fast"); setcolor(GREEN); outtextxy(545,325," ON "); break; } } if(x>=20 && x<=100 && y>=200 && y<=230 && fan_property==ON && b==2 && FAN_ON_OFF==ON) { SPECIAL_STATUS=OFF; hideMouseptr(); depressedButton(20,200,100,230); setcolor(BLACK); outtextxy(26,210," O F F "); switch_off_fan(); showMouse(); fan_home_page(); switch_off_fan(); FAN_ON_OFF=OFF; } if(x>=25 && x<=100 && y>=300 && y<=340 && b==1 && fan_speed != 0 && fan_property==ON && FAN_ON_OFF==ON) { speed_zero(); } if(x>=150 && x<=225 && y>=255 && y<=295 && b==1 && fan_speed != 1 && fan_property==ON && FAN_ON_OFF==ON) { speed_one(); } if(x>=280 && x<=355 && y>=255 && y<=295 && b==1 && fan_speed!=2 && fan_property==ON && FAN_ON_OFF==ON) { speed_two(); } if(x>=415 && x<=490 && y>=255 && y<=295 && b==1 && fan_speed!=3 && fan_property==ON && FAN_ON_OFF==ON) { speed_three(); } if(x>=150 && x<=225 && y>=350 && y<=390 && b==1 && fan_speed!=4 && fan_property==ON && FAN_ON_OFF==ON) { speed_four(); } if(x>=280 && x<=355 && y>=350 && y<=390 && b==1 && fan_speed!=5 && fan_property==ON && FAN_ON_OFF==ON) { speed_five(); } if(x>=415 && x<=490 && y>=350 && y<=390 && b==1 && fan_speed!=6 && fan_property==ON && FAN_ON_OFF==ON) { speed_six(); } if(x>=540 && x<=615 && y>=300 && y<=340 && b==1 && fan_speed!=7 && fan_property==ON && FAN_ON_OFF==ON) { speed_seven(); } if(x>=127 && x<=148 && y>=100 && y<=130 && time_property==ON && b==1 ) { hideMouseptr(); time_setting_bar_left_click(150,100,250,130); showMouse(); delay(50); hideMouseptr(); time_setting_bar_left_release(150,100,250,130); if(HOUR==0) HOUR=23; else HOUR--; sprintf(str,"%d",HOUR); delay(150); outtextxy(200,110,str); showMouse(); } if(x>=253 && x<=286 && y>=100 && y<=130 && time_property==ON && b==1) { hideMouseptr(); time_setting_bar_right_click(150,100,250,130); showMouse(); delay(50); hideMouseptr(); time_setting_bar_right_release(150,100,250,130); if(HOUR==23) HOUR=0; else HOUR++; sprintf(str,"%d",HOUR); delay(150); outtextxy(200,110,str); showMouse(); } if(x>=127 && x<=148 && y>=150 && y<=180 && time_property==ON && b==1 ) { hideMouseptr(); time_setting_bar_left_click(150,150,250,180); showMouse(); delay(50); hideMouseptr(); time_setting_bar_left_release(150,150,250,180); if(MINU==0) MINU=59; else MINU--; sprintf(str,"%d",MINU); delay(150); outtextxy(200,160,str); showMouse(); } if(x>=253 && x<=286 && y>=150 && y<=180 && time_property==ON && b==1) { hideMouseptr(); time_setting_bar_right_click(150,150,250,180); showMouse(); delay(50); hideMouseptr(); time_setting_bar_right_release(150,150,250,180); if(MINU==59) MINU=0; else MINU++; sprintf(str,"%d",MINU); delay(150); outtextxy(200,160,str); showMouse(); } if(x>=70 && x<=150 && y>=250 && y<=280 && time_property==ON && b==1 && set_light1==OFF) { hideMouseptr(); pressedButton(70,250,150,280); setcolor(GREEN); outtextxy(80,260,"L_1 ON"); set_light1=ON; l1_hour=HOUR; l1_min=MINU; showMouse(); } if(set_light1==ON && check_time(l1_hour,l1_min)) { switch_on_first_light(); light1=ON; set_light1=OFF; if(time_property==ON) { hideMouseptr(); depressedButton(70,250,150,280); setcolor(BLACK); outtextxy(80,260,"L_1 OFF"); showMouse(); } if(light_property==ON) { hideMouseptr(); pressedButton(50,80,150,110); setcolor(BLACK); outtextxy(56,88," O F F "); showMouse(); } } if(x>=170 && x<=250 && y>=250 && y<=280 && time_property==ON && b==1 && set_light2==OFF) { hideMouseptr(); pressedButton(170,250,250,280); setcolor(GREEN); outtextxy(180,260,"L_2 ON"); set_light2=ON; l2_hour=HOUR; l2_min=MINU; showMouse(); } if(set_light2==ON && check_time(l2_hour,l2_min)) { switch_on_second_light(); light2=ON; set_light2=OFF; if(time_property==ON) { hideMouseptr(); depressedButton(170,250,250,280); setcolor(BLACK); outtextxy(180,260,"L_2 OFF"); showMouse(); } if(light_property==ON) { hideMouseptr(); pressedButton(50,150,150,180); setcolor(BLACK); outtextxy(56,158," O F F "); showMouse(); } } if(x>=270 && x<=350 && y>=250 && y<=280 && time_property==ON && b==1 && set_light3==OFF) { hideMouseptr(); pressedButton(270,250,350,280); setcolor(GREEN); outtextxy(280,260,"L_3 ON"); set_light3=ON; l3_hour=HOUR; l3_min=MINU; showMouse(); } if(set_light3==ON && check_time(l3_hour,l3_min)) { switch_on_third_light(); light3=ON; set_light3=OFF; if(time_property==ON) { hideMouseptr(); depressedButton(270,250,350,280); setcolor(BLACK); outtextxy(280,260,"L_3 OFF"); showMouse(); } if(light_property==ON) { hideMouseptr(); pressedButton(50,220,150,250); setcolor(BLACK); outtextxy(56,158," O F F "); showMouse(); } } if(x>=370 && x<=450 && y>=250 && y<=280 && time_property==ON && b==1 ) { hideMouseptr(); set_light1=set_light2=set_light3=OFF; pressedButton(370,250,450,280); setcolor(GREEN); outtextxy(380,260,"CLEAR"); delay(100); depressedButton(370,250,450,280); setcolor(BLACK); outtextxy(380,260,"CLEAR"); depressedButton(70,250,150,280); setcolor(BLACK); outtextxy(80,260,"L_1 OFF"); depressedButton(170,250,250,280); setcolor(BLACK); outtextxy(180,260,"L_2 OFF"); depressedButton(270,250,350,280); setcolor(BLACK); outtextxy(280,260,"L_3 OFF"); depressedButton(370,250,450,280); depressedButton(370,250,450,280); setcolor(BLACK); outtextxy(380,260,"CLEAR"); showMouse(); } if(x>=70 && x<=150 && y>=340 && y<=370 && time_property==ON && b==1) { hideMouseptr(); set_low=ON; pressedButton(70,340,150,370); setcolor(GREEN); outtextxy(80,350," LOW"); low_fan_hour=HOUR; low_fan_min=MINU; showMouse(); } if(set_low==ON && check_time(low_fan_hour,low_fan_min)) { FAN_ON_OFF=ON; SPECIAL_STATUS=ON; switch_on_fan(); fan_speed=0; if(time_property==ON) { hideMouseptr(); pressedButton(70,340,150,370); setcolor(BLACK); outtextxy(80,350," LOW"); showMouse(); } set_low=OFF; } if(x>=170 && x<=250 && y>=340 && y<=370 && time_property==ON && b==1) { hideMouseptr(); set_normal=ON; pressedButton(170,340,250,370); setcolor(GREEN); outtextxy(180,350," NORMAL"); normal_fan_hour=HOUR; normal_fan_min=MINU; showMouse(); } if(set_normal==ON && check_time(normal_fan_hour,normal_fan_min)) { FAN_ON_OFF=ON; SPECIAL_STATUS=ON; switch_on_fan(); fan_speed_4(); fan_speed=4; if(time_property==ON) { hideMouseptr(); pressedButton(170,340,250,370); setcolor(BLACK); outtextxy(180,350," NORMAL "); showMouse(); } set_normal=OFF; } if(x>=270 && x<=350 && y>=340 && y<=370 && time_property==ON && b==1) { hideMouseptr(); set_high=ON; pressedButton(270,340,350,370); setcolor(GREEN); outtextxy(280,350," HIGH"); high_fan_hour=HOUR; high_fan_min=MINU; showMouse(); } if(set_high==ON && check_time(high_fan_hour,high_fan_min)) { FAN_ON_OFF=ON; SPECIAL_STATUS=ON; pressedButton(370,340,450,370); setcolor(GREEN); switch_on_fan(); fan_speed_7(); fan_speed=7; if(time_property==ON) { hideMouseptr(); pressedButton(270,340,350,370); setcolor(BLACK); outtextxy(280,350," HIGH "); showMouse(); } set_high=OFF; } if(x>=460 && x<=620 && y>=100 && y<=130 && b==1 && time_property==ON) { hideMouseptr(); pressedButton(460,100,620,130); setcolor(BLACK); outtextxy(470,110,"Clear All Timeing"); delay(150); depressedButton(460,100,620,130); setcolor(17); outtextxy(470,110,"Clear All Timeing"); set_light1=set_light2=set_light3=OFF; set_low=set_normal=set_high=OFF; time_home_page(); sprintf(str,"%d",HOUR); outtextxy(200,110,str); sprintf(str,"%d",MINU); outtextxy(200,160,str); showMouse(); } if(x>=370 && x<=450 && y>=340 && y<=370 && b==1 && time_property==ON) { hideMouseptr(); set_low=set_normal=set_high=OFF; pressedButton(370,340,450,370); setcolor(GREEN); delay(150); depressedButton(370,340,450,370); setcolor(BLACK); outtextxy(380,350," CLEAR "); depressedButton(70,340,150,370); setcolor(BLACK); outtextxy(80,350," LOW"); depressedButton(170,340,250,370); setcolor(BLACK); outtextxy(180,350," NORMAL"); depressedButton(270,340,350,370); setcolor(BLACK); outtextxy(280,350," HIGH"); depressedButton(370,340,450,370); setcolor(BLACK); outtextxy(380,350," CLEAR "); showMouse(); } if(time_property==ON) display_time(); } }