LevelMeter-Display  2.0
An ultrasonic Level Meter for Stormwater Cisterns
Functions | Variables
config.c File Reference

Routines for handling Configuration Data. More...

Include dependency graph for config.c:

Functions

static void DefaultConfig (void)
 Loads default config values into conf-struct and stores it in non volatile Memory. More...
 
void DumpConfig (void)
 Lists the current configuration values. More...
 
void DumpConfigSignal (uint8_t number)
 DumpConfig Helper Function for Optocoupler outputs. More...
 
void ReadConfig (void)
 Reads the Config-Struct from EEPROM into config. More...
 
bool SoundsOK (void)
 Checks if sounds may currently be played. More...
 
void WriteConfig (void)
 Writes the Config-Struct to EEPROM. More...
 

Variables

confStruct_t config
 The Configuration. It is read on startup from the EEPROM. More...
 
bool configDirty =false
 Set to true by routines affecting configuration if config memory needs to be saved to the EEPROM. More...
 
confStruct_t EEMEM defaultConfig
 This Struct will be stored in the EEPROM and is contained in the Production File. More...
 

Detailed Description

Routines for handling Configuration Data.

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 3 of the License, or (at your option) any later version.

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, see http://www.gnu.org/licenses/.

Function Documentation

◆ DefaultConfig()

static void DefaultConfig ( void  )
static

Loads default config values into conf-struct and stores it in non volatile Memory.

This function is mostly useful during development but I recommend to leave it functional. You can omit this routine if you want to save about 300 bytes of flash but it is quite useful if you change the config struct and change CONF_MAGIC. It will reprogram the EEPROM with default values then. Especially in devices already in the field it would lead to unpredictable results if the configuration memory format would not be compatible with the current version.

Note
Keep the values here in sync with the values in defaultConfig if you don't like surprises!

References signalOutput_t::activeAbove, signalOutput_t::activeBelow, ADCVoltsPerLSB, confStruct_t::backlightAlwaysOn, confStruct_t::backlightOnTime, CIST_CONST_AREA, confStruct_t::cistAreaOrDiameter, confStruct_t::cistCapacity, confStruct_t::cisternType, confStruct_t::cistHeight, CONF_MAGIC, config, delay1s(), DISPLAY_4x20, confStruct_t::displayType, dividerP3, dividerP5, dividerSWUnreg, dividerUnreg, confStruct_t::instCal, confStruct_t::invDCF77, confStruct_t::LCDBright, confStruct_t::LCDV0, confStruct_t::magic, NUM_SIGNAL, confStruct_t::P3VoltsPerLSB, confStruct_t::P5VoltsPerLSB, confStruct_t::pageTime, confStruct_t::pageTimeK, confStruct_t::signalOutputs, confStruct_t::sndHourFrom, confStruct_t::sndHourTo, confStruct_t::sndMask, confStruct_t::spontaneousReportVolume, confStruct_t::SWUnregVoltsPerLSB, confStruct_t::UnregVoltsPerLSB, confStruct_t::useRts, and WriteConfig().

Referenced by ReadConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DumpConfig()

void DumpConfig ( void  )

◆ DumpConfigSignal()

void DumpConfigSignal ( uint8_t  number)

DumpConfig Helper Function for Optocoupler outputs.

Parameters
numberThe Number of the Signal Output (Zero-based)

References signalOutput_t::activeAbove, signalOutput_t::activeBelow, config, hprintf_P(), and confStruct_t::signalOutputs.

Referenced by CmdSetSignal(), and DumpConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadConfig()

void ReadConfig ( void  )

Reads the Config-Struct from EEPROM into config.

Only the config-struct in RAM will be used. Changes in config will only become permanent if you use a write-command. There is a configDirty-flag that is set by every routine that changes config and is used to remind the user to execute a write-command.

References CONF_MAGIC, config, configDirty, defaultConfig, DefaultConfig(), and confStruct_t::magic.

Referenced by Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SoundsOK()

bool SoundsOK ( void  )

Checks if sounds may currently be played.

"Currently" means at the actual time-of-day. Check this function before you play sounds that should not be always enabled.

Returns
true if sounds are ok, false if not

References config, hrCnt, confStruct_t::sndHourFrom, and confStruct_t::sndHourTo.

Referenced by DoTflags().

Here is the caller graph for this function:

◆ WriteConfig()

void WriteConfig ( void  )

Writes the Config-Struct to EEPROM.

References config, configDirty, and defaultConfig.

Referenced by CmdWrite(), and DefaultConfig().

Here is the caller graph for this function:

Variable Documentation

◆ config

confStruct_t config

◆ configDirty

bool configDirty =false

Set to true by routines affecting configuration if config memory needs to be saved to the EEPROM.

Referenced by CmdCalibrate(), CmdSetBright(), CmdSetCistern(), CmdSetContrast(), CmdSetDCFInv(), CmdSetDisplay(), CmdSetPTime(), CmdSetPTimeK(), CmdSetSignal(), CmdSetSounds(), CmdSetSpontaneous(), CmdUseRts(), CmdWrite(), ExecCommand(), ReadConfig(), and WriteConfig().

◆ defaultConfig

confStruct_t EEMEM defaultConfig
Initial value:
=
{
.magic=CONF_MAGIC,
.displayType=DISPLAY_4x20,
.cisternType=CIST_CONST_AREA,
.cistAreaOrDiameter=3.0,
.cistHeight=2.8,
.cistCapacity=6000.0,
.invDCF77=0,
.LCDV0=25,
.LCDBright=255,
.P3VoltsPerLSB=ADCVoltsPerLSB/dividerP3,
.P5VoltsPerLSB=ADCVoltsPerLSB/dividerP5,
.UnregVoltsPerLSB=ADCVoltsPerLSB/dividerUnreg,
.SWUnregVoltsPerLSB=ADCVoltsPerLSB/dividerSWUnreg,
.backlightAlwaysOn=true,
.backlightOnTime=5,
.pageTime=4,
.pageTimeK=60,
.signalOutputs[0].activeBelow=0,
.signalOutputs[0].activeAbove=65535,
.signalOutputs[1].activeBelow=0,
.signalOutputs[1].activeAbove=65535,
.sndHourFrom=9,
.sndHourTo=21,
.sndMask=0,
.instCal=117,
.useRts=true,
.spontaneousReportVolume=0.0,
}
Cistern with constant area over volume.
Definition: config.h:42
#define CONF_MAGIC
Change this value if confStruct_t becomes incompatible to previous versions!
Definition: config.h:27
Display is a Winstar WH2004A or equivalent.
Definition: display.h:131
#define dividerP5
Resistor divider for P5. Gives 7.03V FSR or 6.86mV/LSB.
Definition: display.h:89
#define dividerUnreg
Resistor divider for Unreg. Gives 39.6V FSR or 38.7mV/LSB.
Definition: display.h:90
#define ADCVoltsPerLSB
Voltage step for one LSB of the AD converter.
Definition: display.h:87
#define dividerSWUnreg
Resistor divider for SWUnreg. Gives 39.6V FSR or 38.7mV/LSB.
Definition: display.h:91
#define dividerP3
Resistor divider for P3. Gives 7.03V FSR or 6.86mV/LSB.
Definition: display.h:88

This Struct will be stored in the EEPROM and is contained in the Production File.

'New' devices are programmed using the production file which also can write the default EEPROM content and the fuses.

Referenced by ReadConfig(), and WriteConfig().