hi, I have a sketch that uses an oled display, with its own custom library that uses port + bit banging,
I'm converting it to use a tft display with Arduino_ST7789_Fast library instead,
oled library "draw_rect" has 7 parameters
void draw_rect (uint8_t x, uint8_t y, uint8_t w, uint8_t h,
uint16_t edgecol, uint16_t fillcol, boolean filled)
but Arduino_ST7789_Fast library "fillRect" has only 5
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
do I just add the extra parts to "fillRect" to get the 7 parameters the sketch needs?
also, how do I convert the colour parts of the bit banging code to the tft library?
// Draw a rectangle in foreground colour optionally filled another colour
void draw_rect (uint8_t x, uint8_t y, uint8_t w, uint8_t h,
uint16_t edgecol, uint16_t fillcol, boolean filled)
{
if(w == 0 || h == 0)
return;
uint8_t e_red = (edgecol & 0xf800) >> 10;
uint8_t e_green = (edgecol & 0x07e0) >> 5;
uint8_t e_blue = (edgecol & 0x001f) << 1;
uint8_t f_red = (fillcol & 0xf800) >> 10;
uint8_t f_green = (fillcol & 0x07e0) >> 5;
uint8_t f_blue = (fillcol & 0x001f) << 1;
PINB = 1<<cs; // cs low
Send(0x26); Send(filled); // Enable fill
Send(0x22); // Draw rectangle
Send(x); Send(y); Send(x + w - 1); Send(y + h - 1);
Send(e_red); Send(e_green); Send(e_blue);
Send(f_red); Send(f_green); Send(f_blue);
PINB = 1<<cs; // cs high
if(filled) // filled rectangles take time to draw
//delayMicroseconds(200); // must not issue new command too soon
delayMicroseconds(100); // half delay when clocking nano to 8 MHz
}
// ----------------------------------------------------------
void Arduino_ST7789::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
{
if(x>=_width || y>=_height || w<=0 || h<=0) return;
if(x+w-1>=_width) w=_width -x;
if(y+h-1>=_height) h=_height-y;
setAddrWindow(x, y, x+w-1, y+h-1);
writeMulti(color,w*h);
CS_IDLE;
SPI_END;
}