- Thu Nov 06, 2008 4:35 am
#58461
I don't see anything really out of the ordinary in your code that sticks out as a "Aha! There's your problem!" I will say that you don't need to send the "write RAM" command after each byte nor should you need to send a NOP.
As a general speed test, maybe you can try something like this:
robodude666 wrote:Hey,Certainly is quite strange, isn't it? I really think the OLED "freaking out" is actually the processor itself going wonky and sending nonsense to the OLED.
Yea.. It is rather weird. Using a char *pointer method I can write up to 14 characters before the OLED freaks out, while a predefined char array[] allows me to draw 11 characters before it freaks out. Funny thing, is char array[] = "TEXT" only allows for up to 7 characters. If I manually set array[0] = 'A' then I can do 11 characters. It is very weird. Never seen anything like this.. I know I have enough memory because I'm using only 6kB out of 14KB that my ATmega168 has.
AH! So that is what the set col and set row address commands are for? You can set the location of where the ram command will start writing from? I thought they were only for initing the OLED. I'll have to read up on them and give them a try. So if I understand correctly... I can, for example, start at 0, 0 and fill the screen with BMP background image. Then use the commands to move around and draw little icon images with lighting fast speed? Excellent! I'll look into it some more.Yes, exactly. And what's really cool is that when you set it up, you set for a row (or col) increment after each write and so when you do a full-screen write, you just write 16K worth of data, as you've done. When you create a region as I call it, the same principle applies. So for a 15x15 bitmap, it'll do 15 pixels across and then reset to the start column of the region, bumping the row by one. With icons like this, and the use of "dirty" flags indicating what needs updating, you can save alot of time by only drawing what actually needs updating.
I don't see anything really out of the ordinary in your code that sticks out as a "Aha! There's your problem!" I will say that you don't need to send the "write RAM" command after each byte nor should you need to send a NOP.
As a general speed test, maybe you can try something like this:
Code: Select all
Does this run any differently? //make sure start col and row commands issued
//with 0,0 - 127,127 as parms before getting here
digitalWrite(DC, LOW);
send_8bit_serial_data(0x5c); //write ram
//put data for blue pixel at port just once
for(int i = 0; i < 8; i++){
digitalWrite(D[i], (0xe0 & (1 << i)));
digitalWrite(DC, HIGH);
digitalWrite(CS, LOW); //CS(0);
digitalWrite(RW, LOW); //RW(0);
//now pulse the RW line to fill screen
for(int i = 0; i < 16900; i++){
digitalWrite(RW, HIGH);
//may need to wait 60nS min here if processor speedy
digitalWrite(RW, LOW);
//may need to wait 60nS min here if processor speedy
}
digitalWrite(CS, HIGH); //CS(1);
Could writing it in ASM give you that much of a boost in performance? Previously, when stuff worked, I could write 40 (7 x 5px) characters in under 700mS to the screen.I shouldn't think so. I'm sure if you were to look at the resulting machine code generated by your C compiler you'd see it had done a decent job and created pretty clean code. Then again, if it's taking nearly a second to write out just 1400 pixels (5x7x40) when it's theoretically possible to write 16000 pixels in less than 2mS, something's wrong. How fast is the processor itself running? Can you set up, say, an LED to blink (i.e. port pin toggle) at 4Hz and actually get that?