// Menu file AIRCON.MNU for Air Conditioner using TU480X272C // Updated 20-Sep-2010 ///////// //Files// ///////// LIB(libImgAcBg, "SDHC/AirConBg.bmp"); // Load background picture LIB(libImgAcStart, "SDHC/AirConSt.bmp?back=\\76bbfe"); // Load start button + transparency LIB(fntAscii32, "SDHC/asc_32.fnt"); // Load Ascii Font 32 LIB(fntAscii16, "SDHC/asc_16b.fnt"); // Load Ascii Font 16 /////////// //Styles// /////////// STYLE(stAcMainPg, Page) {back=black; image=libImgAcBg;} //create a style for the main page STYLE(stTxt8Wht64, Text) {font=fntAscii16; col=white; maxLen=64; maxRows=1; curRel=CC;} //create a style for the ascii16 font in white STYLE(stTxt32Yel06, Text) {font=fntAscii32; col=yellow; maxLen=6; maxRows=1; curRel=CC;} //create a style for the ascii32 font in yellow STYLE(stTxt32Wht64, Text) {font=fntAscii32; col=white; maxLen=64; maxRows=1; curRel=CC;} //create a style for the ascii32 font in white STYLE(stGenImg,Image) {curRel=CC;} //create a style for the images /////////////// //Variables// ////////////// VAR(varAcHeat, 26, U8E); //create an unsigned 8 bit EEPROM variable to hold the upper limit of the aircon VAR(varAcCool, 20, U8E); //create an unsigned 8 bit EEPROM variable to hold the lower limit of the aircon VAR(varAcAct, 32.7, FLT1); //create a one decimal point float variable to hold the actual room temp VAR(varAcDif, 0.196, FLT1); //create a one decimal point float variable to hold the change in the room temp VAR(varAcTmp, 0.0, FLT1); //create a one decimal point float variable to make calculations for room temp VAR(varAcCnt, 0, U8); //create an unsigned 8 bit variable used to make the loop function ////////// //Page// ///////// PAGE(pgAirConMain, stAcMainPg) //set up the contents of the main page { // Heating Upper Limits POSN(238, 80); TEXT(txtAcHeat, varAcHeat, stTxt32Wht64); //create text to indicate the upper limit setting POSN(-57, +0); KEY(keyAcHeatDn, fncAcHeatDn, 45, 33, TOUCH); //create a touch event to increase the upper limit POSN(+109, +0); KEY(keyAcHeatUp, fncAcHeatUp, 40, 33, TOUCH); //create a touch event to decrease the upper limit // Cooling Lower Limts POSN(238, +52); TEXT(txtAcCool, varAcCool, stTxt32Wht64); //create text to indicate the lower limit setting POSN(-57, +0); KEY(keyAcCoolDn, fncAcCoolDn, 45, 31, TOUCH); //create a touch event to decrease the lower limit POSN(+109, +0); KEY(keyAcCoolUp, fncAcCoolUp, 40, 31, TOUCH); //create a touch event to increase the lower limit POSN(-130, +117); TEXT(txtAcMsg, "Set Limits or press START", stTxt8Wht64); //create text to indicate aircon's status POSN(238, 182); TEXT(txtAcAct, varAcAct, stTxt32Yel06); //create text to indicate actual room temp POSN(400, 208); KEY(keyAcStop, fncAcStop, 95, 95, TOUCH); //create a touch event to turn off the aircon IMG(imgAcStart, libImgAcStart, 95, 95, stGenImg); //add the green start button on top of stop button KEY(keyAcStart, fncAcStart, 95, 95, TOUCH); //create a touch event to start the aircon LOOP(lpAcMain, FOREVER) //this loop runs when the CNTSECS is not 0 { IF(varAcCnt != CNTSECS ? fncAcUpd); //this keeps the loop going when CNTSECS is not 0 } } /////////////// //Functions// ////////////// FUNC(fncAcHeatUp) //this increases the temp for the heating upper limits { CALC(varAcHeat,varAcHeat,1,"+"); //increase the heating upper limit by 1 TEXT(txtAcHeat,varAcHeat);; //indicate the new heating upper limit } FUNC(fncAcHeatDn) //this decreases the temp for the heating upper limits { CALC(varAcHeat,varAcHeat,1,"-"); //decrease the heating upper limit by 1 TEXT(txtAcHeat,varAcHeat); //indicate the new heating upper limit IF(varAcCool=varAcHeat?fncAcCoolDn);; //ensures that the heating upper limit is always reached } FUNC(fncAcCoolUp) //this increases the temp for the cooling lower limits { CALC(varAcCool,varAcCool,1,"+"); //increase the cooling lower limit by 1 TEXT(txtAcCool,varAcCool); //indicate the new cooling lower limit IF(varAcHeat=varAcCool?fncAcHeatUp);; } FUNC(fncAcCoolDn) //this decreases the temp for the cooling lower limits { CALC(varAcCool,varAcCool,1,"-"); //decrease the cooling lower limit by 1 TEXT(txtAcCool,varAcCool);; //indicate the new cooling lower limit } FUNC(fncAcUpd) //set up the airconditioner loop function { LOAD(varAcCnt,CNTSECS); //load the current CNTSECS to varAcCnt CALC(varAcAct,varAcAct,varAcDif,"+"); //add the aircon's change rate to the actual temp IF(txtAcMsg!="Set Limits or press START"?fncAcOn:fncAcOff); //start the ac if start has been pressed or limits were set TEXT(txtAcAct,varAcAct);; //display the actual room temp } FUNC(fncAcOn) //turn on the airconditiner { IF(varAcAct>varAcHeat?fncAcCool); //ensures that the heating upper limits are reached IF(varAcActvarAcTmp?fncAcActHi); //if actual temp is too high decrease the aircon's temp CALC(varAcTmp,varAcCool,3,"-"); //let the cooling lowerl imit temp fluctuate by 3 IF(varAcAct