Announcement

Collapse
No announcement yet.

Can't display image on uOLED128G2 from micro sd card

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't display image on uOLED128G2 from micro sd card

    I am trying to display image on uOLED128G2 from micro sd card. I built usd raw data of one 128*128 jpg file with graphic composer and run the following Arduino sketch on Arduino Due, but I only see the text "Media Tests" on display (so I am sure the connection between Arduino and display is good), not image.

    Code:
    #define DisplaySerial Serial1
    #define LOG_MESSAGES
    
    #ifdef LOG_MESSAGES
    #define HWLOGGING Serial
    #else
    #define HWLOGGING if (1) {} else Serial
    #endif
    
    #include "Goldelox_Serial_4DLib.h"
    #include "GoldeloxBigDemo.h"
    #include "Goldelox_Const4D.h"
    
    Goldelox_Serial_4DLib Display(&DisplaySerial);
    
    // globals for this program
    int fmediatests ;
    
    void Callback(int ErrCode, unsigned char ErrByte)
    {
    #ifdef LOG_MESSAGES
      const char *Error4DText[] = {"OK\0", "Timeout\0", "NAK\0", "Length\0", "Invalid\0"} ;
      HWLOGGING.print(F("Serial 4D Library reports error ")) ;
      HWLOGGING.print(Error4DText[ErrCode]) ;
    
      if (ErrCode == Err4D_NAK)
      {
        HWLOGGING.print(F(" returned data= ")) ;
        HWLOGGING.println(ErrByte) ;
      }
      else
        HWLOGGING.println(F("")) ;
      while (1) ; // you can return here, or you can loop
    #endif
    }
    
    #define RESETLINE 4
    
    void setup()
    {
      pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
      digitalWrite(RESETLINE, 1);  // Reset the Display via D4
      delay(100);
      digitalWrite(RESETLINE, 0);  // unReset the Display via D4
      delay(5000);
    
    #ifdef LOG_MESSAGES
      HWLOGGING.begin(19200);
      while (!HWLOGGING) continue;
      HWLOGGING.print(F("\n\nBigDemo for Arduino\n"));
    #endif
    }
    
    void loop()
    {
      Display.TimeLimit4D   = 5000;
      Display.Callback4D = Callback;
      DisplaySerial.begin(9600) ;
    
      Display.gfx_Cls() ;
      fmediatests = Display.media_Init();
      if (fmediatests)
        HWLOGGING.println(F("Media tests will be done")) ;
      else
        HWLOGGING.println(F("Media tests cannot be done, missing uSD card")) ;
    
      delay(2000) ;
    
      if (fmediatests)
      {
        Display.gfx_Cls() ;
        Display.putstr("Media Tests") ;
        Display.media_Image(0, 0);
        delay(10000);
      }
    }

    When I transfer the data to usd, I added a bitmap file to graphic composer, and built it with "4DGL -uSD Raw" build type and zero offset (see attached screen shots). Click image for larger version

Name:	gc1.PNG
Views:	34
Size:	27.9 KB
ID:	53219

    Click image for larger version

Name:	gc2.PNG
Views:	18
Size:	11.1 KB
ID:	53220

    After building, It produced the following gc file and text file.

    gc file
    Code:
    // Image - "test.bmp" Size 128x128
    // Width  = 128
    // Height = 128
    // Usage: test.bmp(x, y);
    #constant test.bmp    $media_SetSector(0x0000, 0x0000); media_Image
    text file
    Code:
    "test.bmp" 0000 0000 00 00
    Could you give me an advice why I can't see any image on the display?

    Thanks,

  • #2
    Hello Poly,

    Code:
    void loop()
    {
     Display.TimeLimit4D   = 5000;
      Display.Callback4D = Callback;
      DisplaySerial.begin(9600) ;
    
      Display.gfx_Cls() ;
    Perhaps you could move the highlighted lines above to the setup routine, as they are repeatedly executed in the main loop.

    There is an application note written for this.

    Serial Arduino Displaying Images from the uSD Card RAW
    http://www.4dsystems.com.au/appnote/4D-AN-00134/

    Perhaps you can take a look and follow the approach. Let me know how it goes.

    Best Regards,
    Doff

    Comment


    • #3
      Hi Doff,

      After moving the highlighted lines, it works! Thank you very much!

      Here is the working code I used.
      Code:
      #define DisplaySerial Serial1
      #define LOG_MESSAGES
      
      #ifdef LOG_MESSAGES
      #define HWLOGGING Serial
      #else
      #define HWLOGGING if (1) {} else Serial
      #endif
      
      #include "Goldelox_Serial_4DLib.h"
      #include "GoldeloxBigDemo.h"
      #include "Goldelox_Const4D.h"
      
      Goldelox_Serial_4DLib Display(&DisplaySerial);
      
      // globals for this program
      int fmediatests ;
      
      void Callback(int ErrCode, unsigned char ErrByte)
      {
      #ifdef LOG_MESSAGES
        const char *Error4DText[] = {"OK\0", "Timeout\0", "NAK\0", "Length\0", "Invalid\0"} ;
        HWLOGGING.print(F("Serial 4D Library reports error ")) ;
        HWLOGGING.print(Error4DText[ErrCode]) ;
      
        if (ErrCode == Err4D_NAK)
        {
          HWLOGGING.print(F(" returned data= ")) ;
          HWLOGGING.println(ErrByte) ;
        }
        else
          HWLOGGING.println(F("")) ;
        while (1) ; // you can return here, or you can loop
      #endif
      }
      
      #define RESETLINE 4
      
      void setup()
      {
        pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
        digitalWrite(RESETLINE, 1);  // Reset the Display via D4
        delay(100);
        digitalWrite(RESETLINE, 0);  // unReset the Display via D4
        delay(5000);
      
        Display.TimeLimit4D   = 5000;
        Display.Callback4D = Callback;
        DisplaySerial.begin(9600) ;
      
        delay(1000);
      
      #ifdef LOG_MESSAGES
        HWLOGGING.begin(19200);
        while (!HWLOGGING) continue;
        HWLOGGING.print(F("\n\nBigDemo for Arduino\n"));
      #endif
      }
      
      void loop()
      {
        Display.gfx_Cls() ;
        fmediatests = Display.media_Init();
        if (fmediatests)
          HWLOGGING.println(F("Media tests will be done")) ;
        else
          HWLOGGING.println(F("Media tests cannot be done, missing uSD card")) ;
      
        delay(2000) ;
      
        if (fmediatests)
        {
          Display.gfx_Cls() ;
          Display.putstr("Media Tests") ;
          Display.media_Image(0, 0);
          delay(10000);
        }
      }
      By the way, most of my original code is copied from the GoldeloxBigDemo example included in https://github.com/4dsystems/Goldelo...rduino-Library, so I think that example should be updated as well.

      Anyway, thank you for your help.

      Comment

      Working...
      X