Beispiel #1
0
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;
        }
    }
   
}
Beispiel #2
0
ISR(TIMER0_OVF_vect , ISR_BLOCK)
{
    static unsigned int i=0;
    static unsigned char count1=0;
    static unsigned char count3=0;
    if(i-- == 0){
        i = 3588;
        kick = 1;
    }

    if(grant)
        grant--;

    if(PINC & (1<<PC4)){
        if(pl == '-' && count1++ == 70){
            pl = '1';
            hd44780_goto(1,19);
            hd44780_put(pl,NULL);
        }
    }else{
        count1=0;
    }

    if(PINC & (1<<PC3)){
        if(pl == '-' && count3++==70){
            pl = '3';
            hd44780_goto(1,19);
            hd44780_put(pl,NULL);
        }
    }else{
        count3=0;
    }

    if(!grant && count3==0 && count1==0 && pl != '-'){
        PORTC &= ~(1<<PC5);
        PORTC &= ~(1<<PC6);
        pl = '-';
        hd44780_goto(1,19);
        hd44780_put(pl,NULL);
    }
}
Beispiel #3
0
int hd44780_put(char d, FILE *stream)
{
    uint8_t start = 0;

#ifdef HD44780_MULTIENSUPPORT
    uint8_t en = 1;
#endif
    if (d == '\n') {
	while (current_pos % LCD_CHAR_PER_LINE > 0)
	    hd44780_put(' ', stream);

	if (current_pos >= LCD_MAX_CHAR)
	    current_pos -= LCD_MAX_CHAR;

	return 0;
    } else if (d == '\r') {
	current_pos -= current_pos % LCD_CHAR_PER_LINE;
	return 0;
    }

    if (current_pos <= LCD_CHAR_PER_LINE - 1)
       {
	start = LCD_LINE_1_ADR - 0 + current_pos;
#ifdef HD44780_MULTIENSUPPORT
	en = LCD_LINE_1_EN;	
#endif
	}
    else if (current_pos <= ( LCD_CHAR_PER_LINE * 2) - 1 )
    	{
	 start = LCD_LINE_2_ADR - LCD_CHAR_PER_LINE + current_pos;
#ifdef HD44780_MULTIENSUPPORT
	 en = LCD_LINE_2_EN;	
#endif
	}
    else if (current_pos <= ( LCD_CHAR_PER_LINE * 3) - 1 )
        {
	 start = LCD_LINE_3_ADR - (LCD_CHAR_PER_LINE * 2) + current_pos;
#ifdef HD44780_MULTIENSUPPORT
	 en = LCD_LINE_3_EN;	
#endif
	}
    else if (current_pos <= ( LCD_CHAR_PER_LINE * 4) - 1 )
        {
	 start = LCD_LINE_4_ADR - (LCD_CHAR_PER_LINE * 3) + current_pos;
#ifdef HD44780_MULTIENSUPPORT
	 en = LCD_LINE_4_EN;	
#endif
	}
    
 
#ifdef HD44780_MULTIENSUPPORT
    output_byte(0, CMD_SETDRAMADR(start), en);
#else
    output_byte(0, CMD_SETDRAMADR(start), 1);
#endif

#ifdef DEBUG_HD44780
    _delay_ms(50);
#endif

#ifdef HD44780_MULTIENSUPPORT
    output_byte(1, d, en);
#else
    output_byte(1, d, 1);
#endif
    current_pos++;

    if (current_pos == LCD_MAX_CHAR)
        current_pos = 0;

    return 0;
}
Beispiel #4
0
int hd44780_put(char d, FILE *stream)
{
    uint8_t start = 0;

    if (d == '\n') {
	while (current_pos % 20 > 0)
	    hd44780_put(' ', stream);

	if (current_pos >= 80)
	    current_pos -= 80;

	return 0;
    } else if (d == '\r') {
	current_pos -= current_pos % 20;
	return 0;
    }

#if HD44780_TYPE == HD44780_ORIGINAL
    if (current_pos <= 19)
        start = 0x00 - 00 + current_pos;
    else if (current_pos <= 39)
        start = 0x20 - 20 + current_pos;
    else if (current_pos <= 59)
        start = 0x40 - 40 + current_pos;
    else if (current_pos <= 79)
        start = 0x60 - 60 + current_pos;
#elif HD44780_TYPE == HD44780_DISPTECH
    if (current_pos <= 19)
        start = 0x00 - 0 + current_pos;
    else if (current_pos <= 39)
        start = 0x40 - 20 + current_pos;
    else if (current_pos <= 59)
        start = 0x10 - 40 + current_pos;
    else if (current_pos <= 79)
        start = 0x50 - 60 + current_pos;
#elif HD44780_TYPE == HD44780_KS0067B
    if (current_pos <= 19)
        start = 0x00 - 0 + current_pos;
    else if (current_pos <= 39)
        start = 0x40 - 20 + current_pos;
    else if (current_pos <= 59)
        start = 0x14 - 40 + current_pos;
    else if (current_pos <= 79)
        start = 0x54 - 60 + current_pos;
#elif HD44780_TYPE == HD44780_KS0066U
    if (current_pos <= 19)
        start = 0x00 - 0 + current_pos;
    else if (current_pos <= 39)
        start = 0x40 - 20 + current_pos;
    else if (current_pos <= 59)
        start = 0x10 - 40 + current_pos;
    else if (current_pos <= 79)
        start = 0x50 - 60 + current_pos;
#else
#error "unknown hd44780 compatible controller type!"
#endif

    output_byte(0, CMD_SETDRAMADR(start));
#ifdef DEBUG_HD44780
    _delay_ms(50);
#endif

    output_byte(1, d);
    current_pos++;

    if (current_pos == 80)
        current_pos = 0;

    return 0;
}