#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include "pistol.h"
#include "M16.h"
#define TFT_DC 2
#define TFT_CS 15
#define TFT_RST 4
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
tft.begin();
tft.setRotation(3);
drawBitmap(0,0,M16,240,100); // Bitmap dimensions are 240x100 pixels
}
void loop (){}
void drawBitmap(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h) {
for (int16_t j = 0; j < h; j++) {
for (int16_t i = 0; i < w; i++) {
uint16_t pixel = bitmap[(j * w) + i]; // Get the pixel value from the bitmap array
// Check if the pixel value is the transparent color
if (pixel == 0xf7be) {
continue; // Skip drawing this pixel
}
// Swap the red and blue color channels (assuming BGR order)
uint16_t r = (pixel >> 11) & 0x1F; // Extract red channel
uint16_t g = (pixel >> 5) & 0x3F; // Extract green channel
uint16_t b = pixel & 0x1F; // Extract blue channel
uint16_t color565 = (r << 11) | (g << 5) | b;
tft.drawPixel(x + i, y + j, color565); // Draw the pixel
}
}
}