Hi everyone, new to this forum. Would like to ask for help on how to display bitmap on tft screen. I have a 90x90 Jpeg image which I converted using LCD image converter and copied the bitmap into a .h file as shown below. After that, i tried using LCDWIKI_GUI draw_bit_map but was not able to display anything on the image. I also tried a similiar code written by david_prentice but we just get gibberish displayed on the tft. Could anyone help with this? Am I doing anything wrong? Been stuck with this for a week:(
#include <LCDWIKI_GUI.h>
#include <LCDWIKI_SPI.h>
#include <Adafruit_GFX.h>
#include <avr/pgmspace.h>
#include <flowrate.h>
#define CS A3
#define CD A1
#define RST A2
#define LED A0
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
LCDWIKI_SPI my_lcd(ILI9488_18, CS, CD, RST, LED);
const int motorPin = 6;
const int buttonPin = 4;
const int remotePin = 9;
const int remoteLed = 10;
int interval = 0;
char intervalString[10];
float intervalSeconds = interval / 1000.0;
void setupLCD() {
my_lcd.Init_LCD();
my_lcd.Set_Rotation(4);
my_lcd.Fill_Screen(0x0000);
}
void setup(){
setupLCD();
Serial.begin(9600);
drawBitmap(50, 50, flowrate, 90, 90, BLACK, WHITE);
}
void showbgd(int x, int y, const uint8_t *bmp, int w, int h, uint16_t color, uint16_t bg, uint8_t pad = 7)
{
int yy, xx;
uint8_t first = 1, RVS = pad & 0x80;
uint16_t pixel;
pad &= 3;
uint16_t wid = (w + pad) & ~pad; //bits per row
//tft.setAddrWindow(x, y, x + w - 1, y + h - 1); //
my_lcd.Set_Addr_Window(x, y, x + w - 1, y + h - 1); //
for (yy = 0; yy < h; yy++) {
uint32_t ofs = yy*wid; //bit offset
const uint8_t *p = bmp + (ofs >> 3); //flash address
uint8_t mask = 0x80; //bit mask
uint8_t c = pgm_read_byte(p++);
for (xx = 0; xx < w; xx++) {
if (mask == 0) {
c = pgm_read_byte(p++);
mask = 0x80;
}
pixel = (c & mask) ? color : bg;
//tft.pushColors(&pixel, 1, first);
my_lcd.Push_Any_Color(&pixel, 1, first, 0);
first = 0;
mask >>= 1;
}
}
//tft.setAddrWindow(0, 0, tft.width() - 1, tft.height() - 1);
my_lcd.Set_Addr_Window(0, 0, my_lcd.Get_Width() - 1, my_lcd.Get_Height() - 1);
}
void drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color, uint16_t bg)
{
showbgd(x, y, bitmap, w, h, color, bg, 0);
}
void loop() {
}
Trying to display this image
But got this instead
1 post - 1 participant