Subversion Repositories Projects

Rev

Rev 111 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
111 mikeljo 1
 
2
#include <avr/io.h>
3
#include <inttypes.h>
4
#include <stdlib.h>
5
#include <avr/pgmspace.h>
6
 
7
#include "main.h"
8
#include "lcd.h"
9
#include "rs232.h"
10
#include "base64.h"
11
#include "parameter.h"
12
#include "menu.h"
13
 
14
uint8_t read_display (uint8_t command)                  // 
15
{
16
        uint8_t timeout;
17
 
18
        timeout = 0;
19
        p_buffer[0] = '#';                                                      // Display-Zeile anfordern
20
        p_buffer[1] = 'a';
21
        p_buffer[2] = 'h';
22
        p_buffer[3] = command;
23
        p_buffer[4] = 0;
24
        p_buffer[5] = 0;
25
        base64_send(6);
26
 
27
        do                                                                                      // warten, bis die Parameter gesendet werden
28
        {
29
                if (get_message() == 1)
30
                        timeout = 10;
31
                timeout ++;
32
        }
33
        while (((r_buffer[1] < '0') || (r_buffer[1] > '4')) && (timeout < 10));
34
 
35
        if (timeout >= 10)
36
                return 1;
37
        else
38
                return 0;
39
}
40
 
41
void display_data (void)
42
{
43
        uint8_t line;
44
        uint8_t text[10];
45
 
46
        lcd_cls();
47
        lcd_printp(PSTR("Display"),0);
48
        do
49
        {
50
                while (key != 0x00);
51
                if (read_display(0) == 1)
52
                {
53
                        lcd_printp(PSTR("\r\nTimeout!"),0);
54
                        timer = 200;
55
                        while (timer > 0);
56
                        break;
57
                }
58
                else
59
                {
60
                        line = r_buffer[1];
61
                        text[0] = line;
62
                        text[1] = 0x00;
63
                        lcd_print_at(10,0,text,0);
64
 
65
                        lcd_print_at(0,line+1,p_buffer,0);
66
 
67
                        timer = 10;
68
                        while(timer > 0);
69
 
70
                        if (key == 0x01)
71
                                read_display(1);
72
                        if (key == 0x02)
73
                                read_display(2);
74
                }
75
 
76
        }
77
        while (key != 0x04);
78
}