Display-Integration
This commit is contained in:
parent
3cc25b2cae
commit
f714e40344
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +1,6 @@
|
|||||||
[submodule "PID"]
|
[submodule "PID"]
|
||||||
path = PID
|
path = PID
|
||||||
url = https://github.com/Carsten1987/PID.git
|
url = https://github.com/Carsten1987/PID.git
|
||||||
|
[submodule "lcd_16x2"]
|
||||||
|
path = lcd_16x2
|
||||||
|
url = http://gitea.keller/carsten/lcd_16x2.git
|
||||||
|
87
Source/Display.cpp
Normal file
87
Source/Display.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Display.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jul 29, 2023
|
||||||
|
* Author: Carst
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <stm32g0xx_ll_gpio.h>
|
||||||
|
#include "Display.hpp"
|
||||||
|
#include "lcd_1602.h"
|
||||||
|
|
||||||
|
extern "C" void LCD_RS_SetLow(void)
|
||||||
|
{
|
||||||
|
LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_4);
|
||||||
|
}
|
||||||
|
extern "C" void LCD_RS_SetHigh(void)
|
||||||
|
{
|
||||||
|
LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_4);
|
||||||
|
}
|
||||||
|
extern "C" void LCD_RW_SetLow(void)
|
||||||
|
{
|
||||||
|
LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_5);
|
||||||
|
}
|
||||||
|
extern "C" void LCD_RW_SetHigh(void)
|
||||||
|
{
|
||||||
|
LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_5);
|
||||||
|
}
|
||||||
|
extern "C" void LCD_E_SetLow(void)
|
||||||
|
{
|
||||||
|
LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_6);
|
||||||
|
}
|
||||||
|
extern "C" void LCD_E_SetHigh(void)
|
||||||
|
{
|
||||||
|
LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_6);
|
||||||
|
}
|
||||||
|
extern "C" void LCD_DB_Set(uint8_t data)
|
||||||
|
{
|
||||||
|
LL_GPIO_SetOutputPin(GPIOB, data);
|
||||||
|
LL_GPIO_ResetOutputPin(GPIOB, ~data & 0x0FUL);
|
||||||
|
}
|
||||||
|
extern "C" uint8_t LCD_DB_Get(void)
|
||||||
|
{
|
||||||
|
return LL_GPIO_ReadInputPort(GPIOB);
|
||||||
|
}
|
||||||
|
extern "C" void LCD_DB_ConfigInput(void)
|
||||||
|
{
|
||||||
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_0, LL_GPIO_MODE_INPUT);
|
||||||
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_1, LL_GPIO_MODE_INPUT);
|
||||||
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_2, LL_GPIO_MODE_INPUT);
|
||||||
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_3, LL_GPIO_MODE_INPUT);
|
||||||
|
}
|
||||||
|
extern "C" void LCD_DB_ConfigOutput(void)
|
||||||
|
{
|
||||||
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_0, LL_GPIO_MODE_OUTPUT);
|
||||||
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_1, LL_GPIO_MODE_OUTPUT);
|
||||||
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_2, LL_GPIO_MODE_OUTPUT);
|
||||||
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_3, LL_GPIO_MODE_OUTPUT);
|
||||||
|
|
||||||
|
}
|
||||||
|
namespace ElektronischeLast
|
||||||
|
{
|
||||||
|
Display::Display(void)
|
||||||
|
{
|
||||||
|
lcd_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
Display::~Display(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void Display::NewData(uint32_t strom, uint32_t spannung, uint32_t temperatur)
|
||||||
|
{
|
||||||
|
char buf[17]; // 16 Zeichen pro Zeile + \0
|
||||||
|
snprintf(buf, 16, "U: %2" PRIu32 ".%" PRIu32 " T: %2" PRIu32 ".%1" PRIu32,
|
||||||
|
spannung / 1000UL, spannung %1000UL, temperatur, 0UL);
|
||||||
|
lcd_set_cursor(eLine1, 0U);
|
||||||
|
lcd_string(buf);
|
||||||
|
|
||||||
|
snprintf(buf, 16, "I: %2" PRIu32 ".%" PRIu32 " P: %4" PRIu32,
|
||||||
|
strom / 1000UL, strom %1000UL, strom * spannung / 1000UL);
|
||||||
|
lcd_string(buf);
|
||||||
|
lcd_set_cursor(eLine2, 0U);
|
||||||
|
}
|
||||||
|
}
|
45
Source/Display.hpp
Normal file
45
Source/Display.hpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Display.hpp
|
||||||
|
*
|
||||||
|
* Created on: Jul 29, 2023
|
||||||
|
* Author: Carst
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DISPLAY_HPP_
|
||||||
|
#define DISPLAY_HPP_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#include <cstdint>
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void LCD_RS_SetLow(void);
|
||||||
|
void LCD_RS_SetHigh(void);
|
||||||
|
void LCD_RW_SetLow(void);
|
||||||
|
void LCD_RW_SetHigh(void);
|
||||||
|
void LCD_E_SetLow(void);
|
||||||
|
void LCD_E_SetHigh(void);
|
||||||
|
void LCD_DB_Set(uint8_t data); // Write data
|
||||||
|
uint8_t LCD_DB_Get(void); // Read Data
|
||||||
|
void LCD_DB_ConfigInput(void); // Konfiguriere I/O als Input
|
||||||
|
void LCD_DB_ConfigOutput(void); // Konfiguriere I/O als Output
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace ElektronischeLast
|
||||||
|
{
|
||||||
|
class Display
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Display(void);
|
||||||
|
~Display(void);
|
||||||
|
void NewData(uint32_t strom, uint32_t spannung, uint32_t temperatur);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* DISPLAY_HPP_ */
|
@ -17,6 +17,7 @@
|
|||||||
#include "serial.hpp"
|
#include "serial.hpp"
|
||||||
#include "PID.h"
|
#include "PID.h"
|
||||||
#include "FanControl.hpp"
|
#include "FanControl.hpp"
|
||||||
|
#include "Display.hpp"
|
||||||
#include "CLI.h"
|
#include "CLI.h"
|
||||||
|
|
||||||
using namespace ElektronischeLast;
|
using namespace ElektronischeLast;
|
||||||
@ -59,7 +60,9 @@ int main (void)
|
|||||||
iDAC dac = iDAC();
|
iDAC dac = iDAC();
|
||||||
iADC adc = iADC();
|
iADC adc = iADC();
|
||||||
FanControl fan = FanControl();
|
FanControl fan = FanControl();
|
||||||
|
Display display = Display();
|
||||||
std::uint32_t last_tick = systick;
|
std::uint32_t last_tick = systick;
|
||||||
|
std::uint32_t sec_tick = systick;
|
||||||
|
|
||||||
printf("\r\nElektronische Last\r\n");
|
printf("\r\nElektronische Last\r\n");
|
||||||
printf("- Initialisierung erfolgreich\r\n");
|
printf("- Initialisierung erfolgreich\r\n");
|
||||||
@ -85,6 +88,11 @@ int main (void)
|
|||||||
|
|
||||||
serial_cyclic();
|
serial_cyclic();
|
||||||
}
|
}
|
||||||
|
if(sec_tick + 1000UL > systick)
|
||||||
|
{
|
||||||
|
sec_tick = systick;
|
||||||
|
display.NewData(strom, spannung, temperatur);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
Source/lcd_16x2_config.h
Normal file
18
Source/lcd_16x2_config.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* lcd_16x2_config.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 29, 2023
|
||||||
|
* Author: Carst
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LCD_16X2_CONFIG_H_
|
||||||
|
#define LCD_16X2_CONFIG_H_
|
||||||
|
|
||||||
|
#include <stm32g071xx.h>
|
||||||
|
#include "Display.hpp"
|
||||||
|
|
||||||
|
#define NOP __NOP
|
||||||
|
#define __delay_ms(x) { for(int i=0;i<x*64000;i++); }
|
||||||
|
#define __delay_us(x) { for(int i=0;i<x*64;i++); }
|
||||||
|
|
||||||
|
#endif /* LCD_16X2_CONFIG_H_ */
|
1
lcd_16x2
Submodule
1
lcd_16x2
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 89fb8a8d898bc6e7dd1048b2bb706cb2857854ba
|
Loading…
x
Reference in New Issue
Block a user