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.

120 lines
3.2 KiB

  1. /*
  2. CONNECTION from ESP32 to a composite video TV
  3. A) voltageDivider = false; B) voltageDivider = true
  4. 55 shades 179 shades
  5. ESP32 TV ESP32 TV
  6. -----+ -----+ ____ 100 ohm
  7. G|- G|---|____|+
  8. pin25|--------- Comp pin25|---|____|+--------- Comp
  9. pin26|- pin26|- 220 ohm
  10. | |
  11. | |
  12. -----+ -----+
  13. Connect pin 25 or 26
  14. C) R–2R resistor ladder; D) unequal rungs ladder
  15. 55 shades up to 254 shades?
  16. ESP32 TV ESP32 TV
  17. -----+ -----+ ____
  18. G|-+_____ G|---|____|
  19. pinA0|-| R2R |- Comp pinA0|---|____|+--------- Comp
  20. pinA1|-| | pinA1|---|____|
  21. pinA2|-| | ...|
  22. ...|-|_____| |
  23. -----+ -----+
  24. Connect pins of your choice (A0...A8=any pins).
  25. Custom ladders can be used by tweaking colorMinValue and colorMaxValue
  26. */
  27. #include <ESP32Lib.h>
  28. #include <Ressources/Font6x8.h>
  29. #include <Ressources/CodePage437_8x8.h>
  30. //#include <Ressources/CodePage437_8x14.h>
  31. //#include <Ressources/CodePage437_8x16.h>
  32. //#include <Ressources/CodePage437_8x19.h>
  33. //#include <Ressources/CodePage437_9x16.h>
  34. #define FONT CodePage437_8x8
  35. //pin configuration for DAC
  36. const int outputPin = 25;
  37. // A) B)
  38. CompositeGrayDAC videodisplay;
  39. // C) D)
  40. //CompositeGrayLadder videodisplay;
  41. class Display {
  42. public:
  43. // view(able) size
  44. int vw = 350;
  45. int vh = 235;
  46. // offsets (to fix overscan, depends on your display)
  47. int ow = 10;
  48. int oh = 26;
  49. // display size
  50. int w = 365; // vw + 2*ow
  51. int h = 275; // vh + 2*oh
  52. int font_w = FONT.charWidth;
  53. int font_h = FONT.charHeight + 1;
  54. int cols = vw / font_w;
  55. int rows = vh / font_h;
  56. void setup()
  57. {
  58. // Composite video init, see options in the header ^^^
  59. // A)
  60. //videodisplay.init(CompMode::MODEPAL288P, 25, false);
  61. // B)
  62. videodisplay.init(CompMode::MODEPAL288P, 25, true);
  63. videodisplay.clear();
  64. videodisplay.xres = w;
  65. videodisplay.yres = h;
  66. videodisplay.setFont(FONT);
  67. /*/ view area test
  68. videodisplay.rect(ow, oh, vw, vh, 50);
  69. /**/
  70. }
  71. void scroll(int d) {
  72. videodisplay.scroll(d, 0);
  73. }
  74. void fill_rect(int x, int y, int w, int h, int color) {
  75. videodisplay.fillRect(x, y, w, h, color);
  76. }
  77. void pixel(int x, int y, int color) {
  78. videodisplay.dotFast(x, y, color);
  79. }
  80. void print_character(int col, int row, int fg_color, int bg_color, char character) {
  81. int x = ow + col*font_w;
  82. int y = oh + row*font_h;
  83. videodisplay.setCursor(x, y);
  84. videodisplay.setTextColor(fg_color, bg_color);
  85. videodisplay.print(character);
  86. }
  87. int get_display_width() { return w; }
  88. int get_display_height() { return h; }
  89. int get_view_width() { return vw; }
  90. int get_view_height() { return vh; }
  91. int get_view_width_offset() { return ow; }
  92. int get_view_height_offset() { return oh; }
  93. };