#include "gefran_gtf.h"
#include "avrIOhelper/io-helper.h"
#include "temperature.h"
#include <stdint.h>
#include <stdio.h>

uint8_t heizung_state = 0;
uint8_t heizung_ontemp = 0;

void do_heizung(){

    if(ADC_reading[1] > 69)
        heizung_ontemp = 1;
    if(ADC_reading[1] < 66)
        heizung_ontemp = 0;

    if(heizung_state && !heizung_ontemp){
        gtf_write_register(5, 56, 500);
        gtf_write_register(6, 56, 500);
        gtf_write_register(7, 56, 500);
        set_Output(LED_HEIZUNG, BLINK);
    }
    else if(heizung_state && heizung_ontemp){
        gtf_write_register(5, 56, 0);
        gtf_write_register(6, 56, 0);
        gtf_write_register(7, 56, 0);
        set_Output(LED_HEIZUNG, ON);
    }
    else{
        gtf_write_register(5, 56, 0);
        gtf_write_register(6, 56, 0);
        gtf_write_register(7, 56, 0);
        set_Output(LED_HEIZUNG, OFF);
    }

    if(read_Input(BTN_HEIZEN_AN, LEVEL)){
        heizung_state = 1;
    }

    if(read_Input(BTN_HEIZEN_AUS, LEVEL)){
        heizung_state = 0;
    }

}
