Digital Scale 1.0 Digital Scale

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Typedefs | Enumerations | Functions | Variables
scale.h File Reference

Go to the source code of this file.

## Macros
#define | MAX_AVG_WEIGHT 10
| Multiplier for average Value in GetAvg2. Maximum value is 21. More...
#define | MAXHIST 64
| Memory reserved for moving average, used for precision measurement mode. More...
#define | MIN_AVG_WEIGHT 4
| Multiplier for average Value in GetAvg2. More...
#define | MINHIST 8
| Number of values used for fast measurement mode. More...
#define | NUM_COEFF 11
#define | USE_GetAvg3
| Selection of averaging algorithm. Set to USE_GetAvg1 or USE_GetAvg2 as desired. More...

## Typedefs
typedef uint16_t | delay_t
| The data type used by DelayMs(). Set to a type capable of counting the max ms you want to use. More...
typedef int32_t | weight_t
| The data type for a weight value. More...

## Enumerations
enum | SWITCH_ACTION_t { SWITCH_NONE, SWITCH_SHORT, SWITCH_MED, SWITCH_LONG, SWITCH_DOUBLE }

## Functions
void | Calibrate (void)
| Performs Calibration of the Scale. More...
void | DelayMs (delay_t ms)
| Delays for ms Milliseconds. More...
static void | PowerOff (void)
static void | PowerOn (void)

## Variables
uint8_t | avgFactor
| The factor, the last weight is stronger than the current measurement value. More...
uint8_t | cnt128
| Must be set to zero to start summing. More...
const int8_t | coeff []
| The Array holding the Filter Coefficients. More...
static const uint8_t | EFLAG_LOBAT =2
| Is set on low Supply Voltage. More...
static const uint8_t | EFLAG_UNCAL =1
| Device has not been calibrated. More...
volatile uint8_t | eFlags
| Error flags. More...
uint8_t | histSize
| Number of values used for moving average. More...
uint8_t | hxCnt
| is incremented each time the HX receives a new value More...
bool | HXdisplayWeight
| If true, reading a new HX value updates the display. May be disabled for service display. More...
volatile uint8_t | secCnt
| Seconds of inactivity. More...
weight_t | sum128
| Contains the sum of 128 values when cnt128==128. More...
volatile SWITCH_ACTION_t | switchAction
| Is set by interrupt if the switch has been pressed. Must be reset by the surrounding loop. More...
static const uint8_t | TFLAG_SEC =1
| Is set once per Second. More...
volatile uint8_t | tFlags
| Flags set by Time. More...
volatile uint8_t | tickCnt
| Counter for timer0 interrupts. More...
int32_t | weightHist []
| Array holding the last Weight Values. More...
volatile uint8_t | zeroWeightSecCnt
| Counts seconds of 'no load'. Used for accelerated power off. More...

## Macro Definition Documentation

#define USE_GetAvg3

Selection of averaging algorithm. Set to USE_GetAvg1 or USE_GetAvg2 as desired.

#define MAXHIST 64

Memory reserved for moving average, used for precision measurement mode.

#define MINHIST 8

Number of values used for fast measurement mode.

#define MIN_AVG_WEIGHT 4

Multiplier for average Value in GetAvg2.

#define MAX_AVG_WEIGHT 10

Multiplier for average Value in GetAvg2. Maximum value is 21.

#define NUM_COEFF 11

## Typedef Documentation

typedef uint16_t delay_t

The data type used by DelayMs(). Set to a type capable of counting the max ms you want to use.

typedef int32_t weight_t

The data type for a weight value.

## Function Documentation

static void PowerOff | ( | void | ) |  |
| inline static

static void PowerOn | ( | void | ) |  |
| inline static

void DelayMs | ( | delay_t | ms) |  |

Delays for ms Milliseconds.

Note
  The timer resolution is 1ms and the state of the timer when calling this function is normally undefined. The actual delay may differ up to 1ms from the given value (especially, it may be nearly 0 if you specify 1ms)!

Parameters

  ms | The desired delay in Milliseconds

void Calibrate | ( | void | ) |  |

Performs Calibration of the Scale.

## Variable Documentation

uint8_t histSize

Number of values used for moving average.

uint8_t avgFactor

The factor, the last weight is stronger than the current measurement value.

const int8_t coeff[]

The Array holding the Filter Coefficients.

int32_t weightHist[]

Array holding the last Weight Values.

weight_t sum128

Contains the sum of 128 values when cnt128==128.

uint8_t cnt128

Must be set to zero to start summing.

volatile uint8_t tickCnt

Counter for timer0 interrupts.

volatile uint8_t secCnt

Seconds of inactivity.

volatile uint8_t zeroWeightSecCnt

Counts seconds of 'no load'. Used for accelerated power off.

uint8_t hxCnt

is incremented each time the HX receives a new value

bool HXdisplayWeight

If true, reading a new HX value updates the display. May be disabled for service display.