示例#1
0
文件: matemat.c 项目: muccc/matemat
void matemat_process(void)
{
    static uint8_t state = 0;
    static uint8_t timer = 0;

    if(kick){
        cli();
        matemat_global.temps[TEMP_BOTTOM] = GET_BOTTOM;
        printtemp(matemat_global.temps[TEMP_BOTTOM],3,8);
        matemat_global.temps[TEMP_MIDDLE] = GET_MIDDLE;
        printtemp(matemat_global.temps[TEMP_MIDDLE],2,8);
        
        hd44780_goto(1,0);
        fprintf(lcd,"%d",matemat_global.matemat_packetcount);
        hd44780_goto(3,19);
        if(state)
            hd44780_put('.',NULL);
        else
            hd44780_put(' ',NULL);
        sei();
        
        //hd44780_goto(1,19);
        //hd44780_put(pl,NULL);

        //if( (PINC & (1<<PC4)) )
        //    hd44780_put('2',NULL);
        //else if( (PINC & (1<<PC3)) )
        //    hd44780_put('3',NULL);
        //else
        //    hd44780_put('-',NULL);
        state = !state;

        if(matemat_global.mode == MODE_IDLE){
            if(matemat_global.temps[TEMP_BOTTOM] > matemat_global.temps[TEMP_START]){
                matemat_global.mode = MODE_COOLING;
                matemat_putmode();
                PIN_SET(MATEMAT_COOLER);
            }
        }else if(matemat_global.mode == MODE_COOLING){
            if(matemat_global.temps[TEMP_BOTTOM] < matemat_global.temps[TEMP_STOP]){
                matemat_global.mode = MODE_IDLE;
                matemat_putmode();
                PIN_CLEAR(MATEMAT_COOLER);
            }
        }

        kick = 0;
        if(timer++ == 10){
            matemat_global.push = 1;
            timer = 0;
        }
    }
   
}
示例#2
0
文件: display.c 项目: muccc/matemat
void display_updatetemp(void)
{
    printtemp(TEMP_BOTTOM,8,3);
    printtemp(TEMP_MIDDLE,8,2);   
}
示例#3
0
void main(void)
{

	//Variables
	char lcdFirstLine[LCD_LENGTH], lcdSecondLine[LCD_LENGTH];
	int displaymode = 1;
 	int temperature[5];
	int humidity[5];
	
	
	
	/** init **/
	
	// interrupt and SleepTimer init
	M8C_EnableGInt ;                            // Turn on interrupts
	SleepTimer_Start();
    SleepTimer_SetInterval(SleepTimer_8_HZ);    // Set interrupt to a
    SleepTimer_EnableInt();                     // 8 Hz rate

	// LCD init
	LCD_Init();
	
	// print welcome screen to LCD
	csprintf(lcdFirstLine,"   Welcome to   ");
	csprintf(lcdSecondLine, " Weatherstation ");
	LCD_Position(0,0);
	LCD_PrString(lcdFirstLine);
	LCD_Position(1,0);
	LCD_PrString(lcdSecondLine);


	while(1) {
	
		I2Cm_Start();						//Initialize I2C
		I2Cm_fSendStart( 0x28, 0);			//Send Measuring Request	
		measuring(temperature, humidity); 	//measuring temperature and humidity
	
		
		switch(displaymode) {
			case 0:
				// overview();
				break;
				
			case 1:
				printtemp(lcdFirstLine, lcdSecondLine, temperature); //write temp in the variable for the lcd
				break;
				
			case 2:
				printhum(lcdFirstLine, lcdSecondLine, humidity); //wirte humidity in the variable for the lcd
				break;
				
			case 3:
				// rain();
				break;
				
			case 4:
				// wind();
				break;
		
			default:
				displaymode = 0;
				csprintf(lcdFirstLine,"     Error      ");
				csprintf(lcdSecondLine,"                ");
		}
		
		// lets see what we've got
		LCD_Position(0,0);
		LCD_PrString(lcdFirstLine);
		LCD_Position(1,0);
		LCD_PrString(lcdSecondLine);
		
		// lets sleep for a while
		SleepTimer_SyncWait(8, SleepTimer_WAIT_RELOAD);
		
	}
	}