diff --git a/ReadMe.md b/ReadMe.md index 3e8e3e7..98fb2c6 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -10,14 +10,7 @@ ![cppCheck](https://github.com/niwciu/LCD_HD44780/actions/workflows/run_cppcheck.yml/badge.svg) ![clang-format](https://github.com/niwciu/LCD_HD44780/actions/workflows/clang-format_check.yml/badge.svg) ![code complexity](https://github.com/niwciu/LCD_HD44780/actions/workflows/run_lizard_lib_check.yml/badge.svg) -![GitHub License](https://img.shields.io/github/license/niwciu/LCD_HD44780) -![GitHub top language](https://img.shields.io/github/languages/top/niwciu/LCD_HD44780) -![GitHub Release](https://img.shields.io/github/v/release/niwciu/LCD_HD44780) -![GitHub branch check runs](https://img.shields.io/github/check-runs/niwciu/LCD_HD44780/main) -![Unit Tests](https://github.com/niwciu/LCD_HD44780/actions/workflows/run_lcd_hd44780_test.yml/badge.svg) -![cppCheck](https://github.com/niwciu/LCD_HD44780/actions/workflows/run_cppcheck.yml/badge.svg) -![clang-format](https://github.com/niwciu/LCD_HD44780/actions/workflows/clang-format_check.yml/badge.svg) -![code complexity](https://github.com/niwciu/LCD_HD44780/actions/workflows/run_lizard_lib_check.yml/badge.svg) + ## Features diff --git a/reports/Code_Coverage/lcd_hd44780_gcov_report.functions.html b/reports/Code_Coverage/lcd_hd44780_gcov_report.functions.html index e2c90da..cb733e0 100644 --- a/reports/Code_Coverage/lcd_hd44780_gcov_report.functions.html +++ b/reports/Code_Coverage/lcd_hd44780_gcov_report.functions.html @@ -23,7 +23,7 @@

GCC Code Coverage Report

Date: - 2024-01-12 11:24:32 + 2024-08-06 22:02:55 @@ -38,21 +38,21 @@

GCC Code Coverage Report

Lines: - 228 - 230 - 99.1% + 240 + 242 + 99.2% Functions: - 35 - 35 + 37 + 37 100.0% Branches: - 46 + 45 47 - 97.9% + 95.7% @@ -74,492 +74,520 @@

GCC Code Coverage Report

- check_lcd_buf_possition_ptr_overflow + check_lcd_buf_possition_ptr_overflow - src\lcd_hd44780.c + src\lcd_hd44780.c - 438 + 206 - called 837 times + called 126 times - copy_lcd_buf_2_prev_lcd_buf + copy_lcd_buf_2_prev_lcd_buf - src\lcd_hd44780.c + src\lcd_hd44780.c - 445 + 214 - called 469 times + called 71 times - fill_bin_value_buffer + fill_bin_value_buffer - src\lcd_hd44780.c + src\lcd_hd44780.c - 403 + 169 - called 27 times + called 4 times - fill_zeros_buffer + fill_zeros_buffer - src\lcd_hd44780.c + src\lcd_hd44780.c - 423 + 189 - called 27 times + called 4 times - lcd_bin + lcd_bin - src\lcd_hd44780.c + src\lcd_hd44780.c - 671 + 465 - called 14 times + called 2 times - lcd_blinking_cursor_on + lcd_blinking_cursor_on - src\lcd_hd44780.c + src\lcd_hd44780.c - 763 + 557 - called 7 times + called 1 time - lcd_buf_bin + lcd_buf_bin - src\lcd_hd44780.c + src\lcd_hd44780.c - 881 + 703 - called 13 times + called 2 times - lcd_buf_char + lcd_buf_char - src\lcd_hd44780.c + src\lcd_hd44780.c - 780 + 584 - called 63 times + called 9 times - lcd_buf_cls + lcd_buf_cls - src\lcd_hd44780.c + src\lcd_hd44780.c - 770 + 568 - called 382 times + called 58 times - lcd_buf_hex + lcd_buf_hex - src\lcd_hd44780.c + src\lcd_hd44780.c - 856 + 678 - called 32 times + called 5 times - lcd_buf_int + lcd_buf_int - src\lcd_hd44780.c + src\lcd_hd44780.c - 829 + 651 - called 28 times + called 4 times - lcd_buf_locate + lcd_buf_locate - src\lcd_hd44780.c + src\lcd_hd44780.c - 787 + 596 - called 87 times + called 13 times - lcd_buf_str + lcd_buf_str - src\lcd_hd44780.c + src\lcd_hd44780.c - 792 + 605 - called 160 times + called 24 times - lcd_char + lcd_char - src\lcd_hd44780.c + src\lcd_hd44780.c - 587 + 382 - called 348 times + called 103 times - lcd_cls + lcd_cls - src\lcd_hd44780.c + src\lcd_hd44780.c - 540 + 327 - called 382 times + called 58 times - lcd_cursor_off + lcd_cursor_off - src\lcd_hd44780.c + src\lcd_hd44780.c - 754 + 548 - called 7 times + called 1 time - lcd_cursor_on + lcd_cursor_on - src\lcd_hd44780.c + src\lcd_hd44780.c - 744 + 538 - called 7 times + called 1 time - lcd_def_char + lcd_def_char - src\lcd_hd44780.c + src\lcd_hd44780.c - 558 + 348 - called 63 times + called 9 times - lcd_hex + lcd_disable_backlight - src\lcd_hd44780.c + src\lcd_hd44780.c - 645 + 314 - called 28 times + called 58 times - lcd_home + lcd_enable_backlight - src\lcd_hd44780.c + src\lcd_hd44780.c - 731 + 302 - called 7 times + called 2 times - lcd_init + lcd_hex - src\lcd_hd44780.c + src\lcd_hd44780.c - 495 + 439 - called 375 times + called 4 times - lcd_int + lcd_home - src\lcd_hd44780.c + src\lcd_hd44780.c - 617 + 525 - called 28 times + called 1 time - lcd_load_char_bank + lcd_init - src\lcd_hd44780.c + src\lcd_hd44780.c - 568 + 259 + + + called 57 times + + + + + lcd_int + + + src\lcd_hd44780.c + + + 411 + + + called 4 times + + + + + lcd_load_char_bank + + + src\lcd_hd44780.c + + + 363 - called 7 times + called 1 time - lcd_locate + lcd_locate - src\lcd_hd44780.c + src\lcd_hd44780.c - 699 + 493 - called 439 times + called 35 times - lcd_reset_all_SIG + lcd_reset_all_SIG - src\lcd_hd44780.c + src\lcd_hd44780.c - 136 + 85 - called 375 times + called 57 times - lcd_set_all_SIG + lcd_set_all_SIG - src\lcd_hd44780.c + src\lcd_hd44780.c - 127 + 76 - called 375 times + called 57 times - lcd_str + lcd_str - src\lcd_hd44780.c + src\lcd_hd44780.c - 598 + 392 - called 77 times + called 11 times - lcd_update + lcd_update - src\lcd_hd44780.c + src\lcd_hd44780.c - 802 + 619 - called 94 times + called 14 times - lcd_write_4bit_data + lcd_write_4bit_data - src\lcd_hd44780.c + src\lcd_hd44780.c - 145 + 94 - called 8118 times + called 1150 times - lcd_write_byte + lcd_write_byte - src\lcd_hd44780.c + src\lcd_hd44780.c - 165 + 118 - called 3309 times + called 461 times - lcd_write_cmd + lcd_write_cmd - src\lcd_hd44780.c + src\lcd_hd44780.c - 153 + 104 - called 2100 times + called 286 times - lcd_write_data + lcd_write_data - src\lcd_hd44780.c + src\lcd_hd44780.c - 159 + 111 - called 1209 times + called 175 times - register_LCD_IO_driver + register_LCD_IO_driver - src\lcd_hd44780.c + src\lcd_hd44780.c - 122 + 71 - called 375 times + called 57 times - update_lcd_curosr_possition + update_lcd_curosr_possition - src\lcd_hd44780.c + src\lcd_hd44780.c - 455 + 224 - called 7520 times + called 448 times - write_lcd_buf_2_lcd + write_lcd_buf_2_lcd - src\lcd_hd44780.c + src\lcd_hd44780.c - 471 + 240 - called 7520 times + called 448 times diff --git a/reports/Code_Coverage/lcd_hd44780_gcov_report.html b/reports/Code_Coverage/lcd_hd44780_gcov_report.html index ad43667..66b2003 100644 --- a/reports/Code_Coverage/lcd_hd44780_gcov_report.html +++ b/reports/Code_Coverage/lcd_hd44780_gcov_report.html @@ -23,7 +23,7 @@

GCC Code Coverage Report

Date: - 2024-01-12 11:24:32 + 2024-08-06 22:02:55 Coverage: @@ -46,21 +46,21 @@

GCC Code Coverage Report

Lines: - 228 - 230 - 99.1% + 240 + 242 + 99.2% Functions: - 35 - 35 + 37 + 37 100.0% Branches: - 46 + 45 47 - 97.9% + 95.7% @@ -93,14 +93,14 @@

GCC Code Coverage Report

lcd_hd44780.c - 99.1 + 99.2 - 99.1% - 228 / 230 + 99.2% + 240 / 242 100.0% - 35 / 35 - 97.9% - 46 / 47 + 37 / 37 + 95.7% + 45 / 47 diff --git a/reports/Code_Coverage/lcd_hd44780_gcov_report.lcd_hd44780.c.9b5fec2915da14d10e466e7fb812c453.html b/reports/Code_Coverage/lcd_hd44780_gcov_report.lcd_hd44780.c.9b5fec2915da14d10e466e7fb812c453.html index fa04692..a8418ac 100644 --- a/reports/Code_Coverage/lcd_hd44780_gcov_report.lcd_hd44780.c.9b5fec2915da14d10e466e7fb812c453.html +++ b/reports/Code_Coverage/lcd_hd44780_gcov_report.lcd_hd44780.c.9b5fec2915da14d10e466e7fb812c453.html @@ -27,7 +27,7 @@

GCC Code Coverage Report

Date: - 2024-01-12 11:24:32 + 2024-08-06 22:02:55 @@ -41,21 +41,21 @@

GCC Code Coverage Report

Lines: - 228 - 230 - 99.1% + 240 + 242 + 99.2% Functions: - 35 - 35 + 37 + 37 100.0% Branches: - 46 + 45 47 - 97.9% + 95.7% @@ -75,387 +75,409 @@

GCC Code Coverage Report

- check_lcd_buf_possition_ptr_overflow + check_lcd_buf_possition_ptr_overflow - 438 + 206 - called 837 times + called 126 times - copy_lcd_buf_2_prev_lcd_buf + copy_lcd_buf_2_prev_lcd_buf - 445 + 214 - called 469 times + called 71 times - fill_bin_value_buffer + fill_bin_value_buffer - 403 + 169 - called 27 times + called 4 times - fill_zeros_buffer + fill_zeros_buffer - 423 + 189 - called 27 times + called 4 times - lcd_bin + lcd_bin - 671 + 465 - called 14 times + called 2 times - lcd_blinking_cursor_on + lcd_blinking_cursor_on - 763 + 557 - called 7 times + called 1 time - lcd_buf_bin + lcd_buf_bin - 881 + 703 - called 13 times + called 2 times - lcd_buf_char + lcd_buf_char - 780 + 584 - called 63 times + called 9 times - lcd_buf_cls + lcd_buf_cls - 770 + 568 - called 382 times + called 58 times - lcd_buf_hex + lcd_buf_hex - 856 + 678 - called 32 times + called 5 times - lcd_buf_int + lcd_buf_int - 829 + 651 - called 28 times + called 4 times - lcd_buf_locate + lcd_buf_locate - 787 + 596 - called 87 times + called 13 times - lcd_buf_str + lcd_buf_str - 792 + 605 - called 160 times + called 24 times - lcd_char + lcd_char - 587 + 382 - called 348 times + called 103 times - lcd_cls + lcd_cls - 540 + 327 - called 382 times + called 58 times - lcd_cursor_off + lcd_cursor_off - 754 + 548 - called 7 times + called 1 time - lcd_cursor_on + lcd_cursor_on - 744 + 538 - called 7 times + called 1 time - lcd_def_char + lcd_def_char - 558 + 348 - called 63 times + called 9 times - lcd_hex + lcd_disable_backlight - 645 + 314 - called 28 times + called 58 times - lcd_home + lcd_enable_backlight - 731 + 302 - called 7 times + called 2 times - lcd_init + lcd_hex - 495 + 439 - called 375 times + called 4 times - lcd_int + lcd_home - 617 + 525 - called 28 times + called 1 time - lcd_load_char_bank + lcd_init - 568 + 259 + + + called 57 times + + + + + lcd_int + + + 411 + + + called 4 times + + + + + lcd_load_char_bank - called 7 times + 363 + + + called 1 time - lcd_locate + lcd_locate - 699 + 493 - called 439 times + called 35 times - lcd_reset_all_SIG + lcd_reset_all_SIG - 136 + 85 - called 375 times + called 57 times - lcd_set_all_SIG + lcd_set_all_SIG - 127 + 76 - called 375 times + called 57 times - lcd_str + lcd_str - 598 + 392 - called 77 times + called 11 times - lcd_update + lcd_update - 802 + 619 - called 94 times + called 14 times - lcd_write_4bit_data + lcd_write_4bit_data - 145 + 94 - called 8118 times + called 1150 times - lcd_write_byte + lcd_write_byte - 165 + 118 - called 3309 times + called 461 times - lcd_write_cmd + lcd_write_cmd - 153 + 104 - called 2100 times + called 286 times - lcd_write_data + lcd_write_data - 159 + 111 - called 1209 times + called 175 times - register_LCD_IO_driver + register_LCD_IO_driver - 122 + 71 - called 375 times + called 57 times - update_lcd_curosr_possition + update_lcd_curosr_possition - 455 + 224 - called 7520 times + called 448 times - write_lcd_buf_2_lcd + write_lcd_buf_2_lcd - 471 + 240 - called 7520 times + called 448 times @@ -477,434 +499,434 @@

GCC Code Coverage Report

- /* + /** 2 - * @Author: lukasz.niewelt + * @file lcd_hd44780.c 3 - * @Date: 2023-12-06 21:39:30 + * @author niwciu (niwciu@gmail.com) 4 - * @Last Modified by: lukasz.niewelt + * @brief 5 - * @Last Modified time: 2024-01-10 18:04:17 + * @version 1.0.2 6 - */ + * @date 2024-02-25 7 - + * 8 - #include "lcd_hd44780.h" + * @copyright Copyright (c) 2024 9 - #include <stddef.h> + 10 - #include <stdio.h> + */ 11 - #include <stdlib.h> + #include "lcd_hd44780_GPIO_interface.h" 12 - #include <string.h> + #include "lcd_hd44780.h" 13 - + #include "lcd_hd44780_driver_commands.h" 14 - typedef char lcd_pos_t; + #ifdef AVR 15 - // clang-format off + #include "lcd_hd44780_avr_specific.h" 16 - #define BUSY_FLAG 1 << 7 + #endif 17 - #define VAL_PREFIX_LENGHT 2U + #include <stddef.h> 18 - + #include <stdio.h> 19 - // LCD driver commands + #include <string.h> 20 - #define LCDC_CLS 0x01 + 21 - #define LCDC_HOME 0x02 + #define BUSY_FLAG 1 << 7 22 - /********************************/ + #define VAL_PREFIX_LENGHT 2U 23 - #define LCDC_ENTRY_MODE 0x04 + 24 - #define LCDC_ENTRYR 0x02 + #ifndef UNIT_TEST 25 - #define LCDC_ENTRYL 0x00 + #define PRIVATE static 26 - #define LCDC_MOVE 0x01 + #else 27 - /********************************/ + #define PRIVATE 28 - #define LCDC_ONOFF 0x08 + #endif 29 - #define LCDC_DISPLAYON 0x04 + 30 - #define LCDC_CURSORON 0x02 + #if LCD_BUFFERING == ON 31 - #define LCDC_CURSOROFF 0x00 + #define LAST_CHAR_IN_LCD_LINE (LCD_X - 1) 32 - #define LCDC_BLINKON 0x01 + #define LAST_LCD_LINE (LCD_Y - 1) 33 - /********************************/ + 34 - #define LCDC_SHIFT 0x10 + typedef char lcd_pos_t; 35 - #define LCDC_SHIFTDISP 0x08 + static lcd_pos_t *lcd_buf_position_ptr; 36 - #define LCDC_SHIFTR 0x04 + PRIVATE char lcd_buffer[LCD_Y][LCD_X]; 37 - #define LCDC_SHIFTL 0x00 + PRIVATE char prev_lcd_buffer[LCD_Y][LCD_X]; 38 - /********************************/ + #endif 39 - #define LCDC_FUNC 0x20 + 40 - #define LCDC_FUNC8B 0x10 + static const struct LCD_IO_driver_interface_struct *LCD = NULL; 41 - #define LCDC_FUNC4B 0x00 + 42 - #define LCDC_FUNC2L 0x08 + bool LCD_BUFFER_UPDATE_FLAG = false; 43 - #define LCDC_FUNC1L 0x00 + 44 - #define LCDC_FUNC5x10 0x04 + static void register_LCD_IO_driver(void); 45 - #define LCDC_FUNC5x7 0x00 + static void lcd_set_all_SIG(void); 46 - /********************************/ + static void lcd_reset_all_SIG(void); 47 - #define LCDC_SET_CGRAM 0x40 + static void lcd_write_4bit_data(uint8_t data); 48 - #define LCDC_SET_DDRAM 0x80 + static void lcd_write_cmd(uint8_t cmd); 49 - + static void lcd_write_data(uint8_t data); 50 - #ifndef UNIT_TEST + static void lcd_write_byte(uint8_t byte); 51 - #define PRIVATE static + 52 - #else + #if USE_RW_PIN == ON 53 - #define PRIVATE + static uint8_t lcd_read_byte(void); 54 - #endif + static uint8_t lcd_read_4bit_data(void); 55 - + #endif 56 - #if LCD_BUFFERING == ON + 57 - + #ifndef AVR 58 - #define LAST_CHAR_IN_LCD_LINE (LCD_X-1) + #if (USE_LCD_BIN == ON || ((LCD_BUFFERING == ON) && (LCD_USE_BUF_BIN == ON))) 59 - #define LAST_LCD_LINE (LCD_Y-1) + static void fill_bin_value_buffer(int val, char *bin_val_buffer); 60 - + static void fill_zeros_buffer(const char *buffer, uint8_t width, char *zeros_buf); 61 - PRIVATE char lcd_buffer[LCD_Y][LCD_X]; + #endif 62 - PRIVATE char prev_lcd_buffer[LCD_Y][LCD_X]; + #endif 63 @@ -918,559 +940,559 @@

GCC Code Coverage Report

- static lcd_pos_t *lcd_buf_position_ptr; + #if LCD_BUFFERING == ON 65 - #endif + static void check_lcd_buf_possition_ptr_overflow(void); 66 - + static void copy_lcd_buf_2_prev_lcd_buf(void); 67 - static const struct LCD_IO_driver_interface_struct *LCD = NULL; + static void update_lcd_curosr_possition(uint8_t *lcd_cursor_position, uint8_t *lcd_line, uint8_t *missed_char_counter_in_LCD_line); 68 - bool LCD_UPDATE_EVENT = false; + static void write_lcd_buf_2_lcd(const uint8_t *lcd_cursor_position, const uint8_t *lcd_line, uint8_t *missed_char_counter_in_LCD_line, const lcd_pos_t *prev_lcd_buff_pos_ptr); 69 - + #endif 70 - static void register_LCD_IO_driver(void); + 71 - - static void lcd_set_all_SIG(void); + 57 + static void register_LCD_IO_driver(void) 72 - static void lcd_reset_all_SIG(void); + { 73 - - static void lcd_write_4bit_data(uint8_t data); + 57 + LCD = LCD_IO_driver_interface_get(); 74 - - static void lcd_write_cmd(uint8_t cmd); + 57 + } 75 - static void lcd_write_data(uint8_t data); + 76 - - static void lcd_write_byte(uint8_t byte); + 57 + static void lcd_set_all_SIG(void) 77 - + { 78 - - #if USE_RW_PIN == ON + 57 + LCD->set_LCD_E(); 79 - - static uint8_t lcd_read_byte(void); + 57 + LCD->set_LCD_RS(); 80 - static uint8_t lcd_read_4bit_data(void); + #if USE_RW_PIN == ON 81 - #endif + LCD->set_LCD_RW(); 82 - #ifdef AVR + #endif 83 - - #if ((USE_LCD_INT == ON) || (USE_LCD_HEX == ON)) + 57 + } 84 - static void lcd_put_spaces(uint8_t empty_spaces); + 85 - - #endif + 57 + static void lcd_reset_all_SIG(void) 86 - #if USE_LCD_INT == ON + { 87 - static void lcd_int_AVR(int val, uint8_t width, enum alignment alignment); + #if USE_RW_PIN == ON 88 - #endif + LCD->reset_LCD_RW(); 89 - #if USE_LCD_HEX == ON + #endif 90 - - static void lcd_hex_AVR(int val, uint8_t width, enum alignment alignment); + 57 + LCD->reset_LCD_RS(); 91 - - #endif + 57 + LCD->reset_LCD_E(); 92 - - #if USE_LCD_BIN == ON + 57 + } 93 - static void lcd_bin_AVR(int val, uint8_t width); + 94 - - #endif + 1150 + void lcd_write_4bit_data(uint8_t data) 95 - #if LCD_BUFFERING == ON + { 96 - - #if ((USE_LCD_BUF_INT == ON) || (USE_LCD_BUF_HEX == ON)) + 1150 + LCD->set_LCD_E(); 97 - static void lcd_buf_put_spaces(uint8_t empty_spaces); + ; 98 - - #endif + 1150 + data &= 0x0F; 99 - - #if USE_LCD_BUF_INT == ON + 1150 + LCD->write_data(data); 100 - - static void lcd_buf_int_AVR(int val, uint8_t width, enum alignment alignment); + 1150 + LCD->reset_LCD_E(); 101 - #endif + ; 102 - - #if USE_LCD_BUF_HEX == ON + 1150 + } 103 - static void lcd_buf_hex_AVR(int val, uint8_t width, enum alignment alignment); + 104 - - #endif + 286 + static void lcd_write_cmd(uint8_t cmd) 105 - #if USE_LCD_BUF_BIN == ON + { 106 - - static void lcd_buf_bin_AVR(int val, uint8_t width); + 286 + LCD->reset_LCD_RS(); 107 - #endif + ; 108 - - #endif + 286 + lcd_write_byte(cmd); 109 - - #else + 286 + } 110 - #if (USE_LCD_BIN == ON || ((LCD_BUFFERING == ON) && (LCD_USE_BUF_BIN == ON))) + 111 - - static void fill_bin_value_buffer(int val, char *bin_val_buffer); + 175 + void lcd_write_data(uint8_t data) 112 - static void fill_zeros_buffer(const char *buffer, uint8_t width, char *zeros_buf); + { 113 - - #endif + 175 + LCD->set_LCD_RS(); 114 - #endif + ; 115 - - #if LCD_BUFFERING==ON + 175 + lcd_write_byte(data); 116 - - static void check_lcd_buf_possition_ptr_overflow(void); + 175 + } 117 - static void copy_lcd_buf_2_prev_lcd_buf(void); + 118 - - static void update_lcd_curosr_possition(uint8_t *lcd_cursor_position,uint8_t *lcd_line, uint8_t *missed_char_counter_in_LCD_line); + 461 + void lcd_write_byte(uint8_t byte) 119 - static void write_lcd_buf_2_lcd(const uint8_t *lcd_cursor_position,const uint8_t *lcd_line,uint8_t * missed_char_counter_in_LCD_line, const lcd_pos_t *prev_lcd_buff_pos_ptr); + { 120 - #endif + #if USE_RW_PIN == ON 121 - + LCD->reset_LCD_RW(); 122 - 375 - static void register_LCD_IO_driver(void) + + ; 123 - { + #endif 124 - 375 - LCD = LCD_IO_driver_interface_get(); + 461 + lcd_write_4bit_data((byte) >> 4); 125 - 375 - } + 461 + lcd_write_4bit_data((byte) & 0x0F); 126 - + #if USE_RW_PIN == ON 127 - 375 - static void lcd_set_all_SIG(void) + + // check_BUSSY_FALG 128 - { + LCD->set_data_pins_as_inputs(); 129 - 375 - LCD->set_SIG(LCD_E); + + LCD->reset_LCD_RS(); 130 - 375 - LCD->set_SIG(LCD_RS); + + ; 131 - #if USE_RW_PIN == ON + LCD->set_LCD_RW(); 132 - LCD->set_SIG(LCD_RW); + ; 133 - #endif + while (lcd_read_byte() & BUSY_FLAG) 134 - 375 - } + + { 135 - + } 136 - 375 - static void lcd_reset_all_SIG(void) + + LCD->reset_LCD_RW(); 137 - { + ; 138 - #if USE_RW_PIN == ON + LCD->set_data_pins_as_outputs(); 139 - LCD->reset_SIG(LCD_RW); + 140 - #endif + #else 141 - 375 - LCD->reset_SIG(LCD_RS); + 461 + LCD->delay_us(120); 142 - 375 - LCD->reset_SIG(LCD_E); + + #endif 143 - 375 + 461 } @@ -1484,316 +1506,337 @@

GCC Code Coverage Report

145 - 8118 - void lcd_write_4bit_data(uint8_t data) + + #if USE_RW_PIN == ON 146 - { + uint8_t lcd_read_byte(void) 147 - 8118 - LCD->set_SIG(LCD_E); + + { 148 - 8118 - data &= 0x0F; + + uint8_t data; 149 - 8118 - LCD->write_data(data); + + // read 4 MSB 150 - 8118 - LCD->reset_SIG(LCD_E); + + data = (lcd_read_4bit_data() << 4); 151 - 8118 - } + + // read 4 LSB 152 - + data |= (lcd_read_4bit_data() & 0x0F); 153 - 2100 - static void lcd_write_cmd(uint8_t cmd) + + return data; 154 - { + } 155 - 2100 - LCD->reset_SIG(LCD_RS); + + 156 - 2100 - lcd_write_byte(cmd); + + uint8_t lcd_read_4bit_data(void) 157 - 2100 - } + + { 158 - + uint8_t data; 159 - 1209 - void lcd_write_data(uint8_t data) + + LCD->set_LCD_E(); 160 - { + ; 161 - 1209 - LCD->set_SIG(LCD_RS); + + data = LCD->read_data(); 162 - 1209 - lcd_write_byte(data); + + LCD->reset_LCD_E(); 163 - 1209 - } + + ; 164 - + return data; 165 - 3309 - void lcd_write_byte(uint8_t byte) + + } 166 - { + #endif 167 - #if USE_RW_PIN == ON + #ifndef AVR 168 - LCD->reset_SIG(LCD_RW); + #if USE_LCD_BIN == ON 169 - - #endif + 4 + static void fill_bin_value_buffer(int val, char *bin_val_buffer) 170 - 3309 - lcd_write_4bit_data((byte) >> 4); + + { 171 - 3309 - lcd_write_4bit_data((byte) & 0x0F); + 4 + uint32_t bit_mask = 0x80000000; 172 +
+ 2/2 +
+
✓ Branch 0 taken 128 times.
+
✓ Branch 1 taken 4 times.
+
+
- - #if USE_RW_PIN == ON + 132 + while (bit_mask != 0) 173 - // check_BUSSY_FALG + { 174 +
+ 2/2 +
+
✓ Branch 0 taken 8 times.
+
✓ Branch 1 taken 120 times.
+
+
- - LCD->set_data_pins_as_inputs(); + 128 + if ((bit_mask & val) != 0) 175 - LCD->reset_SIG(LCD_RS); + { 176 - - LCD->set_SIG(LCD_RW); + 8 + strcat(bin_val_buffer, "1"); 177 - while (lcd_read_byte() & BUSY_FLAG) + } 178 - { + else 179 - } + { 180 +
+ 2/2 +
+
✓ Branch 0 taken 4 times.
+
✓ Branch 1 taken 116 times.
+
+
- - LCD->reset_SIG(LCD_RW); + 120 + if (strlen(bin_val_buffer) != 0) 181 - LCD->set_data_pins_as_outputs(); + { 182 - - + 4 + strcat(bin_val_buffer, "0"); 183 - #else + } 184 - 3309 - LCD->delay_us(120); + + } 185 - - #endif + 128 + bit_mask = bit_mask >> 1; 186 - 3309 - } + + } 187 - - + 4 + } 188 - #if USE_RW_PIN == ON + 189 - - uint8_t lcd_read_byte(void) + 4 + static void fill_zeros_buffer(const char *buffer, uint8_t width, char *zeros_buf) 190 @@ -1806,1142 +1849,1212 @@

GCC Code Coverage Report

191 - - uint8_t data; + 4 + uint8_t buf_len = strlen(buffer); 192 - - // read 4 MSB + 4 + uint8_t total_str_width = width + VAL_PREFIX_LENGHT; 193 +
+ 2/2 +
+
✓ Branch 0 taken 2 times.
+
✓ Branch 1 taken 2 times.
+
+
- - data = (lcd_read_4bit_data() << 4); + 4 + if (buf_len < (total_str_width)) 194 - // read 4 LSB + { 195 - - data |= (lcd_read_4bit_data() & 0x0F); + 2 + uint8_t zeros_qty = width - ((strlen(buffer) + VAL_PREFIX_LENGHT)); 196 +
+ 2/2 +
+
✓ Branch 0 taken 2 times.
+
✓ Branch 1 taken 2 times.
+
+
- - return data; + 4 + for (uint8_t j = 0; j < zeros_qty; j++) 197 - } + { 198 - - + 2 + strcat(zeros_buf, "0"); 199 - uint8_t lcd_read_4bit_data(void) + } 200 - { + } 201 - - uint8_t data; + 4 + } 202 - LCD->set_SIG(LCD_E); + #endif 203 - data = LCD->read_data(); + #endif 204 - LCD->reset_SIG(LCD_E); + 205 - return data; + #if LCD_BUFFERING == ON 206 - - } + 126 + static void check_lcd_buf_possition_ptr_overflow(void) 207 - #endif + { 208 - - #ifdef AVR + 126 + lcd_buf_position_ptr++; 209 +
+ 2/2 +
+
✓ Branch 0 taken 3 times.
+
✓ Branch 1 taken 123 times.
+
+
- - #if ((USE_LCD_INT == ON) || (USE_LCD_HEX == ON)) + 126 + if (lcd_buf_position_ptr > &lcd_buffer[LAST_LCD_LINE][LAST_CHAR_IN_LCD_LINE]) 210 - static void lcd_put_spaces(uint8_t empty_spaces) + { 211 - - { + 3 + lcd_buf_position_ptr = &lcd_buffer[LINE_1][C1]; 212 - for (uint8_t i = 0; i < empty_spaces; i++) + } 213 - - { + 126 + } 214 - - lcd_char(' '); + 71 + static void copy_lcd_buf_2_prev_lcd_buf(void) 215 - } + { 216 +
+ 2/2 +
+
✓ Branch 0 taken 142 times.
+
✓ Branch 1 taken 71 times.
+
+
- - } + 213 + for (uint8_t y = 0; y < LCD_Y; y++) 217 - #endif + { 218 +
+ 2/2 +
+
✓ Branch 0 taken 2272 times.
+
✓ Branch 1 taken 142 times.
+
+
- - #if USE_LCD_INT == ON + 2414 + for (uint8_t x = 0; x < LCD_X; x++) 219 - static void lcd_int_AVR(int val, uint8_t width, enum alignment alignment) + { 220 - - { + 2272 + prev_lcd_buffer[y][x] = lcd_buffer[y][x]; 221 - uint8_t buf_lenght = 0; + } 222 - char buffer[20]; // 19chars for 64 bit int + end char '\0' + } 223 - - buffer[0] = '\0'; + 71 + } 224 - - itoa(val, buffer, 10); + 448 + static void update_lcd_curosr_possition(uint8_t *lcd_cursor_position, uint8_t *lcd_line, uint8_t *missed_char_counter_in_LCD_line) 225 - buf_lenght = strlen(buffer); + { 226 - - if (buf_lenght >= (width)) + 448 + (*lcd_cursor_position)++; 227 +
+ 2/2 +
+
✓ Branch 0 taken 28 times.
+
✓ Branch 1 taken 420 times.
+
+
- - { + 448 + if ((*lcd_cursor_position) >= LCD_X) 228 - lcd_str(buffer); + { 229 - - } + 28 + *lcd_cursor_position = 0; 230 - - else + 28 + (*lcd_line)++; 231 - - { + 28 + *missed_char_counter_in_LCD_line = 0; 232 +
+ 2/2 +
+
✓ Branch 0 taken 14 times.
+
✓ Branch 1 taken 14 times.
+
+
- - uint8_t empty_spaces_qty = width - buf_lenght; + 28 + if (*lcd_line == LCD_Y) 233 - if (alignment == right) + { 234 - - { + 14 + *lcd_line = LINE_1; 235 - lcd_put_spaces(empty_spaces_qty); + } 236 - - lcd_str(buffer); + 28 + lcd_locate(*lcd_line, *lcd_cursor_position); 237 - } + } 238 - - else + 448 + } 239 - { + 240 - - lcd_str(buffer); + 448 + static void write_lcd_buf_2_lcd(const uint8_t *lcd_cursor_position, const uint8_t *lcd_line, uint8_t *missed_char_counter_in_LCD_line, const lcd_pos_t *prev_lcd_buff_pos_ptr) 241 - lcd_put_spaces(empty_spaces_qty); + { 242 +
+ 2/2 +
+
✓ Branch 0 taken 51 times.
+
✓ Branch 1 taken 397 times.
+
+
- - } + 448 + if ((*lcd_buf_position_ptr) != (*prev_lcd_buff_pos_ptr)) 243 - } + { 244 +
+ 2/2 +
+
✓ Branch 0 taken 4 times.
+
✓ Branch 1 taken 47 times.
+
+
- - } + 51 + if (*missed_char_counter_in_LCD_line != 0) 245 - #endif + { 246 - - #if USE_LCD_HEX == ON + 4 + lcd_locate(*lcd_line, *lcd_cursor_position); 247 - - static void lcd_hex_AVR(int val, uint8_t width, enum alignment alignment) + 4 + *missed_char_counter_in_LCD_line = 0; 248 - { + } 249 - - char buffer[17]; + 51 + lcd_char(*lcd_buf_position_ptr); 250 - buffer[0] = '\0'; + } 251 - itoa(val, buffer, 16); + else 252 - static const char *prefix = {"0x"}; + { 253 - - if (width <= (strlen(buffer) + VAL_PREFIX_LENGHT)) + 397 + (*missed_char_counter_in_LCD_line)++; 254 - { + } 255 - - lcd_str(prefix); + 448 + } 256 - lcd_str(buffer); + 257 - } + #endif 258 - else + 259 - - { + 57 + void lcd_init(void) 260 - uint8_t empty_spaces_qty = width - (VAL_PREFIX_LENGHT + strlen(buffer)); + { 261 - - + 57 + register_LCD_IO_driver(); 262 - - if (alignment == right) + 57 + LCD->init_LCD_pins(); 263 - - { + 57 + lcd_disable_backlight(); 264 - lcd_put_spaces(empty_spaces_qty); + /**************************BASIC LCD INIT - basing on DS init procedure***************************************/ 265 - lcd_str(prefix); + // set all LCD signals to High for more than 15ms ->bit different than in DS based on other implementations from the internet 266 - - lcd_str(buffer); + 57 + lcd_set_all_SIG(); 267 - - } + 57 + LCD->delay_us(15000); 268 - - else + 57 + lcd_reset_all_SIG(); 269 - { + // send 0x03 & wait more then 4,1ms 270 - - lcd_str(prefix); + 57 + lcd_write_4bit_data(0x03); 271 - - lcd_str(buffer); + 57 + LCD->delay_us(4500); 272 - lcd_put_spaces(empty_spaces_qty); + // send 0x03 & wait more then 100us 273 - - } + 57 + lcd_write_4bit_data(0x03); 274 - - } + 57 + LCD->delay_us(110); 275 - } + // send 0x03 & wait more then 100us 276 - - #endif + 57 + lcd_write_4bit_data(0x03); 277 - - #if USE_LCD_BIN == ON + 57 + LCD->delay_us(110); 278 - static void lcd_bin_AVR(int val, uint8_t width) + // send 0x02 & wait more then 100us 279 - - { + 57 + lcd_write_4bit_data(0x02); 280 - - char buffer[35]; // 0b 0000 0000 0000 0000 0000 0000 0000 0000 + 57 + LCD->delay_us(110); 281 - static const char *prefix = {"0b"}; + // FUNCTION SET ->send cmd -> LCD in 4-bit mode, 2 rows, char size 5x7 282 - - buffer[0] = '\0'; + 57 + lcd_write_cmd(LCDC_FUNC | LCDC_FUNC4B | LCDC_FUNC2L | LCDC_FUNC5x7); 283 - + // DISPLAY_ON_OFF send cmd -> enable lcd 284 - - itoa(val, buffer, 2); + 57 + lcd_write_cmd(LCDC_ONOFF | LCDC_CURSOROFF | LCDC_DISPLAYON); 285 - // if (buf_lenght < (width - VAL_PREFIX_LENGHT)) + // LCD clear screen 286 - - if (width <= (strlen(buffer) + VAL_PREFIX_LENGHT)) + 57 + lcd_cls(); 287 - { + // ENTRY MODe SET do not shift the LCD shift cursor right after placing a char 288 - - lcd_str(prefix); + 57 + lcd_write_cmd(LCDC_ENTRY_MODE | LCDC_ENTRYR); 289 - lcd_str(buffer); + /*********************************END of BASIC LCD INIT***************************************/ 290 - } + #if LCD_BUFFERING == ON 291 - else + // clear lcd_buffer by putting spaces inside of the buffer 292 - - { + 57 + lcd_buf_cls(); 293 - uint8_t zeros_qty = (width - (VAL_PREFIX_LENGHT + strlen(buffer))); + // copy lcd_buffer with spaces to prev_lcd_buffer 294 - - lcd_str(prefix); + 57 + copy_lcd_buf_2_prev_lcd_buf(); 295 - for (uint8_t i = 0; i < zeros_qty; i++) + // clear flag due to init procedure that reset LCD screen and buffers 296 - - { + 57 + LCD_BUFFER_UPDATE_FLAG = false; 297 - lcd_char('0'); + #endif 298 - - } + 57 + } 299 - lcd_str(buffer); + /** 300 - } + * @brief Function for disabling backlight od the LCD 301 - } + */ 302 - - #endif + 2 + void lcd_enable_backlight(void) 303 - + { 304 - #if LCD_BUFFERING== ON + #if LCD_BCKL_PIN_EN_STATE == HIGH 305 - - #if ((USE_LCD_BUF_INT == ON) || (USE_LCD_BUF_HEX == ON)) + 2 + LCD->set_LCD_BCKL(); 306 - static void lcd_buf_put_spaces(uint8_t empty_spaces) + #else 307 - { + LCD->reset_LCD_BCKL(); 308 - for (uint8_t i = 0; i < empty_spaces; i++) + #endif 309 - - { + 2 + } 310 - lcd_buf_char(' '); + 311 - } + /** 312 - } + * @brief Function for enabling backlight od the LCD 313 - #endif + */ 314 - - #if USE_LCD_BUF_INT == ON + 58 + void lcd_disable_backlight(void) 315 - static void lcd_buf_int_AVR(int val, uint8_t width, enum alignment alignment) + { 316 - { + #if LCD_BCKL_PIN_EN_STATE == HIGH 317 - - uint8_t buf_lenght = 0; + 58 + LCD->reset_LCD_BCKL(); 318 - char buffer[20]; // 19chars for 64 bit int + end char '\0' + #else 319 - buffer[0] = '\0'; + LCD->set_LCD_BCKL(); 320 - itoa(val, buffer, 10); + #endif 321 - - buf_lenght = strlen(buffer); + 58 + } 322 - if (buf_lenght >= (width)) + 323 - { + /** 324 - lcd_buf_str(buffer); + * @brief Function that clears the LCD screen and sets the cursor on the position of the first character in the first line of the LCD 325 - } + * screen. 326 - else + */ 327 - - { + 58 + void lcd_cls(void) 328 - uint8_t empty_spaces_qty = width - buf_lenght; + { 329 - - if (alignment == right) + 58 + lcd_write_cmd(LCDC_CLS); 330 - { + #if USE_RW_PIN == OFF 331 - - lcd_buf_put_spaces(empty_spaces_qty); + 58 + LCD->delay_us(4900); 332 - lcd_buf_str(buffer); + #endif 333 - - } + 58 + } 334 - else + 335 - { + #if USE_DEF_CHAR_FUNCTION == ON 336 - lcd_buf_str(buffer); + /** 337 - lcd_buf_put_spaces(empty_spaces_qty); + * @brief Function for defining custom user characters in CGRAM of the LCD. 338 - } + * 339 - } + * @param CGRAM_char_index Position/address of the character in CGRAM of the LCD where defined char should be written. 340 - } + * For the predefined example of special characters, taken values are defined in the type enum LCD_CGRAM_BANK_1_e that is declared 341 - #endif + * in lcd-hd44780.h 342 - + * 343 - #if USE_LCD_BUF_HEX == ON + * @param def_char Pointer to the predefined special character. 344 - void lcd_buf_hex_AVR(int val, uint8_t width, enum alignment alignment) + * 345 - { + * @note CGRAM_char_index - This Parameter can take values from 0 to 7. For the predefined example of special 346 - char buffer[17]; + * characters, taken values are defined in the type enum LCD_CGRAM that is defined in lcd_hd44780_def_char.h 347 - buffer[0] = '\0'; + */ 348 - - itoa(val, buffer, 16); + 9 + void lcd_def_char(const uint8_t CGRAM_bank_x_char_adr, const uint8_t *def_char) 349 - static const char *prefix = {"0x"}; + { 350 - - if (width <= (strlen(buffer) + VAL_PREFIX_LENGHT)) + 9 + lcd_write_cmd(LCDC_SET_CGRAM | ((DEF_CHAR_ADR_MASK & CGRAM_bank_x_char_adr) * LCD_CGRAM_BYTES_PER_CHAR)); 351 +
+ 2/2 +
+
✓ Branch 0 taken 72 times.
+
✓ Branch 1 taken 9 times.
+
+
- - { + 81 + for (uint8_t j = 0; j < LCD_CGRAM_BYTES_PER_CHAR; j++) 352 - lcd_buf_str(prefix); + { 353 - - lcd_buf_str(buffer); + 72 + lcd_write_data(def_char[j]); 354 @@ -2954,4011 +3067,2672 @@

GCC Code Coverage Report

355 - - else + 9 + lcd_write_cmd(LCDC_SET_DDRAM); 356 - - { + 9 + } 357 - uint8_t empty_spaces_qty = width - (VAL_PREFIX_LENGHT + strlen(buffer)); + 358 - + /** 359 - if (alignment == right) + * @brief Function that loads to LCD_CGRAM predefined characters form specific user char_bank 360 - { + * 361 - lcd_buf_put_spaces(empty_spaces_qty); + * @param char_bank - pointer to selected user char bank that function should load to LCD_CGRAM. Char banks are defined in lcd_hd44780_def_char.h 362 - lcd_buf_str(prefix); + */ 363 - - lcd_buf_str(buffer); + 1 + void lcd_load_char_bank(const struct char_bank_struct *char_bank) 364 - } + { 365 - - else + 1 + lcd_def_char(0, char_bank->char_0); 366 - - { + 1 + lcd_def_char(1, char_bank->char_1); 367 - - lcd_buf_str(prefix); + 1 + lcd_def_char(2, char_bank->char_2); 368 - - lcd_buf_str(buffer); + 1 + lcd_def_char(3, char_bank->char_3); 369 - - lcd_buf_put_spaces(empty_spaces_qty); + 1 + lcd_def_char(4, char_bank->char_4); 370 - - } + 1 + lcd_def_char(5, char_bank->char_5); 371 - - } + 1 + lcd_def_char(6, char_bank->char_6); 372 - - } + 1 + lcd_def_char(7, char_bank->char_7); 373 - - #endif + 1 + } 374 - #if USE_LCD_BUF_BIN == ON + #endif 375 - static void lcd_buf_bin_AVR(int val, uint8_t width) + 376 - { + /** 377 - char buffer[35]; // 0b 0000 0000 0000 0000 0000 0000 0000 0000 + * @brief Function for printing the char on the LCD screen under the current position of the LCD cursor. 378 - static const char *prefix = {"0b"}; + * @param C char (for example '1') or its ASCI code (0x31). 379 - buffer[0] = '\0'; + * @note For user-defined char, place CGRAM_char_index (Position/address of the character in CGRAM of the LCD where 380 - + * defined char was written). 381 - itoa(val, buffer, 2); + */ 382 - - // if (buf_lenght < (width - VAL_PREFIX_LENGHT)) + 103 + void lcd_char(const char C) 383 - if (width <= (strlen(buffer) + VAL_PREFIX_LENGHT)) + { 384 - - { + 103 + uint8_t data = (uint8_t)(C); 385 - - lcd_buf_str(prefix); + 103 + lcd_write_data(data); 386 - - lcd_buf_str(buffer); + 103 + } 387 - } + 388 - else + /** 389 - { + * @brief Function for printing/writing the string on the LCD screen starting from the current LCD cursor position. 390 - uint8_t zeros_qty = (width - (VAL_PREFIX_LENGHT + strlen(buffer))); + * @param str string that should be printed/written on the LCD screen 391 - lcd_buf_str(prefix); + */ 392 - - for (uint8_t i = 0; i < zeros_qty; i++) + 11 + void lcd_str(const char *str) 393 - { + { 394 +
+ 2/2 +
+
✓ Branch 0 taken 51 times.
+
✓ Branch 1 taken 11 times.
+
+
- - lcd_buf_char('0'); + 62 + while ((*str) != '\0') 395 - } + { 396 - - lcd_buf_str(buffer); + 51 + lcd_char(*str); 397 - - } + 51 + str++; 398 - } + } 399 - - #endif - - - 400 - - - - #endif - - - 401 - - - - #else - - - 402 - - - - #if USE_LCD_BIN == ON - - - 403 - - - 27 - static void fill_bin_value_buffer(int val, char *bin_val_buffer) - - - 404 - - - - { - - - 405 - - - 27 - uint32_t bit_mask = 0x80000000; - - - 406 - -
- 2/2 -
-
✓ Branch 0 taken 864 times.
-
✓ Branch 1 taken 27 times.
-
-
- - 891 - while (bit_mask != 0) - - - 407 - - - - { - - - 408 - -
- 2/2 -
-
✓ Branch 0 taken 54 times.
-
✓ Branch 1 taken 810 times.
-
-
- - 864 - if ((bit_mask & val) != 0) - - - 409 - - - - { - - - 410 - - - 54 - strcat(bin_val_buffer, "1"); - - - 411 - - - - } - - - 412 - - - - else - - - 413 - - - - { - - - 414 - -
- 2/2 -
-
✓ Branch 0 taken 27 times.
-
✓ Branch 1 taken 783 times.
-
-
- - 810 - if (strlen(bin_val_buffer) != 0) - - - 415 - - - - { - - - 416 - - - 27 - strcat(bin_val_buffer, "0"); - - - 417 - - - - } - - - 418 - - - - } - - - 419 - - - 864 - bit_mask = bit_mask >> 1; - - - 420 - - - - } - - - 421 - - - 27 - } - - - 422 - - - - - - - 423 - - - 27 - static void fill_zeros_buffer(const char *buffer, uint8_t width, char *zeros_buf) - - - 424 - - - - { - - - 425 - -
- 2/2 -
-
✓ Branch 0 taken 15 times.
-
✓ Branch 1 taken 12 times.
-
-
- - 27 - if (strlen(buffer) < (width + VAL_PREFIX_LENGHT)) - - - 426 - - - - { - - - 427 - - - 15 - uint8_t zeros_qty = width - ((strlen(buffer) + VAL_PREFIX_LENGHT)); - - - 428 - -
- 2/2 -
-
✓ Branch 0 taken 15 times.
-
✓ Branch 1 taken 15 times.
-
-
- - 30 - for (uint8_t t = 0; t < zeros_qty; t++) - - - 429 - - - - { - - - 430 - - - 15 - strcat(zeros_buf, "0"); - - - 431 - - - - } - - - 432 - - - - } - - - 433 - - - 27 - } - - - 434 - - - - #endif - - - 435 - - - - #endif - - - 436 - - - - - - - 437 - - - - #if LCD_BUFFERING==ON - - - 438 - - - 837 - static void check_lcd_buf_possition_ptr_overflow(void) - - - 439 - - - - { - - - 440 - -
- 2/2 -
-
✓ Branch 0 taken 21 times.
-
✓ Branch 1 taken 816 times.
-
-
- - 837 - if(++lcd_buf_position_ptr>&lcd_buffer[LAST_LCD_LINE][LAST_CHAR_IN_LCD_LINE]) - - - 441 - - - - { - - - 442 - - - 21 - lcd_buf_position_ptr=&lcd_buffer[LINE_1][C1]; - - - 443 - - - - } - - - 444 - - - 837 - } - - - 445 - - - 469 - static void copy_lcd_buf_2_prev_lcd_buf(void) - - - 446 - - - - { - - - 447 - -
- 2/2 -
-
✓ Branch 0 taken 1876 times.
-
✓ Branch 1 taken 469 times.
-
-
- - 2345 - for(uint8_t y=0;y<LCD_Y;y++) - - - 448 - - - - { - - - 449 - -
- 2/2 -
-
✓ Branch 0 taken 37520 times.
-
✓ Branch 1 taken 1876 times.
-
-
- - 39396 - for(uint8_t x=0;x<LCD_X;x++) - - - 450 - - - - { - - - 451 - - - 37520 - prev_lcd_buffer[y][x]=lcd_buffer[y][x]; - - - 452 - - - - } - - - 453 - - - - } - - - 454 - - - 469 - } - - - 455 - - - 7520 - static void update_lcd_curosr_possition(uint8_t *lcd_cursor_position,uint8_t *lcd_line, uint8_t *missed_char_counter_in_LCD_line) - - - 456 - - - - { - - - 457 - -
- 2/2 -
-
✓ Branch 0 taken 376 times.
-
✓ Branch 1 taken 7144 times.
-
-
- - 7520 - if((++(*lcd_cursor_position))>=LCD_X) - - - 458 - - - - { - - - 459 - - - 376 - *lcd_cursor_position=0; - - - 460 - - - 376 - (*lcd_line)++; - - - 461 - - - 376 - *missed_char_counter_in_LCD_line=0; - - - 462 - -
- 2/2 -
-
✓ Branch 0 taken 94 times.
-
✓ Branch 1 taken 282 times.
-
-
- - 376 - if(*lcd_line==LCD_Y) - - - 463 - - - - { - - - 464 - - - 94 - *lcd_line=LINE_1; - - - 465 - - - - } - - - 466 - - - 376 - lcd_locate(*lcd_line,*lcd_cursor_position); - - - 467 - - - - - - - 468 - - - - } - - - 469 - - - 7520 - } - - - 470 - - - - - - - 471 - - - 7520 - void write_lcd_buf_2_lcd(const uint8_t * lcd_cursor_position, const uint8_t *lcd_line, uint8_t * missed_char_counter_in_LCD_line, const lcd_pos_t *prev_lcd_buff_pos_ptr) - - - 472 - - - - { - - - 473 - -
- 2/2 -
-
✓ Branch 0 taken 341 times.
-
✓ Branch 1 taken 7179 times.
-
-
- - 7520 - if(*lcd_buf_position_ptr!=*prev_lcd_buff_pos_ptr) - - - 474 - - - - { - - - 475 - -
- 2/2 -
-
✓ Branch 0 taken 28 times.
-
✓ Branch 1 taken 313 times.
-
-
- - 341 - if (*missed_char_counter_in_LCD_line!=0) - - - 476 - - - - { - - - 477 - - - 28 - lcd_locate(*lcd_line,*lcd_cursor_position); - - - 478 - - - 28 - *missed_char_counter_in_LCD_line=0; - - - 479 - - - - } - - - 480 - - - 341 - lcd_char(*lcd_buf_position_ptr); - - - 481 - - - - } - - - 482 - - - - else - - - 483 - - - - { - - - 484 - - - 7179 - (*missed_char_counter_in_LCD_line)++; - - - 485 - - - - } - - - 486 - - - 7520 - } - - - 487 - - - - - - - 488 - - - - #endif - - - 489 - - - - - - - 490 - - - - /** - - - 491 - - - - * @brief Function that initialize LCD in 4-bit mode with or without LCD R/W Pin handling. - - - 492 - - - - * @attention LCD R/W handling should be configured in lcd_hd44780_config.h by setting USE_RW_PIN to 1 (Enable R/W Pin - - - 493 - - - - * handling) or 0 (disable R/W Pin handling). - - - 494 - - - - */ - - - 495 - - - 375 - void lcd_init(void) - - - 496 - - - - { - - - 497 - - - 375 - register_LCD_IO_driver(); - - - 498 - - - 375 - LCD->init_LCD_pins(); - - - 499 - - - - /**************************BASIC LCD INIT - basing on DS init procedure***************************************/ - - - 500 - - - - // set all LCD signals to High for more than 15ms ->bit different then in DS base on other implementation from internet - - - 501 - - - 375 - lcd_set_all_SIG(); - - - 502 - - - 375 - LCD->delay_us(15000); - - - 503 - - - 375 - lcd_reset_all_SIG(); - - - 504 - - - - // send 0x03 & wait more then 4,1ms - - - 505 - - - 375 - lcd_write_4bit_data(0x03); - - - 506 - - - 375 - LCD->delay_us(4500); - - - 507 - - - - // send 0x03 & wait more then 100us - - - 508 - - - 375 - lcd_write_4bit_data(0x03); - - - 509 - - - 375 - LCD->delay_us(110); - - - 510 - - - - // send 0x03 & wait more then 100us - - - 511 - - - 375 - lcd_write_4bit_data(0x03); - - - 512 - - - 375 - LCD->delay_us(110); - - - 513 - - - - // send 0x02 & wait more then 100us - - - 514 - - - 375 - lcd_write_4bit_data(0x02); - - - 515 - - - 375 - LCD->delay_us(110); - - - 516 - - - - // FUNCTION SET ->send cmd -> LCD in 4-bit mode, 2 rows, char size 5x7 - - - 517 - - - 375 - lcd_write_cmd(LCDC_FUNC | LCDC_FUNC4B | LCDC_FUNC2L | LCDC_FUNC5x7); - - - 518 - - - - // DISPLAY_ON_OFF send cmd -> enable lcd - - - 519 - - - 375 - lcd_write_cmd(LCDC_ONOFF | LCDC_CURSOROFF | LCDC_DISPLAYON); - - - 520 - - - - // LCD clear screen - - - 521 - - - 375 - lcd_cls(); - - - 522 - - - - // ENTRY MODe SET do not shift LCD shift cursor right after placing a char - - - 523 - - - 375 - lcd_write_cmd(LCDC_ENTRY_MODE | LCDC_ENTRYR); - - - 524 - - - - /*********************************END of BASIC LCD INIT***************************************/ - - - 525 - - - - #if LCD_BUFFERING == ON - - - 526 - - - - //clear lcd_buffer by putting spaces inside of the buffer - - - 527 - - - 375 - lcd_buf_cls(); - - - 528 - - - - //copy lcd_buffer with spaces to prev_lcd_buffer - - - 529 - - - 375 - copy_lcd_buf_2_prev_lcd_buf(); - - - 530 - - - - // clear flag due to init procedure that reset lcd screan and buffers - - - 531 - - - 375 - LCD_UPDATE_EVENT=false; - - - 532 - - - - #endif - - - 533 - - - - - - - 534 - - - 375 - } - - - 535 - - - - - - - 536 - - - - /** - - - 537 - - - - * @brief Function that clear the LCD screen and set the cursor on the position of first character in first line of LCD - - - 538 - - - - * screen. - - - 539 - - - - */ - - - 540 - - - 382 - void lcd_cls(void) - - - 541 - - - - { - - - 542 - - - 382 - lcd_write_cmd(LCDC_CLS); - - - 543 - - - - #if USE_RW_PIN == OFF - - - 544 - - - 382 - LCD->delay_us(4900); - - - 545 - - - - #endif - - - 546 - - - 382 - } - - - 547 - - - - - - - 548 - - - - #if USE_DEF_CHAR_FUNCTION == ON - - - 549 - - - - /** - - - 550 - - - - * @brief Function for defining custom user characters in CGRAM of the LCD. - - - 551 - - - - * @param CGRAM_char_index Position/addres of the character in CGRAM of the LCD where defined char should be written. - - - 552 - - - - * For the predefined example of special characters, taken values are defined in the type enum LCD_CGRAM that is defined - - - 553 - - - - * in lcd-hd44780.h - - - 554 - - - - * @param def_char Pointer to the predefined special character. - - - 555 - - - - * @note CGRAM_char_index - This Parameter can take values from 0 to 7. For the predefined example of special - - - 556 - - - - * characters, taken values are defined in the type enum LCD_CGRAM that is defined in lcd-hd44780.h - - - 557 - - - - */ - - - 558 - - - 63 - void lcd_def_char(const uint8_t CGRAM_bank_x_char_adr, const uint8_t *def_char) - - - 559 - - - - { - - - 560 - - - 63 - lcd_write_cmd(LCDC_SET_CGRAM | ((DEF_CHAR_ADR_MASK & CGRAM_bank_x_char_adr) * LCD_CGRAM_BYTES_PER_CHAR)); - - - 561 - -
- 2/2 -
-
✓ Branch 0 taken 504 times.
-
✓ Branch 1 taken 63 times.
-
-
- - 567 - for (uint8_t j = 0; j < LCD_CGRAM_BYTES_PER_CHAR; j++) - - - 562 - - - - { - - - 563 - - - 504 - lcd_write_data(def_char[j]); - - - 564 - - - - } - - - 565 - - - 63 - lcd_write_cmd(LCDC_SET_DDRAM); - - - 566 - - - 63 - } - - - 567 - - - - - - - 568 - - - 7 - void lcd_load_char_bank(const struct char_bank_struct *char_bank) - - - 569 - - - - { - - - 570 - - - 7 - lcd_def_char(0, char_bank->char_0); - - - 571 - - - 7 - lcd_def_char(1, char_bank->char_1); - - - 572 - - - 7 - lcd_def_char(2, char_bank->char_2); - - - 573 - - - 7 - lcd_def_char(3, char_bank->char_3); - - - 574 - - - 7 - lcd_def_char(4, char_bank->char_4); - - - 575 - - - 7 - lcd_def_char(5, char_bank->char_5); - - - 576 - - - 7 - lcd_def_char(6, char_bank->char_6); - - - 577 - - - 7 - lcd_def_char(7, char_bank->char_7); - - - 578 - - - 7 - } - - - 579 - - - - #endif - - - 580 - - - - - - - 581 - - - - /** - - - 582 - - - - * @brief Function for print the char on the LCD screen under current position of the LCD cursor. - - - 583 - - - - * @param C char (for example '1') or it's ASCI code (0x31). - - - 584 - - - - * @note For user defined char, place CGRAM_char_index (Position/addres of the character in CGRAM of the LCD where - - - 585 - - - - * defined char was written). - - - 586 - - - - */ - - - 587 - - - 348 - void lcd_char(const char C) - - - 588 - - - - { - - - 589 - - - 348 - uint8_t data = (uint8_t)(C); - - - 590 - - - 348 - lcd_write_data(data); - - - 591 - - - 348 - } - - - 592 - - - - - - - 593 - - - - /** - - - 594 - - - - * @brief Function for printing/writing string on LCD screen. Writing the string on LCD screen start from current LCD - - - 595 - - - - * cursor position. - - - 596 - - - - * @param str string that should be printed/written on the LCD screen - - - 597 - - - - */ - - - 598 - - - 77 - void lcd_str(const char *str) - - - 599 - - - - { - - - 600 - - - - register char znak; - - - 601 - -
- 2/2 -
-
✓ Branch 0 taken 357 times.
-
✓ Branch 1 taken 77 times.
-
-
- - 434 - while ((znak = *(str++))) - - - 602 - - - - { - - - 603 - - - 357 - lcd_write_data((uint8_t)(znak)); - - - 604 - - - - } - - - 605 - - - 77 + 11 } - 606 + 400 - 607 + 401 #if USE_LCD_INT == ON - 608 + 402 /** - 609 + 403 - * @brief Function for print the integer value on the LCD screen under current position of the LCD cursor. + * @brief Function for printing the integer value on the LCD screen under the current position of the LCD cursor. - 610 + 404 * @param val int type value to print on LCD screen - 611 + 405 * @param width Minimum number of characters to be printed. If the value to be printed is shorter than this number, the - 612 + 406 * result is padded with blank spaces. The value is not truncated even if the result is larger. - 613 + 407 - * @param alignment If the value to be printed is shorter than width, this parmaeter will specify aligment of the + * @param alignment This parameter can only accept values defined in ::LCD_alignment_e. If the value to be printed is shorter than the width, this parameter will specify the alignment of the - 614 + 408 - * printed tekst value. This parameter can be set to "left" or "right" + * printed text value. - 615 + 409 * @attention to compile for AVR ucontrollers definition of flag AVR is required. - 616 + 410 */ - 617 + 411 - 28 - void lcd_int(int val, uint8_t width, enum alignment alignment) + 4 + void lcd_int(int val, uint8_t width, enum LCD_alignment_e alignment) - 618 + 412 { - 619 + 413 #ifdef AVR - 620 + 414 lcd_int_AVR(val, width, alignment); - 621 + 415 #else - 622 + 416 char buffer[20]; // 19chars for 64 bit int + end char '\0' - 623 + 417 - 28 + 4 buffer[0] = '\0'; - 624 + 418
2/2
-
✓ Branch 0 taken 21 times.
-
✓ Branch 1 taken 7 times.
+
✓ Branch 0 taken 3 times.
+
✓ Branch 1 taken 1 times.
- 28 + 4 if (alignment == right) - 625 + 419 - 21 + 3 sprintf(buffer, "%*i", width, val); - 626 + 420 else - 627 + 421 - 7 + 1 sprintf(buffer, "%-*i", width, val); - 628 + 422 - 28 + 4 lcd_str(buffer); - 629 + 423 #endif - 630 + 424 - 28 + 4 } - 631 + 425 #endif - 632 + 426 - 633 + 427 #if USE_LCD_HEX == ON - 634 + 428 /** - 635 + 429 - * @brief Function for print the integer value in hexadecimal format on the LCD screen under current position of the LCD + * @brief Function for printing the integer value in hexadecimal format on the LCD screen under the current position of the LCD - 636 + 430 * cursor. - 637 + 431 * @param val int type value to print on LCD screen in hexadecimal format - 638 + 432 * @param width Minimum number of characters to be printed. If the value to be printed is shorter than this number, the - 639 + 433 - * result is padded with blank spaces. The value is not truncated even if the result is larger. Width should contain + * result is padded with blank spaces. The value is not truncated even if the result is larger. The width should contain - 640 + 434 - * additional 2 characters for '0x' at the begining of the printed value. + * additional 2 characters for '0x' at the beginning of the printed value. - 641 + 435 - * @param alignment If the value to be printed is shorter than width, this parmaeter will specify aligment of the + * @param alignment This parameter can only accept values defined in ::LCD_alignment_e. If the value to be printed is shorter than the width, this parameter will specify the alignment of the - 642 + 436 - * printed tekst value. This parameter can be set to "left" or "right" + * printed text value. - 643 + 437 * @attention to compile for AVR ucontrollers definition of flag AVR is required. - 644 + 438 */ - 645 + 439 - 28 - void lcd_hex(int val, uint8_t width, enum alignment alignment) + 4 + void lcd_hex(int val, uint8_t width, enum LCD_alignment_e alignment) - 646 + 440 { - 647 + 441 #ifdef AVR - 648 + 442 lcd_hex_AVR(val, width, alignment); - 649 + 443 #else - 650 + 444 char buffer[17]; - 651 + 445 - 28 + 4 buffer[0] = '\0'; - 652 + 446
2/2
-
✓ Branch 0 taken 21 times.
-
✓ Branch 1 taken 7 times.
+
✓ Branch 0 taken 3 times.
+
✓ Branch 1 taken 1 times.
- 28 + 4 if (alignment == right) - 653 + 447 - 21 + 3 sprintf(buffer, "%#*x", width, val); - 654 + 448 else - 655 + 449 - 7 + 1 sprintf(buffer, "%-#*x", width, val); - 656 + 450 - 28 + 4 lcd_str(buffer); - 657 + 451 #endif - 658 + 452 - 28 + 4 } - 659 + 453 #endif - 660 + 454 - 661 + 455 #if USE_LCD_BIN == ON - 662 + 456 /** - 663 + 457 - * @brief Function for print the integer value in hexadecimal format on the LCD screen under current position of the LCD + * @brief Function for printing the integer value in hexadecimal format on the LCD screen under the current position of the LCD - 664 + 458 * cursor. - 665 + 459 * @param val int type value to print on LCD screen in hexadecimal format - 666 + 460 * @param width Minimum number of characters to be printed. If the value to be printed is shorter than this number, the - 667 + 461 - * result is padded with blank spaces. The value is not truncated even if the result is larger. Width should contain + * result is padded with blank spaces. The value is not truncated even if the result is larger. The width should contain - 668 + 462 - * additional 2 characters for '0x' at the begining of the printed value. + * additional 2 characters for '0x' at the beginning of the printed value. - 669 + 463 * @attention to compile for AVR ucontrollers definition of flag AVR is required. - 670 + 464 */ - 671 + 465 - 14 + 2 void lcd_bin(int val, uint8_t width) - 672 + 466 { - 673 + 467 #ifdef AVR - 674 + 468 lcd_bin_AVR(val, width); - 675 + 469 #else - 676 + 470 char buffer[35]; - 677 + 471 char bin_val_buffer[35]; - 678 + 472 char zeros_buf[35]; - 679 + 473 - 14 + 2 buffer[0] = '\0'; - 680 + 474 - 14 + 2 bin_val_buffer[0] = '\0'; - 681 + 475 - 14 + 2 zeros_buf[0] = '\0'; - 682 + 476 - 683 + 477 - 14 + 2 fill_bin_value_buffer(val, bin_val_buffer); - 684 + 478 - 14 + 2 fill_zeros_buffer(bin_val_buffer, width, zeros_buf); - 685 + 479 - 14 + 2 strcat(buffer, "0b"); - 686 + 480 - 14 + 2 strcat(buffer, zeros_buf); - 687 + 481 - 14 + 2 strcat(buffer, bin_val_buffer); - 688 + 482 - 14 + 2 lcd_str(buffer); - 689 + 483 #endif - 690 + 484 - 14 + 2 } - 691 + 485 - 692 + 486 #endif - 693 + 487 - 694 + 488 /** - 695 + 489 - * @brief Function that move LCD cursor to specific posiotion located under x and y coordinate + * @brief Function that moves LCD cursor to a specific position located under the x and y coordinate - 696 + 490 - * @param y LCD row/line number. Defined enum value LINE_1, LINE_2,... etc. + * @param y LCD row/line number. This parameter can only accept values defined in ::LCD_LINES_e. - 697 + 491 - * @param x LCD column number. Defined enum value C1, C2, C3,... etc. + * @param x LCD column number. This parameter can only accept values defined in ::LCD_COLUMNS_e. - 698 + 492 */ - 699 + 493 - 439 - void lcd_locate(enum LCD_LINES y, enum LCD_COLUMNS x) + 35 + void lcd_locate(enum LCD_LINES_e y, enum LCD_COLUMNS_e x) - 700 + 494 { - 701 + 495
- 4/5 + 2/3
-
✓ Branch 0 taken 122 times.
-
✓ Branch 1 taken 108 times.
-
✓ Branch 2 taken 101 times.
-
✓ Branch 3 taken 108 times.
-
✗ Branch 4 not taken.
+
✓ Branch 0 taken 18 times.
+
✓ Branch 1 taken 17 times.
+
✗ Branch 2 not taken.
- 439 + 35 switch (y) - 702 + 496 { - 703 + 497 - 122 + 18 case 0: - 704 + 498 - 122 + 18 y = LCD_LINE1_ADR; - 705 + 499 - 122 + 18 break; - 706 + 500 - 707 + 501 #if (LCD_Y > 1) - 708 + 502 - 108 + 17 case 1: - 709 + 503 - 108 + 17 y = LCD_LINE2_ADR; - 710 + 504 - 108 + 17 break; - 711 + 505 #endif - 712 + 506 #if (LCD_Y > 2) - 713 + 507 - 101 - case 2: + + case 2: - 714 + 508 - 101 - y = LCD_LINE3_ADR; + + y = LCD_LINE3_ADR; - 715 + 509 - 101 - break; + + break; - 716 + 510 #endif - 717 + 511 #if (LCD_Y > 3) - 718 + 512 - 108 - case 3: + + case 3: - 719 + 513 - 108 - y = LCD_LINE4_ADR; + + y = LCD_LINE4_ADR; - 720 + 514 - 108 - break; + + break; - 721 + 515 #endif - 722 + 516 default: - 723 + 517 break; - 724 + 518 } - 725 + 519 - 439 + 35 lcd_write_cmd((uint8_t)(LCDC_SET_DDRAM + y + x)); - 726 + 520 - 439 + 35 } - 727 + 521 #if USE_LCD_CURSOR_HOME == ON - 728 + 522 /** - 729 + 523 - * @brief Function that move lcd cursor to the first posision at first row of LCD screen + * @brief Function that moves LCD cursor to the first position at the first row of the LCD screen - 730 + 524 */ - 731 + 525 - 7 + 1 void lcd_home(void) - 732 + 526 { - 733 + 527 - 7 + 1 lcd_write_cmd(LCDC_CLS | LCDC_HOME); - 734 + 528 #if USE_RW_PIN == OFF - 735 + 529 - 7 + 1 LCD->delay_us(4900); - 736 + 530 #endif - 737 + 531 - 7 + 1 } - 738 + 532 #endif - 739 + 533 - 740 + 534 #if USE_LCD_CURSOR_ON == ON - 741 + 535 /** - 742 + 536 * @brief Function that activates the visibility of the LCD cursor. - 743 + 537 */ - 744 + 538 - 7 + 1 void lcd_cursor_on(void) - 745 + 539 { - 746 + 540 - 7 + 1 lcd_write_cmd(LCDC_ONOFF | LCDC_DISPLAYON | LCDC_CURSORON); - 747 + 541 - 7 + 1 } - 748 + 542 #endif - 749 + 543 - 750 + 544 #if USE_LCD_CURSOR_OFF == ON - 751 + 545 /** - 752 + 546 * @brief Function that deactivates the visibility and blinking of the LCD cursor. - 753 + 547 */ - 754 + 548 - 7 + 1 void lcd_cursor_off(void) - 755 + 549 { - 756 + 550 - 7 + 1 lcd_write_cmd(LCDC_ONOFF | LCDC_DISPLAYON); - 757 + 551 - 7 + 1 } - 758 + 552 #endif - 759 + 553 #if USE_LCD_BLINKING_CURSOR_ON == ON - 760 + 554 /** - 761 + 555 * @brief Function that activates the visibility and blinking of the LCD cursor. - 762 + 556 */ - 763 + 557 - 7 + 1 void lcd_blinking_cursor_on(void) - 764 + 558 { - 765 + 559 - 7 + 1 lcd_write_cmd(LCDC_ONOFF | LCDC_DISPLAYON | LCDC_CURSORON | LCDC_BLINKON); - 766 + 560 - 7 + 1 } - 767 + 561 #endif - 768 + 562 - 769 + 563 #if LCD_BUFFERING == ON - 770 + 564 + + + + /** + + + 565 + + + + * @brief Function that puts spaces(0x32) in the whole LCD buffer and sets the cursor on the position of the first character in the first line of the LCD + + + 566 + + + + * buffer. + + + 567 + + + + */ + + + 568 - 382 + 58 void lcd_buf_cls(void) - 771 + 569 { - 772 + 570
2/2
-
✓ Branch 0 taken 30560 times.
-
✓ Branch 1 taken 382 times.
+
✓ Branch 0 taken 1856 times.
+
✓ Branch 1 taken 58 times.
- 30942 - for(lcd_buf_position_ptr=&lcd_buffer[LINE_1][C1]; lcd_buf_position_ptr<=&lcd_buffer[LAST_LCD_LINE][LAST_CHAR_IN_LCD_LINE]; lcd_buf_position_ptr++) + 1914 + for (lcd_buf_position_ptr = &lcd_buffer[LINE_1][C1]; lcd_buf_position_ptr <= &lcd_buffer[LAST_LCD_LINE][LAST_CHAR_IN_LCD_LINE]; lcd_buf_position_ptr++) - 773 + 571 { - 774 + 572 - 30560 - *lcd_buf_position_ptr=' '; + 1856 + *lcd_buf_position_ptr = ' '; - 775 + 573 } - 776 + 574 + + + 58 + lcd_buf_position_ptr = &lcd_buffer[LINE_1][C1]; + + + 575 + + + 58 + LCD_BUFFER_UPDATE_FLAG = true; + + + 576 + + + 58 + } + + + 577 + + + + + + + 578 + + + + /** + + + 579 + + + + * @brief Function for adding the char to the LCD buffer under the current position of the LCD buffer. + + + 580 + + + + * @param C char (for example '1') or its ASCI code (0x31). + + + 581 + + + + * @note For user-defined char, place LCD_CGRAM_BANK_x_e (Position/address of the character in CGRAM of the LCD where + + + 582 + + + + * defined char was written). + + + 583 + + + + */ + + + 584 + + + 9 + void lcd_buf_char(const char c) + + + 585 + + + + { + + + 586 + + + 9 + *lcd_buf_position_ptr = c; + + + 587 + + + 9 + check_lcd_buf_possition_ptr_overflow(); + + + 588 + + + 9 + LCD_BUFFER_UPDATE_FLAG = true; + + + 589 - 382 - lcd_buf_position_ptr=&lcd_buffer[LINE_1][C1]; + 9 + } + + + 590 + + + + - 777 + 591 - 382 - LCD_UPDATE_EVENT=true; + + /** - 778 + 592 - 382 - } + + * @brief Function that changes the current LCD buffer position pointer to a specific position located under the x and y coordinate - 779 + 593 - + * @param y LCD row/line number. This parameter can only accept values defined in ::LCD_LINES_e. - 780 + 594 - 63 - void lcd_buf_char(const char c) + + * @param x LCD column number. This parameter can only accept values defined in ::LCD_COLUMNS_e. - 781 + 595 - { + */ - 782 + 596 - 63 - *lcd_buf_position_ptr=c; + 13 + void lcd_buf_locate(enum LCD_LINES_e y, enum LCD_COLUMNS_e x) - 783 + 597 - 63 - check_lcd_buf_possition_ptr_overflow(); + + { - 784 + 598 - 63 - LCD_UPDATE_EVENT=true; + 13 + lcd_buf_position_ptr = &lcd_buffer[y][x]; - 785 + 599 - 63 + 13 } - 786 + 600 - 787 - - - 87 - void lcd_buf_locate(enum LCD_LINES y, enum LCD_COLUMNS x) - - - 788 + 601 - { + /** - 789 + 602 - 87 - lcd_buf_position_ptr=&lcd_buffer[y][x]; + + * @brief Function for placing the string in the LCD buffer starts from the current LCD buffer position pointer. - 790 + 603 - 87 - } + + * @param str string that should be placed in the LCD buffer - 791 + 604 - + */ - 792 + 605 - 160 + 24 void lcd_buf_str(const char *str) - 793 + 606 { - 794 + 607
2/2
-
✓ Branch 0 taken 774 times.
-
✓ Branch 1 taken 160 times.
+
✓ Branch 0 taken 117 times.
+
✓ Branch 1 taken 24 times.
- 934 + 141 while (*str) - 795 + 608 { - 796 + 609 - 774 - *(lcd_buf_position_ptr)=*(str++); + 117 + *(lcd_buf_position_ptr) = *(str++); - 797 + 610 - 774 + 117 check_lcd_buf_possition_ptr_overflow(); - 798 + 611 } - 799 + 612 - 160 - LCD_UPDATE_EVENT=true; + 24 + LCD_BUFFER_UPDATE_FLAG = true; - 800 + 613 - 160 + 24 } - 801 + 614 - 802 + 615 - 94 - void lcd_update(void) + + /** - 803 + 616 - { + * @brief Function that prints on the LCD screen the content of The LCD buffer. - 804 + 617 - static uint8_t lcd_cursor_position=0; + * The function sets also The LCD buffer position pointer to the First line's first character. - 805 + 618 - static uint8_t lcd_line=0; + */ + + + 619 + + + 14 + void lcd_update(void) - 806 + 620 - static uint8_t missed_char_counter_in_LCD_line=0; + { + + + 621 + +
+ 1/2 +
+
✓ Branch 0 taken 14 times.
+
✗ Branch 1 not taken.
+
+
+ + 14 + if (LCD_BUFFER_UPDATE_FLAG == true) - 807 + 622 - // static const lcd_pos_t *prev_lcd_buff_pos_ptr=&prev_lcd_buffer[LINE_1][C1]; + { + + + 623 + + + 14 + uint8_t lcd_cursor_position = 0; + + + 624 + + + 14 + uint8_t lcd_line = 0; + + + 625 + + + 14 + uint8_t missed_char_counter_in_LCD_line = 0; + + + 626 + + + 14 + const lcd_pos_t *prev_lcd_buff_pos_ptr = &prev_lcd_buffer[LINE_1][C1]; - 808 + 627 - + - 809 + 628
2/2
-
✓ Branch 0 taken 7520 times.
-
✓ Branch 1 taken 94 times.
+
✓ Branch 0 taken 448 times.
+
✓ Branch 1 taken 14 times.
- 7614 - for(lcd_buf_position_ptr=&lcd_buffer[LINE_1][C1]; lcd_buf_position_ptr<=&lcd_buffer[LAST_LCD_LINE][LAST_CHAR_IN_LCD_LINE]; lcd_buf_position_ptr++) + 462 + for (lcd_buf_position_ptr = &lcd_buffer[LINE_1][C1]; lcd_buf_position_ptr <= &lcd_buffer[LAST_LCD_LINE][LAST_CHAR_IN_LCD_LINE]; lcd_buf_position_ptr++) - 810 + 629 - { + { + + + 630 + + + 448 + write_lcd_buf_2_lcd(&lcd_cursor_position, &lcd_line, &missed_char_counter_in_LCD_line, prev_lcd_buff_pos_ptr); - 811 + 631 - 7520 - write_lcd_buf_2_lcd(&lcd_cursor_position,&lcd_line,&missed_char_counter_in_LCD_line,&prev_lcd_buffer[LINE_1][C1]); + 448 + update_lcd_curosr_possition(&lcd_cursor_position, &lcd_line, &missed_char_counter_in_LCD_line); - 812 + 632 - 7520 - update_lcd_curosr_possition(&lcd_cursor_position,&lcd_line,&missed_char_counter_in_LCD_line); + 448 + prev_lcd_buff_pos_ptr++; - 813 + 633 - } + } - 814 + 634 - 94 - lcd_buf_position_ptr=&lcd_buffer[LINE_1][C1]; + + - 815 + 635 - 94 - copy_lcd_buf_2_prev_lcd_buf(); + 14 + lcd_buf_position_ptr = &lcd_buffer[LINE_1][C1]; + + + 636 + + + 14 + copy_lcd_buf_2_prev_lcd_buf(); + + + 637 + + + 14 + LCD_BUFFER_UPDATE_FLAG = false; - 816 + 638 - 94 - LCD_UPDATE_EVENT=false; + + } - 817 + 639 - 94 + 14 } - 818 + 640 - 819 + 641 #if USE_LCD_BUF_INT == ON - 820 + 642 /** - 821 + 643 - * @brief Function for adding intiger value as string to the LCD buffer under current position of the LCD buffer pointer. + * @brief Function for adding integer value as string to the LCD buffer under the current position of the LCD buffer pointer. - 822 + 644 * @param val int type value to add to LCD buffer - 823 + 645 * @param width Minimum number of characters to be added to LCD buffer. If the value to be added to the LCD buffer is shorter than width, the - 824 + 646 - * result is padded with blank spaces. The value to be added to buffer as string is not truncated if the string lenght is larger then width value. + * result is padded with blank spaces. The value to be added to the buffer as a string is not truncated if the string length is larger than the width value. - 825 + 647 - * @param alignment If the value to be added to LCD buffer as string is shorter than width, this parameter will specify alignment of the + * @param alignment This parameter can only accept values defined in ::LCD_alignment_e. If the value to be printed is shorter than the width, this parameter will specify the alignment of the - 826 + 648 - * tekst represented the value. This parameter can be set to "left" or "right" + * printed text value. - 827 + 649 - * @attention to compile for AVR ucontrollers definition of flag AVR is required. + * @attention to compile for AVR ucontrollers, definition of flag AVR is required. - 828 + 650 */ - 829 + 651 - 28 - void lcd_buf_int(int val, uint8_t width, enum alignment alignment) + 4 + void lcd_buf_int(int val, uint8_t width, enum LCD_alignment_e alignment) - 830 + 652 { - 831 + 653 #ifdef AVR - 832 + 654 lcd_buf_int_AVR(val, width, alignment); - 833 + 655 #else - 834 + 656 char buffer[20]; // 19chars for 64 bit int + end char '\0' - 835 + 657 - 28 + 4 buffer[0] = '\0'; - 836 + 658
2/2
-
✓ Branch 0 taken 21 times.
-
✓ Branch 1 taken 7 times.
+
✓ Branch 0 taken 3 times.
+
✓ Branch 1 taken 1 times.
- 28 + 4 if (alignment == right) - 837 + 659 - 21 + 3 sprintf(buffer, "%*i", width, val); - 838 + 660 else - 839 + 661 - 7 + 1 sprintf(buffer, "%-*i", width, val); - 840 + 662 - 28 + 4 lcd_buf_str(buffer); - 841 + 663 #endif - 842 + 664 - 28 + 4 } - 843 + 665 #endif - 844 + 666 - 845 + 667 #if USE_LCD_BUF_HEX == ON - 846 + 668 /** - 847 + 669 - * @brief Function for adding intiger value in hexadecimal format as string to the LCD buffer under current position of the LCD buffer pointer. + * @brief Function for adding integer value in hexadecimal format as a string to the LCD buffer under the current position of the LCD buffer pointer. - 848 + 670 - * @param val int type value to add to LCD buffer as string in hexadecimal format + * @param val int type value to add to LCD buffer as a string in hexadecimal format - 849 + 671 - * @param width Minimum number of characters to be added to lcd buffer. If the value to be added to buffer is shorter than width, the + * @param width Minimum number of characters to be added to lcd buffer. If the value to be added to the buffer is shorter than the width, the - 850 + 672 - * result is padded with blank spaces. The value to be added to buffer as string is not truncated if the string lenght is larger then width value. Width should contain + * result is padded with blank spaces. The value to be added to the buffer as a string is not truncated if the string length is larger than the width value. Width should contain - 851 + 673 - * additional 2 characters for "0x" at the begining of the value represented as string. example: 0x01-> width=4 + * additional 2 characters for "0x" at the beginning of the value represented as a string. example: 0x01-> width=4 - 852 + 674 - * @param alignment If the value to be added to LCD buffer as string is shorter than width, this parameter will specify alignment of the + * @param alignment This parameter can only accept values defined in ::LCD_alignment_e. If the value to be printed is shorter than the width, this parameter will specify the alignment of the - 853 + 675 - * tekst represented the value. This parameter can be set to "left" or "right" + * printed text value. - 854 + 676 - * @attention to compile for AVR ucontrollers definition of flag AVR is required. + * @attention to compile for AVR ucontrollers, definition of flag AVR is required. - 855 + 677 */ - 856 + 678 - 32 - void lcd_buf_hex(int val, uint8_t width, enum alignment alignment) + 5 + void lcd_buf_hex(int val, uint8_t width, enum LCD_alignment_e alignment) - 857 + 679 { - 858 + 680 #ifdef AVR - 859 + 681 lcd_buf_hex_AVR(val, width, alignment); - 860 + 682 #else - 861 + 683 char buffer[17]; - 862 + 684 - 32 + 5 buffer[0] = '\0'; - 863 + 685
2/2
-
✓ Branch 0 taken 21 times.
-
✓ Branch 1 taken 11 times.
+
✓ Branch 0 taken 3 times.
+
✓ Branch 1 taken 2 times.
- 32 + 5 if (alignment == right) - 864 + 686 - 21 + 3 sprintf(buffer, "%#*x", width, val); - 865 + 687 else - 866 + 688 - 11 + 2 sprintf(buffer, "%-#*x", width, val); - 867 + 689 - 32 + 5 lcd_buf_str(buffer); - 868 + 690 #endif - 869 + 691 - 32 + 5 } - 870 + 692 #endif - 871 + 693 - 872 + 694 #if USE_LCD_BUF_BIN == ON - 873 + 695 /** - 874 + 696 - * @brief Function for adding to the LCD buffer the integer value in binary format as string under current position of the LCD buffer pointer + * @brief Function for adding to the LCD buffer the integer value in binary format as a string under the current position of the LCD buffer pointer - 875 + 697 - * @param val int type value to be added to the LCD buffer as string in hexadecimal format + * @param val int type value to be added to the LCD buffer as a string in hexadecimal format - 876 + 698 - * @param width Minimum number of characters to be added to LCD buffer. If the value to be added to buffer as string lenght is shorter than width, the + * @param width Minimum number of characters to be added to LCD buffer. If the value to be added to the buffer as string length is shorter than width, the - 877 + 699 - * result is padded with blank spaces. The value to be added to buffer as string is not truncated if the string lenght represented the value i binary format lenght + * result is padded with blank spaces. The value to be added to the buffer as a string is not truncated if the string length represents the value in binary format length - 878 + 700 - * is larger then width value. Width should contain additional 2 characters for "0b" at the begining of the value represented as string. example: 0b01-> width=4 + * is larger than the width value. The width should contain an additional 2 characters for "0b" at the beginning of the value represented as a string. example: 0b01-> width=4 - 879 + 701 - * @attention to compile for AVR ucontrollers definition of flag AVR is required. + * @attention to compile for AVR ucontrollers, definition of flag AVR is required. - 880 + 702 */ - 881 + 703 - 13 + 2 void lcd_buf_bin(int val, uint8_t width) - 882 + 704 { - 883 + 705 #ifdef AVR - 884 + 706 lcd_buf_bin_AVR(val, width); - 885 + 707 #else - 886 + 708 char buffer[35]; - 887 + 709 char bin_val_buffer[35]; - 888 + 710 char zeros_buf[35]; - 889 + 711 - 13 + 2 buffer[0] = '\0'; - 890 + 712 - 13 + 2 bin_val_buffer[0] = '\0'; - 891 + 713 - 13 + 2 zeros_buf[0] = '\0'; - 892 + 714 - 893 + 715 - 13 + 2 fill_bin_value_buffer(val, bin_val_buffer); - 894 + 716 - 13 + 2 fill_zeros_buffer(bin_val_buffer, width, zeros_buf); - 895 + 717 - 13 + 2 strcat(buffer, "0b"); - 896 + 718 - 13 + 2 strcat(buffer, zeros_buf); - 897 + 719 - 13 + 2 strcat(buffer, bin_val_buffer); - 898 + 720 - 13 + 2 lcd_buf_str(buffer); - 899 + 721 #endif - 900 + 722 - 13 + 2 } - 901 + 723 - 902 + 724 #endif - 903 + 725 #endif - 904 - - - - - - - 905 + 726 diff --git a/reports/Cyclomatic_Complexity/Lizard_report.html b/reports/Cyclomatic_Complexity/Lizard_report.html index fd3b96d..5027ec5 100644 --- a/reports/Cyclomatic_Complexity/Lizard_report.html +++ b/reports/Cyclomatic_Complexity/Lizard_report.html @@ -99,7 +99,7 @@

Code Complexity Report

- 27 + 24 @@ -119,7 +119,7 @@

Code Complexity Report

- 27 + 24 @@ -135,7 +135,7 @@

Code Complexity Report

- 7 + 9 @@ -155,7 +155,7 @@

Code Complexity Report

- 5 + 6 @@ -175,7 +175,7 @@

Code Complexity Report

- 5 + 6 @@ -195,7 +195,7 @@

Code Complexity Report

- 15 + 19 @@ -235,7 +235,7 @@

Code Complexity Report

- 8 + 10 @@ -248,18 +248,58 @@

Code Complexity Report

- lcd_put_spaces + fill_bin_value_buffer + 4 + + + + 19 + + + + 71 + + + 2 + + + + fill_zeros_buffer + + + 3 + - 7 + 13 - 28 + 80 + + + + 3 + + + + + check_lcd_buf_possition_ptr_overflow + + + 2 + + + + 8 + + + + 35 @@ -268,38 +308,38 @@

Code Complexity Report

- lcd_int_AVR + copy_lcd_buf_2_prev_lcd_buf 3 - 26 + 10 - 104 + 54 - 3 + 1 - lcd_hex_AVR + update_lcd_curosr_possition 3 - 28 + 15 - 129 + 72 @@ -308,38 +348,38 @@

Code Complexity Report

- lcd_bin_AVR + write_lcd_buf_2_lcd 3 - 22 + 16 - 117 + 75 - 2 + 4 - lcd_buf_put_spaces + lcd_init 2 - 7 + 24 - 28 + 126 @@ -348,78 +388,78 @@

Code Complexity Report

- lcd_buf_int_AVR + lcd_enable_backlight - 3 + 2 - 26 + 5 - 104 + 18 - 3 + 1 - lcd_buf_hex_AVR + lcd_disable_backlight - 3 + 2 - 28 + 5 - 129 + 18 - 3 + 1 - lcd_buf_bin_AVR + lcd_cls - 3 + 2 - 22 + 5 - 117 + 18 - 2 + 1 - fill_bin_value_buffer + lcd_def_char - 4 + 2 - 19 + 9 - 71 + 57 @@ -428,10 +468,10 @@

Code Complexity Report

- fill_zeros_buffer + lcd_load_char_bank - 3 + 1 @@ -439,27 +479,27 @@

Code Complexity Report

- 70 + 82 - 3 + 1 - check_lcd_buf_possition_ptr_overflow + lcd_char - 2 + 1 - 7 + 5 - 33 + 23 @@ -468,18 +508,18 @@

Code Complexity Report

- copy_lcd_buf_2_prev_lcd_buf + lcd_str - 3 + 2 - 10 + 8 - 54 + 29 @@ -488,18 +528,18 @@

Code Complexity Report

- update_lcd_curosr_possition + lcd_int 3 - 14 + 11 - 69 + 70 @@ -508,98 +548,98 @@

Code Complexity Report

- write_lcd_buf_2_lcd + lcd_hex 3 - 16 + 11 - 71 + 70 - 4 + 3 - lcd_init + lcd_bin 2 - 23 + 16 - 122 + 98 - 1 + 2 - lcd_cls + lcd_locate - 2 + 8 - 5 + 21 - 18 + 72 - 1 + 2 - lcd_def_char + lcd_home 2 - 9 + 5 - 57 + 20 - 2 + 1 - lcd_load_char_bank + lcd_cursor_on 1 - 11 + 4 - 82 + 15 @@ -608,18 +648,18 @@

Code Complexity Report

- lcd_char + lcd_cursor_off 1 - 5 + 4 - 23 + 13 @@ -628,18 +668,18 @@

Code Complexity Report

- lcd_str + lcd_blinking_cursor_on - 2 + 1 - 8 + 4 - 37 + 17 @@ -648,58 +688,58 @@

Code Complexity Report

- lcd_int + lcd_buf_cls - 3 + 2 - 11 + 9 - 70 + 55 - 3 + 1 - lcd_hex + lcd_buf_char - 3 + 1 - 11 + 6 - 70 + 21 - 3 + 1 - lcd_bin + lcd_buf_locate - 2 + 1 - 16 + 4 - 98 + 23 @@ -708,38 +748,38 @@

Code Complexity Report

- lcd_locate + lcd_buf_str - 8 + 2 - 21 + 9 - 72 + 35 - 2 + 1 - lcd_home + lcd_update - 2 + 3 - 5 + 19 - 20 + 120 @@ -748,78 +788,97 @@

Code Complexity Report

- lcd_cursor_on + lcd_buf_int - 1 + 3 - 4 + 11 - 15 + 70 - 1 + 3 - lcd_cursor_off + lcd_buf_hex - 1 + 3 - 4 + 11 - 13 + 70 - 1 + 3 - lcd_blinking_cursor_on + lcd_buf_bin - 1 + 2 - 4 + 16 - 17 + 98 - 1 + 2 + + + Source file: ../../../src/lcd_hd44780.h + + + + + Source file: ../../../src/lcd_hd44780_avr_specific.c + +Function name +Cyclomatic complexity +(12) +LOC (30) + + Token count + +Parameter count (4) + + - lcd_buf_cls + lcd_put_spaces 2 - 9 + 7 - 55 + 28 @@ -828,18 +887,18 @@

Code Complexity Report

- lcd_buf_char + lcd_buf_put_spaces - 1 + 2 - 6 + 7 - 21 + 28 @@ -848,78 +907,78 @@

Code Complexity Report

- lcd_buf_locate + lcd_int_AVR - 1 + 3 - 4 + 26 - 23 + 104 - 2 + 3 - lcd_buf_str + lcd_hex_AVR - 2 + 3 - 9 + 28 - 35 + 129 - 1 + 3 - lcd_update + lcd_bin_AVR - 2 + 3 - 14 + 22 - 105 + 117 - 1 + 2 - lcd_buf_int + lcd_buf_int_AVR 3 - 11 + 26 - 70 + 104 @@ -928,18 +987,18 @@

Code Complexity Report

- lcd_buf_hex + lcd_buf_hex_AVR 3 - 11 + 28 - 70 + 129 @@ -948,18 +1007,18 @@

Code Complexity Report

- lcd_buf_bin + lcd_buf_bin_AVR - 2 + 3 - 16 + 22 - 98 + 117 @@ -969,7 +1028,7 @@

Code Complexity Report

- Source file: ../../../src/lcd_hd44780.h + Source file: ../../../src/lcd_hd44780_avr_specific.h @@ -984,7 +1043,12 @@

Code Complexity Report

- Source file: ../../../src/lcd_hd44780_interface.h + Source file: ../../../src/lcd_hd44780_driver_commands.h + + + + + Source file: ../../../src/lcd_hd44780_GPIO_interface.h @@ -994,7 +1058,7 @@

Code Complexity Report


diff --git a/src/lcd_hd44780_avr_specific.c b/src/lcd_hd44780_avr_specific.c index eb2409e..0e6b22f 100644 --- a/src/lcd_hd44780_avr_specific.c +++ b/src/lcd_hd44780_avr_specific.c @@ -77,7 +77,7 @@ void lcd_hex_AVR(int val, uint8_t width, enum LCD_alignment_e alignment) char buffer[17]; buffer[0] = '\0'; itoa(val, buffer, 16); - static char *prefix = {"0x"}; + static const char *prefix = {"0x"}; if (width <= (strlen(buffer) + VAL_PREFIX_LENGHT)) { lcd_str(prefix); @@ -106,7 +106,7 @@ void lcd_hex_AVR(int val, uint8_t width, enum LCD_alignment_e alignment) void lcd_bin_AVR(int val, uint8_t width) { char buffer[35]; // 0b 0000 0000 0000 0000 0000 0000 0000 0000 - static char *prefix = {"0b"}; + static char const *prefix = {"0b"}; buffer[0] = '\0'; itoa(val, buffer, 2); diff --git a/test/hw_test/ATMEGA328P_ARDUINO_UNO_R3/src/LCD_IO_driver.c b/test/hw_test/ATMEGA328P_ARDUINO_UNO_R3/src/LCD_IO_driver.c index 02e3ec4..518ec15 100644 --- a/test/hw_test/ATMEGA328P_ARDUINO_UNO_R3/src/LCD_IO_driver.c +++ b/test/hw_test/ATMEGA328P_ARDUINO_UNO_R3/src/LCD_IO_driver.c @@ -5,7 +5,7 @@ * @Last Modified time: 2023-12-08 10:49:44 */ -#include "lcd_hd44780_interface.h" +#include "lcd_hd44780_GPIO_interface.h" #include "lcd_hd44780_config.h" #include #include diff --git a/test/lcd_hd44780/custom_targets.cmake b/test/lcd_hd44780/custom_targets.cmake index b82f072..2c7cb0f 100644 --- a/test/lcd_hd44780/custom_targets.cmake +++ b/test/lcd_hd44780/custom_targets.cmake @@ -53,4 +53,4 @@ else() message(STATUS "python3 and gcovr were not found. \r\n\tInstall python 3 and gcovr to get predefined targets for uint tests code coverage report generation") endif() endif() -add_custom_target(ccr python3 -m gcovr CMakeFiles/lcd_hd44780_test.dir/D_/0_Projekty/6_Biblioteki/LCD_HD44780/src -r ../../.. --html-details ../../../reports/Code_Coverage/lcd_hd44780_gcov_report.html) \ No newline at end of file +add_custom_target(ccr python3 -m gcovr CMakeFiles/lcd_hd44780_test.dir/D_/EMBEDDED/LIBRARIES/C_libraries/LCD_HD44780/src -r ../../.. --html-details ../../../reports/Code_Coverage/lcd_hd44780_gcov_report.html) \ No newline at end of file