It's due to the I2C system not sending data until 'endTramsmission' is called. Once I finish my re-write of the I2C system this won't be an issue, but for now we have to delay after each I2C call. Sending text and any other command to the display is still basically instant, it just really slows down the transfer of large color bitmaps over I2C.
Man, this CS issue is killing me. If I hook the OLEDās CS pin to the Core it just doesnāt work correctly. Iāve tried toggling the CS pin before the SPI.transfer statement, Iāve tried toggling it in the main code before calling the display function and nothing works. I just get a corrupt line or something drawn on the screen. However, if I tie CS straight to ground it works fine. Iāve tried both digitalWrite and direct port manipulation, plus adding delays.
Fear not, Iāve got my logic out and Iām working it!
Will do, Iām going to grab some test data with the Logic real quick and try a couple more tricks,
If that doesnāt work Iāll send you some test code. Have you used Digoleās Image to C Array Tool on your custom image? What size is it and did you convert it in 256 Color or 262K Color modes? Finally, how much longer are you going to be around tonight?
Yep, I converted a 160 x 128 png with that tool to DEC format and stuck it all in a const uint8_t digole256[20480] = { 23,27,27,27,27,27,27,27,23,14,10,9, etc..}; itās big⦠seems too big, but Iām pretty confident this will be in Flash memory so Iām not worried.
That looks good except you should change your array like this: const unsigned char digole256[] = { 23,27,27,27,27,27,27,27,23,14,10,9, etc.. };
It does seem large, but it only takes up 20KB which still leaves a lot of space on the flash! Itās the 262K Color images that are too big for the onboard flash. Iāve found the biggest I can go is around 120x92. My plan is to add a function to display bitmaps compressed with Run Length Encoding, which should drastically decrease the space needed without sacrificing speed. Iād like to expand that to some sort of Golomb Entropy Encoding or a Burrows-Wheeler compression, possibly on top of the RLE (depending on how I implement it). Depending on the image this should let us losslessly bring a 60KB 262K Color Bitmap down to 6KB.
Sorry, I'm in the habit of using unsigned char in C since it's 8-bits and can be read as a byte (yay for weak types). But obviously uint8_t is a single byte as well. Anyway, yeah, you don't need to define the size of the array; I guess you can if you want but it's just extra work figuring it out. When you make the drawBitmap call you have to define the size (height and width) of the bitmap, so it handles the math for you.
Okay, so take a look at this:
Each of those blocks of data decodes just fine if I zoom in. The CS line is going low with plenty of buffer time. Can you see anything wrong with it?
@timb Just some quick feedback⦠you talk about CS and SS. They are one in the same right? Why not use SS as A2 since the SPI Class is already setting it to an output and setting it high. You obviously have to control it thereafter.
One other user found that when using a pin other than A2, it would only clock on the lower 3 bits of data (i.e. missing 5 clock transitions from bit 7 through bit 3. I have no idea why that would happen, and shouldnāt⦠but something to try.
Have you tried leaving the SS pin low from start to finish? Looking at the code I donāt see why it should matter though⦠typically you just have to wrap your transfers with SS low.
I know you said itās working if you just ground the SS pin, which leads me to believe it needs to be low sooner than it is. See if getting it low before the SCLK goes high matters/helps.
Just checking, you are using MODE0 right? I know I know, it works when SS is grounded⦠hmm.
Probably doesnāt mattery MUCH, but all pins are defined as uint16_t ⦠A0 actually equals 10 in decimal⦠again, probably doesnāt matter. #define CS A0 should work too.
Damn I think everyone in the world besides me has a Logic or Logic 16 -_- why not me?? hehehe
Yeah, CS and SS are both terms for Chip Select. We can use A2, but I'm using a separate pin just to verify everything is working right.
According to my Logic all the data is valid. Like I said in the last post, if I zoom in on those data blocks I can see the text commands (CL, EDIM3, etc.) plusā¦
It works if I tie CS low. Pulling it low before SCLK goes high is a good idea, let me try it.
MODE3, actually, which is the default SPI condition on the Spark Core anyway.
Look out for a private message shortly.
So my next step is to hook this to my Arduino and see how it works with their library. I'll report back shortly!
Yup, I had tried it earlier this evening and it flat out doesn't work. Like I said, it's working with the CS line tied low, so MODE3 is certainly the right way to go.
So it works just fine on the Arduino. Iām going to capture that with my Logic and compare the timing. An interesting thing I noticed about the stock Digole library is theyāre using shiftOut instead of the hardware SPI to communicate with the display. The Core has shiftOut support in the library now, right? Is it software based or does it run off the SPI interface?
If itās the former I could add a SoftSPI mode to the library so you could use it on a different pin set if needed. (Thatās something for down the road, just a thought!)
Well this is interesting⦠Hooked to the Arduino using the stock Digole Library and itās talking to the display using MODE0. But when I use MODE3 on the Spark Core it works fine.
Try MODE0 It looks like the only difference really between 3 and 0 is MODE3 is SLCK idle high, and MODE0 is SLCK idle low. SS does have to be low before you start to clock (i.e. transition away from idle state) so just by changing the mode it might be the fix.
@timb this is so lame, but I feel empowered that Iāve cleared my welcome display! xD Time to sleep bro, I hung in there til 1:06am. Tomorrow will be like Xmas morning!