You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.8 KiB

  1. #ifndef uint8
  2. #define uint8 unsigned char
  3. #endif
  4. typedef struct
  5. {
  6. int cs, a0, rs;
  7. uint8 width, height;
  8. } lcd_t;
  9. /*
  10. * Initialize the display and create a data structure for it.
  11. * The last initialized display is active.
  12. *
  13. * Parameters:
  14. * spiSpeed - Speed of the SPI interface.
  15. * cs - Chip selection pin.
  16. * a0 - Data/Command pin.
  17. * rs - Optional reset pin. If you do not use it, enter -1.
  18. *
  19. * Return: Pointer to the structure with display data.
  20. *
  21. */
  22. lcd_t *lcd_init(int spiSpeed, int cs, int a0, int rs);
  23. /*
  24. * Reset the specified display and clear the previously assigned memory.
  25. *
  26. * Parameters:
  27. * display - Pointer to the structure with display data.
  28. *
  29. * Return: void
  30. */
  31. void lcd_deinit(lcd_t *display);
  32. /*
  33. * Set the drawing area on the currently active display.
  34. *
  35. * Parameters:
  36. * x1 - The X parameter of the first point.
  37. * y1 - The Y parameter of the first point.
  38. * x2 - The X parameter of the second point.
  39. * y2 - The Y parameter of the second point.
  40. *
  41. * Return: Confirmation of the occurrence or non-occurrence of an error.
  42. * 0 - The error did not occur; 1 - The error occurred.
  43. *
  44. */
  45. uint8 lcd_setWindow(uint8 x1, uint8 y1, uint8 x2, uint8 y2);
  46. /*
  47. * Draw one pixel on the currently active display.
  48. * The color intensity scale for a normal pixel is from 0 to 255.
  49. * The color intensity scale for the reduced pixel is from 0 to 15.
  50. *
  51. * Parameters:
  52. * x - The X parameter of the pixel.
  53. * y - The Y parameter of the pixel.
  54. * r - The intensity of the red color.
  55. * g - The intensity of the green color.
  56. * b - The intensity of the blue color.
  57. *
  58. * Return: void
  59. */
  60. void lcd_drawPx(uint8 x, uint8 y, uint8 r, uint8 g, uint8 b);
  61. /*
  62. * Draw a filled rectangle on the currently active display.
  63. * The color intensity scale for a normal pixel is from 0 to 255.
  64. * The color intensity scale for the reduced pixel is from 0 to 15.
  65. *
  66. * Parameters:
  67. * x - Parameter X of the upper left corner of the rectangle.
  68. * y - Parameter Y of the upper left corner of the rectangle.
  69. * w - The width of the rectangle.
  70. * h - The height of the rectangle.
  71. * r - The intensity of the red color.
  72. * g - The intensity of the green color.
  73. * b - The intensity of the blue color.
  74. *
  75. * Return: void
  76. */
  77. void lcd_fillRect(uint8 x, uint8 y, uint8 w, uint8 h, uint8 r, uint8 g, uint8 b);
  78. /*
  79. * Fill the entire screen with one color of the currently active display.
  80. * The color intensity scale for a normal pixel is from 0 to 255.
  81. * The color intensity scale for the reduced pixel is from 0 to 15.
  82. *
  83. * Parameters:
  84. * r - The intensity of the red color.
  85. * g - The intensity of the green color.
  86. * b - The intensity of the blue color.
  87. *
  88. * Return: void
  89. */
  90. void lcd_fillScreen(uint8 r, uint8 g, uint8 b);
  91. void lcd_printChar(uint8 x, uint8 y, char c);
  92. void lcd_printText(uint8 x, uint8 y, char* text);