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.

92 lines
2.0 KiB

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