HD44780-I2C.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*-------------------------------------------------------------------------------------------------
  2. * Wyświetlacz alfanumeryczny ze sterownikiem HD44780
  3. * Sterowanie w trybie 8-bitowym z odczytem flagi zajętości
  4. * Plik : HD44780-I2C.h
  5. * Mikrokontroler : Atmel AVR
  6. * Kompilator : avr-gcc
  7. * Autor : Radosław Kwiecień
  8. * Źródło : http://radzio.dxp.pl/hd44780/
  9. * Data : 24.03.2007
  10. * Modified: k4be, 2022 (I2C access mode)
  11. * ------------------------------------------------------------------------------------------------ */
  12. #pragma once
  13. #include <avr/io.h>
  14. #include <util/delay.h>
  15. #include "expander.h"
  16. //-------------------------------------------------------------------------------------------------
  17. //
  18. // Konfiguracja sygnałów sterujących wyświetlaczem.
  19. // Można zmieniæ stosownie do potrzeb.
  20. //
  21. //-------------------------------------------------------------------------------------------------
  22. #define LCD_RS_PORT 1
  23. #define LCD_RS (1 << 3)
  24. #define LCD_RW_PORT 1
  25. #define LCD_RW (1 << 2)
  26. #define LCD_E_PORT 1
  27. #define LCD_E (1 << 1)
  28. #define LCD_DATA_OUTPUT() expander_set_dir(0, 0x00, 0x00)
  29. #define LCD_DATA_INPUT() expander_set_dir(0, 0xFF, 0x00)
  30. //-------------------------------------------------------------------------------------------------
  31. //
  32. // Instrukcje kontrolera Hitachi HD44780
  33. //
  34. //-------------------------------------------------------------------------------------------------
  35. #define HD44780_CLEAR 0x01
  36. #define HD44780_HOME 0x02
  37. #define HD44780_ENTRY_MODE 0x04
  38. #define HD44780_EM_SHIFT_CURSOR 0
  39. #define HD44780_EM_SHIFT_DISPLAY 1
  40. #define HD44780_EM_DECREMENT 0
  41. #define HD44780_EM_INCREMENT 2
  42. #define HD44780_DISPLAY_ONOFF 0x08
  43. #define HD44780_DISPLAY_OFF 0
  44. #define HD44780_DISPLAY_ON 4
  45. #define HD44780_CURSOR_OFF 0
  46. #define HD44780_CURSOR_ON 2
  47. #define HD44780_CURSOR_NOBLINK 0
  48. #define HD44780_CURSOR_BLINK 1
  49. #define HD44780_DISPLAY_CURSOR_SHIFT 0x10
  50. #define HD44780_SHIFT_CURSOR 0
  51. #define HD44780_SHIFT_DISPLAY 8
  52. #define HD44780_SHIFT_LEFT 0
  53. #define HD44780_SHIFT_RIGHT 4
  54. #define HD44780_FUNCTION_SET 0x20
  55. #define HD44780_FONT5x7 0
  56. #define HD44780_FONT5x10 4
  57. #define HD44780_ONE_LINE 0
  58. #define HD44780_TWO_LINE 8
  59. #define HD44780_4_BIT 0
  60. #define HD44780_8_BIT 16
  61. #define HD44780_CGRAM_SET 0x40
  62. #define HD44780_DDRAM_SET 0x80
  63. //-------------------------------------------------------------------------------------------------
  64. //
  65. // Deklaracje funkcji
  66. //
  67. //-------------------------------------------------------------------------------------------------
  68. void LCD_WriteCommand(unsigned char);
  69. unsigned char LCD_ReadStatus(void);
  70. void LCD_WriteData(unsigned char);
  71. unsigned char LCD_ReadData(void);
  72. void LCD_WriteText(const char *);
  73. void LCD_GoTo(unsigned char, unsigned char);
  74. void LCD_Clear(void);
  75. void LCD_Home(void);
  76. void LCD_Initialize(void);
  77. void LCD_WriteTextP(const char *);
  78. //-------------------------------------------------------------------------------------------------
  79. //
  80. // Koniec pliku HD44780.h
  81. //
  82. //-------------------------------------------------------------------------------------------------