moononournation / RGB565_video

142 stars 33 forks source link

ssd1331 oled #15

Closed amirjak0 closed 2 years ago

amirjak0 commented 2 years ago

https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino //////////////////////////////////////////////////////////////////////////////////////////////// 61-lsE-Gc2L _SL1000_

amirjak0 commented 2 years ago

i change all code

/ Please upload SPIFFS data with ESP32 Sketch Data Upload: https://github.com/me-no-dev/arduino-esp32fs-plugin / / GIF src: https://steamcommunity.com/sharedfiles/filedetails/?id=593882316 / // #define GIF_FILENAME "/teamMadokaRetro240.gif"

define GIF_FILENAME "/teamMadokaRetro220.gif"

include

//#include // Core graphics library

include

include

include

include

// The SSD1331 is connected like this (plus VCC plus GND)

define sclk 14

define mosi 13

define cs 15

define rst -1

define dc 12

Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, mosi, sclk, rst);

include "gifdec.h"

void setup() { Serial.begin(115200);

// Init Video display.begin(); display.fillScreen(0x07E0);

// Init SPIFFS if (!SPIFFS.begin(true)) { Serial.println(F("ERROR: SPIFFS mount failed!")); display.println(F("ERROR: SPIFFS mount failed!")); } else { File vFile = SPIFFS.open(GIF_FILENAME); if (!vFile || vFile.isDirectory()) { Serial.println(F("ERROR: Failed to open "GIF_FILENAME" file for reading")); display.println(F("ERROR: Failed to open "GIF_FILENAME" file for reading")); } else { gd_GIF gif = gd_open_gif(&vFile); if (!gif) { Serial.println(F("gd_open_gif() failed!")); } else { int32_t s = gif->width gif->height; uint8_t buf = (uint8_t )malloc(s); if (!buf) { Serial.println(F("buf malloc failed!")); } else { Serial.println(F("GIF video start")); display.setAddrWindow((display.width() - gif->width) / 2, (display.height() - gif->height) / 2, gif->width, gif->height); int t_fstart, t_delay = 0, t_real_delay, res, delay_until; int duration = 0, remain = 0; while (1) { t_fstart = millis(); t_delay = gif->gce.delay 10; res = gd_get_frame(gif, buf); if (res < 0) { Serial.println(F("ERROR: gd_get_frame() failed!")); break; } else if (res == 0) { Serial.printf("rewind, duration: %d, remain: %d (%0.1f %%)\n", duration, remain, 100.0 remain / duration); duration = 0; remain = 0; gd_rewind(gif); continue; }

        display.startWrite();
        display.writeIndexedPixels(buf, gif->palette->colors, s);
       //  display.writePixels(buf[s], gif->palette->colors, s);
        display.endWrite();

        t_real_delay = t_delay - (millis() - t_fstart);
        duration += t_delay;
        remain += t_real_delay;
        delay_until = millis() + t_real_delay;
        do
        {
          delay(1);
        } while (millis() < delay_until);
      }
      Serial.println(F("GIF video end"));
      Serial.printf("duration: %d, remain: %d (%0.1f %%)\n", duration, remain, 100.0 * remain / duration);
      gd_close_gif(gif);
    }
  }
}

}

esp_deep_sleep_start(); }

void loop() { }

amirjak0 commented 2 years ago

I have issues with ssd1331 oled Adafruit_SSD1331 have no code : .writeIndexedPixels();

C:\Users***\Desktop\SPIFFS_GIF_video\SPIFFS_GIF_video.ino: In function 'void setup()': SPIFFS_GIF_video:89:21: error: 'class Adafruit_SSD1331' has no member named 'writeIndexedPixels'; did you mean 'writePixels'? display.writeIndexedPixels(buf, gif->palette->colors, s); ^~~~~~ writePixels

I try this code: .writePixels();

C:\Users\Desktop\SPIFFS_GIF_video\SPIFFS_GIF_video.ino: In function 'void setup()': SPIFFS_GIF_video:90:39: error: invalid conversion from 'uint8_t' {aka 'unsigned char'} to 'uint16_t' {aka 'short unsigned int*'} [-fpermissive] display.writePixels(buf[s], gif->palette->colors, s);


In file included from C:\Users********\Documents\Arduino\libraries\Adafruit_SSD1331_OLED_Driver_Library_for_Arduino/Adafruit_SSD1331.h:7,
from C:\Users\ali\Desktop\SPIFFS_GIF_video\SPIFFS_GIF_video.ino:12:
C:\Users*\Documents\Arduino\libraries\Adafruit_GFX_Library/Adafruit_SPITFT.h:218:30: note: initializing argument 1 of 'void Adafruit_SPITFT::writePixels(uint16_t*, uint32_t, bool, bool)'
void writePixels(uint16_t colors, uint32_t len, bool block = true,
~~~~~~~~~~^~~~~~
SPIFFS_GIF_video:90:56: error: invalid conversion from 'uint16_t' {aka 'short unsigned int*'} to 'uint32_t' {aka 'unsigned int'} [-fpermissive]
display.writePixels(buf[s], gif->palette->colors, s);
~~~~~~~~~~~~~~^~~~~~
In file included from C:\Users*\Documents\Arduino\libraries\Adafruit_SSD1331_OLED_Driver_Library_for_Arduino/Adafruit_SSD1331.h:7,
from C:\Users\ali\Desktop\SPIFFS_GIF_video\SPIFFS_GIF_video.ino:12:
C:\Users***\Documents\Arduino\libraries\Adafruit_GFX_Library/Adafruit_SPITFT.h:218:47: note: initializing argument 2 of 'void Adafruit_SPITFT::writePixels(uint16_t, uint32_t, bool, bool)'
void writePixels(uint16_t *colors, uint32_t len, bool block = true,
~~~~~~~~~^~~

but not working
Please help me
moononournation commented 2 years ago

What dev board are you using?

amirjak0 commented 2 years ago

ESP32-DOIT-DEVKIT-V1

moononournation commented 2 years ago

I think Adafruit_SSD1331 should be Arduino_SSD1331

amirjak0 commented 2 years ago

Arduino_SSD1331 Does not exist

moononournation commented 2 years ago

It should exists:

https://github.com/moononournation/Arduino_GFX/blob/master/src/display/Arduino_SSD1331.cpp

amirjak0 commented 2 years ago

I will try these codes and let you know

amirjak0 commented 2 years ago

i change this code but I think I am doing something wrong /////////////////////////////////////////////////////////////////////////////////////////////////////////

include "Arduino_SSD1331.h" // Hardware-specific library

define sclk 14

define mosi 13

define cs 15

define rst -1

define dc 12

Arduino_DataBus *bus = Arduino_SSD1331(cs, dc, mosi, sclk, rst);

////////////////////////////////////////////////////////////////////////////////////////////////////////// SPIFFS_GIF_video:21:66: error: invalid conversion from 'int' to 'Arduino_DataBus' [-fpermissive] Arduino_SSD1331 display = Arduino_SSD1331(cs, dc, mosi, sclk, rst); ^ In file included from C:\Users\000\Desktop\SPIFFS_GIF_video\SPIFFS_GIF_video.ino:9: C:\Users\ali\Desktop\SPIFFS_GIF_video\Arduino_SSD1331.h:51:24: note: initializing argument 1 of 'Arduino_SSD1331::Arduino_SSD1331(Arduino_DataBus, int8_t, uint8_t, int16_t, int16_t, uint8_t, uint8_t, uint8_t, uint8_t)' Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,


Multiple libraries were found for "Arduino_GFX.h"
 Used: C:\Users\ali\Documents\Arduino\libraries\Arduino_GFX-master
 Not used: C:\Users\ali\Documents\Arduino\libraries\GFX_Library_for_Arduino
Multiple libraries were found for "WiFi.h"
 Used: C:\Users\ali\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.4\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
invalid conversion from 'int' to 'Arduino_DataBus*' [-fpermissive]
moononournation commented 2 years ago

I think you should start with the built-in example first.

amirjak0 commented 2 years ago

Thank you, I will work on it

amirjak0 commented 2 years ago

190434378-6aaf39e1-4205-45a5-913b-8435e735a2f5

amirjak0 commented 2 years ago

i have no MISO pin

//Arduino_DataBus bus = new Arduino_ESP32SPI(27 / DC /, 14 / CS */, SCK, MOSI, MISO);

moononournation commented 2 years ago

https://www.instructables.com/ArduinoGFX/

amirjak0 commented 2 years ago

Now I understand It was a very good guide thanks a lot

amirjak0 commented 2 years ago

There is a way to use HSPI PIN ESP32-SPI-Pins

moononournation commented 2 years ago

Yes, this is the default pin mapping. Actually, in ESP32, most pins can remap to VSPI or HSPI.

amirjak0 commented 2 years ago

thanks a lot