t4_dsp.h
1 /* 2 TFT/VGA driver 3 DMA TFT driver based on C64 ILI9341 dma driver from Frank Bösing, 2017 4 */ 5 6 #ifndef _T4_DSPH_ 7 #define _T4_DSPH_ 8 9 #ifdef __cplusplus 10 #include <Arduino.h> 11 #include <DMAChannel.h> 12 #endif 13 14 #include "platform_config.h" 15 #include "iopins.h" 16 17 18 19 #ifndef TFT_WIDTH 20 #define TFT_WIDTH 320 21 #endif 22 #define TFT_REALWIDTH 320 23 24 #ifndef TFT_HEIGHT 25 #define TFT_HEIGHT 240 26 #endif 27 #define TFT_REALHEIGHT 240 28 29 30 typedef enum gfx_mode_t 31 { 32 MODE_UNDEFINED = 0, 33 MODE_TFTILI_320x240 = 1, 34 MODE_TFTST_320x240 = 2, 35 MODE_VGA_320x240 = 3, 36 MODE_VGA_320x480 = 4, 37 MODE_VGA_352x240 = 5, 38 MODE_VGA_352x480 = 6, 39 MODE_VGA_512x240 = 7, 40 MODE_VGA_512x480 = 8, 41 MODE_VGA_640x240 = 9, 42 MODE_VGA_640x480 = 10 43 } gfx_mode_t; 44 45 typedef enum gfx_error_t 46 { 47 GFX_OK = 0, 48 GFX_ERROR = -1 49 } gfx_error_t; 50 51 52 #ifdef __cplusplus 53 54 class T4_DSP 55 { 56 public: 57 T4_DSP(); 58 59 gfx_error_t begin(gfx_mode_t mode); 60 gfx_mode_t getMode(void); 61 void startRefresh(void); 62 void stopRefresh(); 63 64 int get_frame_buffer_size(int *width, int *height); 65 void setArea(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2); 66 67 // wait next Vsync 68 void waitSync(); 69 void waitLine(int line); 70 71 // NoDMA functions 72 void fillScreenNoDma(uint16_t color); 73 void drawTextNoDma(int16_t x, int16_t y, const char * text, uint16_t fgcolor, uint16_t bgcolor, bool doublesize); 74 void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 75 void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap); 76 void drawSpriteNoDma(int16_t x, int16_t y, const uint16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh); 77 78 // DMA functions 79 void fillScreen(uint16_t color); 80 void drawText(int16_t x, int16_t y, const char * text, uint16_t fgcolor, uint16_t bgcolor, bool doublesize); 81 void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 82 void drawSprite(int16_t x, int16_t y, const uint16_t *bitmap); 83 void drawSprite(int16_t x, int16_t y, const uint16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh); 84 85 void writeLine(int width, int height, int y, uint16_t *buf); 86 void writeLinePal(int width, int height, int y, uint8_t *buf, uint16_t *palette16); 87 void writeScreenPal(int width, int height, int stride, uint8_t *buf, uint16_t *palette16); 88 void writeLine8(int width, int height, int y, uint8_t *buf, uint16_t *palette16); 89 90 protected: 91 static uint8_t _rst, _cs, _dc; 92 static uint8_t _mosi, _sclk; 93 static uint8_t _vsync_pin; 94 static DMAChannel flexio1DMA; 95 static DMAChannel flexio2DMA; 96 void tft_setup(bool isST); 97 static void TFT_isr(void); 98 static void QT3_isr(void); 99 }; 100 101 #endif 102 #endif