1

I´m using Spark Fun Micro Pro board 5V: https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro

and to that i´ve hooked a true color OLED from digole: http://www.digole.com/index.php?productID=859

Got a wire from OLED "data" to Pro micro "TX"-pin.

The OLED starts up and runs the start up screen, but the sample code I uploaded won't run. And that code looks like this:(the code is pretty long, if anybody would have a simplified sample code it would be much appreciated!! To get the OLED to show a simple "Hello World" would make me a very happy man! =)

Thanks!

#ifndef DigoleSerialDisp_h
#define DigoleSerialDisp_h

#include <inttypes.h>
#include "Print.h"
#include "Wire.h"
#include "Arduino.h"

// Communication set up command

// Text function command

// Graph function command

#define Serial_UART 0
#define Serial_I2C 1
#define Serial_SPI 2
#define _TEXT_ 0
#define _GRAPH_ 1

void setup() {}

void loop () {}

class DigoleSerialDisp : public Print {

public:
#if defined(_Digole_Serial_UART_)

DigoleSerialDisp(HardwareSerial1 *s, unsigned long baud) //UART set up

{

    _mySerial = s;

    _Baud = baud;

    _Comdelay=2;

}

size_t write(uint8_t value) {
    _mySerial->write((uint8_t)value);
    return 1; // assume sucess
}

void begin(void) {

    _mySerial->begin(9600);
    _mySerial->print("SB");
    _mySerial->println(_Baud);
    delay(100);
    _mySerial->begin(_Baud);

}

 #endif

 #if defined(_Digole_Serial_I2C_)


void begin(void) {
    _myWire->begin();
}


DigoleSerialDisp(TwoWire *s, uint8_t add) //U2C set up

{

    _myWire = s;
    _I2Caddress = add;
    _Comdelay=6;

}



size_t write(uint8_t value) {

    _myWire->beginTransmission(_I2Caddress);

    _myWire->write((uint8_t)value);
    _myWire->endTransmission();

    return 1; // assume sucess

}

#endif

#if defined(_Digole_Serial_SPI_)

void begin(void) {

}

DigoleSerialDisp(uint8_t pin_data, uint8_t pin_clock, uint8_t SS) //spi set up

{

    _Clockpin = pin_clock;
    _Datapin = pin_data;
    _SSpin = SS;

    pinMode(_Clockpin, OUTPUT);
    pinMode(_Datapin, OUTPUT);
    pinMode(_SSpin, OUTPUT);

    digitalWrite(_SSpin, HIGH);
    digitalWrite(_Clockpin, LOW);
    digitalWrite(_Datapin, LOW);

    _Comdelay=6;

}

size_t write(uint8_t value) {

    digitalWrite(_SSpin, LOW);
    digitalWrite(_SSpin, LOW);
    digitalWrite(_SSpin, LOW);

    shiftOut(_Datapin, _Clockpin, MSBFIRST, value);

    digitalWrite(_SSpin, HIGH);

    return 1; // assume sucess

}

#endif

//    virtual size_t write(uint8_t);

    /*---------fucntions for Text and Graphic LCD adapters---------*/


void disableCursor(void) {

    Print::print("CS0");

}



void enableCursor(void) {

    Print::print("CS1");

}



void clearScreen(void) {

    Print::print("CL");

}



void setI2CAddress(uint8_t add) {

    Print::print("SI2CA");

    write(add);

    _I2Caddress = add;

}



void displayConfig(uint8_t v) {

    Print::print("DC");

    write(v);

}

//print function



size_t println(const __FlashStringHelper *v) {

    preprint();

    Print::println(v);

    Print::print("\x0dTRT");

}



size_t println(const String &v) {

    preprint();

    Print::println(v);

    Print::println("\x0dTRT");

}



size_t println(const char v[]) {

    preprint();

    Print::println(v);

    Print::println("\x0dTRT");

}



size_t println(char v) {

    preprint();

    Print::println(v);

    Print::println("\x0dTRT");

}



size_t println(unsigned char v, int base = DEC) {

    preprint();

    Print::println(v, base);

    Print::println("\x0dTRT");

}



size_t println(int v, int base = DEC) {

    preprint();

    Print::println(v, base);

    Print::println("\x0dTRT");

}



size_t println(unsigned int v, int base = DEC) {

    preprint();

    Print::println(v, base);

    Print::println("\x0dTRT");

}



size_t println(long v, int base = DEC) {

    preprint();

    Print::println(v, base);

    Print::println("\x0dTRT");

}



size_t println(unsigned long v, int base = DEC) {

    preprint();

    Print::println(v, base);

    Print::println("\x0dTRT");

}



size_t println(double v, int base = 2) {

    preprint();

    Print::println(v, base);

    Print::println("\x0dTRT");

}



size_t println(const Printable& v) {

    preprint();

    Print::println(v);

    Print::println("\x0dTRT");

}



size_t println(void) {

    Print::println("\x0dTRT");

}



size_t print(const __FlashStringHelper *v) {

    preprint();

    Print::println(v);

}



size_t print(const String &v) {

    preprint();

    Print::println(v);

}



size_t print(const char v[]) {

    preprint();

    Print::println(v);

}



size_t print(char v) {

    preprint();

    Print::println(v);

}



size_t print(unsigned char v, int base = DEC) {

    preprint();

    Print::println(v, base);

}



size_t print(int v, int base = DEC) {

    preprint();

    Print::println(v, base);

}



size_t print(unsigned int v, int base = DEC) {

    preprint();

    Print::println(v, base);

}



size_t print(long v, int base = DEC) {

    preprint();

    Print::println(v, base);

}



size_t print(unsigned long v, int base = DEC) {

    preprint();

    Print::println(v, base);

}



size_t print(double v, int base = 2) {

    preprint();

    Print::println(v, base);

}



size_t print(const Printable& v) {

    preprint();

    Print::println(v);

}

void preprint(void);

/*----------Functions for Graphic LCD/OLED adapters only---------*/

//the functions in this section compatible with u8glib

void drawBitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const uint8_t *bitmap);

void drawBitmap256(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const uint8_t *bitmap);

void drawBitmap262K(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const uint8_t *bitmap);

void setTrueColor(uint8_t r, uint8_t g, uint8_t b);

void setRot90(void);

void setRot180(void);

void setRot270(void);

void undoRotation(void);

void setRotation(uint8_t);

void setContrast(uint8_t);

void drawBox(unsigned int x, unsigned int y, unsigned int w, unsigned int h);

void drawCircle(unsigned int x, unsigned int y, unsigned int r, uint8_t = 0);

void drawDisc(unsigned int x, unsigned int y, unsigned int r);

void drawFrame(unsigned int x, unsigned int y, unsigned int w, unsigned int h);

void drawPixel(unsigned int x, unsigned int y, uint8_t = 1);

void drawLine(unsigned int x, unsigned int y, unsigned int x1, unsigned int y1);

void drawLineTo(unsigned int x, unsigned int y);

void drawHLine(unsigned int x, unsigned int y, unsigned int w);

void drawVLine(unsigned int x, unsigned int y, unsigned int h);

//-------------------------------

//special functions for our adapters

void setFont(uint8_t font); //set font, availale: 6,10,18,51,120,123, user font: 200-203

void nextTextLine(void); //got to next text line, depending on the font size

void setColor(uint8_t); //set color for graphic function

void backLightOn(void); //Turn on back light

void backLightOff(void); //Turn off back light

void directCommand(uint8_t d); //send command to LCD drectly

void directData(uint8_t d); //send data to LCD drectly

void moveArea(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, char xoffset, char yoffset); //move a area of screen to another place
void drawStr(unsigned int x, unsigned int y, const char *s);
void setPrintPos(unsigned int x, unsigned int y, uint8_t =0 );
void setLCDColRow(uint8_t col, uint8_t row);

void setTextPosAbs(unsigned int x, unsigned int y);
void write2B(unsigned int v);


void displayStartScreen(uint8_t m) {

    Print::print("DSS");

    write(m);

} //display start screen



void setMode(uint8_t m) {

    Print::print("DM");

    write(m);

} //set display mode



void setTextPosBack(void) {

    Print::print("ETB");

} //set text position back to previous, only one back allowed



  void setTextPosOffset(char xoffset, char yoffset) {

    Print::print("ETO");

    write(xoffset);

    write(yoffset);

}



void setLinePattern(uint8_t pattern) {

    Print::print("SLP");

    write(pattern);

 }

void setLCDChip(uint8_t chip) {      //only for universal LCD adapter

    Print::print("SLCD");

    write(chip);

 }
void setBackLight(uint8_t bl){
    Print::print("BL");

    write(bl);

}

void uploadStartScreen(int lon, const unsigned char *data); //upload start screen

void uploadUserFont(int lon, const unsigned char *data, uint8_t sect); //upload user font

void digitalOutput(uint8_t x) {Print::print("DOUT");write(x);}

private:

unsigned long _Baud;

HardwareSerial *_mySerial;

uint8_t _I2Caddress;

TwoWire *_myWire;

uint8_t _Clockpin;

uint8_t _Datapin;

uint8_t _SSpin;

uint8_t _Comdelay;

};



#endif
VE7JRO
  • 2,554
  • 18
  • 25
  • 29
MrHaze
  • 81
  • 7
  • Are the SPI and I2C jumpers on the bottom disconnected? – Gerben May 07 '15 at 15:51
  • @Gerben, no haven't done that.. am I supposed to solder anything or how do I disconnect the jumpers? Thx – MrHaze May 08 '15 at 11:32
  • @Gerben I´m pretty new to this, as you can imagine, but aren't the jumpers supposed to be "open" when using UART according to the OLED´s jumper chart? – MrHaze May 08 '15 at 12:06
  • That's what I was getting at. Sometimes these jumpers are soldered, or there is still some copper between them. In the latter case you have to take a knife and scrape/cut away the copper trace between the jumper. Use a multimeter to check that both jumpers are open/disconnected. – Gerben May 08 '15 at 13:23
  • Got it to work. Found another sample code that did it! Thx for your time!! – MrHaze May 11 '15 at 11:31

0 Answers0