Deschidem programul Img2Lcd
Imaginea nu trebuie sa depaseasca dimensiunile display-ului. in cazul nostru 128x64 pixeli (8192pixeli). Imaginea are exact 128x64 pixeli.
Inainte de a selecta imaginea selectam in casuta "Scan mode:" Horizon Scan" (scanare orizontala a pixelilor si completam in casutele "Max Width and Height" 128 si respectiv 64, dimensiunile imaginii pe care am verificat-o mai inainte.
Acum putem deschide imaginea in programul nostru, Img2Lcd, cu ajutorul butonului "Open"
Apasam "Open" si imaginea apare in program
Apasam "Save" si se deschide o fereastra in Notepad
Selectam fisierul hex si il aducem in programul nostru:
#include "U8glib.h"
U8GLIB_ST7920_128X64_1X u8g( 13, //E
11, //R/W
12 //RS
/*10*/); //RST
void disp_graph_init()
{
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); //branco
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); //máxima intensidade
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255, 255, 255);
}
} // end disp_graph_init
// Image Bitmap
const uint8_t lion[] PROGMEM = { //128x64
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X00, 0X80, 0XFF, 0X01, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X00, 0XE0, 0XFF, 0X0F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X00, 0XFC, 0XDB, 0X7F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X00, 0X7E, 0XF7, 0XF7, 0X01, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X00, 0X03, 0X78, 0X40, 0X07, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X80, 0X01, 0X78, 0X02, 0X04, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0XC0, 0X60, 0X38, 0X02, 0X04, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X60, 0XC6, 0X38, 0X09, 0X04, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X60, 0X8C, 0X30, 0X1C, 0X09, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0XE0, 0X01, 0X70, 0X80, 0X04, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X30, 0X00, 0X30, 0XC3, 0X04, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X10, 0XC0, 0X33, 0X07, 0X0E, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X90, 0XE1, 0X30, 0X8E, 0X03, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X90, 0XF3, 0X30, 0X98, 0X0B, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X30, 0X27, 0X20, 0X80, 0X09, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0XF8, 0X37, 0X60, 0X90, 0X09, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0XC8, 0X18, 0X72, 0X22, 0X0C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X4C, 0X84, 0XC3, 0XC2, 0X0C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X04, 0XE2, 0XC3, 0X8F, 0X0C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X24, 0X03, 0XFB, 0X27, 0X11, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X32, 0X07, 0XFC, 0X22, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X39, 0X06, 0XFF, 0X22, 0X31, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X80, 0X1D, 0X00, 0XF3, 0XA2, 0X23, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X80, 0X08, 0X00, 0XF6, 0XB0, 0X43, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X80, 0X40, 0X0C, 0XF6, 0X9B, 0XC3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X70, 0X1E, 0X4A, 0X0E, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X40, 0X0B, 0X3C, 0XF8, 0XEF, 0XC4, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0XC0, 0XC0, 0X21, 0XF0, 0X3D, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X60, 0XE0, 0X41, 0XC0, 0X18, 0XC8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X60, 0XA3, 0X41, 0X40, 0X10, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0XE0, 0XF1, 0XD8, 0XC0, 0X10, 0XC1, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0XE0, 0X49, 0XD8, 0XF1, 0X1F, 0XC3, 0X03, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0XE0, 0X24, 0XC0, 0X0F, 0X3C, 0XE2, 0X3F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X70, 0X00, 0XC0, 0X03, 0X18, 0XF0, 0XE7, 0X03, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0XF0, 0X08, 0XC0, 0X03, 0X1C, 0X78, 0X07, 0X3F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0XF0, 0X6C, 0XE0, 0X7F, 0X0F, 0XFF, 0X0F, 0XF0, 0X3F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X70, 0XEC, 0X25, 0XFD, 0X0F, 0XEF, 0X0F, 0X80, 0XFF, 0X01, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0XD0, 0XE4, 0XBD, 0XFB, 0XDF, 0XCF, 0X07, 0X00, 0XFE, 0X0F, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X90, 0X56, 0X97, 0XCB, 0XF7, 0XDB, 0X03, 0X00, 0XF0, 0X3F, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0XB0, 0X17, 0XC2, 0X49, 0XC2, 0XF7, 0X07, 0X00, 0XA0, 0XFF, 0X03, 0X00, 0X00, 0X00, 0X00,
0X00, 0X30, 0X13, 0XC2, 0X48, 0X03, 0XE7, 0X07, 0X00, 0X00, 0XFC, 0X03, 0X00, 0X00, 0X00, 0X00,
0X00, 0X90, 0X0B, 0X60, 0X40, 0X01, 0XEE, 0X0F, 0X00, 0X00, 0XFC, 0X07, 0X00, 0X00, 0X00, 0X00,
0X00, 0X98, 0X1D, 0X20, 0X40, 0X87, 0XFE, 0X0F, 0X00, 0XC0, 0XFC, 0X0F, 0X00, 0X00, 0X00, 0X00,
0X00, 0XD8, 0X1F, 0X00, 0X00, 0X1D, 0XFF, 0X0F, 0X00, 0X60, 0XF8, 0X1F, 0X00, 0X00, 0X00, 0X00,
0X00, 0XE8, 0X0F, 0X00, 0X00, 0X19, 0XFF, 0X1F, 0X00, 0X00, 0XF0, 0XFF, 0X00, 0X00, 0X00, 0X00,
0X00, 0XF8, 0X0E, 0X00, 0X00, 0X39, 0XFF, 0X0F, 0X00, 0X00, 0XF0, 0XF8, 0X00, 0X00, 0X00, 0X00,
0X00, 0X78, 0X2E, 0X00, 0X14, 0X79, 0XFE, 0X0F, 0X00, 0X40, 0XE0, 0XE3, 0X01, 0X00, 0X00, 0X00,
0X00, 0X78, 0X2F, 0X00, 0X56, 0XFD, 0XFF, 0X0F, 0X00, 0X60, 0XC0, 0XC7, 0X01, 0X00, 0X00, 0X00,
0X00, 0X78, 0XAF, 0X00, 0XCB, 0XFF, 0X3F, 0X0E, 0X00, 0X60, 0X00, 0X8E, 0X03, 0X00, 0X00, 0X00,
0X00, 0XF8, 0XBF, 0X08, 0XCB, 0XFF, 0X1F, 0X0C, 0X00, 0XF0, 0X00, 0X8E, 0X07, 0X00, 0X00, 0X00,
0X00, 0XFC, 0XFF, 0X14, 0XED, 0XFF, 0X0F, 0X0C, 0X00, 0XF0, 0X06, 0X9C, 0X1F, 0X00, 0X00, 0X00,
0X00, 0XFC, 0XFF, 0X1E, 0XFF, 0XFF, 0X07, 0X0C, 0X00, 0XD0, 0X1D, 0XF8, 0X73, 0X00, 0X00, 0X00,
0X00, 0X8E, 0XFF, 0X9F, 0XFF, 0XFF, 0X03, 0X0C, 0X00, 0X3C, 0X7E, 0XE0, 0XC7, 0X00, 0X00, 0X00,
0X00, 0X06, 0XFF, 0X9F, 0XFF, 0XFF, 0X03, 0X06, 0X00, 0X1C, 0XF8, 0XC0, 0X07, 0X07, 0X00, 0X00,
0X00, 0X02, 0XF9, 0XFF, 0X1F, 0XFE, 0X03, 0X03, 0X00, 0X07, 0XC0, 0X81, 0X1F, 0XF0, 0X00, 0X00,
0X00, 0X43, 0X38, 0X00, 0X00, 0XF8, 0X83, 0X81, 0XD1, 0X03, 0X3F, 0X00, 0X7F, 0X00, 0XFF, 0X03,
0X80, 0X41, 0X0E, 0X0F, 0X00, 0XFC, 0XE3, 0XC0, 0XF1, 0X83, 0XFB, 0X0E, 0X84, 0X1F, 0X00, 0X0C,
0XF4, 0X70, 0X01, 0X0E, 0X80, 0X7F, 0XF0, 0XFC, 0XFF, 0XCF, 0XD9, 0X3E, 0X04, 0X80, 0XFF, 0X19,
0XD2, 0XE1, 0XC0, 0X07, 0XE0, 0XFF, 0XFF, 0XFF, 0X00, 0XC0, 0XCF, 0X3F, 0X03, 0X00, 0X00, 0X3E,
0XF1, 0XF0, 0X80, 0X01, 0XF8, 0XFF, 0X01, 0X00, 0X00, 0X80, 0XFF, 0XFF, 0X03, 0X00, 0X00, 0X78,
0XED, 0X99, 0XFF, 0X00, 0XFC, 0X1F, 0X00, 0X00, 0X00, 0X00, 0XFC, 0X63, 0X00, 0X00, 0X00, 0X70,
0XFE, 0X0F, 0X00, 0X7C, 0X0F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X60,
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
}; // lion 128x64
void draw(void) {
u8g.drawXBMP( 0, 0, 128, 64, lion); // coloana, rand, nr pixeli pe orizontala, nr pixeli pe verticala, imagine
}
void setup()
{
disp_graph_init();
} //end setup
void loop()
{
u8g.firstPage();
do {
draw();
} while ( u8g.nextPage() );
} //end loop
Se poate folosi si img2cpp care este online:
O adaptare a codului pentru libraria Mcufriend_kbv pentru tft 3,5' UNO se poate ?
RăspundețiȘtergereSalut!
RăspundețiȘtergereMai exact ce te intereseaza? Imaginea, sau codul in sine?
Codul postat de mine nu face altceva decat sa afiseze imaginea unui "leu" folosind libraria .
incerc sa pun o imagine pe un lcd 3,5'UNO . toate exemplele pe care le-am gasit pe net foloseste card SD pentru a stoca imaginea . eu vreau sa pun imaginea in cod nu pe card , cardul de pe lcd nu imi functioneaza pe placa Mega .
RăspundețiȘtergereDaca te referi la o imagine de tip jpeg, bitmap,...color, e mai complicat. Si eu am display-uri de 3.2" si 3.5" (vezi in videoclipurile mele), si am folosit cardul pt fotografii. In videoclipurile mele am doar exemple cu iconite/simboluri monocrome. Libraria pe care o folosesti tu nu am folosit-o niciodata. Dar daca vrei sa te ajut cu iconite te pot ajuta.
RăspundețiȘtergereEu imagini am convertit cu ajutorul unui site:
http://www.rinkydinkelectronics.com/t_imageconverter565.php
dupa care le-am incarcat in card si le-am afisat pe display. Cu Arduino UNO sau Mega2560 imaginile sau incarcat foarte greu si am renuntat la folosirea cardului.