Change of code for larger, 1.3"-OLED-display (u8glib)

Hi all

I have a code from instructables.com to drive a led-light. What I did is I replaced the 1", 128x64, I2C Oled-Display with a 1.3" (128x64 and also I2C).
Now I'd like to change the code for the larger display because the circuit does not perfom really well at the moment. The display is really slow, and so are the commands (rotary switch and button). I have to admit that of course the code is kind of large. But maybe a code change might help.

I'm not really familiar with u8glib and the identifiers and so on. So I'm asking you guys.
Thanks already.

Laurin

VideoLight1.3.ino (21.2 KB)

It's easier for those of us on mobile devices if you post your code, in code tags.

Did you use u8glib or u8g2? For u8g2, only the software I2C emulation is used. This should be changed to HW I2C.

Oliver

AWOL:
It's easier for those of us on mobile devices if you post your code, in code tags.

It's too big :wink: Unless the 9000 character limit was dropped.

The code uses u8glib..

sterretje:
It's too big :wink: Unless the 9000 character limit was dropped.

At which point you ask yourself how the code got so big without testing the basics. :wink:

laurin123:
The code uses u8glib..

Then the next question is: Which Arduino Board do you use? The old u8glib will fallback to software I2C if the board is not an Arduino Uno or Mega.

Oliver

I programmed it the atmega328 via ISP. Its a circuit without any arduino board

laurin123:
I programmed it the atmega328 via ISP. Its a circuit without any arduino board

But you use Arduino IDE? If so, it should use Hardware I2C and the reason for the slow response is probably something else.

Oliver

Yes I use Arduino IDE. The thing is that the circuit runs fast and smooth with the 1" display..

Strange. There should be no difference.

Oliver

AWOL:
At which point you ask yourself how the code got so big without testing the basics. :wink:

Usually 5 minutes of cutting and pasting. :slight_smile:

Usually 5 minutes of cutting and pasting.

What do you mean by that?

I actually made the code about 5% shorter but the response of the display is still slow..

Ok, I found out that my u8glib-library should be defined for the SH1106 controller instead of the SSD1306. The 1.3" display has most likely the SH1106 controller on it and that's probably the reason for the frozen display. But unfortunately I don't know how to change the lines. Any help is very much appreciated!
I'm gonna post the sections that need to be changed:

Section 1

//Input and Output
#define BUTTON1 8
#define BUTTON_ON 7
#define DT 2
#define CLK 3

#define COLD 9
#define WARM 10

#define OLED_RESET 4

[color=yellow]
//U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE);  // I2C / TWI[/color]

class Button
{

Section 2

RotEnc rotenc;
[color=yellow]U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_FAST);[/color]
Screen screen;
Button button1(BUTTON1);
Button buttonOn(BUTTON_ON);
Light light(WARM, COLD);
Thermistor therm1(0);
Thermistor therm2(1);
//Thermistor therm3(2);
Voltage volt1(3);

void setup() {
  // put your setup code here, to run once:
  TCCR1B = (TCCR1B & 0b11111000) | 0x01;
  light.begin();
  Serial.begin(9600);
  button1.begin(true);
  buttonOn.begin(true)

Section 3

//Screen-methods

Screen::Screen() {
#ifndef u8glib_h
#define u8glib_h
#include <u8glib.h>
#endif
[color=yellow]  //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE);  // I2C / TWI
  //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_FAST);  // Dev 0, Fast I2C / TWI
  U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NO_ACK);  // Display which does not send ACK[/color]
  _valueChange = true;
  _showBigText = false;
  _showBat = false;
  _showBottom = false;
  _showCaption = false;