restructured Folder-Structure
This commit is contained in:
138
Software/include/config.h
Normal file
138
Software/include/config.h
Normal file
@@ -0,0 +1,138 @@
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <I2C_eeprom.h>
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "common.h"
|
||||
|
||||
#if PCB_REV == 1 || PCB_REV == 2 || PCB_REV == 3
|
||||
#define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC64
|
||||
#elif PCB_REV == 4
|
||||
#define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC256
|
||||
#endif
|
||||
|
||||
typedef enum SpeedSource_e
|
||||
{
|
||||
#ifdef FEATURE_ENABLE_TIMER
|
||||
SOURCE_TIME,
|
||||
#endif
|
||||
SOURCE_IMPULSE,
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
SOURCE_GPS,
|
||||
#endif
|
||||
#if FEATURE_ENABLE_CAN
|
||||
SOURCE_CAN
|
||||
#endif
|
||||
} SpeedSource_t;
|
||||
|
||||
const char SpeedSourceString[][8] = {
|
||||
#ifdef FEATURE_ENABLE_TIMER
|
||||
"Timer",
|
||||
#endif
|
||||
"Impuls",
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
"GPS",
|
||||
#endif
|
||||
#if FEATURE_ENABLE_CAN
|
||||
"CAN-Bus"
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
typedef enum GPSBaudRate_e
|
||||
{
|
||||
BAUD_9600,
|
||||
BAUD_115200
|
||||
} GPSBaudRate_t;
|
||||
|
||||
const char GPSBaudRateString[][7] = {
|
||||
"9600",
|
||||
"115200"};
|
||||
|
||||
const size_t GPSBaudRateString_Elements = sizeof(GPSBaudRateString) / sizeof(GPSBaudRateString[0]);
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_ENABLE_CAN
|
||||
typedef enum CANSource_e
|
||||
{
|
||||
KTM_890_ADV_R_2021
|
||||
} CANSource_t;
|
||||
|
||||
const char CANSourceString[][28] = {
|
||||
"KTM 890 Adventure R (2021)"};
|
||||
|
||||
const char CANSourceString_Elements = sizeof(CANSourceString) / sizeof(CANSourceString[0]);
|
||||
#endif
|
||||
|
||||
const size_t SpeedSourceString_Elements = sizeof(SpeedSourceString) / sizeof(SpeedSourceString[0]);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t writeCycleCounter = 0;
|
||||
uint32_t tankRemain_microL = 0;
|
||||
uint32_t TravelDistance_highRes_mm = 0;
|
||||
uint32_t odometer_mm = 0;
|
||||
uint32_t odometer = 0;
|
||||
uint32_t checksum = 0;
|
||||
} persistenceData_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t EEPROM_Version = 0;
|
||||
uint32_t DistancePerLube_Default = 8000;
|
||||
uint32_t DistancePerLube_Rain = 4000;
|
||||
uint32_t tankCapacity_ml = 320;
|
||||
uint32_t amountPerDose_microL = DEFAULT_PUMP_DOSE;
|
||||
uint8_t TankRemindAtPercentage = 30;
|
||||
uint8_t PulsePerRevolution = 1;
|
||||
uint32_t TireWidth_mm = 150;
|
||||
uint32_t TireWidthHeight_Ratio = 70;
|
||||
uint32_t RimDiameter_Inch = 18;
|
||||
uint32_t DistancePerRevolution_mm = 2000;
|
||||
uint16_t BleedingPulses = 25;
|
||||
SpeedSource_t SpeedSource = SOURCE_IMPULSE;
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
GPSBaudRate_t GPSBaudRate = BAUD_115200;
|
||||
#endif
|
||||
#ifdef FEATURE_ENABLE_CAN
|
||||
CANSource_t CANSource = KTM_890_ADV_R_2021;
|
||||
#endif
|
||||
bool LED_Mode_Flash = false;
|
||||
uint8_t LED_Max_Brightness = 255;
|
||||
uint8_t LED_Min_Brightness = 5;
|
||||
uint32_t checksum = 0;
|
||||
} LubeConfig_t;
|
||||
|
||||
const LubeConfig_t LubeConfig_defaults = {
|
||||
0, 8000, 4000, 320, DEFAULT_PUMP_DOSE, 30, 1, 150, 70, 18, 2000, 25, SOURCE_IMPULSE,
|
||||
#ifdef FEATURE_ENABLE_GPS
|
||||
BAUD_115200,
|
||||
#endif
|
||||
#ifdef FEATURE_ENABLE_CAN
|
||||
KTM_890_ADV_R_2021,
|
||||
#endif
|
||||
false,
|
||||
255,
|
||||
5,
|
||||
0};
|
||||
|
||||
void InitEEPROM();
|
||||
void EEPROM_Process();
|
||||
void StoreConfig_EEPROM();
|
||||
void GetConfig_EEPROM();
|
||||
void StorePersistence_EEPROM();
|
||||
void GetPersistence_EEPROM();
|
||||
void FormatConfig_EEPROM();
|
||||
void FormatPersistence_EEPROM();
|
||||
uint32_t Checksum_EEPROM(uint8_t const *data, size_t len);
|
||||
void dumpEEPROM(uint16_t memoryAddress, uint16_t length);
|
||||
void MovePersistencePage_EEPROM(boolean reset);
|
||||
uint32_t ConfigSanityCheck(bool autocorrect = false);
|
||||
|
||||
extern LubeConfig_t LubeConfig;
|
||||
extern persistenceData_t PersistenceData;
|
||||
extern uint16_t eePersistenceMarker;
|
||||
#endif // _CONFIG_H_
|
Reference in New Issue
Block a user