UniGraphic-Fork for ST7920-LCD-controller and SH1106. Tested with 128x64 LCD with SPI and 128x64-OLED with IIC
Dependents: UniGraphic-St7920-Test AfficheurUTILECO
Fork of UniGraphic by
PAR8.h
00001 #ifndef PAR8_H 00002 #define PAR8_H 00003 00004 #include "mbed.h" 00005 #include "Protocols.h " 00006 00007 #if DEVICE_PORTINOUT 00008 //#include "GraphicsDisplay.h" 00009 00010 /** Parallel 8bit interface 00011 */ 00012 class PAR8 : public Protocols 00013 { 00014 public: 00015 00016 /** Create a PAR8 display interface with a GPIO port and 5 control pins 00017 * 00018 * @param port GPIO port to use 00019 * @param CS pin connected to CS of display 00020 * @param reset pin connected to RESET of display 00021 * @param DC pin connected to data/command of display 00022 * @param WR pin connected to SDI of display 00023 * @param RD pin connected to RS of display 00024 */ 00025 PAR8(PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD); 00026 00027 protected: 00028 00029 /** Send 8bit command to display controller 00030 * 00031 * @param cmd: byte to send 00032 * 00033 */ 00034 virtual void wr_cmd8(unsigned char cmd); 00035 00036 /** Send 8bit data to display controller 00037 * 00038 * @param data: byte to send 00039 * 00040 */ 00041 virtual void wr_data8(unsigned char data); 00042 00043 /** Send 2x8bit command to display controller 00044 * 00045 * @param cmd: halfword to send 00046 * 00047 */ 00048 virtual void wr_cmd16(unsigned short cmd); 00049 00050 /** Send 2x8bit data to display controller 00051 * 00052 * @param data: halfword to send 00053 * 00054 */ 00055 virtual void wr_data16(unsigned short data); 00056 00057 /** Send 16bit pixeldata to display controller 00058 * 00059 * @param data: halfword to send 00060 * 00061 */ 00062 virtual void wr_gram(unsigned short data); 00063 00064 /** Send same 16bit pixeldata to display controller multiple times 00065 * 00066 * @param data: halfword to send 00067 * @param count: how many 00068 * 00069 */ 00070 virtual void wr_gram(unsigned short data, unsigned int count); 00071 00072 /** Send array of pixeldata shorts to display controller 00073 * 00074 * @param data: unsigned short pixeldata array 00075 * @param lenght: lenght (in shorts) 00076 * 00077 */ 00078 virtual void wr_grambuf(unsigned short* data, unsigned int lenght); 00079 00080 /** Read 16bit pixeldata from display controller (with dummy cycle) 00081 * 00082 * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit 00083 * @returns 16bit color 00084 */ 00085 virtual unsigned short rd_gram(bool convert); 00086 00087 /** Read 4x8bit register data (with dummy cycle) 00088 * @param reg the register to read 00089 * @returns data as uint 00090 * 00091 */ 00092 virtual unsigned int rd_reg_data32(unsigned char reg); 00093 00094 /** Read 3x8bit ExtendedCommands register data 00095 * @param reg the register to read 00096 * @returns data as uint 00097 * @note EXTC regs (0xB0 to 0xFF) are read/write registers, for Parallel mode directly accessible in both directions 00098 */ 00099 virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd); 00100 00101 /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent 00102 * for PAR protocols: a signle RD bit toggle 00103 * for SPI8: 8clocks 00104 * for SPI16: 16 clocks 00105 */ 00106 virtual void dummyread (); 00107 00108 /** ILI932x specific, select register for a successive write or read 00109 * 00110 * @param reg register to be selected 00111 * @param forread false = a write next (default), true = a read next 00112 * @note forread only used by SPI protocols 00113 */ 00114 virtual void reg_select(unsigned char reg, bool forread =false); 00115 00116 /** ILI932x specific, write register with data 00117 * 00118 * @param reg register to write 00119 * @param data 16bit data 00120 */ 00121 virtual void reg_write(unsigned char reg, unsigned short data); 00122 00123 /** ILI932x specific, read register 00124 * 00125 * @param reg register to be read 00126 * @returns 16bit register value 00127 */ 00128 virtual unsigned short reg_read(unsigned char reg); 00129 00130 /** HW reset sequence (without display init commands) 00131 */ 00132 virtual void hw_reset(); 00133 00134 /** Set ChipSelect high or low 00135 * @param enable 0/1 00136 */ 00137 virtual void BusEnable(bool enable); 00138 00139 00140 00141 private: 00142 00143 PortInOut _port; 00144 DigitalOut _CS; 00145 DigitalOut _reset; 00146 DigitalOut _DC; 00147 DigitalOut _WR; 00148 DigitalOut _RD; 00149 00150 }; 00151 #endif 00152 00153 #endif
Generated on Tue Jul 12 2022 18:00:35 by 1.7.2