EXPERIMENT: simple lcd test
This commit is contained in:
parent
a0110696ae
commit
0c0f7a5be0
@ -19,6 +19,7 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "usb_device.h"
|
||||
#include "LCD_I2C_Driver.h"
|
||||
|
||||
#define SLAVE_ADDRESS_LCD 0x4e
|
||||
|
||||
@ -93,20 +94,21 @@ void lcd_send_data (char data)
|
||||
|
||||
void lcd_init (void)
|
||||
{
|
||||
// 4 bit initialisation
|
||||
// Initialization by Instruction (from HD44780U Datasheet)
|
||||
HAL_Delay(50); // wait for >40ms
|
||||
lcd_send_cmd (0x30);
|
||||
HAL_Delay(5); // wait for >4.1ms
|
||||
lcd_send_cmd (0x30);
|
||||
HAL_Delay(1); // wait for >100us
|
||||
lcd_send_cmd (0x30);
|
||||
HAL_Delay(10);
|
||||
lcd_send_cmd (0x20); // 4bit mode
|
||||
HAL_Delay(10); // Wait for command execution lengt
|
||||
|
||||
lcd_send_cmd (0x20); // Set Interface to 4-bit mode
|
||||
HAL_Delay(10);
|
||||
|
||||
// dislay initialisation
|
||||
lcd_send_cmd (0x28); // Function set --> DL=0 (4 bit mode), N = 1 (2 line display) F = 0 (5x8 characters)
|
||||
HAL_Delay(1);
|
||||
|
||||
lcd_send_cmd (0x08); //Display on/off control --> D=0,C=0, B=0 ---> display off
|
||||
HAL_Delay(1);
|
||||
lcd_send_cmd (0x01); // clear display
|
||||
@ -156,10 +158,25 @@ int main(void)
|
||||
MX_ADC1_Init();
|
||||
MX_I2C1_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
char buf [] = "SensorTest";
|
||||
char buf [] = "Hallo THM";
|
||||
//CDC_Transmit_FS(buf, sizeof(buf));
|
||||
|
||||
lcd_init();
|
||||
floatpump::LCD_I2C_Driver display(hi2c1, SLAVE_ADDRESS_LCD);
|
||||
display.LCDInitialize();
|
||||
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);
|
||||
display.LCDSendCString("XX");
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
@ -170,6 +187,7 @@ int main(void)
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
||||
|
||||
HAL_ADC_Start(&hadc1);
|
||||
HAL_ADC_PollForConversion(&hadc1, 1);
|
||||
value = HAL_ADC_GetValue(&hadc1);
|
||||
@ -177,8 +195,7 @@ int main(void)
|
||||
char buf [250] = "";
|
||||
sprintf(buf, "Value: %d \r\n", value);
|
||||
//CDC_Transmit_FS(buf, sizeof(buf));
|
||||
lcd_send_cmd (0x80|0x00);
|
||||
lcd_send_string(buf);
|
||||
//display.LCDSendCString(buf);
|
||||
HAL_Delay(1000);
|
||||
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
|
||||
|
Loading…
Reference in New Issue
Block a user