aboutsummaryrefslogtreecommitdiffhomepage
path: root/workspace/TS100/Core/Inc/Settings.h
blob: f7c0f229c5c8a45061d44ea8e581c5a1bb49692f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Settings.h
 *
 *  Created on: 29 Sep 2016
 *      Author: Ralim
 *
 *      Houses the system settings and allows saving / restoring from flash
 */

#ifndef SETTINGS_H_
#define SETTINGS_H_
#include <stdint.h>
#include "stm32f1xx_hal.h"
#define SETTINGSVERSION   ( 0x1B )
/*Change this if you change the struct below to prevent people getting \
          out of sync*/

/*
 * This struct must be a multiple of 2 bytes as it is saved / restored from
 * flash in uint16_t chunks
 */
typedef struct {
	uint16_t SolderingTemp;  // current set point for the iron
	uint16_t SleepTemp;      // temp to drop to in sleep
	uint8_t SleepTime;       // minutes timeout to sleep
	uint8_t cutoutSetting; // The voltage we cut out at for under voltage OR Power level for TS80
	uint8_t OrientationMode :2; // If true we want to invert the display for lefties
	uint8_t sensitivity :4;  // Sensitivity of accelerometer (5 bits)
	uint8_t autoStartMode :2;  // Should the unit automatically jump straight
							   // into soldering mode when power is applied
	uint8_t ShutdownTime;          // Time until unit shuts down if left alone
	uint8_t boostModeEnabled :1;  // Boost mode swaps BUT_A in soldering mode to
								  // temporary soldering temp over-ride
	uint8_t coolingTempBlink :1;  // Should the temperature blink on the cool
								  // down screen until its <50C
	uint8_t detailedIDLE :1;       // Detailed idle screen
	uint8_t detailedSoldering :1;  // Detailed soldering screens
	uint8_t temperatureInF;         // Should the temp be in F or C (true is F)
	uint8_t descriptionScrollSpeed :1;  // Description scroll speed
	uint16_t voltageDiv;                 // Voltage divisor factor
	uint16_t BoostTemp;                  // Boost mode set point for the iron
	uint16_t CalibrationOffset; // This stores the temperature offset for this tip
								// in the iron.

	uint8_t customTipGain;  // Tip gain value if custom tuned, or 0 if using a
							// tipType param
	uint8_t pidPowerLimit;
	uint8_t version;  // Used to track if a reset is needed on firmware upgrade
	uint32_t padding;  // This is here for in case we are not an even divisor so
					   // that nothing gets cut off
} systemSettingsType;

extern volatile systemSettingsType systemSettings;

void saveSettings();
bool restoreSettings();
uint8_t lookupVoltageLevel(uint8_t level);
void resetSettings();
bool showBootLogoIfavailable();
#endif /* SETTINGS_H_ */