FEATURE: Initialisation Sequence
This commit is contained in:
parent
9c54f76787
commit
7af951766d
@ -18,6 +18,16 @@ project(FloatPUMP C CXX ASM)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
# custom options
|
||||
execute_process(
|
||||
COMMAND git log -1 --format=%h
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
add_definitions(-DGIT_HASH=${GIT_HASH})
|
||||
|
||||
#Uncomment for hardware floating point
|
||||
#add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING)
|
||||
#add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
|
||||
#include "LCD_I2C_Driver.h"
|
||||
#include "InitSequence.h"
|
||||
|
||||
#define SLAVE_ADDRESS_LCD 0x4e
|
||||
|
||||
@ -34,26 +35,31 @@ int main(void) {
|
||||
MX_I2C1_Init();
|
||||
MX_USART1_UART_Init();
|
||||
|
||||
HAL_GPIO_WritePin(BEEP_GPIO_Port, BEEP_Pin, GPIO_PIN_RESET);
|
||||
|
||||
|
||||
//Simple dummy lcd test
|
||||
char buf[] = "Hallo THM -- es funktioniert";
|
||||
// char buf[] = "Hallo THM -- es funktioniert";
|
||||
//
|
||||
// auto &display = floatpump::LCD_I2C_Driver::getInstance(hi2c1, SLAVE_ADDRESS_LCD);
|
||||
// display.LCDSetBacklight(false);
|
||||
// HAL_Delay(1000);
|
||||
// display.LCDSetBacklight(true);
|
||||
// display.LCDSendCString(buf);
|
||||
// HAL_Delay(1000);
|
||||
// display.LCDPower(false);
|
||||
// HAL_Delay(1000);
|
||||
// display.LCDPower(true);
|
||||
// HAL_Delay(1000);
|
||||
// display.LCDCursor(true);
|
||||
// display.LCDCursorBlink(true);
|
||||
//
|
||||
// HAL_Delay(1000);
|
||||
// display.LCDSetCursor(18, 3);
|
||||
|
||||
auto &display = floatpump::LCD_I2C_Driver::getInstance(hi2c1, SLAVE_ADDRESS_LCD);
|
||||
display.LCDSetBacklight(false);
|
||||
HAL_Delay(1000);
|
||||
display.LCDSetBacklight(true);
|
||||
display.LCDSendCString(buf);
|
||||
HAL_Delay(1000);
|
||||
display.LCDPower(false);
|
||||
HAL_Delay(1000);
|
||||
display.LCDPower(true);
|
||||
HAL_Delay(1000);
|
||||
display.LCDCursor(true);
|
||||
display.LCDCursorBlink(true);
|
||||
floatpump::LCD_I2C_Driver &display = floatpump::LCD_I2C_Driver::getInstance(hi2c1, SLAVE_ADDRESS_LCD);
|
||||
floatpump::InitSequence initializer(display);
|
||||
initializer.runInitSequence();
|
||||
|
||||
HAL_Delay(1000);
|
||||
display.LCDSetCursor(18, 3);
|
||||
|
||||
while (1) {
|
||||
|
||||
|
46
Middlewares/floatpump/Inc/InitSequence.h
Normal file
46
Middlewares/floatpump/Inc/InitSequence.h
Normal file
@ -0,0 +1,46 @@
|
||||
//
|
||||
// Created by robtor on 15.12.22.
|
||||
//
|
||||
|
||||
#ifndef FLOATPUMP_INITSEQUENCE_H
|
||||
#define FLOATPUMP_INITSEQUENCE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "main.h"
|
||||
#include "LCD_I2C_Driver.h"
|
||||
#include "git_rev.h"
|
||||
|
||||
|
||||
namespace floatpump {
|
||||
|
||||
class InitSequence {
|
||||
public:
|
||||
InitSequence(LCD_I2C_Driver &driver) : driver(driver) {};
|
||||
|
||||
void runInitSequence(bool silent = false, bool noBacklight = false);
|
||||
|
||||
private:
|
||||
LCD_I2C_Driver &driver;
|
||||
|
||||
uint16_t flash_duration = 100;
|
||||
uint16_t beep_duration = 50;
|
||||
uint16_t welcome_duration = 5000;
|
||||
|
||||
std::string welcometext[4] = {
|
||||
"FloatPUMP Controller",
|
||||
" Rev " GIT_HASH,
|
||||
" ********** ",
|
||||
" www.robtor.de "
|
||||
};
|
||||
|
||||
void ledFlash(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
|
||||
|
||||
void beeperExecute();
|
||||
|
||||
void displayWelcome(bool backlight);
|
||||
};
|
||||
|
||||
} // floatpump
|
||||
|
||||
#endif //FLOATPUMP_INITSEQUENCE_H
|
@ -30,7 +30,6 @@ namespace floatpump{
|
||||
void LCDSendCString(char *str);
|
||||
|
||||
// Functions for configuration
|
||||
void LCDInitialize(void);
|
||||
void LCDClearDisplay(void);
|
||||
void LCDSetBacklight(bool enabled);
|
||||
void LCDPower(bool enabled);
|
||||
|
49
Middlewares/floatpump/Src/InitSequence.cpp
Normal file
49
Middlewares/floatpump/Src/InitSequence.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
//
|
||||
// Created by robtor on 15.12.22.
|
||||
//
|
||||
|
||||
#include "InitSequence.h"
|
||||
|
||||
namespace floatpump {
|
||||
void floatpump::InitSequence::runInitSequence(bool silent, bool noBacklight) {
|
||||
beeperExecute();
|
||||
displayWelcome(true);
|
||||
|
||||
ledFlash(LED0_GPIO_Port, LED0_Pin);
|
||||
ledFlash(LED1_GPIO_Port, LED1_Pin);
|
||||
ledFlash(LED2_GPIO_Port, LED2_Pin);
|
||||
ledFlash(LED3_GPIO_Port, LED3_Pin);
|
||||
ledFlash(LED4_GPIO_Port, LED4_Pin);
|
||||
ledFlash(LED5_GPIO_Port, LED5_Pin);
|
||||
}
|
||||
|
||||
|
||||
void InitSequence::ledFlash(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) {
|
||||
HAL_GPIO_WritePin(GPIOx, GPIO_Pin, GPIO_PIN_RESET);
|
||||
HAL_Delay(this->flash_duration);
|
||||
HAL_GPIO_WritePin(GPIOx, GPIO_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
void InitSequence::displayWelcome(bool backlight) {
|
||||
driver.LCDPower(true);
|
||||
driver.LCDClearDisplay();
|
||||
driver.LCDSetBacklight(backlight);
|
||||
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
driver.LCDSetCursor(0, i);
|
||||
driver.LCDSendCString(const_cast<char *>(welcometext[i].c_str()));
|
||||
}
|
||||
driver.LCDSetCursor(0, 0);
|
||||
|
||||
HAL_Delay(this->welcome_duration);
|
||||
driver.LCDClearDisplay();
|
||||
}
|
||||
|
||||
void InitSequence::beeperExecute() {
|
||||
HAL_GPIO_WritePin(BEEP_GPIO_Port, BEEP_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(this->beep_duration);
|
||||
HAL_GPIO_WritePin(BEEP_GPIO_Port, BEEP_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
} // floatpump
|
@ -51,7 +51,7 @@ namespace floatpump {
|
||||
m_lcdSendCmnd (0x30);
|
||||
HAL_Delay(1); // wait for >100us
|
||||
m_lcdSendCmnd (0x30);
|
||||
HAL_Delay(10); // Wait for command execution lengt
|
||||
HAL_Delay(10); // Wait for command execution length
|
||||
|
||||
// Configuration
|
||||
m_lcdSendCmnd (0x20); // Set Interface to 4-bit mode
|
||||
|
Loading…
Reference in New Issue
Block a user