Announcement

Collapse
No announcement yet.

OLED-96 Test program with source code

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

  • OLED-96 Test program with source code

    Hello!
    I have recently purchased the OLED-96 (1Mb) and i have playing with them this last weekend. It's a amazing product, i recomend it seriously!
    I write just this little lines to all people whant to make some aplication with a microchip PIC like me. I think it's a good idea to make a simple software to comunicate with the display with serial port (with microUSB too), implementing all things to fully testing the display before making it embeded with a microcontroller.

    I known the guys from 4D was very busy making new and cool products and i think don't have the time to make this software, so im making my own . Im wondered with this display and do a lot of fun with it, i have maked a simple software in Visual C 6 to display graphics with a simple graphical interface with push buttons. Im implementing all the functions but at this moment just the basics is working: Display initialisation on serial com, putpixel, circle, set background color and erase background. In few weeks, i think i can have all drawing functions ready to go.

    The reason to chose Visual C (Win32 app, may be a Linux GTK port soon) is for compatibility. All drawing function is in a separate file and we can call them like DrawCircle(...), EraseBackground() etc...from the main program. Then, is simple to port this to a microcontroller and obiously you can make and test your visual interface before programing your device.

    At this moment, my software isn't complete but i think in few weeks can be ready for fun. Im pleased if you release it in your site or directly in the forum to allow all people to fully testing the display in a few minutes and learn about. My source code is under the General Public Licence (GPL) because i think software must be free

    If you like the idea, let me known about...all coments is wellcome!

    To be continued... regards.

    Oscar G. (aka pK)

    P.S: Some testing picture and video posted here: http://pk.e-pulse.org/index/cat/4/nid/763/
    Oscar G.
    4D Systems Software Engineering
    http://www.bricogeek.com

  • #2


    Hello,

    Cool thingy isn't it ? What do you plan to do with it ?
    Though I'm not good in Spanish I understood you'd like to build a MP3 player around it right ? Which processor you plan to use ?

    Lol I know that's a lot of question but with some mates from school we project to make a multimedia player around an ARM (at91 ) using the 4D Systems screen so we can do all the decoding in software (rather than using a hardware decoder).
    For the moment we'll use the µOLED-96 8mb but, hey, the Goldelox is already out there !

    We also finished a school project for uni, a room sensor that probes, with infrared sensors, for human presence and report it on the screen. The source code for this is available to you if you wish to use it.


    The reason to chose Visual C (Win32 app, may be a Linux GTK port soon) is for compatibility. All drawing function is in a separate file and we can call them like DrawCircle(...), EraseBackground() etc...from the main program. Then, is simple to port this to a microcontroller and obiously you can make and test your visual interface before programing your device.

    That's a nice idea but be careful as to how much computer power you use in your computer program, porting it to a smaller device could reserve some surprises.

    Im pleased if you release it in your site or directly in the forum to allow all people to fully testing the display in a few minutes and learn about.
    That's an idea I thought about some time ago but had to give up to concentrate on the exams. I'll have a talk with Atilla to see if this can be implemented in the actual website.

    Cheers,
    Julien

    Comment


    • #3


      Hi Oscar,

      Hey that's pretty neat and we love to see those little things go into cool applications such as yours. Also my apologies for not replying earlier, first chance I've had to come onto the Forum, it's been very hectic here with over 15 new products rolling out of production and you can just imagine the documentation etc.

      I'll be happy to include your suggestions on the website. I'll have a talk to Julien first and see what we can do.

      BTW, some of the new modules are released, see the announcements in the main forum.

      Regards,
      Atilla
      Atilla

      Comment


      • #4


        Hello folks!

        Thanks for your reply. I have played with my OLED this week with a microcontroller and have lot of fun. I have programmed a VERY buggy and simple Arkanoid game with a 16F876. Im ported my little library from VC6 to CCS and work fine, ieah!
        At this moment, no colision detection but work fast at 4Mhz. Code is just over 2.5Kb including display and sound library (16F876 have 8Kb) and i have "lot" of space to finish the entire game.

        Posted (in spanish) here:
        http://pk.e-pulse.org/index/cat/4/nid/771/

        Direct youtube video here:
        http://es.youtube.com/watch?v=DHMc_YOCkCs

        No more time now (im at work). See you soon!
        Oscar G.
        4D Systems Software Engineering
        http://www.bricogeek.com

        Comment


        • #5


          Hi,

          Cool ! How do you get such nice screenshots ? The screen's always too bright on my pics so I can't actually see anything.
          Even the camera in the engineering lecture theatre had hard time to pick up pictures from it.

          Cheers,
          Julien.

          Comment


          • #6


            Hi Oscar,

            That looks excellent. Well done. Now that you've given us a taste of what you can do I'm sure we'll see more great projects from you in the future. Keep up the great work.
            Atilla

            Comment


            • #7


              Hi!
              Sorry, but this morning have no too much time to post here.

              Julien: The picture is with a Logitech Webcam, because have low refresh rate (about 15-18 pfs) the pixtures becomes fines without flikering.

              The arkanoid game (maybe teris, snake etc) was just for playing with the display. My real proyect is a (very) little mp3 player using this same microcontroller. Not too much processing power to do this, but suficent to make some cool user interface Now, obiously the hard work is the mp3 decoding part. At this time i have the VMUSIC1 from Vinculum to do this work (via UART or SPI selected via onboard jumper), so i have just to interface the display and vmusic1 to my little microcontroller and all it's done! The idea is interfacing the display with UART and the mp3 player module with SPI. This is a very limited module, only can play, stop and "dir" a directory but it's sufisant to have some fun with stream playing hehe. _have some more software control like volume and balance but nothing more than this. If you what more, buy an iPod or similar

              I have choosed this OLED display because of the internal 1Mb flash. It's can store some cool icons for the user interface without external memory. As you can see, my microcontroller is very limited in memory and horse power...

              Now, the major problem to create the display library was the bit depth color (16-bits 5:6:5). Due to display requierements, is necesary to send two bytes for the color data. I think this isn't practical for drawing. Much better use a function to send RGB (24-bits) color to all functions.
              I have remebered my old years demoscene code for a very old software 3D engine and to simplify the color indexing for the library function, i have a function to make conversion from 32 to 16 bpp 5:6:5.

              This work like a simple bits rotation:
              [HTML]int16 result = (red
              Oscar G.
              4D Systems Software Engineering
              http://www.bricogeek.com

              Comment


              • #8


                Hello folks!

                Okey, here is 4:00am and some new work comes out. There is my little library for PCW PIC C compiler tested on my 16F876. She have some bugs and have some trouble with the color parameters.

                Well, my little library work well for drawing and is relatively small but i am not able to draw the correct color on the display. Is unsettling because in my first library using VC6 andusing the SAME function it's works fine... i dont known about that some aid would be appreciated.

                Basically i use a function to manage the tree color components and build a 16-bits WORD like this:

                color = (red 8); // MSB
                putc(color & 0xFF); // LSB

                I am deranged with this...

                Regarding my Arkanoid game, i am raising the collisions system reading the pixel color upon ball and asume "colide" if isn't a black color (0x0000). Obiously the trick is to have a black background allways hehe. Simple, fast but not working yet!
                The reason is my ReadPixel function simply crash (reset) my PIC when i call it. It seems happens when i call getc() but i dont known because.

                Here is the function:

                HTML Code:
                // Return a word with pixel color (crash my PIC! WTF?)
                int16 OLED_ReadPixel(int8 x, int8 y)
                {
                
                int8 msb=0;
                int8 lsb=0;
                int16 pixel_color=0;
                
                // Read pixel color
                putc(uOLED_READPIXEL); // Pixel read
                putc(x);    // x
                putc(y);    // y
                
                delay_ms(10); // Wait for display
                
                msb = getc();
                lsb = getc();
                
                pixel_color = msb | lsb;
                
                return pixel_color;
                
                }
                Now is almost 5:00am and it's time to sleep for me

                Have lot of fun and good weekend! To be continued...
                Attached files uOLEDlib-beta.zip (2.2 KB)
                Oscar G.
                4D Systems Software Engineering
                http://www.bricogeek.com

                Comment


                • #9


                  [HTML]// Return a word with pixel color (crash my PIC! WTF?)
                  int16 OLED_ReadPixel(int8 x, int8 y)
                  {

                  int8 msb=0;
                  int8 lsb=0;
                  int16 pixel_color=0;

                  // Read pixel color
                  putc(uOLED_READPIXEL); // Pixel read
                  putc(x); // x
                  putc(y); // y

                  delay_ms(10); // Wait for display

                  msb = getc();
                  lsb = getc();

                  pixel_color = msb | lsb; //This is actually wrong, should shift the msb up.

                  return pixel_color;

                  }

                  I don't know exactly what's going on on your µC, I'd check the getc() function since I don't know what it is doing (returning an 8bit variable ? Is it a blocking function ? ...) I guess it depends on your compiler.
                  Also you've put a delay there, what if the OLED was sending a NAK ? (x,y coordinate out of range etc...) Also I'd check if the timing is good.
                  Still that does not explain really why the PIC is _resetting_ which sound weird to me. Any electrical problems ?


                  msb = getc();
                  if (msb != uOLED_NAK) {
                  lsb = getc();
                  return (msb

                  Comment


                  • #10


                    Hello Julien, thanks for your reply

                    I dont known about the forced reseting of the microcontroller. It seems to be a problem with getc() function and discart completely electrical problem because when i comment getc() it's work (no this function, but all program runs fine whithout reset).

                    Maybe a problem with watchdog, but nothing else... i have disabled WTD and take the same result: when i call getc() my pic reset... I should investigate this with more time.

                    Now for the bad color interpretation:
                    I thing you are right, maybe is a problem with passed values. I have suposed the range from pixel indexing (5:6:5). Well, 5 bits for red (0-31), 6 bits for green (0-63) and 5 bits for blue (0-31). I think this is correct but in practice, im wrong:

                    When i whant to place a white pixel i call like this:

                    [HTML]
                    uOLED_PutPixel(10, 10, GetRGB(31,63,31)); // White pixel at x:10 y:10

                    At this point the pixel is black... I have a test program running a loop from 0 to 31/63 for each component, drawing a horizontal line to show what's going with the palete colors like this:


                    for (x=0; xi
                    Oscar G.
                    4D Systems Software Engineering
                    http://www.bricogeek.com

                    Comment


                    • #11


                      Hello,
                      Here is the code I use to convert my pictures into a raw format:
                      (VB express)
                      For y = 0 To (picture.PhysicalDimension.Height - 1)
                      For x = 0 To (picture.PhysicalDimension.Width - 1)
                      cSource = picture.GetPixel(x, y)
                      outR = ((cSource.R * 31) / 255) * 2 ^ 11
                      outG = ((cSource.G * 63) / 255) * 2 ^ 5
                      outB = ((cSource.B * 31) / 255)
                      out = outR + outG + outB
                      out = Convert.ToString(out)
                      fileWriter.WriteLine(out & ",")
                      Next x
                      Next y


                      Also for the getc() problem, this is what I use:
                      (ANSI C)

                      unsigned char getch() {
                      while(!RCIF) /* The RX interrupt flag is not set */
                      continue;
                      return RCREG; /* Return the content of the RX register */
                      }
                      Talk to you later (well, after work )
                      Julien.

                      Comment

                      Working...
                      X