#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include "pgmspace.h"
#include "Image.h"
#include <Fonts/FreeSerif9pt7b.h>
#include <Fonts/FreeMono9pt7b.h>
Adafruit_ILI9341 tft(15,2);
void Text1(int x, int y, int size, uint16_t color, char *text) {
tft.setFont(&FreeSerif9pt7b);
tft.setCursor(x,y);
tft.setTextSize(size);
tft.setTextColor(color);
tft.print(text);
}
void Text2(int x, int y, int size, uint16_t color, char *text) {
tft.setFont(&FreeMono9pt7b);
tft.setCursor(x,y);
tft.setTextSize(size);
tft.setTextColor(color);
tft.print(text);
}
void drawBitmap(int x, int y, float angle, const uint16_t *bitmap, int w, int h) {
float rad = (angle*3.14159)/180;
float rot = tan(rad);
int shift = int(1/rot);
int offset_x = 0, offset_y = 0;
for(int j=0; j<h; j++) {
if(j%shift==0) {
offset_x++;
}
for(int i=0; i<w; i++) {
if(i%shift==0) {
offset_y++;
tft.drawPixel(x+i+offset_x-1, y+j-offset_y, pgm_read_word(&bitmap[(j*w)+i]));
}
tft.drawPixel(x+i+offset_x, y+j-offset_y, pgm_read_word(&bitmap[(j*w)+i]));
}
offset_y = 0;
}
}
float size;
void setup() {
tft.begin();
tft.fillScreen(0xFFFF);
}
void loop() {
//Text1(40, 20, 1, 0x000F, "Shree Radha Krishna");
drawBitmap(-120,150, 40, Image1, IMAGE_WIDTH, IMAGE_HEIGHT);
//Text2(10, 300, 1, 0x39E7, "File Size :");
//size = IMAGE_WIDTH*IMAGE_HEIGHT*2;
//tft.print(size/1024);
//tft.print(" kB");
}