Main.c


1
// Wenn LCD nach flashen dunkle bleibt dann Stromversorgung AUS -> AN
2
#define F_CPU 16000000UL
3
#include "Main.h"
4
int test0 = 0;
5
int test1 = 0;
6
int test2 = 0;
7
int test3 = 0;
8
int test4 = 0;
9
int test5 = 0;
10
int test6 = 0;
11
int test7 = 0;
12
int test8 = 0;
13
uint16_t temperature=0;
14
float celsius=0;
15
16
uint8_t error=0;
17
18
19
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
20
// Interupt @60Hz
21
ISR(SIG_OUTPUT_COMPARE0) {
22
23
}
24
25
 void timer_init(void)
26
 {
27
 /*
28
 * Timer1 wird unsere Systemuhr definieren.
29
 * Modus: CTC, Normal Port Operation, Prescaler clk/1024
30
 * Freq.: 14745600/(N*(1+OCR0)) = 60.0Hz
31
 *        mit OCR0 = 239 und N = 1024
32
 *        Wird für Interupt benötigt !!!
33
 */
34
 TCCR0 = (1 << WGM01) | (1 << CS02) | (1 << CS01) | (1 << CS00);
35
 OCR0 = 239;
36
 TIMSK |= (1 << OCIE0);
37
 }
38
39
40
//Unsere Main
41
int main(void) {
42
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
43
44
45
  init_spi_lcd(); // SPI Init
46
47
  TSIC_INIT();  // Init TSIC Temperatursensor
48
49
  //DOGL Display
50
  lcd_init();
51
  lcd_set_font(FONT_PROP_8, 0);
52
53
54
  //Timer initialisieren
55
//  timer_init();
56
57
  sei();  //  Global Interrupt Enable
58
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
59
  while (1) {
60
61
    BACKLIGHT_ON();
62
63
      // Temperatur messen
64
        if (getTSicTemp(&temperature)){ //turn the TSIC-Sensor ON -> messure -> OFF
65
          temperature = ((temperature * 250L) >> 8) - 500;        // Temperatur *10 also 26,4 = 264
66
          celsius = temperature / 10 + (float) (temperature % 10) / 10;  // Temperatur mit 1 Nachkommastelle z.b. 26,4
67
68
          lcd_moveto_xy(0, 0);
69
          lcd_put_string(FONT_PROP_8, 0, "Temperatur: ");
70
          lcd_put_float(celsius);
71
72
          lcd_moveto_xy(1, 0);
73
        lcd_clear_area(1, 128, 0);
74
        lcd_put_string(FONT_PROP_8, 0, "OK");
75
        }
76
        else{
77
          lcd_moveto_xy(1, 0);
78
          lcd_clear_area(1, 128, 0);
79
          lcd_put_string(FONT_PROP_8, 0, "Fehler");
80
          }
81
82
83
84
85
              if(test0>10000){
86
                test0=0;
87
              }
88
              lcd_moveto_xy(6, 0);
89
              lcd_put_long(test0++);
90
91
92
93
          _delay_ms(200);
94
95
  }
96
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
97
}