Phoenard
Classes | Macros | Functions | Variables
PHNSettings.h File Reference

Manages the loading and saving of settings in EEPROM with the PHN_Settings struct. More...

#include <avr/eeprom.h>

Go to the source code of this file.

Classes

struct  PHN_Settings
 Structure holding the settings stored in EEPROM. More...
 

Macros

#define SETTINGS_DEFAULT_SKETCH   {'S', 'K', 'E', 'T', 'C', 'H', 'E', 'S'}
 
#define SETTINGS_DEFAULT_FLAGS   (SETTINGS_LOAD | SETTINGS_CHANGED | SETTINGS_TOUCH_HOR_INV)
 
#define SETTINGS_DEFAULT_TOUCH_HOR_A   100
 
#define SETTINGS_DEFAULT_TOUCH_HOR_B   100
 
#define SETTINGS_DEFAULT_TOUCH_VER_A   120
 
#define SETTINGS_DEFAULT_TOUCH_VER_B   120
 
#define EEPROM_SIZE   4096
 The total size of the device EEPROM.
 
#define EEPROM_SETTINGS_SIZE   sizeof(PHN_Settings)
 The total size of the settings stored.
 
#define EEPROM_SETTINGS_ADDR   (EEPROM_SIZE - EEPROM_SETTINGS_SIZE)
 The address in EEPROM where the settings are stored.
 
#define EEPROM_SETTINGS_ADDR_FIELD(field)   (const uint8_t*) (EEPROM_SETTINGS_ADDR+offsetof(PHN_Settings, field))
 Macro to obtain the EEPROM address to a particular option field.
 
#define PHN_Settings_Load(settings)   eeprom_read_block( &settings, (void*) EEPROM_SETTINGS_ADDR, EEPROM_SETTINGS_SIZE)
 Macro to load settings from EEPROM.
 
#define PHN_Settings_Save(settings)   eeprom_write_block(&settings, (void*) EEPROM_SETTINGS_ADDR, EEPROM_SETTINGS_SIZE)
 Macro to save settings to EEPROM.
 
#define PHN_Settings_LoadField(settings, field, size)   eeprom_read_block(&settings.field, EEPROM_SETTINGS_ADDR_FIELD(field), size)
 Macro to load a single or a group of setting fields from EEPROM.
 
Setting flags

The available flags stored inside PHN_Settings

#define SETTINGS_LOAD   0x01
 Specifies a sketch has to be loaded from Micro-SD.
 
#define SETTINGS_LOADWIPE   0x02
 Specifies that loading must be skipped, with program wiped.
 
#define SETTINGS_MODIFIED   0x04
 Specifies that the current sketch is modified and needs saving.
 
#define SETTINGS_TOUCH_HOR_INV   0x08
 Specifies that touch input is inverted horizontally.
 
#define SETTINGS_TOUCH_VER_INV   0x10
 Specifies that touch input is inverted vertically.
 
#define SETTINGS_CHANGED   0x80
 Specifies settings have been changed - never written to EEPROM.
 

Functions

void PHN_Settings_ReadCali (PHN_Settings settings, int *hor_a, int *hor_b, int *ver_a, int *ver_b)
 Reads the screen calibration information from the settings.
 
void PHN_Settings_WriteCali (PHN_Settings *settings, int hor_a, int hor_b, int ver_a, int ver_b)
 Writes the screen calibration information to the settings.
 
void PHN_loadSketch (const char *sketchName, bool loadNow=true)
 Requests the bootloader to load a particular sketch.
 

Variables

const PHN_Settings SETTINGS_DEFAULT
 

Detailed Description

Manages the loading and saving of settings in EEPROM with the PHN_Settings struct.

Settings are stored in the back of EEPROM and are used by the bootloader to perform actions. When set in EEPROM, the bootloader can be told to switch to a new sketch. The current sketch and sketch size is stored, as well as calibration values for the LCD screen.

Variable Documentation

const PHN_Settings SETTINGS_DEFAULT
Initial value:
= {
SETTINGS_DEFAULT_TOUCH_HOR_A, SETTINGS_DEFAULT_TOUCH_HOR_B,
SETTINGS_DEFAULT_TOUCH_VER_A, SETTINGS_DEFAULT_TOUCH_VER_B,
SETTINGS_DEFAULT_SKETCH, SETTINGS_DEFAULT_SKETCH, 0, SETTINGS_DEFAULT_FLAGS
}