Welcome! Log In Create A New Profile

Advanced

AdaFruit OLED display in Repetier Firmware

Posted by kscharf 
AdaFruit OLED display in Repetier Firmware
January 01, 2015 06:21PM
I'm looking at building a display for my RepRap Wilson using an Adafruit OLED display. These tiny displays are very readable due to their high contrast. They use an SSD1306 controller that is supported by the U8GLIB used in Repetier Firmware. It looks like the following changes will add this support:

UI.cpp ~ line 617

#if UI_DISPLAY_TYPE == DISPLAY_U8G
//u8glib support two different controllors, wired the same way.
#ifdef U8GLIB_ST7920 || defined(U8GLIB_SSD1306)
#define UI_SPI_SCK UI_DISPLAY_D4_PIN
#define UI_SPI_MOSI UI_DISPLAY_ENABLE_PIN
#define UI_SPI_CS UI_DISPLAY_RS_PIN
#endif
#include "u8glib_ex.h"


UI.cpp ~ line 709

void initializeLCD()
{
#ifdef U8GLIB_ST7920
//U8GLIB_ST7920_128X64_1X u8g(UI_DISPLAY_D4_PIN, UI_DISPLAY_ENABLE_PIN, UI_DISPLAY_RS_PIN);
u8g_InitSPI(&u8g,&u8g_dev_st7920_128x64_sw_spi, UI_DISPLAY_D4_PIN, UI_DISPLAY_ENABLE_PIN, UI_DISPLAY_RS_PIN, U8G_PIN_NONE, U8G_PIN_NONE);
#endif
#ifdef U8GLIB_SSD1306
u8g_InitSPI(&u8g,&u8g_dev_ssd1306_128x64_sw_spi, UI_DISPLAY_D4_PIN, UI_DISPLAY_ENABLE_PIN, UI_DISPLAY_RS_PIN, U8G_PIN_NONE, U8G_PIN_NONE);
#endif

Somewhere instead of defining U8GLIB_ST7920, the new item U8GLIB_SSD1306 must be defined instead.

I think this will be all that is necessary to use the OLED controller. It will be wired up the same way as the ST7920 one is.
I'd like to look into using the HW spi support of the library, but I don't know if the LCD and the SD card can share the SPI interface. Two different CS lines are used, so if the existing SD driver behaves correctly (Releasing the CS when not in use) and the LCD library does the same it SHOULD work.
Re: AdaFruit OLED display in Repetier Firmware
January 03, 2015 04:26AM
There is one more thing to consider:

u8glib_ex.h

Is a file containing all u8glib files. But it does not contain all drivers from u8glib. So I guess you have to copy the U8GLIB_SSD1306 driver files into that file as well.

Using the hardware SPI can work or not. The display could use a different speed or different SPI mode. Not sure if they get reset every time the sd card requests some byte. But at least sd card and display are managed in the same main thread so only one of them wants spi access at a time.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: AdaFruit OLED display in Repetier Firmware
January 03, 2015 10:42AM
Another thing I need to figure out is what to add to configuration.h to force it to actually build for the display. I might have to build a config file from the on line tool containing the reprapdiscount graphical display, and then modify the other files to use the SSD1306 instead. I can tell by the size of the built image that my attempt at including the display in the build failed, it should be around 120K or greater in size, and was only 70K. (I left out eeprom support too).
Re: AdaFruit OLED display in Repetier Firmware
January 04, 2015 03:56AM
You need to add a new section in ui.h with a unused

#if FEATURE_CONTROLER == 17

#endif

where you put you definitions in. Then set FEATURE_CONTROLLER to that number by hand since it is not in the configs list.
You can add a
#error would compile
inside it to test if it compiles that section. The error will abort so remove it once you know that part gets compiled.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Sorry, only registered users may post in this forum.

Click here to login