Passing parameters to LCD command?

david_prentice:
here is an example:

#include "Adafruit_ILI9341.h"

...
void diag_reg(char *name, uint8_t reg, uint8_t n)
{
    uint8_t x = reg;
    Serial.print(name);
    Serial.print(" (0x");
    Serial.print(x < 0x10 ? "0" : "");
    Serial.print(x, HEX);
    Serial.print("):");
    for (int i = 0; i < n; i++) {
        uint8_t x = tft.readcommand8(reg, i);
        Serial.print(x < 0x10 ? " 0" : " ");
        Serial.print(x, HEX);
    }
    Serial.println("");
}

void setup() {
    Serial.begin(9600);
    tft.begin();

// read diagnostics (optional but can help debug problems)
    diag_reg("RDMODE", ILI9341_RDMODE, 1);
    diag_reg("ILI9341_RDMADCTL", ILI9341_RDMADCTL, 1);
    diag_reg("ILI9341_RDPIXFMT", ILI9341_RDPIXFMT, 1);
    diag_reg("ILI9341_RDIMGFMT", ILI9341_RDIMGFMT, 1);
    diag_reg("ILI9341_RDSELFDIAG", ILI9341_RDSELFDIAG, 1);
    diag_reg("DSPFUNC      ", 0xb6, 5);
    diag_reg("ID4          ", 0xD3, 4);
    diag_reg("ILI9341_RDID1", ILI9341_RDID1, 2);
    diag_reg("ILI9341_RDID2", ILI9341_RDID2, 2);
    diag_reg("ILI9341_RDID3", ILI9341_RDID3, 2);
    diag_reg("GAMMAP      ", 0xE0, 16);
    diag_reg("GAMMAN      ", 0xE1, 16);
    diag_reg("INTERFACE    ", 0xf6, 4);
    ...



and the Adafruit_ILI9341.cpp has:


uint8_t Adafruit_ILI9341::readcommand8(uint8_t c, uint8_t index) {
  if (hwSPI) spi_begin();
  digitalWrite(_dc, LOW); // command
  digitalWrite(_cs, LOW);
  spiwrite(0xD9);  // woo sekret command?
  digitalWrite(_dc, HIGH); // data
  spiwrite(0x10 + index);
  digitalWrite(_cs, HIGH);

digitalWrite(_dc, LOW);
  digitalWrite(_sclk, LOW);
  digitalWrite(_cs, LOW);
  spiwrite(c);

digitalWrite(_dc, HIGH);
  uint8_t r = spiread();
  digitalWrite(_cs, HIGH);
  if (hwSPI) spi_end();
  return r;
}



Note the "secret" 0xD9 command. I get output:


RDMODE (0x0A): 9C
ILI9341_RDMADCTL (0x0B): 48
ILI9341_RDPIXFMT (0x0C): 05
ILI9341_RDIMGFMT (0x0A): 9C
ILI9341_RDSELFDIAG (0x0F): C0
DSPFUNC      (0xB6): 00 08 82 27 04
ID4          (0xD3): 41 00 93 41
ILI9341_RDID1 (0xDA): 00 00
ILI9341_RDID2 (0xDB): 00 00
ILI9341_RDID3 (0xDC): 00 00
GAMMAP        (0xE0): 00 0F 31 2B 0C 0E 08 4E F1 37 07 10 03 0E 09 00
GAMMAN        (0xE1): 00 00 0E 14 03 11 07 31 C1 48 08 0F 0C 31 36 0F
INTERFACE    (0xF6): 00 01 00 00




David.

Thanks,
I should be able to rewrite it for SPI.
I may just ditch current code alltogether , it goes thru about five functions before it does the actual SPI read.
But it is not time critical , so Arduino API's are cool.
The chain I have been tracing also has the "sekret" command.

It funny how "original " some of the code in use is.

I was unable to find the secret command in ILI9341 spec.
Jim