Go Down

Topic: i2c SP1106 OLED Slow refresh on UNO (Read 290 times) previous topic - next topic

olikraus

I once used a  SSD1327 with more than 100kHz. It did not work.
So in the library, it is currently fixed to 100KHz.Not sure what is written in the datasheet for the SSD1306.

Oliver

paulsvang

#16
Dec 20, 2014, 01:21 am Last Edit: Dec 20, 2014, 01:22 am by paulsvang
I changed the frequency from the file u8g_com_i2c.c file on line 126 from 100khz to 400khz and that improved the refresh rate.  It's running quite fast now. 

 
Code: [Select]
TWBR = F_CPU/(2*400000)-8;

Thanks again Oliver for such a great library!

Paul

jboyton

Both the 1306 and 1106 are rated to 400 KHz for the I2C clock.

olikraus

#18
Dec 20, 2014, 08:06 am Last Edit: Dec 20, 2014, 09:28 am by olikraus
ok, good to know that 400KHz are working.

Oliver

Edit: I have created an issue for this: https://code.google.com/p/u8glib/issues/detail?id=303

paulsvang

#19
Dec 20, 2014, 10:41 am Last Edit: Dec 20, 2014, 10:43 am by paulsvang
Jboyton / Oliver,


I have another question.  Would it be possible for the numbers to be right aligned?  I'm have an issue with the numbers shifting one point from 9.9 to 10.0.

I'm using the code below but if var1 hits the spot where it can't make up it's mind and is shifting from 9.9 to 10.0, the numbers shift back in forth.  If it was aligned from the right side, I wouldn't have this problem.  Or if you know another way to adjust this issue, that would be great.

The setPrintPos is setup so that the decimal point is aligned when var1 is below 10 or above 10.
Code: [Select]
  if (var1 < 10) {
    u8g.setPrintPos(43, 64);
    u8g.print(var1,1);
  }   
  else {
    u8g.setPrintPos(20, 64);
    u8g.print(var1,1);
  }


Paul

JimboZA

#20
Dec 20, 2014, 11:18 am Last Edit: Dec 20, 2014, 11:19 am by JimboZA
You need a variation of the "print2digits" approach in the RTC1307 library (and other places) where it prints (say) 7 as 07. You just need a leading space instead of the leading 0 then your display will always have the same length.

I attach example code in case you don't have it.
"Could you do the egg bacon spam and sausage without the spam then? "

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.

olikraus

Together with the suggestion from JimboZA, you may need a monospaced font in u8glib. For example the x11 fonts might be suitable (https://code.google.com/p/u8glib/wiki/fontgroup).

Oliver

paulsvang

JimboZA & Oliver,

I've tried both approach but can't see to get this issue resolved.   I've also tried it with a leading "0" if the value is less than 10 and it keeps shifting.  If I go past the "10" or "9.9" value then it seems okay but if I get a value with those values, it shifts back and forth.  See the video link. 

FYI I'm turning the variable resistor.


https://www.youtube.com/watch?v=XtMIdmGowHU&list=UUdE8gW28m5yE6cwyLfkfgLA


olikraus

Strange. Can you attach your code?

Oliver

paulsvang

Oliver,

Here's the code.  Let me know what you find. 

Thanks

Paul


Code: [Select]
#include "U8glib.h"
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NO_ACK); // Display which does not send ACK

float var1;

void draw(void) {
  u8g.setFont(u8g_font_fub30n);

  if (var1 < 10) {
    u8g.setPrintPos(43, 64);
    u8g.print(var1,1);
  }   
  else {
    u8g.setPrintPos(20, 64);
    u8g.print(var1,1);
  }
}

void setup(void) {

  pinMode(A0, INPUT);
  u8g.setColorIndex(1);         // pixel on
}

void loop(void) {

  var1 = (float)(analogRead(A0))*(44-0)/(1023-0)+0; 

  // picture loop
  u8g.firstPage();

  do {
    draw();
  } while( u8g.nextPage() );

}

olikraus

 Hi

I think it is a rounding error: 9.99999 < 10 might be true, but print(9.99999,1) could become 10.0.
Use dtostrf to convert the float to a string first.
This function includes an alignment of the number.

Oliver

paulsvang

Great insight Oliver.  I'll give it a go and see what it does.

Paul

Go Up