Here is a diagnostic sketch:
It will show a big WHITE letter F with the default power-up registers.
It will then cycle through the argument bytes, flipping one bit at a time.
These will show a RED letter F with the specific argument byte.
Watch the display. Take notes with pencil and paper.
e.g. does the RED display look exactly like the WHITE display for every argument ?
e.g. does the RED F turn BLUE ?
e.g. do you get a single F or two F ?
e.g. does the F get mirrored vertically?
e.g. does the F get mirrored horizontally?
Write down the argument value that gets a single F
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
uint16_t ID;
uint8_t d7[] = { 0x20, 0x80, 0x31, 0x80 }; //mystery
uint8_t b6[] = { 0x0A, 0x82, 0x27, 0x80 }; //ILI9341
uint8_t c0[] = { 0x0A }; //R61520
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
void setup()
{
ID = tft.readID();
ID = 0x9327; //force ID for mystery controller
tft.begin(ID);
}
void printhex(uint8_t c)
{
if (c < 0x10) tft.print("0");
tft.print(c, HEX);
}
void showreg(uint8_t reg, uint8_t d[], uint8_t n, uint8_t idx, uint16_t color)
{
tft.fillScreen(BLACK);
tft.setTextColor(color, BLACK);
tft.setTextSize(10);
tft.setCursor(0, 0);
tft.print("F");
tft.setTextSize(2);
tft.print(" ID = 0x");
printhex(ID >> 8);
printhex(ID & 0xFF);
tft.pushCommand(reg, d, n);
tft.setCursor(0, 100);
tft.println("reg: args ...");
printhex(reg);
tft.print(":");
for (uint8_t i = 0; i < n; i++) {
tft.setTextColor(color, BLACK);
tft.print(" ");
if (i == idx) tft.setTextColor(BLACK, WHITE);
printhex(d[i]);
}
delay(5000);
}
void flipreg(uint8_t reg, uint8_t args[], uint8_t n, uint8_t idx)
{
uint8_t d[6];
memcpy(d, args, n);
showreg(reg, d, n, idx, WHITE);
for (uint8_t mask = 0x80; mask; mask >>= 1) {
d[idx] = args[idx]; //default
d[idx] ^= mask;
showreg(reg, d, n, idx, RED);
}
d[idx] = args[idx]; //default
showreg(reg, d, n, idx, WHITE);
}
void loop()
{
switch (ID) {
case 0x9341:
flipreg(0xB6, b6, sizeof(b6), 0);
flipreg(0xB6, b6, sizeof(b6), 1);
flipreg(0xB6, b6, sizeof(b6), 3);
break;
case 0x1520:
case 0x1526:
flipreg(0xC0, c0, sizeof(c0), 0);
break;
case 0x9327: //forced for mystery controller
flipreg(0xD7, d7, sizeof(d7), 0);
flipreg(0xD7, d7, sizeof(d7), 1);
flipreg(0xD7, d7, sizeof(d7), 3);
break;
default:
tft.println("not supported");
delay(1000);
break;
}
}
David.