fontDriver.h 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. This is an example of how a driver could implement a font in HyperDisplay
  3. Created: August 2018
  4. Modified: August 2018
  5. Authors: Owen Lyke
  6. */
  7. #ifndef FONT_DRIVER_H
  8. #define FONT_DRIVER_H
  9. ////////////////////////////////////////////////////////////
  10. // Includes //
  11. ////////////////////////////////////////////////////////////
  12. #include "hyperdisplay.h" // Click here to get the library: http://librarymanager/All#SparkFun_HyperDisplay
  13. ////////////////////////////////////////////////////////////
  14. // Defines //
  15. ////////////////////////////////////////////////////////////
  16. ////////////////////////////////////////////////////////////
  17. // Typedefs //
  18. ////////////////////////////////////////////////////////////
  19. ////////////////////////////////////////////////////////////
  20. // Class Definition //
  21. ////////////////////////////////////////////////////////////
  22. class fontDriver : virtual public hyperdisplay{ // Using hyperdisplay as virtual will allow support for future I/O libraries that also inherit from hyperdisplay
  23. private:
  24. protected:
  25. public:
  26. // Constructor: at minimum pass in the size of the display
  27. /*
  28. xSize: number of pixels in the x direction of the display
  29. ySize: number of pixels in the y direction of the display
  30. */
  31. fontDriver(uint16_t xSize, uint16_t ySize /* Additional Parameters */);
  32. // getoffsetColor: allows hyperdisplay to use your custom color type
  33. /*
  34. base: the pointer to the first byte of the array that holds the color data
  35. numPixels: the number of pixels away from the beginning that the function should return the pointer to
  36. */
  37. color_t getOffsetColor(color_t base, uint32_t numPixels);
  38. // hwPixel: the method by which hyperdisplay actually changes your screen
  39. /*
  40. x0, y0: the x and y coordinates at which to place the pixel. 0,0 is the upper-left corner of the screen, x is horizontal and y is vertical
  41. data: the pointer to where the color data is stored
  42. colorCycleLength: this indicates how many pixels worth of valid color data exist contiguously after the memory location pointed to by color.
  43. startColorOffset: this indicates how many pixels to offset by from the color pointer to arrive at the actual color to display
  44. */
  45. void hwpixel(hd_hw_extent_t x0, hd_hw_extent_t y0, color_t data = NULL, hd_colors_t colorCycleLength = 1, hd_colors_t startColorOffset = 0);
  46. // Additional hardware drawing functions
  47. /*
  48. There are additional hardware drawing functions beyond hwpixel. They are already implemented by default using
  49. hwpixel so they are not required in order to start drawing. However implementing them with more efficient
  50. methods for your particular hardware can reduce overhead and speed up the drawing process.
  51. In these functions the coordiantes x0, x1, y0, and y1 are always with respect to the hardware screen. (0,0) is the upper-left pixel
  52. The variables pertaining to color sequences (data, colorCycleLength, and startColorOffset) always have the same meaning as in hwpixel
  53. Additional variables will be described in the function prototype in bareMinimumDerivedClass.cpp
  54. */
  55. // void hwxline(uint16_t x0, uint16_t y0, uint16_t len, color_t data, uint16_t colorCycleLength = 1, uint16_t startColorOffset = 0, bool goLeft = false);
  56. // void hwyline(uint16_t x0, uint16_t y0, uint16_t len, color_t data, uint16_t colorCycleLength = 1, uint16_t startColorOffset = 0, bool goUp = false);
  57. // void hwrectangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, color_t data, bool filled = false, uint16_t colorCycleLength = 1, uint16_t startColorOffset = 0, bool gradientVertical = false, bool reverseGradient = false);
  58. // void hwfillFromArray(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t numPixels, color_t data);
  59. // Additional optional implementations by the user:
  60. // ================================================
  61. // getCharInfo: you can create custom fonts without changing how printing functions work
  62. /*
  63. character: the byte-sized character to show on screen
  64. pchar: a pointer to a valid char_info_t object that needs to be filled out peroperly for the given character
  65. */
  66. void getCharInfo(uint8_t character, char_info_t * pchar);
  67. // write: you decide what happens when someone calls fontDriver.print or fontDriver.println
  68. /*
  69. val: the byte-sized character value to display
  70. */
  71. // size_t write(uint8_t val);
  72. };
  73. #endif /* FONT_DRIVER_H */