Shop OBEX P1 Docs P2 Docs Learn Events
Spin code needed for OLED display "28087" — Parallax Forums

Spin code needed for OLED display "28087"

Hello there, I need some help.
I just started to learn the spin language weeks ago and I have passed through all the given lessons on the parallax homepage.
I can now write simple codes and from day to day I learn more - so far so good...
I have bought the new OLED display 96x64 (order number 28087) where I please need some code for it to keep this working.
I have read some projects and I have found C language code sequences only, but this (as a beginner) it is to strong for me to understand right now.
Ask me one year later - I just want to get knowledge on the Spin first...

So where can I get some simple codes for it?

What I want is simple. I have 2 voltages to measure and I want to display them at the same time at the display. Well, for now and if this will succeed, I can continue the basic code to more if I want...

Any proposal here?
(sorry for my english, I live in Germany, close to Hamburg. Thank you so much...
«1

Comments

  • Thomas,
    Thank you for pointing out the SPIN code gap in the Documentation and Downloads of Product 28087.
    Actually Parallax lost a sale here - I wanted to buy the OLED module, but passed when I saw there was no official SPIN code associated with it.
    I know that I can probably find the SPIN code by dredging through OBEX and the Forum, but I really just wanted to get going quickly and surely with the OLED module.
    Please could Parallax consider adding SPIN kickstart code to Product 28087 Documentation and Downloads.
    Many thanks.
  • I get the feeling that spin support is pretty low on the Parallax priority list. The new GPS module (28509) doesn't have official spin code, either.
  • Yes, I know. Thank you anyway for help. I just have to wait a bit for now... Well, I asked Parallax what they can do some minutes ago. Hopefully they can arange "someone" to make some spin codes for both hardware platforms. Well, some people kept this display runnig, so transfer C or C+ into spin should be only a job of hours, not of understanding...
  • I get the feeling that spin support is pretty low on the Parallax priority list. The new GPS module (28509) doesn't have official spin code, either.

    I was going to quote this source of spin code for that gps module, although now I see you wrote and contributed it :)

    http://obex.parallax.com/object/844

    @ThomasK if you decide to have a go writing your own driver, please share to obex too! In fact, share here along the way too- you might find other users able to offer advice or test code.

  • Two things:

    1. A lot of people don't know to or don't want to dredge through OBEX and the forums to find code.
    2. The material on OBEX and the forums isn't necessarily vetted by Parallax. To my mind, that means it is not "official".
  • Sorry, I do not really know how to move inside this forum. I will avoid PM in the future...
    (ups...)
  • I am super bummed about this. Just got my OLED board. Ihad to install Simple IDE and the demo program to verify I had everything wired up correctly. The documentation, I mean code comments, do not even match up with what is written on the board. Here are my additional comments for anyone that has the same challenge.
    //Set up SPI pins.
    #define SID  6                                    // Serial data in. <- Marked  DIN
    #define SCLK 7                                    // Clock. <- Marked CLK
    #define CS   8                                    // Chip select. <- Marked correctly
    #define RS   9                                // <- Marked D/C
    #define RST  10                             // <- Marked RES
    

    Well, I will dig in and see if I can make it display *SOMETHING* with PASM and Spin. Just disappointing, because it's a cool display and I don't want to rewrite all of my projects in C.
  • "Just disappointing, because it's a cool display and I don't want to rewrite all of my projects in C".
    Thanks for making the point ke4pjw, a lot of us feel the same way.
    It would be greatly appreciated if you can share your findings and code.
  • macrobeak wrote: »
    Actually Parallax lost a sale here - I wanted to buy the OLED module, but passed when I saw there was no official SPIN code associated with it.


    I hope the lack of spin examples will not be the new normal. Before I purchase a product from Parallax, I usually check for code examples, to get an understanding of the item before I receive it. That lack of example will effect my purchase. I hope spin isn't getting pushed aside, or last thing someone worries about. It's one of the most attractive aspects of the P1, they are made for each other.

    P.S.: I may one day have the expertise to write driver object's in spin or PASM. But the hunt and peck programmer in me can only follow one path at a time. Boards like Propeller Activity sit gathering dust, because I don't want to clutter my mind.
  • ke4pjwke4pjw Posts: 1,169
    edited 2016-12-24 22:33
    It appears that this driver is similar.

    http://obex.parallax.com/object/48

    If you change it to the following so that the pins match the pins used for the C demo
    CS    = 8
      RST   = 10
      DC    = 9
      CLK   = 7
      DATA  = 6
    

    it will produce garbage on the screen. (After waiting 45 seconds) This looks promising as way to hack together a spin driver.

    This code is for the SSD1306 as opposed to the SSD1331 that is the Parallax 28087.
  • Ok, by forcing OLED.invertDisplay(true), the display comes on immediately.
    ''**********************************
        ''Display the Adafruit Splash Screen
        ''**********************************
        OLED.clearDisplay
        OLED.AutoUpdateOff
        OLED.invertDisplay(true)
        bytemove(OLED.getBuffer,OLED.getSplash,OLED#LCD_BUFFER_SIZE_BOTH_TYPES)  
        OLED.updateDisplay
        waitcnt(clkfreq*3+cnt)
        count++
        'if(count&$1)
        '  OLED.invertDisplay(true)
        'else  
        '  OLED.invertDisplay(false)
        OLED.updateDisplay
        waitcnt(clkfreq*3+cnt)
    

    I highly suspect I can take this code, change the commands sent to the display, update the built in font, and we will have a usable display driver accessible from spin.

    Santa is on his way here, so I most likely won't be able to work on this much more tonight. :)

    Here is what we have so far:


  • I have been reading the data sheet for the SSD1331, and if I understand correctly, it works kinds of like this:

    The display has it's own video RAM.
    There are two data transfer modes. One is command mode, the other is data mode.
    When in command mode you set the address mode and other information.
    When in data mode, data is moved into the display's RAM and the display's memory pointer is updated automatically.

    The same appears to be true for the SSD1306, but the memory map is different. If I get more time, I will look closer to what the c driver is doing and see if we can transpose the commands and fonts into PASM/Spin for this object.
  • Looks like this is the first step to setting this bad boy up.
    // Initialization Sequence
      oledc_writeCommand(SSD1331_CMD_DISPLAYOFF, 0);     // 0xAE
      oledc_writeCommand(SSD1331_CMD_SETREMAP, 0);       // 0xA0
      oledc_writeCommand(0x72, 0);                       // RGB Color
      oledc_writeCommand(SSD1331_CMD_STARTLINE, 0);      // 0xA1
      oledc_writeCommand(0x00, 0);
      oledc_writeCommand(SSD1331_CMD_DISPLAYOFFSET, 0);  // 0xA2
      oledc_writeCommand(0x00, 0);
      oledc_writeCommand(SSD1331_CMD_NORMALDISPLAY, 0);  // 0xA4
      oledc_writeCommand(SSD1331_CMD_SETMULTIPLEX, 0);   // 0xA8
      oledc_writeCommand(0x3F, 0);                       // 0x3F 1/64 duty
      oledc_writeCommand(SSD1331_CMD_SETMASTER, 0);      // 0xAD
      oledc_writeCommand(0x8E, 0);
      oledc_writeCommand(SSD1331_CMD_POWERMODE, 0);      // 0xB0
      oledc_writeCommand(0x0B, 0);
      oledc_writeCommand(SSD1331_CMD_PRECHARGE, 0);      // 0xB1
      oledc_writeCommand(0x31, 0);
      oledc_writeCommand(SSD1331_CMD_CLOCKDIV, 0);       // 0xB3
      oledc_writeCommand(0xF0, 0);                       // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16)
      oledc_writeCommand(SSD1331_CMD_PRECHARGEA, 0);     // 0x8A
      oledc_writeCommand(0x64, 0);
      oledc_writeCommand(SSD1331_CMD_PRECHARGEB, 0);     // 0x8B
      oledc_writeCommand(0x78, 0);
      oledc_writeCommand(SSD1331_CMD_PRECHARGEA, 0);     // 0x8C
      oledc_writeCommand(0x64, 0);
      oledc_writeCommand(SSD1331_CMD_PRECHARGELEVEL, 0); // 0xBB
      oledc_writeCommand(0x3A, 0);
      oledc_writeCommand(SSD1331_CMD_VCOMH, 0);          // 0xBE
      oledc_writeCommand(0x3E, 0);
      oledc_writeCommand(SSD1331_CMD_MASTERCURRENT, 0);  // 0x87
      oledc_writeCommand(0x06, 0);
      oledc_writeCommand(SSD1331_CMD_CONTRASTA, 0);      // 0x81
      oledc_writeCommand(0x91, 0);
      oledc_writeCommand(SSD1331_CMD_CONTRASTB, 0);      // 0x82
      oledc_writeCommand(0x50, 0);
      oledc_writeCommand(SSD1331_CMD_CONTRASTC, 0);      // 0x83
      oledc_writeCommand(0x7D, 0);
      oledc_writeCommand(SSD1331_CMD_DISPLAYON, 0);      //--turn on oled panel
      
      oledc_setRotation(screen_rotation);
      TFTROTATION = screen_rotation & 3;
    

    However, the font may be more complicated than I first thought, as they appear to be located in the prop's EEPROM. That's ok. I still think we a unspool this thing and transpose much of it into PASM/Spin. At lease enough to produce something on the screen.

    If anyone has any pointers, I am all ears.

    --Terry
  • Made more progress tonight. I think I understand more as to how the buffer works in the SSD1306 driver and how it should work for the SSD1331. It's two bytes per pixel vs 1 bit.

    I used the SSD1331 driver's data commands to attempt to display the propeller beanie hat, and had some success. This was all done in spin. I just need to determine why colors and xy is wrong. I think I can figure it out if I can find the time.

    --Terry
    1574 x 885 - 232K
  • More success. Attached is the image of the bitmap of the propeller beanie hat on the display. This was done in Spin and PASM. I will release some demo code as soon as I can. There are a couple of bugs to quash.

    I think I will implement the draw and copy functions that are native to the display first. Then I will attempt to implement the font/text printing routines.

    I am having a lot of fun with this :)

    --Terry
    1440 x 810 - 112K
  • That beanie is looking fantastic in color.

    Great going Terry. Fun+++
  • The next big question now is: To frame buffer or not to frame buffer.

    The downside to the frame buffer is it uses 12K of RAM.

    The upside to the frame buffer is you can manipulate the buffer and then update the screen all at once. The update could be super fast, as the whole thing could be done in PASM.

    If I do use a frame buffer, I will use the beanie hat as the default values in the buffer. That would be a cool because on initialization, you would see that image.
  • Hello Terry, I am so happy that you have time (and fun) to proceed here. Thank you so much. I think for all of us...
    Excellent!
    :-)
  • Thanks Thomas. I hope I have the time to clean this up and make it public. I am scared I will be terribly embarrassed by the hack job I am doing to Thomas P. Sullivan's code. :)

    Internal fonts work! Check it!



    The code to do the "Spin Code !" message is as follows:
         OLED.clearDisplay
         OLED.write1x8String(String("Spin"),4,0,0,$2F,$5F)  ' (String to print,number of characters, Screen Column Start, Screen Row Start, Red-Green Color, Green-Blue color)
         OLED.write1x8String(String("Code"),4,0,32,$2F,$5F)
         OLED.write1x8String(String("!"),1,64,15,$2F,$5F)
    

    Now, this font is not practical on this screen. It's WAY too big. I will attempt to implement the 5x7 font next.

    --Terry
  • And now the 5x7 fonts work too! W00T! I never thought I would actually get this far.



    Code to display 5x7font text is as follows:
         OLED.clearDisplay
         OLED.write1x16String(String("Spin Code!"),10,12,0,$2F,$5F)
         OLED.write1x16String(String("W00T! W00T!"),11,8,10,$2F,$5F)
    

    Let me do some code cleanup and I will post the source in this thread. Still a lot of features to implement, but we be spinnin' baby! W00T!
  • OK, OK, last video, then off to bed. Sorry for the autofocus.

  • ke4pjwke4pjw Posts: 1,169
    edited 2017-01-02 22:08
    OK guys, attached is a quick demo. Nothing is documented, parts of it are wrong/don't work/are legacy, and parts of it work and I don't know why. :)

    Hopefully I will have some time tomorrow to implement the graphic acceleration features of the display.

    Happy New Year!

    (Demo deleted, see current version below)
  • VonSzarvas wrote: »
    That beanie is looking fantastic in color.

    Great going Terry. Fun+++


    I agree.

    @ ke4pjw, That beanie hat is a work of art.
  • Thanks guys.

    Currently I am in the process of ripping out the useless SSD1306-isms (constants,names,buffer,etc) and am about to implement the accelerated graphics commands. Hopefully I will have another publish this evening.

    Ok, question guys. Do we *REALLY* need 65,535 colors? It would help for speed to drop the display to 256 colors. What say ye?
  • No code today :( It appears that the color scheme for the accelerated graphics commands is 24bit color! Why would they do that?!? Made me feel crazy for the past two hours!

    So, it looks like I am going to have to do some bit twiddling with colors to make everything simple to use. I think I am going to just put the colors in a long and call it a day. I have constants with friendly names setup for colors at this point, time to start using them.

    I will say this, the line and rectangle drawing are *FAST*.

    Hopefully tomorrow I can have this cleaned up to a point that a code publish into the OBEX can be done.

    It has been interesting researching this. There are drivers available for using this display in parallel mode for the prop, but not serial.

    I would be interested to know if anyone got the demo running on their workbench.

    --Terry
  • kwinnkwinn Posts: 8,697
    ke4pjw wrote: »
    Thanks guys.

    Currently I am in the process of ripping out the useless SSD1306-isms (constants,names,buffer,etc) and am about to implement the accelerated graphics commands. Hopefully I will have another publish this evening.

    Ok, question guys. Do we *REALLY* need 65,535 colors? It would help for speed to drop the display to 256 colors. What say ye?

    The applications I have for the prop would not need more than 256 colors. In fact I could get by with 16 colors.
  • ke4pjw wrote: »
    OK guys, attached is a quick demo. Nothing is documented, parts of it are wrong/don't work/are legacy, and parts of it work and I don't know why. :)

    Hopefully I will have some time tomorrow to implement the graphic acceleration features of the display.

    Happy New Year!

    Unfortunately, That SPIN code does not compile. Too many discrepancies between constants in the Demo program and the ASM program.

    Great work Terry!



  • ke4pjwke4pjw Posts: 1,169
    edited 2017-01-03 04:46
    Attached is a current copy of my code. I need to add proper interpolation of 16 to 24 bit color.

    Rectangles and lines have been added. Take a close look at the code to see how quickly it draws lines. :)

    @Publison Let me know if this version does not compile. I suspect there were competing file names.

    **File Deleted**
    New version below.
  • ke4pjw wrote: »
    Attached is a current copy of my code. I need to add proper interpolation of 16 to 24 bit color.

    Rectangles and lines have been added. Take a close look at the code to see how quickly it draws lines. :)

    @Publison Let me know if this version does not compile. I suspect there were competing file names.

    Just changed the PIN assigment to what I had hooked up.. Works GREAT. Nice work Terry.

  • ke4pjwke4pjw Posts: 1,169
    edited 2017-01-10 04:20
    New version. (v.3) Now will unfilled rectangles and screen copy command.

    Be sure to use web safe colors as my 16bit to 24bit interpolation is brain dead. I just multiply Red by 8, Green by 4, and Blue by 8. I will circle back to this.

    Todo maybe:

    Background colors for fonts? What say ye?

    Validate the scroll commands. I didn't change these from the ssd1306 code.

    Possibly implement the dim command. Not sure there is much value here, but easy to implement.

    Enjoy!
    --Terry

    Update: Code has been moved to the OBEX.

    http://obex.parallax.com/object/858
Sign In or Register to comment.