va_cristi Posted January 24 Share Posted January 24 Salutare! Am incercat sa incarc in EEPROM-ul extern, symbol.uri cu dimensiunea de 8x8pixeli sau 8x16pixeli si am reusit: #include <Wire.h> #include <EEPROM.h> #include <Adafruit_SSD1306.h> #define OLED_ADDR 0x3C #define EEPROM_ADDR 0x50 Adafruit_SSD1306 display(OLED_ADDR); // byte symbol[8] = {0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}; byte symbol[16] = {0XFF,0X81,0XC5,0X6E,0X7E,0X3C,0XBC,0X98,0X18,0X24,0X24,0X42,0X52,0XB9,0XFD,0XFF}; void setup() { Wire.begin(); display.begin(SSD1306_SWITCHCAPVCC); display.clearDisplay(); /* //write symbol to EEPROM for (int i = 0; i < 8; i++) { EEPROM.write(i, symbol[i]); } //read symbol from EEPROM for (int i = 0; i < 8; i++) { symbol[i] = EEPROM.read(i); } //display symbol for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (symbol[i] & (0x01 << j)) { display.drawPixel(i, j, WHITE); } } } */ //write symbol to EEPROM for (int i = 0; i < 16; i++) { EEPROM.write(i, symbol[i]); } delay(2000); //read symbol from EEPROM for (int i = 0; i < 16; i++) { symbol[i] = EEPROM.read(i); } //display symbol for (int i = 0; i < 8; i++) { for (int j = 0; j < 16; j++) { if (symbol[j] & (0x01 << i)) { display.drawPixel(i, j, WHITE); } } } display.display(); } void loop() { //nothing to do here } Dar cand am vrut sa adaug un symbol de 32x32pixeli, nu prea merge imi afiseaza cu totul altceva: pe orizontala 32pixeli, pe verticala doar 16pixeli. #include <Wire.h> #include <EEPROM.h> #include <Adafruit_SSD1306.h> #define OLED_ADDR 0x3C #define EEPROM_ADDR 0x50 // eeprom chip 24LC256 Adafruit_SSD1306 display(OLED_ADDR); // byte symbol[8] = {0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09}; byte symbol[32][4] = { // 32x32pixeli 0X00, 0X0F, 0XF0, 0X00, 0X00, 0X70, 0X0E, 0X00, 0X01, 0X80, 0X03, 0X80, 0X03, 0X07, 0XF8, 0XC0, 0X04, 0X06, 0X0E, 0X20, 0X08, 0X01, 0X81, 0X10, 0X10, 0X07, 0X81, 0X88, 0X30, 0X08, 0X00, 0X8C, 0X24, 0X18, 0X00, 0X44, 0X4C, 0XF0, 0X00, 0X46, 0X54, 0XC0, 0X00, 0X42, 0X54, 0X20, 0X00, 0X42, 0X93, 0X10, 0X00, 0X41, 0X91, 0X98, 0X00, 0X41, 0X90, 0X8F, 0X00, 0X21, 0X90, 0X60, 0X80, 0X19, 0X80, 0X20, 0X60, 0X01, 0X80, 0X20, 0X38, 0X01, 0X80, 0X40, 0X0E, 0X01, 0X80, 0X20, 0X02, 0X03, 0X40, 0X20, 0X04, 0X02, 0X40, 0X18, 0X04, 0X02, 0X60, 0X08, 0X08, 0X06, 0X20, 0X04, 0X18, 0X04, 0X30, 0X04, 0X60, 0X08, 0X10, 0X0D, 0X80, 0X18, 0X08, 0X09, 0X00, 0X10, 0X04, 0X06, 0X00, 0X60, 0X03, 0X06, 0X00, 0XC0, 0X01, 0XC0, 0X03, 0X00, 0X00, 0X78, 0X1E, 0X00, 0X00, 0X0F, 0XF0, 0X00, }; void setup() { Wire.begin(); display.begin(SSD1306_SWITCHCAPVCC); display.clearDisplay(); delay(3000); for (int i = 0; i < 32; i++) { // [32] reprezintă numărul de linii (pixeli pe orizontală) for (int j = 0; j < 4; j++) { // [4] reprezinta numarul de octeti necesari pentru a salva valoarea fiecarui pixel // 32 pixeli necesita 32/8 = 4 octeti EEPROM.write(i * 4 + j, symbol[i][j]); } } for (int i = 0; i < 32; i++) { for (int j = 0; j < 4; j++) { symbol[i][j] = EEPROM.read(i * 4 + j); } } for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { if (symbol[i / 8][i % 8] & (0x01 << j)) { display.drawPixel(i, j, WHITE); } } } display.display(); } void loop() { //nothing to do here } Stie cineva unde am gresit? Quote Link to comment Share on other sites More sharing options...
antemir Posted January 27 Share Posted January 27 (edited) Tu testezi 16 respectiv 32 de biti dintr-un octet cu urmatoarele instructiuni. Nu stiu cum de merge corect si la 8x16. for (int j = 0; j < 16; j++) { if (symbol[j] & (0x01 << i)) for (int j = 0; j < 32; j++) { if (symbol[i / 8][i % 8] & (0x01 << j)) Acum vad ca la 8x16 deplasezi corect, (1<< i) Edited January 27 by antemir Quote Link to comment Share on other sites More sharing options...
antemir Posted January 27 Share Posted January 27 Pentru 32x32 poti incerca cam asa. Eu am testat pe PC in mod terminal si iese globul pamantesc. ( dar am pus (0x80 >> (j%8)) , adica test biti de la stanga la dreapta) for ( int i = 0; i < 32; i++) { for ( int j = 0; j < 32; j++) // 32 biti pe linie { if (symbol[i][j/8] & (0x01 << (j%8))) // 4 octeti pe linie display.drawPixel(i, j, WHITE); } } Quote Link to comment Share on other sites More sharing options...
va_cristi Posted January 27 Author Share Posted January 27 Am incercat ambele variante si tot nu functioneaza corespunzator. Quote Link to comment Share on other sites More sharing options...
antemir Posted January 27 Share Posted January 27 (edited) ( 0x80 >> (j%8) ) deplasare la dreapta. Trebuie sa mearga. Te astept cu globul. Edited January 27 by antemir Quote Link to comment Share on other sites More sharing options...
va_cristi Posted January 27 Author Share Posted January 27 A mers dle. Multumesc frumos! Acuma mai este o problema. Nu incarca in EERPOM-ul extern. O sa incerc cu o librarie dedicata pt EEPROM-urile externe. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.