Add second variant of 128x128 CGRAM offset

This commit is contained in:
vanklompf 2018-01-14 23:39:34 +01:00
parent 523fec4e3f
commit 92b6021f03
3 changed files with 33 additions and 19 deletions

View File

@ -7,10 +7,6 @@
#define TFT_HEIGHT 160
#endif
#if (TFT_HEIGHT == 128) && (TFT_WIDTH == 128)
#define CGRAM_OFFSET
#endif
// Color definitions for backwards compatibility with old sketches
// use colour definitions like TFT_BLACK to make sketches more portable
#define ILI9163_BLACK 0x0000 /* 0, 0, 0 */

View File

@ -9,36 +9,48 @@
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
_width = _width_orig;
_height = _height_orig;
#ifdef CGRAM_OFFSET
#if CGRAM_OFFSET == OFFSET_FROM_START
colstart = 0;
rowstart = 32;
#else
colstart = 0;
rowstart = 0;
#endif
#endif
break;
case 1:
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
_width = _height_orig;
_height = _width_orig;
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
#if CGRAM_OFFSET == OFFSET_FROM_START
colstart = 32;
rowstart = 0;
#else
colstart = 0;
rowstart = 0;
#endif
break;
case 2:
writedata(TFT_MAD_BGR);
_width = _width_orig;
_height = _height_orig;
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 32;
#endif
#if CGRAM_OFFSET == OFFSET_FROM_START
colstart = 0;
rowstart = 0;
#else
colstart = 0;
rowstart = 32;
#endif
break;
case 3:
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
_width = _height_orig;
_height = _width_orig;
#ifdef CGRAM_OFFSET
colstart = 32;
rowstart = 0;
#endif
#if CGRAM_OFFSET == OFFSET_FROM_START
colstart = 0;
rowstart = 0;
#else
colstart = 32;
rowstart = 0;
#endif
break;
}

View File

@ -20,9 +20,15 @@
// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
#define TFT_WIDTH 128
//#define TFT_HEIGHT 160
#define TFT_HEIGHT 128
// There are two variants of 128x128 IL9163. One has CGRAM offset due to unused 32 lines on the beginning of the memory, and one on the end
// If You see that your screen is shifted by 32 pixel change to other setting
#ifndef CGRAM_OFFSET
//#define CGRAM_OFFSET OFFSET_FROM_START
#define CGRAM_OFFSET OFFSET_FROM_END
#endif
//
// ##################################################################################
//
// Section 1. Define the pins that are used to interface with the display here