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.

96 lines
2.1 KiB

  1. #ifndef uint8
  2. #define uint8 unsigned char
  3. #endif
  4. #ifndef uint16
  5. #define uint16 unsigned short
  6. #endif
  7. #ifndef __SPILCD_H__
  8. #define __SPILCD_H__
  9. typedef struct
  10. {
  11. int channel;
  12. int cs, a0, rs;
  13. uint16 width, height;
  14. } lcd_t;
  15. /*
  16. * Initialize the display.
  17. *
  18. * Parameters:
  19. * spiSpeed - Speed of the SPI interface.
  20. * channel - SPI channel
  21. * cs - Chip selection pin.
  22. * a0 - Data/Command pin.
  23. * rs - Optional reset pin. Use -1 when not connected.
  24. *
  25. * Return: Pointer to the structure with display data.
  26. *
  27. */
  28. lcd_t *lcd_init(int spiSpeed, int channel, int cs, int a0, int rs);
  29. /*
  30. * Reset the specified display and clear the previously assigned memory.
  31. *
  32. * Parameters:
  33. * lcd - display to use
  34. *
  35. * Return: void
  36. */
  37. void lcd_deinit(lcd_t *lcd);
  38. /*
  39. * Set the drawing area.
  40. *
  41. * Parameters:
  42. * lcd - display to use
  43. * x1 - The X parameter of the starting point.
  44. * y1 - The Y parameter of the starting point.
  45. * x2 - The X parameter of the ending point.
  46. * y2 - The Y parameter of the ending point.
  47. *
  48. * Return: 0 for success, 1 for error.
  49. *
  50. */
  51. uint16 lcd_setWindow(lcd_t* lcd, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
  52. /*
  53. * Push a pixel into the previously set drawing area.
  54. *
  55. * Parameters:
  56. * lcd - display to use
  57. * r - red color (0 to 255)
  58. * g - green color (0 to 255)
  59. * b - blue color (0 to 255)
  60. */
  61. void lcd_pushPixel(lcd_t* lcd, uint8 r, uint8 g, uint8 b);
  62. /*
  63. * Push a 'transparent' pixel into the previously set drawing area.
  64. * Requires buffering to be enabled.
  65. *
  66. * Parameters:
  67. * lcd - display to use
  68. */
  69. void lcd_pushPixelSkip(lcd_t* lcd);
  70. /*
  71. * Push an array of pixels into the previously set drawing area.
  72. * Significantly faster than pushing pixels individually.
  73. *
  74. * Parameters:
  75. * lcd - display to use
  76. * pixels - array of pixels where:
  77. * pixels[i * 3 + 0] = i-th red color (0 to 255)
  78. * pixels[i * 3 + 1] = i-th green color (0 to 255)
  79. * pixels[i * 3 + 2] = i-th blue color (0 to 255)
  80. * count - number of pixels in the array
  81. */
  82. void lcd_pushPixels(lcd_t* lcd, uint8* pixels, size_t count);
  83. void lcd_redrawBuffer(lcd_t* lcd);
  84. #endif // __SPILCD_H__