I posted this also on the u8glib Forum, but Oliver Kraus answered that he has no idea what the Problem could be, so I'm asking here:
On the attached photo you can see the backsides of two 128x64 displays with ssd1306 controller.
The display color of the right one is white and the color of the left one is yellow/blue.
Both displays are working with hardware SPI on the ARDUINO DUE, but only the white ones (on the right of the photo) are working with the TEENSY3.0! I tried it with software SPI (native u8glib) and an own com procedure for hardware SPI, but only the white displays (I tested several displays of both types) are working on the Teensy3.0!?
I also tried it with a 3.7V (at present 4V) lipo battery, but with the same result! Adding a 1500uF capacitor also does not help.
I'm a bit confused now. I think that in this case it is unlikely that the badly (by me) soldered (TEENSY-)headers are the reason!?
Here's my com procedure for hw SPI on the TEENSY3.0 (it's a slightly modified version of this port: https://github.com/FriedCircuits/Ug8lib_Teensy):
and here's the test code:
On the attached photo you can see the backsides of two 128x64 displays with ssd1306 controller.
The display color of the right one is white and the color of the left one is yellow/blue.
Both displays are working with hardware SPI on the ARDUINO DUE, but only the white ones (on the right of the photo) are working with the TEENSY3.0! I tried it with software SPI (native u8glib) and an own com procedure for hardware SPI, but only the white displays (I tested several displays of both types) are working on the Teensy3.0!?
I also tried it with a 3.7V (at present 4V) lipo battery, but with the same result! Adding a 1500uF capacitor also does not help.
I'm a bit confused now. I think that in this case it is unlikely that the badly (by me) soldered (TEENSY-)headers are the reason!?
Here's my com procedure for hw SPI on the TEENSY3.0 (it's a slightly modified version of this port: https://github.com/FriedCircuits/Ug8lib_Teensy):
Code:
#if defined(__MK20DX256__)|| defined(__MK20DX128__)
#include <Arduino.h>
#include "u8glib.h"
#include <SPI.h>
uint8_t u8g_com_hw_spi_fn1(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
{
switch(msg)
{
case U8G_COM_MSG_STOP:
//STOP THE DEVICE
break;
case U8G_COM_MSG_INIT:
//INIT HARDWARE INTERFACES, TIMERS, GPIOS...
pinMode(3, OUTPUT);
//For hardware SPI
pinMode(10, OUTPUT);
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2);
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
// VDD (3.3V) goes high at start, lets just chill for a ms
delay(1);
// bring reset low
digitalWrite(2, LOW);
// wait 10ms
delay(10);
// bring out of reset
digitalWrite(2, HIGH);
//pinMode(MOSI, OUTPUT);
//pinMode(SCK, OUTPUT);
/*
clkport = portOutputRegister(digitalPinToPort(SCK));
clkpinmask = digitalPinToBitMask(SCK);
mosiport = portOutputRegister(digitalPinToPort(MOSI));
mosipinmask = digitalPinToBitMask(MOSI);
csport = portOutputRegister(digitalPinToPort(10));
cspinmask = digitalPinToBitMask(10);
dcport = portOutputRegister(digitalPinToPort(3));
dcpinmask = digitalPinToBitMask(3);
*/
break;
case U8G_COM_MSG_ADDRESS:
//SWITCH FROM DATA TO COMMAND MODE (arg_val == 0 for command mode)
if (arg_val != 0)
{
digitalWrite(3, HIGH);
}
else
{
digitalWrite(3, LOW);
}
break;
case U8G_COM_MSG_CHIP_SELECT:
if(arg_val == 0)
{
digitalWrite(10, HIGH);
}
else{
digitalWrite(10, LOW);
}
break;
case U8G_COM_MSG_RESET:
//TOGGLE THE RESET PIN ON THE DISPLAY BY THE VALUE IN arg_val
digitalWrite(2, arg_val);
break;
case U8G_COM_MSG_WRITE_BYTE:
//WRITE BYTE TO DEVICE
SPI.transfer(arg_val);
break;
case U8G_COM_MSG_WRITE_SEQ:
case U8G_COM_MSG_WRITE_SEQ_P:
{
//WRITE A SEQUENCE OF BYTES TO THE DEVICE
register uint8_t *ptr = static_cast<uint8_t *>(arg_ptr);
while(arg_val > 0){
SPI.transfer(*ptr++);
arg_val--;
}
}
break;
}
return 1;
}
#endif
and here's the test code:
Code:
#include <SPI.h>
#include <u8g_teensy.h>
#include "U8glib.h"
/* Create an instance of the library for the SSD1306 OLD display in SPI mode */
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 3, 2);
U8GLIB u8g(&u8g_dev_ssd1306_128x64_2x_hw_spi, u8g_com_hw_spi_fn1);
void setup(void)
{
u8g.setColorIndex(1);
u8g.setFont(u8g_font_fur30);
u8g.setFontPosTop();
}
int x = -30, a = 1;
void loop(void) {
x += a;
if (x > 100 || x < -30) a = -a;
u8g.firstPage();
do
{
u8g.drawStr(x, 0, "Hallo");
}
while(u8g.nextPage());
}