Compare commits
8 Commits
beta-0.0.1
...
master
Author | SHA1 | Date | |
---|---|---|---|
674dbb96c2 | |||
4122ec3631 | |||
bb0cd45a76 | |||
47cf5388e3 | |||
33ab540653 | |||
bf9d8dafb6 | |||
15352ddfcd | |||
2a9e8efb3d |
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
FloatPUMP
|
11
.idea/cmake.xml
generated
Normal file
11
.idea/cmake.xml
generated
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakeSharedSettings">
|
||||||
|
<configurations>
|
||||||
|
<configuration PROFILE_NAME="Debug-fw" ENABLED="true" GENERATION_DIR=".out/fw-debug" CONFIG_NAME="Debug" TOOLCHAIN_NAME="dev-arm-stm32" NO_GENERATOR="true" />
|
||||||
|
<configuration PROFILE_NAME="Release-fw" ENABLED="true" GENERATION_DIR=".out/fw-release" CONFIG_NAME="Release" TOOLCHAIN_NAME="dev-arm-stm32" NO_GENERATOR="true" />
|
||||||
|
<configuration PROFILE_NAME="RelWithDebInfo-fw" ENABLED="true" GENERATION_DIR=".out/fw-relwithdebinfo" CONFIG_NAME="RelWithDebInfo" TOOLCHAIN_NAME="dev-arm-stm32" NO_GENERATOR="true" />
|
||||||
|
<configuration PROFILE_NAME="MinSizeRel-fw" ENABLED="true" GENERATION_DIR=".out/fw-minsizerel" CONFIG_NAME="MinSizeRel" TOOLCHAIN_NAME="dev-arm-stm32" NO_GENERATOR="true" />
|
||||||
|
</configurations>
|
||||||
|
</component>
|
||||||
|
</project>
|
2
.idea/floatpump-firmware.iml
generated
Normal file
2
.idea/floatpump-firmware.iml
generated
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
|
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/floatpump-firmware.iml" filepath="$PROJECT_DIR$/.idea/floatpump-firmware.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
102
README.md
102
README.md
@ -1,3 +1,101 @@
|
|||||||
# study_research
|
# FloatPUMP - Firmware Repository
|
||||||
|
|
||||||
Studienarbeit Semester 7
|
This repository contains the necessary files to completely build the firmware for the FloatPUMP controller.
|
||||||
|
The toolchain used in this project is built up using **docker**. The following sections describe how to setup the
|
||||||
|
jetbrains
|
||||||
|
CLion IDE to automatically use the included docker image to build the project. It also contains some description
|
||||||
|
on how to use OpenOCD to flash the controller using a **STLink-V2** Programmer.
|
||||||
|
|
||||||
|
## Toolchain Setup
|
||||||
|
|
||||||
|
This chapter describes how to setup the CLion IDE to use the toolchain built with docker.
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
- Install jetbrains CLion IDE
|
||||||
|
- Install Docker
|
||||||
|
- Open the Project by clicking _New project from version control_
|
||||||
|
|
||||||
|
### Build the docker image
|
||||||
|
|
||||||
|
You can build the image by yourself. Alternatively you can pull the image from the robtor.de registry.
|
||||||
|
Open a command line and enter the subdirectory build-tools. There run the follwing command to
|
||||||
|
build the docker image:
|
||||||
|
|
||||||
|
`docker build -t dev-arm-stm32:latest .`
|
||||||
|
|
||||||
|
As an alternative you could open the Dockerfile in this directory using CLion and build it directly out of the IDE!
|
||||||
|
|
||||||
|
### Pulling the image
|
||||||
|
|
||||||
|
This method is currently not supported. Coming soon...
|
||||||
|
|
||||||
|
### Configure toolchain
|
||||||
|
|
||||||
|
First enter the Settings dialog in CLion while the floatpump-firmware project is opened.
|
||||||
|
Under `Build, Execution, Deployment > Toolchain` add a new toolchain and choose the type `docker`.
|
||||||
|
Now setup everything as depicted in this screenshot:
|
||||||
|
![toolchain_settings.png](doc/toolchain_settings.png)
|
||||||
|
|
||||||
|
If you named the image different than dev-arm-stm32:latest, choose the correct image corresponding to your name.
|
||||||
|
|
||||||
|
Usually now the correct CMake build targets should appear under `Build, Execution, Deployment > CMake`.
|
||||||
|
|
||||||
|
### Configure OpenOCD
|
||||||
|
|
||||||
|
To configure OpenOCD for directly flashing and debugging out of CLion go to the BuildTargets dropdown in the
|
||||||
|
header line and click on `Edit configurations`.
|
||||||
|
There add a new configuration for `OpenOCD` and enter the following proerties:
|
||||||
|
![openocd_settings.png](doc/openocd_settings.png)
|
||||||
|
As `Board config file` chosse the correct `floatpump.cfg` file contained in the project root dir.
|
||||||
|
|
||||||
|
## Project structure
|
||||||
|
|
||||||
|
| Folder | Contents |
|
||||||
|
|:--------------------------------|:-----------------------|
|
||||||
|
| .out | Build output directory |
|
||||||
|
| build-tools | Files for building the toolchain|
|
||||||
|
| doc | Files for documentation or inclusion in .md Files|
|
||||||
|
| floatpump/Core | Firmware core source files |
|
||||||
|
| floatpump/Drivers | STM32 HAL and CMSIS Library files |
|
||||||
|
| floatpump/Middlewares/floatpump | Modules for the floatpump firmware |
|
||||||
|
| Middlewares/ST | STM32 Middleware files for USB OTG implementation |
|
||||||
|
| USB_DEVICE | same as above |
|
||||||
|
| net | Folder containing material for external Tasmota device and SmartHome integration |
|
||||||
|
| stm32-cube | Old files from the originating STM32 Cube Project |
|
||||||
|
|
||||||
|
# License
|
||||||
|
| Component | Copyright | License |
|
||||||
|
|:--------- |:----------------------------------------------------------|:---------------------------------------------|
|
||||||
|
| CMSIS | ARM Limited | Apache License 2.0 |
|
||||||
|
| CMSIS Device | ARM Limited - STMicroelectronics | Apache License 2.0 |
|
||||||
|
| STM32F4 HAL | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32F4-Discovery | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32F4xx_Nucleo_144 | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32F4xx-Nucleo | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32F401-Discovery | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32F411E-Discovery | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32F413H-Discovery | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32F429I-Discovery | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM324x9I_EVAL | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM324xG_EVAL | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32412G-Discovery | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32446E_EVAL | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32469I_EVAL | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP STM32469I-Discovery | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP Components | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| BSP Adafruit | STMicroelectronics | BSD-3-Clause |
|
||||||
|
| FreeRTOS kernel | Amazon.com, Inc. or its affiliates | MIT |
|
||||||
|
| FatFS | ChaN - STMicroelectronics | BSD-3-Clause |
|
||||||
|
| LibJPEG | Thomas G. Lane, Guido Vollbe | Independent JPEG Group License |
|
||||||
|
| LwIP | Swedish Institute of Computer Science | BSD-3-Clause |
|
||||||
|
| mbedTLS | ARM Limited | Apache License 2.0 |
|
||||||
|
| STM32_USB_Device_Library | STMicroelectronics | SLA0044 |
|
||||||
|
| STM32_USB_Host_Library | STMicroelectronics | SLA0044 |
|
||||||
|
| STemWin | STMicroelectronics | SLA0044 |
|
||||||
|
| TouchGFX | STMicroelectronics | SLA0044 |
|
||||||
|
| STM32_Audio | STMicroelectronics | SLA0044 |
|
||||||
|
| STM32 Projects | STMicroelectronics | SLA0044 (BSD-3-Clause for basic Examples) |
|
||||||
|
| STM32 Utilities | STMicroelectronics | BSD-3-Clause |
|
||||||
|
|
||||||
|
The default `LICENSE` file applies on all other Components not covered by the table above!
|
@ -1,4 +0,0 @@
|
|||||||
# Toolchain Setup
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
- Install Docker
|
|
BIN
doc/openocd_settings.png
Normal file
BIN
doc/openocd_settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
BIN
doc/toolchain_settings.png
Normal file
BIN
doc/toolchain_settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 123 KiB |
@ -218,57 +218,64 @@ int main(void) {
|
|||||||
|
|
||||||
static uint16_t old_minute_counter = minute_counter;
|
static uint16_t old_minute_counter = minute_counter;
|
||||||
|
|
||||||
|
static uint32_t dly_disp, dly_stats, dly_switch;
|
||||||
|
|
||||||
|
|
||||||
SendUartString(&huart1, "Hello from FloatPUMP Controller");
|
SendUartString(&huart1, "Hello from FloatPUMP Controller");
|
||||||
SendUartString(&huart1, {"Revision: " GIT_HASH});
|
SendUartString(&huart1, {"Revision: " GIT_HASH});
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
display.LCDSetBacklight(S_backlight);
|
//Execute this block each second only
|
||||||
|
if(HAL_GetTick() > dly_disp + 1000)
|
||||||
|
{
|
||||||
|
dly_disp = HAL_GetTick();
|
||||||
|
display.LCDSetBacklight(S_backlight);
|
||||||
|
//Increase to 21 -> crucial bug! usually never use sprintf! TODO: find another option instead!!!!
|
||||||
|
char buf[21];
|
||||||
|
|
||||||
|
display.LCDSetCursor(0, 0);
|
||||||
|
sprintf(buf, "Fuellstand %3d %%", tankLevel0.getPercent());
|
||||||
|
display.LCDSendCString(buf);
|
||||||
|
display.LCDSetCursor(0, 1);
|
||||||
|
if (S_tankempty) {
|
||||||
|
display.LCDSendCString(const_cast<char *>(std::string("Tank Wassermangel ").c_str()));
|
||||||
|
HAL_GPIO_WritePin(LED5_GPIO_Port, LED5_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
display.LCDSetCursor(0, 0);
|
} else {
|
||||||
display.LCDSendCString(
|
display.LCDSendCString(const_cast<char *>(std::string("Tank Normal ").c_str()));
|
||||||
const_cast<char *>(std::string(
|
HAL_GPIO_WritePin(LED5_GPIO_Port, LED5_Pin, GPIO_PIN_RESET);
|
||||||
"Fuellstand " + std::to_string(tankLevel0.getPercent()) + " %").c_str()));
|
}
|
||||||
display.LCDSetCursor(0, 1);
|
|
||||||
if (S_tankempty) {
|
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Tank Wassermangel ").c_str()));
|
|
||||||
HAL_GPIO_WritePin(LED5_GPIO_Port, LED5_Pin, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
} else {
|
display.LCDSetCursor(0, 2);
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Tank Normal ").c_str()));
|
if (S_refilling) {
|
||||||
HAL_GPIO_WritePin(LED5_GPIO_Port, LED5_Pin, GPIO_PIN_RESET);
|
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung laeuft ").c_str()));
|
||||||
|
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_RESET);
|
||||||
|
} else {
|
||||||
|
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung inaktiv").c_str()));
|
||||||
|
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
display.LCDSetCursor(0, 3);
|
||||||
|
if (S_refillcooldown > 0) {
|
||||||
|
int remaining_mins = S_refillcooldown / 60;
|
||||||
|
if (remaining_mins > 0) {
|
||||||
|
sprintf(buf, "Nsp. wartet: %3d min", S_refillcooldown / 60);
|
||||||
|
display.LCDSendCString(buf);
|
||||||
|
} else {
|
||||||
|
sprintf(buf, "Nsp. wartet: %3d sec", S_refillcooldown);
|
||||||
|
display.LCDSendCString(buf);
|
||||||
|
}
|
||||||
|
} else if (S_refillempty) {
|
||||||
|
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung mangel ").c_str()));
|
||||||
|
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET);
|
||||||
|
} else {
|
||||||
|
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung ok ").c_str()));
|
||||||
|
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
display.LCDSetCursor(0, 2);
|
|
||||||
if (S_refilling) {
|
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung laeuft ").c_str()));
|
|
||||||
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_RESET);
|
|
||||||
} else {
|
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung inaktiv").c_str()));
|
|
||||||
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
display.LCDSetCursor(0, 3);
|
|
||||||
if (S_refillcooldown > 0) {
|
|
||||||
int remaining_mins = S_refillcooldown / 60;
|
|
||||||
if (remaining_mins > 0)
|
|
||||||
display.LCDSendCString(const_cast<char *>(std::string(
|
|
||||||
"Nsp. wartet: min " + std::to_string(S_refillcooldown / 60)).c_str()));
|
|
||||||
else
|
|
||||||
display.LCDSendCString(
|
|
||||||
const_cast<char *>(std::string("Nsp. wartet: s " + std::to_string(S_refillcooldown)).c_str()));
|
|
||||||
} else if (S_refillempty) {
|
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung mangel ").c_str()));
|
|
||||||
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET);
|
|
||||||
} else {
|
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung ok ").c_str()));
|
|
||||||
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Check for rotation to enable display backlight
|
//Check for rotation to enable display backlight
|
||||||
if (old_pos < rot_counter) {
|
if (old_pos < rot_counter) {
|
||||||
controller.pushEvent(menu::Menu_Controller::Event::Increase);
|
controller.pushEvent(menu::Menu_Controller::Event::Increase);
|
||||||
@ -315,27 +322,28 @@ int main(void) {
|
|||||||
old_pos = rot_counter;
|
old_pos = rot_counter;
|
||||||
last_menu_retrigger = HAL_GetTick();
|
last_menu_retrigger = HAL_GetTick();
|
||||||
}
|
}
|
||||||
HAL_Delay(100);
|
HAL_Delay(10);
|
||||||
|
|
||||||
//Execute Calibrations if necessary
|
//Execute Calibrations if necessary
|
||||||
if (a_caliblow) {
|
if (a_caliblow) {
|
||||||
tankLevel0.calibrateLow();
|
|
||||||
controller.execute();
|
controller.execute();
|
||||||
HAL_Delay(2000);
|
tankLevel0.calibrateLow();
|
||||||
a_caliblow = false;
|
a_caliblow = false;
|
||||||
} else if (a_calibhigh) {
|
} else if (a_calibhigh) {
|
||||||
tankLevel0.calibrateHigh();
|
|
||||||
controller.execute();
|
controller.execute();
|
||||||
HAL_Delay(2000);
|
tankLevel0.calibrateHigh();
|
||||||
a_calibhigh = false;
|
a_calibhigh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Store or restore if necessary
|
//Store or restore if necessary
|
||||||
if (f_store) {
|
if (f_store) {
|
||||||
|
controller.execute();
|
||||||
Config_Store::getInstance().saveToFlash();
|
Config_Store::getInstance().saveToFlash();
|
||||||
f_store = false;
|
f_store = false;
|
||||||
} else if (f_restore) {
|
} else if (f_restore) {
|
||||||
|
controller.execute();
|
||||||
Config_Store::getInstance().loadFromFlash();
|
Config_Store::getInstance().loadFromFlash();
|
||||||
|
HAL_Delay(300);
|
||||||
f_restore = false;
|
f_restore = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,53 +357,63 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);
|
//Execute this only each 5 seconds
|
||||||
|
if(HAL_GetTick() > dly_switch + 5000)
|
||||||
|
{
|
||||||
|
dly_switch = HAL_GetTick();
|
||||||
|
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
//Poll Sensors
|
//Poll Sensors
|
||||||
tankLevel0.poll();
|
tankLevel0.poll();
|
||||||
refillBlocker0.poll();
|
refillBlocker0.poll();
|
||||||
|
|
||||||
//Check conditions
|
//Check conditions
|
||||||
CheckTankConditions(Config_Store::getInstance(), tankLevel0, tankPump);
|
CheckTankConditions(Config_Store::getInstance(), tankLevel0, tankPump);
|
||||||
CheckRefillConditions(Config_Store::getInstance(), tankLevel0, refillBlocker0, refillPump);
|
CheckRefillConditions(Config_Store::getInstance(), tankLevel0, refillBlocker0, refillPump);
|
||||||
|
|
||||||
//Create history
|
//Create history
|
||||||
if (old_minute_counter < minute_counter) {
|
if (old_minute_counter < minute_counter) {
|
||||||
old_minute_counter = minute_counter;
|
old_minute_counter = minute_counter;
|
||||||
history_h[minute_counter % 60] = tankLevel0.getPercent();
|
history_h[minute_counter % 60] = tankLevel0.getPercent();
|
||||||
history_d[minute_counter / 60] = tankLevel0.getPercent();
|
history_d[minute_counter / 60] = tankLevel0.getPercent();
|
||||||
|
|
||||||
//Calculate diff to value 1h ago -> minute_counter+1's entry is always 60mins ago !
|
//Calculate diff to value 1h ago -> minute_counter+1's entry is always 60mins ago !
|
||||||
diff_hist_hour = history_h[minute_counter % 60] - history_h[(minute_counter + 1) % 60];
|
diff_hist_hour = history_h[minute_counter % 60] - history_h[(minute_counter + 1) % 60];
|
||||||
//Same here for daily history
|
//Same here for daily history
|
||||||
diff_hist_day = history_d[(minute_counter / 60) % 24] - history_d[((minute_counter + 60) / 60) % 24];
|
diff_hist_day = history_d[(minute_counter / 60) % 24] - history_d[((minute_counter + 60) / 60) % 24];
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
|
|
||||||
HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
|
|
||||||
//Periodically send stats via uart in json format:
|
|
||||||
|
|
||||||
char buffer[400];
|
//Periodically send stats via uart in json format each minute
|
||||||
sprintf(buffer, "{"
|
if(HAL_GetTick() > dly_stats + 60000)
|
||||||
"\"Status\": true, "
|
{
|
||||||
"\"TankLevel\": %hhd, "
|
dly_stats = HAL_GetTick();
|
||||||
"\"TankPump\": %s, "
|
char buffer[400];
|
||||||
"\"RefillPump\": %s, "
|
sprintf(buffer, "{"
|
||||||
"\"RefillEmpty\": %s, "
|
"\"Status\": true, "
|
||||||
"\"RefillCooldown\": %hhd, "
|
"\"TankLevel\": %hhd, "
|
||||||
"\"HourlyHist\": %hhd, "
|
"\"TankPump\": %s, "
|
||||||
"\"DailyHist\": %hhd, "
|
"\"RefillPump\": %s, "
|
||||||
"}",
|
"\"RefillEmpty\": %s, "
|
||||||
tankLevel0.getPercent(),
|
"\"RefillCooldown\": %hhd, "
|
||||||
(S_tankempty) ? "false" : "true",
|
"\"HourlyHist\": %hhd, "
|
||||||
(S_refilling) ? "true" : "false",
|
"\"DailyHist\": %hhd, "
|
||||||
(S_refillempty) ? "true" : "false",
|
"}",
|
||||||
S_refillcooldown,
|
tankLevel0.getPercent(),
|
||||||
diff_hist_hour,
|
(S_tankempty) ? "false" : "true",
|
||||||
diff_hist_day);
|
(S_refilling) ? "true" : "false",
|
||||||
SendUartString(&huart1, buffer);
|
(S_refillempty) ? "true" : "false",
|
||||||
//HAL_UART_Transmit(&huart1, (uint8_t*) buffer, sizeof(buffer), 100);
|
S_refillcooldown,
|
||||||
|
diff_hist_hour,
|
||||||
|
diff_hist_day);
|
||||||
|
SendUartString(&huart1, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ namespace floatpump {
|
|||||||
|
|
||||||
|
|
||||||
void saveToFlash() {
|
void saveToFlash() {
|
||||||
uint32_t data[11];
|
uint32_t data[12];
|
||||||
data[0] = TankCalibLow.getValue();
|
data[0] = TankCalibLow.getValue();
|
||||||
data[1] = TankCalibHigh.getValue();
|
data[1] = TankCalibHigh.getValue();
|
||||||
data[2] = TankMinLevel.getValue();
|
data[2] = TankMinLevel.getValue();
|
||||||
@ -72,28 +72,48 @@ namespace floatpump {
|
|||||||
data[8] = RefillBelow.getValue();
|
data[8] = RefillBelow.getValue();
|
||||||
data[9] = RefillHysteresis.getValue();
|
data[9] = RefillHysteresis.getValue();
|
||||||
data[10] = RefillCooldown.getValue();
|
data[10] = RefillCooldown.getValue();
|
||||||
|
data[11] = 0xf0f0;
|
||||||
|
|
||||||
StoreInFlash(startAddr, data, 11);
|
StoreInFlash(startAddr, data, 12);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
void resetDefaults();
|
void resetDefaults();
|
||||||
|
|
||||||
void loadFromFlash() {
|
void loadFromFlash() {
|
||||||
uint32_t data[11];
|
uint32_t data[12];
|
||||||
ReadFromFlash(startAddr, data, 11);
|
ReadFromFlash(startAddr, data, 12);
|
||||||
TankCalibLow.setValue(data[0]);
|
|
||||||
TankCalibHigh.setValue(data[1]);
|
//Check if intial values must be loaded
|
||||||
TankMinLevel.setValue(data[2]);
|
if(data[11] == 0xf0f0) {
|
||||||
TankHysteresis.setValue(data[3]);
|
TankCalibLow.setValue(data[0]);
|
||||||
TankPumpInvert.setValue(data[4]);
|
TankCalibHigh.setValue(data[1]);
|
||||||
RefillEnable.setValue(data[5]);
|
TankMinLevel.setValue(data[2]);
|
||||||
RefillBlockInvert.setValue(data[6]);
|
TankHysteresis.setValue(data[3]);
|
||||||
RefillBlockEnable.setValue(data[7]);
|
TankPumpInvert.setValue(data[4]);
|
||||||
RefillBelow.setValue(data[8]);
|
RefillEnable.setValue(data[5]);
|
||||||
RefillHysteresis.setValue(data[9]);
|
RefillBlockInvert.setValue(data[6]);
|
||||||
RefillCooldown.setValue(data[10]);
|
RefillBlockEnable.setValue(data[7]);
|
||||||
return;
|
RefillBelow.setValue(data[8]);
|
||||||
|
RefillHysteresis.setValue(data[9]);
|
||||||
|
RefillCooldown.setValue(data[10]);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
//Set default values for fist initialization only
|
||||||
|
//TODO: refactor this, maybe edit linker script to initially store values to correct flash location
|
||||||
|
TankCalibLow.setValue(0);
|
||||||
|
TankCalibHigh.setValue(10000);
|
||||||
|
TankMinLevel.setValue(25);
|
||||||
|
TankHysteresis.setValue(5);
|
||||||
|
TankPumpInvert.setValue(1);
|
||||||
|
RefillEnable.setValue(0);
|
||||||
|
RefillBlockInvert.setValue(0);
|
||||||
|
RefillBlockEnable.setValue(1);
|
||||||
|
RefillBelow.setValue(35);
|
||||||
|
RefillHysteresis.setValue(5);
|
||||||
|
RefillCooldown.setValue(5);
|
||||||
|
saveToFlash();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -19,7 +19,7 @@ namespace floatpump::menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto MenuEntryExecute::toString() -> std::string {
|
auto MenuEntryExecute::toString() -> std::string {
|
||||||
return buildString({(*m_storage) ? "[--]" : "[XX]"});
|
return buildString({(*m_storage) ? "[-]" : "[X]"});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MenuEntryNumeric::u_press() -> void {
|
auto MenuEntryNumeric::u_press() -> void {
|
||||||
|
Loading…
Reference in New Issue
Block a user