Does anybody know how to skip a line of pixels using ILI9327 library?
I mean not to do draw anythig until the end of current line of pixels then go to the next line and draw something. Something on the similarity of the alpha channel.
I'm trying to understand basing on the example that I have.
#include <SPI.h> // We use this library, so it must be called here.
//
// GPA port - these show which wires from the LCD are connected to which pins on the I/O expander
//
#define LCD_RST 0b00001000 // reset 0x08
#define LCD_RD 0b00010000 // not used 0x10
#define LCD_WR 0b00100000 // 1 = read; 0 = write 0x20
#define LCD_RS 0b01000000 // 1 = data; 0 = command 0x40
#define LCD_CS 0b10000000 // enable by toggling low 0x80
#define MCP23S17 B01000000 // MCP23017 SPI Address
#define IODIRA 0x00 // MCP23017 address of I/O direction
#define IODIRB 0x01 // MCP23017 1=input
#define GPIOA 0x12 // MCP23017 address of GP Value
#define GPIOB 0x13 // MCP23017 address of GP Value
// SPI
#define SS 10 // Pin mapping to Arduino = SELECT
#define MOSI 11 // Pin mapping to Arduino = Master Out Slave In
#define SCLK 13 // Pin mapping to Arduino = Serial clock
#define MISO 12 // Pin mapping to Arduino = Master IN slave OUT
void setup()
{
pinMode (SS, OUTPUT);
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
SPI_portexpanderinit();
initft();
dis_color4(0xf800, 0x07e0, 0x001f, 0x07ff, 0xf81f, 0xffe0, 0x0000, 0xffff); //8色间隔画面
SPI.end();
}
void loop(){}
void SPI_portexpanderinit()
{
// --- Set I/O Direction
SPI_TX(MCP23S17, IODIRB, B00000000); // MCP23S17 port B = OUTPUT
SPI_TX(MCP23S17, IODIRA, B00000000); // MCP23S17 port A = OUTPUT
// --- Clear ALL Bits of GPIOA and GPIOB
SPI_TX(MCP23S17, GPIOB, B00000000); // MCP23S17 Clear port B
SPI_TX(MCP23S17, GPIOA, B00000000); // MCP23S17 Clear port A
}
void SPI_TX(int device, int regadd, int tx_data)
{
PORTB &= 0b11111011; // set CS low with direct write to digital pin 10
SPI.transfer(device); // device address write bit already 1ow
SPI.transfer(regadd);
SPI.transfer(tx_data);
PORTB |= 0b00000100; // set CS high with direct write to digital pin 10
}
void cmd(int dat)
{ SPI_TX(MCP23S17, GPIOB, dat);
SPI_TX(MCP23S17, GPIOA, B00011000); // 10 08 toggle cs
SPI_TX(MCP23S17, GPIOA, B10111000); // 80 20 10 08
}
void writeData(int dat)
{ SPI_TX(MCP23S17, GPIOB, dat);
SPI_TX(MCP23S17, GPIOA, B01011000); // 40 10 08
SPI_TX(MCP23S17, GPIOA, B11111000); // 80 40 20 10 08 toggle cs,
}
void initft()
{
SPI_TX(MCP23S17, GPIOA, LCD_RST );
delay(50);
SPI_TX(MCP23S17, GPIOA, 0 );
delay(10);
SPI_TX(MCP23S17, GPIOA, B11111000); // turn on all LCD control bits
delay(50);
cmd(0xE9);
writeData (0x20);
cmd(0x11); //Exit Sleep
//delay(100);
cmd(0xD1);
writeData (0x00);
writeData (0x71);
writeData (0x19);
cmd(0xD0);
writeData (0x07);
writeData (0x01);
writeData (0x08);
cmd(0x36);
writeData (0x48);
cmd(0x3A);
writeData (0x05);
cmd(0xC1);
writeData (0x10);
writeData (0x10);
writeData (0x02);
writeData (0x02);
cmd(0xC0); //Set Default Gamma
writeData (0x00);
writeData (0x35);
writeData (0x00);
writeData (0x00);
writeData (0x01);
writeData (0x02);
cmd(0xC5); //Set frame rate
writeData (0x04);
cmd(0xD2); //power setting
writeData (0x01);
writeData (0x44);
cmd(0xC8); //Set Gamma
writeData (0x04);
writeData (0x67);
writeData (0x35);
writeData (0x04);
writeData (0x08);
writeData (0x06);
writeData (0x24);
writeData (0x01);
writeData (0x37);
writeData (0x40);
writeData (0x03);
writeData (0x10);
writeData (0x08);
writeData (0x80);
writeData (0x00);
cmd(0x2A);
writeData (0x00);
writeData (0x00);
writeData (0x00);
writeData (0xeF);
cmd(0x2B);
writeData (0x00);
writeData (0x00);
writeData (0x01);
writeData (0x8F);
cmd(0x29); //display on
cmd(0x2C); //display on
//delay(100);
}
//=============================8色彩间隔画面======================================//
void dis_color4(unsigned int a, unsigned int b, unsigned int c, unsigned int d, unsigned int e, unsigned int f, unsigned int g, unsigned int h)
{
unsigned int i, m;
cmd(0x002c);
for (i = 0; i < 50; i++)
for (m = 0; m < 240; m++)
{
SPI_TX(MCP23S17, GPIOA, 0x58); //LCD_RST|LCD_RD|LCD_RS
SPI_TX(MCP23S17, GPIOB, a >> 8);
SPI_TX(MCP23S17, GPIOA, 0x78 ); //LCD_RST|LCD_WR|LCD_RS|LCD_RD
SPI_TX(MCP23S17, GPIOA, 0x58);
SPI_TX(MCP23S17, GPIOB, a);
SPI_TX(MCP23S17, GPIOA, 0x78 );
}
SPI_TX(MCP23S17, GPIOA, 0xf8 );
}
It seems that these commands are responsible for drawing
SPI_TX(MCP23S17, GPIOA, 0x58); //LCD_RST|LCD_RD|LCD_RS
SPI_TX(MCP23S17, GPIOB, a >> 8 );
SPI_TX(MCP23S17, GPIOA, 0x78 ); //LCD_RST|LCD_WR|LCD_RS|LCD_RD
SPI_TX(MCP23S17, GPIOA, 0x58 );
SPI_TX(MCP23S17, GPIOB, a );
SPI_TX(MCP23S17, GPIOA, 0x78
How can I move the pointer to draw where I want on the screen?