Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GDEW075T8.cpp
- Committer:
- HarryChen
- Date:
- 2018-10-15
- Revision:
- 1:6ae4383194a1
- Parent:
- 0:518ad5d26088
- Child:
- 2:73f957691c31
File content as of revision 1:6ae4383194a1:
#include "mbed.h" #include "GDEW075T8.h" #include "PixelSource.h" #define nCS_L HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET) #define nCS_H HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET) #define nDC_L HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_RESET) #define nDC_H HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_SET) #define nRST_L HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_RESET) #define nRST_H HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_SET) // TODO: use real value static DigitalOut nCS(D1); static DigitalOut nDC(D2); static DigitalOut nRST(D3); static DigitalIn busyPin(D8); static SPI spi(D4, D5, D6, D7); static void sendCommand(unsigned char command) { nCS = 0; nDC = 0; // command write spi.write(command); nCS = 1; } static void sendData(unsigned char data) { nCS = 0; nDC = 1; // data write spi.write(data); nCS = 1; } static void waitForReady(void) { unsigned char busy; do { sendCommand(0x71); busy = busyPin; busy = !(busy & 0x01); } while (busy); wait(0.2); } static void init(void) { // BS tied to GND // nBS_L; //4 wire spi mode selected // module reset nRST = 0; wait(0.1); nRST = 1;; wait(0.1); } #define PIXEL_WHITE 0x02 #define PIXEL_BLACK 0x00 #define PIXEL(p) ((p) ? (PIXEL_BLACK) : (PIXEL_WHITE)) static void display(GDE::PixelSource &source) { // start user data transmission sendCommand(0x10); source.init(); while (source.hasNext()) { unsigned char p = source.nextPixelGroup(); // transmit 2 pixels each time for (int j = 0; j < 4; ++j) { unsigned char data = ((PIXEL(p & 0x01)) << 4) | (PIXEL(p & 0x02)); sendData(data); p >>= 2; } } // power on sendCommand(0x04); waitForReady(); // display refresh GDE::refresh(); wait(1); } namespace GDE { void start() { init(); // power setting sendCommand(0x01); sendData(0x37); sendData(0x00); // pannel setting sendCommand(0x00); sendData(0xCF); sendData(0x08); // boost setting sendCommand(0x06); sendData(0xc7); sendData(0xcc); sendData(0x28); // PLL setting sendCommand(0x30); sendData(0x3c); // temperature setting sendCommand(0x41); sendData(0x00); // VCOM and DATA interval setting sendCommand(0x50); sendData(0x77); // TCON setting sendCommand(0x60); sendData(0x22); // resolution setting sendCommand(0x61); // source 640 sendData(0x02); sendData(0x80); // gate 384 sendData(0x01); sendData(0x80); // VDCS setting sendCommand(0x82); // decided by LUT file sendData(0x1E); // flash mode sendCommand(0xe5); sendData(0x03); } void refresh() { sendCommand(0x12); wait(0.1); waitForReady(); } void showPixels(PixelSource &source, bool needRefresh) { if (needRefresh) { PixelSource fullBlackSource = PixelSource(); display(fullBlackSource); } display(source); } void stop() { sendCommand(0x02); waitForReady(); sendCommand(0x07); sendData(0xa5); } }