Subversion Repositories Projects

Rev

Rev 1307 | Blame | Last modification | View Log | RSS feed

/*****************************************************************************
 *   Copyright (C) 2010 seb@exse.net                                                                             *
 *   Copyright (C) 2011 Christian Brandtner brandtner@brandtner.net          *
 *                                                                           *
 *   This program is free software; you can redistribute it and/or modify    *
 *   it under the terms of the GNU General Public License as published by    *
 *   the Free Software Foundation; either version 2 of the License.          *
 *                                                                           *
 *   This program is distributed in the hope that it will be useful,         *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 *   GNU General Public License for more details.                            *
 *                                                                           *
 *   You should have received a copy of the GNU General Public License       *
 *   along with this program; if not, write to the                           *
 *   Free Software Foundation, Inc.,                                         *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
 *                                                                           *
 *****************************************************************************/

/*14.6.2011 Parameter erweitert Wi232 Cebra */

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <stdlib.h>
#include <string.h>
#include <avr/eeprom.h>
#include "lcd.h"
#include "main.h"
#include "timer.h"
#include "eeprom.h"
#include "Wi232.h"

#define EEpromVersion  3

//*****************************************************************************
//

uint8_t EE_LowBat               EEMEM= 137;
uint8_t EE_DisplayTimeout       EEMEM= 0;
uint8_t EE_DisplayLanguage      EEMEM= 0;
uint8_t EE_WiTXRXChannel        EEMEM= 1;
uint8_t EE_WiNetworkGroup       EEMEM=66;
uint8_t EE_WiNetworkMode        EEMEM=NetMode_Normal;
uint8_t EE_PKTVersion           EEMEM=EEpromVersion;
uint8_t EE_LCD_Orientation  EEMEM=0;

volatile uint8_t DisplayTimeout;
volatile uint8_t DisplayLanguage;
volatile uint8_t WiTXRXChannel;
volatile uint8_t WiNetworkGroup;
volatile uint8_t WiNetworkMode;

//*****************************************************************************
//
void ReadParameter (void)
{
        MK_LowBat = eeprom_read_byte(&EE_LowBat);
        DisplayTimeout = eeprom_read_byte(&EE_DisplayTimeout);
        DisplayLanguage = eeprom_read_byte(&EE_DisplayLanguage);
        WiTXRXChannel =eeprom_read_byte(&EE_WiTXRXChannel);
        WiNetworkGroup =eeprom_read_byte(&EE_WiNetworkGroup);
        WiNetworkMode =eeprom_read_byte(&EE_WiNetworkMode);
        LCD_ORIENTATION = eeprom_read_byte(&EE_LCD_Orientation);

        if (eeprom_read_byte(&EE_PKTVersion)!= EEpromVersion)

        { /* EEPROM auf Default setzen*/

                MK_LowBat = 137;                                /*13,7V*/
                DisplayTimeout = 0;                     /* Display immer an */
                DisplayLanguage = 0;                    /* deutsch*/
                WiTXRXChannel = 1;                              /* Kanal 1 MK Standard*/
                WiNetworkGroup = 66;                    /*Gruppe 66  MK Standard*/
                WiNetworkMode = NetMode_Normal;         /* MK Standard */
                LCD_ORIENTATION = 0;                    /* normale Ansicht */

            eeprom_write_byte(&EE_LowBat, MK_LowBat);
                eeprom_write_byte(&EE_DisplayTimeout, DisplayTimeout);
                eeprom_write_byte(&EE_DisplayLanguage, DisplayLanguage);
                eeprom_write_byte(&EE_WiTXRXChannel, WiTXRXChannel);
                eeprom_write_byte(&EE_WiNetworkGroup, WiNetworkGroup);
                eeprom_write_byte(&EE_WiNetworkMode, WiNetworkMode);
                eeprom_write_byte(&EE_PKTVersion,EEpromVersion);
        eeprom_write_byte(&EE_LCD_Orientation, LCD_ORIENTATION);

                lcd_cls ();
                lcd_printp (PSTR("EEPROM Parameter\r\n"), 0);
                lcd_printp (PSTR("auf Default gesetzt\r\n"), 0);
                lcd_printp (PSTR("weiter mit ENTER\r\n"), 0);
                while (!(get_key_press (1 << KEY_ENTER)));
                return;
         }


}

//*****************************************************************************
//
void WriteParameter (void)
{
         eeprom_write_byte(&EE_LowBat, MK_LowBat);
         eeprom_write_byte(&EE_DisplayTimeout, DisplayTimeout);
         eeprom_write_byte(&EE_DisplayLanguage, DisplayLanguage);
         eeprom_write_byte(&EE_WiTXRXChannel, WiTXRXChannel);
         eeprom_write_byte(&EE_WiNetworkGroup, WiNetworkGroup);
         eeprom_write_byte(&EE_WiNetworkMode, WiNetworkMode);
         eeprom_write_byte(&EE_LCD_Orientation, LCD_ORIENTATION);
}