gds.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _GDS_H_
  2. #define _GDS_H_
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. /* NOTE for drivers:
  6. The build-in DrawPixel(Fast), DrawCBR and ClearWindow have optimized for 1 bit
  7. and 4 bits grayscale screen depth and 8, 16, 24 color. For any other type of screen,
  8. DrawCBR and ClearWindow default to use DrawPixel, which is very sub-optimal. For
  9. other depth, you must supply the DrawPixelFast. The built-in 1 bit depth function
  10. are only for screen with vertical framing (1 byte = 8 lines). For example SSD1326 in
  11. monochrome mode is not such type of screen, SH1106 and SSD1306 are
  12. */
  13. // this is an ordered enum, do not change!
  14. enum { GDS_MONO = 0, GDS_GRAYSCALE, GDS_RGB332, GDS_RGB444, GDS_RGB555, GDS_RGB565, GDS_RGB666, GDS_RGB888 };
  15. #define GDS_COLOR_BLACK (0)
  16. #define GDS_COLOR_WHITE (-1)
  17. #define GDS_COLOR_XOR (256)
  18. struct GDS_Device;
  19. struct GDS_FontDef;
  20. struct GDS_BacklightPWM {
  21. int Channel, Timer, Max;
  22. bool Init;
  23. };
  24. struct GDS_Layout {
  25. bool HFlip, VFlip;
  26. bool Rotate;
  27. bool Invert;
  28. bool ColorSwap;
  29. };
  30. typedef struct GDS_Device* GDS_DetectFunc(char *Driver, struct GDS_Device *Device);
  31. struct GDS_Device* GDS_AutoDetect( char *Driver, GDS_DetectFunc* DetectFunc[], struct GDS_BacklightPWM *PWM );
  32. void GDS_SetContrast( struct GDS_Device* Device, uint8_t Contrast );
  33. void GDS_DisplayOn( struct GDS_Device* Device );
  34. void GDS_DisplayOff( struct GDS_Device* Device );
  35. void GDS_Update( struct GDS_Device* Device );
  36. void GDS_SetLayout( struct GDS_Device* Device, struct GDS_Layout* Layout);
  37. void GDS_SetDirty( struct GDS_Device* Device );
  38. int GDS_GetWidth( struct GDS_Device* Device );
  39. void GDS_SetTextWidth( struct GDS_Device* Device, int TextWidth );
  40. int GDS_GetHeight( struct GDS_Device* Device );
  41. int GDS_GetDepth( struct GDS_Device* Device );
  42. int GDS_GetMode( struct GDS_Device* Device );
  43. int GDS_GrayMap( struct GDS_Device* Device, uint8_t Level );
  44. void GDS_ClearExt( struct GDS_Device* Device, bool full, ...);
  45. void GDS_Clear( struct GDS_Device* Device, int Color );
  46. void GDS_ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color );
  47. #define GDS_CHECK_FOR_DEVICE(dev,ret_act) if(!dev) ret_act
  48. #endif