Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1164 - 1
/*****************************************************************************
2
 *   Copyright (C) 2010 seb@exse.net                                                                             *
3
 *   Copyright (C) 2011 Christian Brandtner brandtner@brandtner.net          *
4
 *                                                                           *
5
 *   This program is free software; you can redistribute it and/or modify    *
6
 *   it under the terms of the GNU General Public License as published by    *
7
 *   the Free Software Foundation; either version 2 of the License.          *
8
 *                                                                           *
9
 *   This program is distributed in the hope that it will be useful,         *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
12
 *   GNU General Public License for more details.                            *
13
 *                                                                           *
14
 *   You should have received a copy of the GNU General Public License       *
15
 *   along with this program; if not, write to the                           *
16
 *   Free Software Foundation, Inc.,                                         *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
18
 *                                                                           *
19
 *****************************************************************************/
20
/*14.6.2011 Parameter erweitert Wi232 Cebra */
21
 
22
#include <avr/io.h>
23
#include <avr/pgmspace.h>
24
#include <util/delay.h>
25
#include <stdlib.h>
26
#include <string.h>
27
#include <avr/eeprom.h>
28
#include "lcd.h"
29
#include "main.h"
30
#include "timer.h"
31
#include "eeprom.h"
32
#include "Wi232.h"
33
 
34
#define EEpromVersion  3
35
 
36
//*****************************************************************************
37
// 
38
 
39
uint8_t EE_LowBat               EEMEM= 137;
40
uint8_t EE_DisplayTimeout       EEMEM= 0;
41
uint8_t EE_DisplayLanguage      EEMEM= 0;
42
uint8_t EE_WiTXRXChannel        EEMEM= 1;
43
uint8_t EE_WiNetworkGroup       EEMEM=66;
44
uint8_t EE_WiNetworkMode        EEMEM=NetMode_Normal;
45
uint8_t EE_PKTVersion           EEMEM=EEpromVersion;
46
uint8_t EE_LCD_Orientation  EEMEM=0;
47
 
48
volatile uint8_t DisplayTimeout;
49
volatile uint8_t DisplayLanguage;
50
volatile uint8_t WiTXRXChannel;
51
volatile uint8_t WiNetworkGroup;
52
volatile uint8_t WiNetworkMode;
53
 
54
//*****************************************************************************
55
// 
56
void ReadParameter (void)
57
{
58
        MK_LowBat = eeprom_read_byte(&EE_LowBat);
59
        DisplayTimeout = eeprom_read_byte(&EE_DisplayTimeout);
60
        DisplayLanguage = eeprom_read_byte(&EE_DisplayLanguage);
61
        WiTXRXChannel =eeprom_read_byte(&EE_WiTXRXChannel);
62
        WiNetworkGroup =eeprom_read_byte(&EE_WiNetworkGroup);
63
        WiNetworkMode =eeprom_read_byte(&EE_WiNetworkMode);
64
        LCD_ORIENTATION = eeprom_read_byte(&EE_LCD_Orientation);
65
 
66
        if (eeprom_read_byte(&EE_PKTVersion)!= EEpromVersion)
67
 
68
        { /* EEPROM auf Default setzen*/
69
 
70
                MK_LowBat = 137;                                /*13,7V*/
71
                DisplayTimeout = 0;                     /* Display immer an */
72
                DisplayLanguage = 0;                    /* deutsch*/
73
                WiTXRXChannel = 1;                              /* Kanal 1 MK Standard*/
74
                WiNetworkGroup = 66;                    /*Gruppe 66  MK Standard*/
75
                WiNetworkMode = NetMode_Normal;         /* MK Standard */
76
                LCD_ORIENTATION = 0;                    /* normale Ansicht */
77
 
78
            eeprom_write_byte(&EE_LowBat, MK_LowBat);
79
                eeprom_write_byte(&EE_DisplayTimeout, DisplayTimeout);
80
                eeprom_write_byte(&EE_DisplayLanguage, DisplayLanguage);
81
                eeprom_write_byte(&EE_WiTXRXChannel, WiTXRXChannel);
82
                eeprom_write_byte(&EE_WiNetworkGroup, WiNetworkGroup);
83
                eeprom_write_byte(&EE_WiNetworkMode, WiNetworkMode);
84
                eeprom_write_byte(&EE_PKTVersion,EEpromVersion);
85
        eeprom_write_byte(&EE_LCD_Orientation, LCD_ORIENTATION);
86
 
87
                lcd_cls ();
88
                lcd_printp (PSTR("EEPROM Parameter\r\n"), 0);
89
                lcd_printp (PSTR("auf Default gesetzt\r\n"), 0);
90
                lcd_printp (PSTR("weiter mit ENTER\r\n"), 0);
91
                while (!(get_key_press (1 << KEY_ENTER)));
92
                return;
93
         }
94
 
95
 
96
}
97
 
98
//*****************************************************************************
99
// 
100
void WriteParameter (void)
101
{
102
         eeprom_write_byte(&EE_LowBat, MK_LowBat);
103
         eeprom_write_byte(&EE_DisplayTimeout, DisplayTimeout);
104
         eeprom_write_byte(&EE_DisplayLanguage, DisplayLanguage);
105
         eeprom_write_byte(&EE_WiTXRXChannel, WiTXRXChannel);
106
         eeprom_write_byte(&EE_WiNetworkGroup, WiNetworkGroup);
107
         eeprom_write_byte(&EE_WiNetworkMode, WiNetworkMode);
108
         eeprom_write_byte(&EE_LCD_Orientation, LCD_ORIENTATION);
109
}