Skip to content

Commit

Permalink
Merge pull request #39 from niwciu/hot_fix
Browse files Browse the repository at this point in the history
Hot fix
  • Loading branch information
niwciu authored Mar 11, 2024
2 parents e1f9f8b + 9a2ee90 commit 3d61f00
Show file tree
Hide file tree
Showing 18 changed files with 9,881 additions and 9,926 deletions.
2 changes: 1 addition & 1 deletion examples/ATMEGA328P_ARDUINO_UNO_R3/src/LCD_IO_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/


#include "lcd_hd44780_interface.h"
#include "lcd_hd44780_GPIO_interface.h"
#include "lcd_hd44780_config.h"
#include <stdio.h>
#include <avr/io.h>
Expand Down
3 changes: 2 additions & 1 deletion examples/ESP8266_NONOS_SDK/LCD_HD44780_TEST/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ if not exist include (

echo Copy files to include\lcd_hd44780\
copy "..\..\..\src\lcd_hd44780.h" "include\"
copy "..\..\..\src\lcd_hd44780_interface.h" "include\"
copy "..\..\..\src\lcd_hd44780_GPIO_interface.h" "include\"
copy "..\..\..\src\lcd_hd44780_def_char.h" "include\"
copy "..\..\..\src\lcd_hd44780_config.h" "include\"
copy "..\..\..\src\lcd_hd44780_driver_commands.h" "include\"
echo =======================================================================
echo BUILD PROJECT
echo =======================================================================
Expand Down
70 changes: 58 additions & 12 deletions examples/ESP8266_NONOS_SDK/LCD_HD44780_TEST/include/lcd_hd44780.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/*
* @Author: lukasz.niewelt
* @Date: 2023-12-06 21:40:29
* @Last Modified by: lukasz.niewelt
* @Last Modified time: 2024-01-10 14:00:22
/**
* @file lcd_hd44780.h
* @author niwciu ([email protected])
* @brief
* @version 1.0.2
* @date 2024-02-25
*
* @copyright Copyright (c) 2024
* @defgroup LCD_HD44780_lib_API
* @{
*/

#ifndef _LCD_HD_44780_H_
Expand All @@ -12,15 +17,56 @@
extern "C"
{
#endif /* __cplusplus */
#include <stdbool.h>
#include "lcd_hd44780_config.h"
#include "lcd_hd44780_interface.h"
#include "lcd_hd44780_def_char.h"

#include <stdbool.h>
/**
* @brief Labels for alignment parameter used by lcd_int() and lcd_hex() functions
* @enum LCD_alignment_e
*/
enum LCD_alignment_e
{
left,
right
left, /**< @brief pass as argument when calling lcd_int() or lcd_buf_int() or lcd_hex() or lcd_buf_hex() to set left alighment */
right /**< @brief pass as argument when calling lcd_int() or lcd_buf_int() or lcd_hex() or lcd_buf_hex() to set right alighment */
};
/**
* @brief Line labels used when calling lcd_locate() or lcd_buf_locate() function
* @enum LCD_LINES_e
*/
enum LCD_LINES_e
{
LINE_1, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to first line of LCD */
LINE_2, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to second line of LCD */
LINE_3, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to third line of LCD */
LINE_4, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to fourth line of LCD */
};

/**
* @enum LCD_COLUMNS_e
* @brief Column labels used when calling lcd_locate() or lcd_buf_locate() function
*
*/
enum LCD_COLUMNS_e
{
C1, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 1'st char/collumn of LCD */
C2, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 2'nd char/collumn of LCD */
C3, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 3'th char/collumn of LCD */
C4, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 4'th char/collumn of LCD */
C5, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 5'th char/collumn of LCD */
C6, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 6'th char/collumn of LCD */
C7, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 7'th char/collumn of LCD */
C8, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 8'th char/collumn of LCD */
C9, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 9'th char/collumn of LCD */
C10, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 10'th char/collumn of LCD */
C11, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 11'th char/collumn of LCD */
C12, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 12'th char/collumn of LCD */
C13, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 13'th char/collumn of LCD */
C14, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 14'th char/collumn of LCD */
C15, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 15'th char/collumn of LCD */
C16, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 16'th char/collumn of LCD */
C17, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 17'th char/collumn of LCD */
C18, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 18'th char/collumn of LCD */
C19, /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 19'th char/collumn of LCD */
C20 /**< @brief pass as argument when calling lcd_locate() or lcd_buf_locate() to move curson to 20'th char/collumn of LCD */
};

extern bool LCD_BUFFER_UPDATE_FLAG;
Expand Down Expand Up @@ -55,7 +101,7 @@ extern "C"
void lcd_buf_int(int val, uint8_t width, enum LCD_alignment_e alignment);
void lcd_buf_hex(int val, uint8_t width, enum LCD_alignment_e alignment);
void lcd_buf_bin(int val, uint8_t width);

/**@}*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @file lcd_hd44780_interface.h
* @author niwciu ([email protected])
* @brief Header file with driver interface declaration that needs to be implemented on the driver layer side.
* This instance eliminates dependencies between the LCD library and the specific microcontroller driver layer.
* @version 1.0.2
* @date 2024-02-25
*
* @copyright Copyright (c) 2024
* @defgroup LCD_HD44780_driver_interface
* @{
*/
#ifndef _LCD_HD44780_INTERFACE_H_
#define _LCD_HD44780_INTERFACE_H_

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <stdint.h>

typedef uint8_t LCD_data_port_t;

typedef void (*LCD_interface_func_p)(void);
typedef void (*set_LCD_data_port_func_p)(uint8_t data);
typedef LCD_data_port_t (*get_LCD_data_port_func_p)(void);
typedef void (*delay_us_func_p)(uint32_t delay_us);

/**
* @struct LCD_IO_driver_interface_struct
* @brief LCD I/O driver interface definition.
* @attention This interface declaration need to be defined on driver layer side and "full fill the contract" of the defined LCD_IO_driver_interface_struct
*
*/
struct LCD_IO_driver_interface_struct
{
LCD_interface_func_p init_LCD_pins;
LCD_interface_func_p set_data_pins_as_outputs;
LCD_interface_func_p set_data_pins_as_inputs;
set_LCD_data_port_func_p write_data;
get_LCD_data_port_func_p read_data;
delay_us_func_p delay_us;
LCD_interface_func_p set_LCD_E;
LCD_interface_func_p reset_LCD_E;
LCD_interface_func_p set_LCD_RS;
LCD_interface_func_p reset_LCD_RS;
LCD_interface_func_p set_LCD_RW;
LCD_interface_func_p reset_LCD_RW;
LCD_interface_func_p set_LCD_BCKL;
LCD_interface_func_p reset_LCD_BCKL;
};
// clang-format off
/**
* @brief Declaration of the function that return pointer to the interface structure implemented on driver layer side.
* @attention This function need to be defined on driver layer side and must return pointer to LCD_IO_driver_interface_struct defined on dirver layer side
* @return const struct LCD_IO_driver_interface_struct*
*/
const struct LCD_IO_driver_interface_struct* LCD_IO_driver_interface_get(void);
// clang-format on
/**@}*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _LCD_HD_44780_H_ */
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/*
* @Author: lukasz.niewelt
* @Date: 2023-12-06 21:38:27
* @Last Modified by: lukasz.niewelt
* @Last Modified time: 2024-01-09 21:20:52
/**
* @file lcd_hd44780_config.h
* @author niwciu ([email protected])
* @brief
* @version 1.0.2
* @date 2024-02-25
*
* @copyright Copyright (c) 2024
* @addtogroup LCD_HD44780_lib_API
*
*/

#ifndef _LCD_HD44780_CONFIG_H_
Expand All @@ -28,29 +33,12 @@ extern "C"
* ON - when the RW pin is connected
* OFF - when the RW pin is not connected
********************************************************************************************/
#define LCD_TYPE 1602
#define USE_RW_PIN OFF
#define LCD_TYPE 1602
#define USE_RW_PIN OFF

#define LCD_BCKL_PIN_EN_STATE HIGH
#define LCD_BCKL_PIN_EN_STATE HIGH

#define LCD_BUFFERING ON

//definitions of Line and column labels for lcd_locate
enum LCD_LINES_e
{
LINE_1,
LINE_2,
#if ((LCD_TYPE==2004) ||(LCD_TYPE ==1604))
LINE_3,
LINE_4,
#endif
};
enum LCD_COLUMNS_e{
C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,
#if LCD_TYPE==2004
C17,C18,C19,C20
#endif
};
#define LCD_BUFFERING ON

/******************************** LCD LIBRARY COMPILATION SETTINGS ************************
* Setting USE_(procedure name) to:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/*
* @Author: lukasz.niewelt
* @Date: 2023-12-08 11:15:52
* @Last Modified by: lukasz.niewelt
* @Last Modified time: 2023-12-13 13:17:53
/**
* @file lcd_hd44780_def_char.h
* @author niwciu ([email protected])
* @brief
* @version 1.0.2
* @date 2024-02-25
* @addtogroup LCD_HD44780_lib_API
* @copyright Copyright (c) 2024
*
*/

#ifndef _LCD_HD44780_DEF_CHAR_H_
Expand All @@ -12,7 +16,14 @@
extern "C"
{
#endif /* __cplusplus */

#include <stdint.h>
#include "lcd_hd44780_config.h"
/**
* @struct char_bank_struct
* @brief Structure that contain pointers to 8 user predefined characters. Structure is used to define user character banks.
* Each bank can contain combinatio of maksimum 8 user special cahracters.
*
*/
struct char_bank_struct
{
const uint8_t *char_0;
Expand All @@ -28,8 +39,10 @@ extern "C"
#if USE_DEF_CHAR_FUNCTION == ON
#define LCD_CGRAM_BYTES_PER_CHAR 8
#define DEF_CHAR_ADR_MASK 7
/**********************USER CHAR DEFINITIONS START*******************************/
/******To sace flash when using defchar comment char definitions that are unused*/
/**********************USER CHAR DECLARATION SECTION*******************************/
/**
* @note To save flash when using defchar comment char definitions that are unused
* */
static const uint8_t Pol_e[8] = {32, 32, 14, 17, 31, 16, 14, 3};
static const uint8_t Pol_o[8] = {2, 4, 14, 17, 17, 17, 14, 0};
static const uint8_t Pol_s[8] = {2, 4, 14, 16, 14, 1, 30, 32};
Expand All @@ -39,9 +52,8 @@ extern "C"
static const uint8_t Pol_n[8] = {2, 4, 22, 25, 17, 17, 17, 0};
static const uint8_t Zn_wody[8] = {0, 0, 0, 6, 9, 2, 4, 15};
// here add "definition" of new chars
/**********************USER CHAR DEFINITIONS END********************************/

/**********************USER CHAR CGRAM BANKS DEFINITIONS START*******************/
/**********************USER CHAR CGRAM BANKS DECALRATION SECTION*******************/
static const struct char_bank_struct lcd_cgram_bank_1 = {
Pol_e,
Pol_o,
Expand All @@ -51,16 +63,23 @@ extern "C"
Pol_a,
Pol_n,
Zn_wody};
enum LCD_CGRAM_BANK_1

/**
* @enum LCD_CGRAM_BANK_1_e
* @brief Labels representing specific user defined chars collected in lcd_cgram_bank_1.
* Labels value are equal to adress in lcd_cgram_bank_1 and addres of LCD_CGRAM where all chars from lcd_cgram_bank_1 will be written when using
* lcd_load_char_bank() or lcd_def_char() when defining single char in LCD_CGRAM
*/
enum LCD_CGRAM_BANK_1_e
{
pol_e,
pol_o,
pol_s,
pol_l,
pol_c,
pol_a,
pol_n,
zn_wody,
pol_e, /**< @brief label with vlaue 0 created for custom Char Piol_e placed under adress 0x00 in lcd_cgram_bank_1 and LCD_CGRAM*/
pol_o, /**< @brief label with vlaue 1 created for custom Char Piol_o placed under adress 0x01 in lcd_cgram_bank_1 and LCD_CGRAM*/
pol_s, /**< @brief label with vlaue 2 created for custom Char Piol_s placed under adress 0x02 in lcd_cgram_bank_1 and LCD_CGRAM*/
pol_l, /**< @brief label with vlaue 3 created for custom Char Piol_l placed under adress 0x03 in lcd_cgram_bank_1 and LCD_CGRAM*/
pol_c, /**< @brief label with vlaue 4 created for custom Char Piol_c placed under adress 0x03 in lcd_cgram_bank_1 and LCD_CGRAM*/
pol_a, /**< @brief label with vlaue 5 created for custom Char Piol_a placed under adress 0x03 in lcd_cgram_bank_1 and LCD_CGRAM*/
pol_n, /**< @brief label with vlaue 6 created for custom Char Piol_n placed under adress 0x03 in lcd_cgram_bank_1 and LCD_CGRAM*/
zn_wody, /**< @brief label with vlaue 7 created for custom Char Zn_wody placed under adress 0x03 in lcd_cgram_bank_1 and LCD_CGRAM*/
};
// //here define new bank with adreses for chars that you want load to this specifci bank
// static const struct char_bank_struct lcd_cgram_bank_x = {
Expand All @@ -73,7 +92,7 @@ extern "C"
// Pol_n,
// Zn_wody};
// // here define labels for lcd_cgram_bank_x
// enum LCD_CGRAM_BANK_x
// enum LCD_CGRAM_BANK_x_e
// {
// pol_e_bank_x,
// pol_o_bank_x,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @file lcd_hd44780_driver_commands.h
* @author niwciu ([email protected])
* @brief
* @version 1.0.2
* @date 2024-02-25
*
* @copyright Copyright (c) 2024
*
*/
// clang-format off

// LCD driver commands
#define LCDC_CLS 0x01
#define LCDC_HOME 0x02
/********************************/
#define LCDC_ENTRY_MODE 0x04
#define LCDC_ENTRYR 0x02
#define LCDC_ENTRYL 0x00
#define LCDC_MOVE 0x01
/********************************/
#define LCDC_ONOFF 0x08
#define LCDC_DISPLAYON 0x04
#define LCDC_CURSORON 0x02
#define LCDC_CURSOROFF 0x00
#define LCDC_BLINKON 0x01
/********************************/
#define LCDC_SHIFT 0x10
#define LCDC_SHIFTDISP 0x08
#define LCDC_SHIFTR 0x04
#define LCDC_SHIFTL 0x00
/********************************/
#define LCDC_FUNC 0x20
#define LCDC_FUNC8B 0x10
#define LCDC_FUNC4B 0x00
#define LCDC_FUNC2L 0x08
#define LCDC_FUNC1L 0x00
#define LCDC_FUNC5x10 0x04
#define LCDC_FUNC5x7 0x00
/********************************/
#define LCDC_SET_CGRAM 0x40
#define LCDC_SET_DDRAM 0x80

// clang-format on
Loading

0 comments on commit 3d61f00

Please sign in to comment.