0.5" oled non-arduino

Ardiuno Compatible shields

Moderators: lily.li, violet

Post Reply
vetorala
Pre-kindergarten
Pre-kindergarten
Posts: 3
Joined: Wed Mar 21, 2018 11:22 am

0.5" oled non-arduino

Post by vetorala » Mon Aug 06, 2018 8:20 am

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: Select all

#include <algorithm>
#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);

	}
}

bill.yu
Junior-7
Junior-7
Posts: 735
Joined: Mon Apr 02, 2018 11:05 am

Re: 0.5" oled non-arduino

Post by bill.yu » Mon Aug 06, 2018 7:01 pm

Hi there,

do you have a link about the oled? So we can check if we have and we can test it. thanks,

best rgds
Bill

vetorala
Pre-kindergarten
Pre-kindergarten
Posts: 3
Joined: Wed Mar 21, 2018 11:22 am

Re: 0.5" oled non-arduino

Post by vetorala » Tue Aug 07, 2018 12:13 am


bill.yu
Junior-7
Junior-7
Posts: 735
Joined: Mon Apr 02, 2018 11:05 am

Re: 0.5" oled non-arduino

Post by bill.yu » Tue Aug 07, 2018 7:35 pm

Hi there,
Have you followed by http://www.seeedstudio.com/document/pdf ... ide%20.pdf? If you still can't solve the issue by the instructions, please drop mail to designer tom@rxxdisplay.com. thanks.

Bill

Post Reply