having trouble with the small oled on mbed.
've attached code. this doesnt produce anything on the display. i’ve gone through 3 displays now trying to see if they are broken.
[code]#include
#include “mbed.h”
#include <stdlib.h>
#define KLED LED1
DigitalOut led1(LED1);
#define KUARTBAUD 9600
#define KSPIBAUD 1000000
#define KMOSI SPI_PSELMOSI0 //p06
#define KMISO SPI_PSELMISO0 //p07
#define KSCLK SPI_PSELSCK0 //p08
SPI spi(KMOSI, KMISO, KSCLK);
#define KOLEDCS P0_3
#define KOLEDRESET P0_4
#define KOLEDDC P0_5
DigitalOut reset(KOLEDRESET);
DigitalOut cs(KOLEDCS);
DigitalOut dc(KOLEDDC);
Serial pc(USBTX, USBRX);
int main(void) {
pc.baud(KUARTBAUD);
wait_ms(100);
pc.printf("\n");
reset = 0;
cs = 1;
dc = 0;
spi.format(8, 0); // 8 Bit wide SPI and Mode (0 - 3)
spi.frequency(KSPIBAUD); // SPI speed in Hz
// two methods of reset
#if 1 // by reset pin
reset = 0;
reset = 1;
wait_ms(1);
reset = 0;
wait_ms(100);
reset = 1;
wait_ms(1);
#else // by oled command
cs = 0;
dc = 0;
pc.printf(“01 %d\n”, spi.write(0x01));
// cs = 1;
#endif
wait_ms(100);
cs = 0;
// standby off
dc = 0;
pc.printf("14 %d\n", spi.write(0x14));
dc = 1;
pc.printf("00 %d\n", spi.write(0x00));
wait_ms(0);
cs = 1;
wait_ms(0);
cs = 0;
dc = 0;
pc.printf("30 %d\n", spi.write(0x30));
dc = 1;
pc.printf("00 %d\n", spi.write(0x00));
pc.printf("3b %d\n", spi.write(0x3b));
wait_ms(0);
cs = 1;
wait_ms(0);
cs = 0;
dc = 0;
pc.printf("32 %d\n", spi.write(0x32));
dc = 1;
pc.printf("00 %d\n", spi.write(0x00));
pc.printf("1f %d\n", spi.write(0x1f));
wait_ms(0);
cs = 1;
wait_ms(0);
#if 1
// draw image
cs = 0;
dc = 0;
pc.printf(“08 %d\n”, spi.write(0x08));
dc = 1;
for (int i=0;i<240;i++) {
pc.printf("-- %d\n", spi.write(i));
}
cs = 1;
wait_ms(0);
#endif
// display on
cs = 0;
dc = 0;
pc.printf("02 %d\n", spi.write(0x02));
dc = 1;
pc.printf("01 %d\n", spi.write(0x01));
cs = 1;
wait_ms(0);
while (1) {
led1 = !led1;
// draw image
cs = 0;
dc = 0;
spi.write(0x08);
dc = 1;
for (int i=0;i<240;i++) {
spi.write(i);
}
cs = 1;
wait_ms(100);
}
}
[/code]