10 years, 11 months ago.

FRDM-KL25Z I2C Problem

Hi, I am using a Digole OLED display connected via I2C. I found a library on this site for controlling the display. http://mbed.org/users/shimniok/code/DigoleSerialDisp/

This works fine when using my LPC1768 mbed, but not when using the FRDM-KL25Z. I have got pullups on the I2C bus and can write basic text to the OLED from the FDRM board, but when I try any other commands it doesn't work and locks up in the I2C writing function somewhere. Is is something to do with when it is writing binary data? Text characters are fine, but to even tell it to position the text position to the next line down it doesn't work.

Everything is fine on the LPC1768 and I can draw circles and line etc.

Can anyone suggest what is wrong with the I2C control on the FRDM-KL25Z library? I can resort to an I2C analyser but this will be a last resort!

Regards Phil.

2 Answers

10 years, 9 months ago.

Hi Phil, do you have the code for the LPC1768? I'm not sure how define the interface to get going, I have a KL25Z so will try my end once its working. Paul

Phil Green
poster
10 years, 9 months ago.

Hi Paul, I had to alter the DigoleSerialDisp library to get it working on the KL25Z, this is because of a problem in the I2C library for the KL25Z. My code is attached below.

main.cpp

#include "mbed.h"
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "DigoleSerialDisp.h"

DigoleSerialDisp myOLED(PTE0, PTE1, 0x27);
DigitalOut myled(LED1);



int main() {
int i;
char ac[30];
    i = 0;
    myOLED.clearScreen();
    myOLED.println("Quad");
    myOLED.nextTextLine();
    myOLED.println("Altimeter");
    wait(2);
    while(1) {
        myled = 1;
        wait(0.01);
        //myOLED.setPrintPos(0,2,_TEXT_);
        //myOLED.println("                ");
        myOLED.setPrintPos(0,2,_TEXT_);
        sprintf(ac,"Count: %5dM", i++);
        //myOLED.clearScreen();
        myOLED.println(ac);
        //myOLED.drawBox(0,0,10,10);
        myled = 0;
    }
}

DigoleSerialDisp.cpp

/** Digole Serial Display library
 *
 * @Author: Digole Digital Solutions : www.digole.com ported to mbed by Michael Shimniok www.bot-thoughts.com
 */
 
#include "mbed.h"
#include "DigoleSerialDisp.h"
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

char null = 0;


// that resetting the Arduino doesn't reset the LCD, so we
// can't assume that its in that state when a sketch starts (and the
// LiquidCrystal constructor is called).

//UART function

char buf[128];
char tmp[128];

DigoleSerialDisp::DigoleSerialDisp(PinName sda, PinName scl, uint8_t address):
    _device(sda, scl)
{
    _address = (address<<1);
    _device.frequency(100000);
    _Comdelay=70;
}

size_t DigoleSerialDisp::write(const char x)
{
    _device.write(_address, (char *) &x, 1);
    _device.stop();
    return 1;
}

size_t DigoleSerialDisp::write(const char *str) 
{
    if (str == NULL) return 0;
    return write(str, strlen(str));
}
    
size_t DigoleSerialDisp::write(const char *buffer, size_t size)
{
    int len = 0;
    if (buffer != NULL) {
        _device.write(_address, (char *) buffer, size);
        len = size;
        delay(7);
        _device.stop();
    }
    return len;
}


size_t DigoleSerialDisp::print(const char c)
{
    buf[0] = 'T';
    buf[1] = 'T';
    buf[2] = c;
    buf[3] = 0;
    write(buf);
    write(null);
    return 1;
}

size_t DigoleSerialDisp::print(const char s[])
{
    int len = strlen(s);

    if (s == NULL) return 0;

    buf[0] = 'T';
    buf[1] = 'T';
    buf[2] = 0;
    strncat(buf, s, 125);
    write(buf);
    write(null);
    return len;
}

size_t DigoleSerialDisp::println(const char s[])
{
    return print(s);
}

/*
 Print.cpp - Base class that provides print() and println()
 Copyright (c) 2008 David A. Mellis.  All right reserved.
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.
 
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 Modified 23 November 2006 by David A. Mellis
 */

size_t DigoleSerialDisp::print(unsigned char b, int base)
{
  return print((unsigned long) b, base);
}

size_t DigoleSerialDisp::print(int n, int base)
{
  return print((long) n, base);
}

size_t DigoleSerialDisp::print(unsigned int n, int base)
{
  return print((unsigned long) n, base);
}

size_t DigoleSerialDisp::print(long n, int base)
{
  if (base == 0) {
    return write(n);
  } else if (base == 10) {
    if (n < 0) {
      int t = print('-');
      n = -n;
      return printNumber(n, 10) + t;
    }
    return printNumber(n, 10);
  } else {
    return printNumber(n, base);
  }
}

size_t DigoleSerialDisp::print(unsigned long n, int base)
{
  if (base == 0) return write(n);
  else return printNumber(n, base);
}

size_t DigoleSerialDisp::print(double n, int digits)
{
  return printFloat(n, digits);
}

size_t DigoleSerialDisp::println(unsigned char b, int base)
{
  size_t n = print(b, base);
  n += println();
  return n;
}

size_t DigoleSerialDisp::println(int num, int base)
{
  size_t n = print(num, base);
  n += println();
  return n;
}

size_t DigoleSerialDisp::println(unsigned int num, int base)
{
  size_t n = print(num, base);
  n += println();
  return n;
}

size_t DigoleSerialDisp::println(long num, int base)
{
  size_t n = print(num, base);
  n += println();
  return n;
}

size_t DigoleSerialDisp::println(unsigned long num, int base)
{
  size_t n = print(num, base);
  n += println();
  return n;
}

size_t DigoleSerialDisp::println(double num, int digits)
{
  size_t n = print(num, digits);
  n += println();
  return n;
}

size_t DigoleSerialDisp::println(void) 
{
    return 1;
}

// Private Methods /////////////////////////////////////////////////////////////

size_t DigoleSerialDisp::printNumber(unsigned long n, uint8_t base) {
  char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
  char *str = &buf[sizeof(buf) - 1];

  *str = '\0';

  // prevent crash if called with base == 1
  if (base < 2) base = 10;

  do {
    unsigned long m = n;
    n /= base;
    char c = m - base * n;
    *--str = c < 10 ? c + '0' : c + 'A' - 10;
  } while(n);

  return write(str);
}

size_t DigoleSerialDisp::printFloat(double number, uint8_t digits) 
{ 
  size_t n = 0;
  
  if (isnan(number)) return print("nan");
  if (isinf(number)) return print("inf");
  if (number > 4294967040.0) return print ("ovf");  // constant determined empirically
  if (number <-4294967040.0) return print ("ovf");  // constant determined empirically
  
  // Handle negative numbers
  if (number < 0.0)
  {
     n += print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  n += print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0) {
    n += print("."); 
  }

  // Extract digits from the remainder one at a time
  while (digits-- > 0)
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    n += print(toPrint);
    remainder -= toPrint; 
  } 
  
  return n;
}

/*---------functions for Text and Graphic LCD adapters---------*/
void DigoleSerialDisp::disableCursor(void) 
{
    write("CS");
    write(null);
}

void DigoleSerialDisp::enableCursor(void) 
{
    write("CS");
    write(1);
}

void DigoleSerialDisp::drawStr(uint8_t x, uint8_t y, const char *s) 
{
    write("TP");
    write(x);
    write(y);
    write("TT");
    write(s);
    write(null);
}

void DigoleSerialDisp::setPrintPos(uint8_t x, uint8_t y, uint8_t graph) 
{
    if (graph == _TEXT_) {
        write("TP");
        write(x);
        write(y);
    } else {
        write("GP");
        write(x);
        write(y);
    }
}

void DigoleSerialDisp::clearScreen(void) 
{
    //write(null);
    write("CL");
}

void DigoleSerialDisp::setLCDColRow(uint8_t col, uint8_t row) 
{
    write("STCR");
    write(col);
    write(row);
    write("\x80\xC0\x94\xD4");
}

void DigoleSerialDisp::setI2CAddress(uint8_t add) 
{
    write("SI2CA");
    write(add);
    _address = (add<<1);
}

void DigoleSerialDisp::displayConfig(uint8_t v) 
{
    write("DC");
    write(v);
}

void DigoleSerialDisp::preprint(void) 
{
    //print("TT");
}

/*----------Functions for Graphic LCD/OLED adapters only---------*/
void DigoleSerialDisp::drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *bitmap) {
    uint8_t i = 0;
    if ((w & 7) != 0)
        i = 1;
    write("DIM");
    write(x); //x;
    write(y);
    write(w);
    write(h);
    for (int j = 0; j < h * ((w >> 3) + i); j++) {
        write( (const char *) (bitmap+j) );
        delay(1);
    }
}

void DigoleSerialDisp::setRot90(void) {
    write("SD1");
}

void DigoleSerialDisp::setRot180(void) {
    write("SD2");
}

void DigoleSerialDisp::setRot270(void) {
    write("SD3");
}

void DigoleSerialDisp::undoRotation(void) {
    write("SD0");
}

void DigoleSerialDisp::setRotation(uint8_t d) {
    write("SD");
    write(d);
}

void DigoleSerialDisp::setContrast(uint8_t c) {
    write("CT");
    write(c);
}

void DigoleSerialDisp::drawBox(uint8_t x, uint8_t y, uint8_t w, uint8_t h) {
    write("FR");
    write(x);
    write(y);
    write(x + w);
    write(y + h);
}

void DigoleSerialDisp::drawCircle(uint8_t x, uint8_t y, uint8_t r, uint8_t f) {
    write("CC");
    write(x);
    write(y);
    write(r);
    write(f);
}

void DigoleSerialDisp::drawDisc(uint8_t x, uint8_t y, uint8_t r) {
    drawCircle(x, y, r, 1);
}

void DigoleSerialDisp::drawFrame(uint8_t x, uint8_t y, uint8_t w, uint8_t h) {
    write("DR");
    write(x);
    write(y);
    write(x + w);
    write(y + h);
}

void DigoleSerialDisp::drawPixel(uint8_t x, uint8_t y, uint8_t color) {
    write("DP");
    write(x);
    write(y);
    write(color);
}

void DigoleSerialDisp::drawLine(uint8_t x, uint8_t y, uint8_t x1, uint8_t y1) {
    write("LN");
    write(x);
    write(y);
    write(x1);
    write(y1);
}

void DigoleSerialDisp::drawLineTo(uint8_t x, uint8_t y) {
    write("LT");
    write(x);
    write(y);
}

void DigoleSerialDisp::drawHLine(uint8_t x, uint8_t y, uint8_t w) {
    drawLine(x, y, x + w, y);
}

void DigoleSerialDisp::drawVLine(uint8_t x, uint8_t y, uint8_t h) {
    drawLine(x, y, x, y + h);
}

void DigoleSerialDisp::nextTextLine(void) {
    write(null);
    write("TRT");
}

void DigoleSerialDisp::setFont(uint8_t font) {
    write("SF");
    write(font);
}

void DigoleSerialDisp::setColor(uint8_t color) {
    write("SC");
    write(color);
}

void DigoleSerialDisp::backLightOn(void) {
    write("BL");
    write(1);
}

void DigoleSerialDisp::backLightOff(void) {
    write("BL");
    write(null);
}

void DigoleSerialDisp::directCommand(uint8_t d) {
    write("MCD");
    write(d);
}

void DigoleSerialDisp::directData(uint8_t d) {
    write("MDT");
    write(d);
}

void DigoleSerialDisp::moveArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, char xoffset, char yoffset) {
    write("MA");
    write(x0);
    write(y0);
    write(x1);
    write(y1);
    write(xoffset);
    write(yoffset);
}


void DigoleSerialDisp::displayStartScreen(uint8_t m) {
    write("DSS");
    write(m);
} //display start screen


void DigoleSerialDisp::setMode(uint8_t m) {
    write("DM");
    write(m);
} //set display mode


void DigoleSerialDisp::setTextPosBack(void) {
    write("ETB");
} //set text position back to previous, only one back allowed


void DigoleSerialDisp::setTextPosOffset(char xoffset, char yoffset) {
    write("ETO");
    write(xoffset);
    write(yoffset);
}


void DigoleSerialDisp::setTextPosAbs(uint8_t x, uint8_t y) {
    write("ETP");
    write(x);
    write(y);
}


void DigoleSerialDisp::setLinePattern(uint8_t pattern) {
    write("SLP");
    write(pattern);
}


void DigoleSerialDisp::setLCDChip(uint8_t chip) {      //only for universal LCD adapter
    write("SLCD");
    write(chip);
}


void DigoleSerialDisp::uploadStartScreen(int lon, const unsigned char *data) 
{
    int j;
    uint8_t c;
    write("SSS");
    write((uint8_t) (lon % 256));
    write((uint8_t) (lon / 256));
    for (j = 0; j < lon;j++) {
        if((j%32)==0)
            delay(10);
        delay(_Comdelay);
        c = data[j];
        write(c);
    }
}


void DigoleSerialDisp::uploadUserFont(int lon, const unsigned char *data, uint8_t sect) {
    uint8_t c;
    write("SUF");
    write(sect);
    write((uint8_t) (lon % 256));
    write((uint8_t) (lon / 256));
    for (int j = 0; j < lon; j++) {
        if((j%32)==0)
            delay(10);
        delay(_Comdelay);
        c = data[j];
        write(c);
    }
}

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

DigoleSerialDisp.h

/** Digole Serial Display library, I2C
 *
 * @Author: Digole Digital Solutions : www.digole.com ported from Arduino to mbed by Michael Shimniok www.bot-thoughts.com
 */
#ifndef DigoleSerialDisp_h
#define DigoleSerialDisp_h
 
#include "mbed.h"
#include <inttypes.h>
 
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
 
#define delay(x) wait_ms(x)
 
// 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
 
/** Digole Serial LCD/OLED Library
 * www.digole.com/index.php?productID=535
 *
 * Includes Arduino Print class member functions
 */
class DigoleSerialDisp {
public:
 
    /** Create a new Digole Serial Display interface
     *
     * @param sda is the pin for I2C SDA
     * @param scl is the pin for I2C SCL
     * @param address is the 7-bit address (default is 0x27 for the device)
     */
    DigoleSerialDisp(PinName sda, PinName scl, uint8_t address=0x27);
 
 
    /** Carryover from Arduino library, not needed
     */
    void begin(void) { } // nothing to do here
 
 
    /** Write out a raw character
     * @param x is the character to write
     * @returns 1
     */
    size_t write(const char x);
 
 
    /** Write out raw data from a buffer
     * @param buffer is the char array to write
     * @param size is the the number of bytes to write
     * @returns size
     */
    size_t write(const char *buffer, size_t size);
 
 
    /** Write out raw string
     * @param str is the string to write
     * @returns number of bytes written
     */
    size_t write(const char *str);
   
   
    /** Prints a char to the display in a single I2C transmission using "TTb\0"
     *
     * @param c is the character to print
     * @returns 1
     */
    size_t print(const char c);
 
 
    /** Prints a string of data to the display in a single I2C transmission using "TTbbb...\0"
     *
     * @param s is the null-terminated char array to print
     * @returns length of s 
     */
    size_t print(const char s[]);
 
 
    /** Print out an unsigned char as a number
     * @param u is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t print(unsigned char u, int base = DEC);
 
 
    /** Print out an integer
     * @param i is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t print(int i, int base = DEC);
 
 
    /** Print out an unsigned integer
     * @param u is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t print(unsigned int u, int base = DEC);
    
 
    /** Print out a long as a number
     * @param l is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t print(long l, int base = DEC);
    
 
    /** Print out an unsigned long
     * @param l is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t print(unsigned long l, int base = DEC);
 
 
    /** Print out a double
     * @param f is the integer to print
     * @param digits is the number of digits after the decimal
     */
    size_t print(double f, int digits = 2);
 
 
    /** Prints a string of data to the display in a single I2C transmission using "TTbbb...\0"
     *
     * @param s is the null-terminated char array to print
     * @returns length of s 
     */
    size_t println(const char s[]);
 
 
    /** Prints a char the display in a single I2C transmission using "TTb\0"
     *
     * @param c is the character to print
     * @returns 1
     */
    size_t println(char c);
 
 
    /** Prints an unsigned char as a number
     *
     * @param u is the unsigned char number
     * @returns 1
     */
    size_t println(unsigned char u, int base = DEC);
 
 
    /** Print out an integer
     * @param i is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t println(int i, int base = DEC);
 
 
    /** Print out an unsigned char as a number
     * @param u is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t println(unsigned int u, int base = DEC);
 
 
    /** Print out a long as a number
     * @param l is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t println(long l, int base = DEC);
 
 
    /** Print out an unsigned long
     * @param l is the integer to print
     * @param base is the base to print, either DEC (default), HEX, BIN
     * @returns number of chars written
     */
    size_t println(unsigned long l, int base = DEC);
 
 
    /** Print out a double
     * @param f is the integer to print
     * @param digits is the number of digits after the decimal
     * @returns number of chars written
     */
    size_t println(double f, int digits = 2);
 
 
    /** prints, well, nothing in this case, but pretend we printed a newline
     * @returns 1
     */
    size_t println(void);
   
 
    /*---------functions for Text and Graphic LCD adapters---------*/    
 
    /** Turns off the cursor */
    void disableCursor(void);
    
    /** Turns on the cursor */
    void enableCursor(void);
    
    /** Displays a string at specified coordinates
     * @param x is the x coordinate to display the string
     * @param y is the y coordinate to display the string
     * @param s is the string to display
     */
    void drawStr(uint8_t x, uint8_t y, const char *s);
    
    /** Sets the print position for graphics or text
     * @param x is the x coordinate to display the string
     * @param y is the y coordinate to display the string
     * @param graph if set to _TEXT_ affects subsequent text position, otherwise, affects graphics position
     */
    void setPrintPos(uint8_t x, uint8_t y, uint8_t graph = _TEXT_);
    
    /** Clears the display screen */
    void clearScreen(void);
    
    /** Configure your LCD if other than 1602 and the chip is other than KS0066U/F / HD44780 
     * @param col is the number of columns
     * @param row is the number of rows
     */
    void setLCDColRow(uint8_t col, uint8_t row);
    
    /** Sets a new I2C address for the display (default is 0x27), the adapter will store the new address in memory
     * @param address is the the new address 
     */
    void setI2CAddress(uint8_t add);
    
    /** Display Config on/off, the factory default set is on, 
     * so, when the module is powered up, it will display 
     * current communication mode on LCD, after you 
     * design finished, you can turn it off
     * @param v is the 1 is on, 0 is off
     */
    void displayConfig(uint8_t v);
    
    /** Holdover from Arduino library; not needed */
    void preprint(void);
    
    /*----------Functions for Graphic LCD/OLED adapters only---------*/
    //the functions in this section compatible with u8glib
    void drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *bitmap);
    void setRot90(void);
    void setRot180(void);
    void setRot270(void);
    void undoRotation(void);
    void setRotation(uint8_t);
    void setContrast(uint8_t);
    void drawBox(uint8_t x, uint8_t y, uint8_t w, uint8_t h);
    void drawCircle(uint8_t x, uint8_t y, uint8_t r, uint8_t = 0);
    void drawDisc(uint8_t x, uint8_t y, uint8_t r);
    void drawFrame(uint8_t x, uint8_t y, uint8_t w, uint8_t h);
    void drawPixel(uint8_t x, uint8_t y, uint8_t = 1);
    void drawLine(uint8_t x, uint8_t y, uint8_t x1, uint8_t y1);
    void drawLineTo(uint8_t x, uint8_t y);
    void drawHLine(uint8_t x, uint8_t y, uint8_t w);
    void drawVLine(uint8_t x, uint8_t y, uint8_t h);
    //-------------------------------
    //special functions for our adapters
    
    /** Sets the font
     *
     * @parameter font - available fonts: 6,10,18,51,120,123, user font 200-203
     */
    void setFont(uint8_t font);
    
    /** go to next text line, depending on the font size */
    void nextTextLine(void);
    
    /** set color for graphic function */ 
    void setColor(uint8_t); 
    
    /** Turn on back light */
    void backLightOn(void); 
    
    /** Turn off back light */
    void backLightOff(void); 
    
    /** send command to LCD drectly 
     * @param d - command
     */
    void directCommand(uint8_t d); 
    
    /** send data to LCD drectly
     * @param d is the data
     */
    void directData(uint8_t d); 
    
    /** Move rectangle area on screen to another place
     * @param x0, y1 is the top left of the area to move
     * @param x1, y1 is the bottom right of the area to move
     * @param xoffset, yoffset is the the distance to move
     */
    void moveArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, char xoffset, char yoffset);
 
    /** Display startup screen */
    void displayStartScreen(uint8_t m);
    
    /** Set display mode */
    void setMode(uint8_t m);
 
    /** set text position back to previous, only one back allowed */
    void setTextPosBack(void);    
    
    void setTextPosOffset(char xoffset, char yoffset);
    void setTextPosAbs(uint8_t x, uint8_t y);
    void setLinePattern(uint8_t pattern);
    /** Only for universal serial adapter */
    void setLCDChip(uint8_t chip);
 
 
    /** Set Start Screen, 1st B is the lower byte of data length. 
     * Convert images to C array here: <a href="http://www.digole.com/tools/PicturetoC_Hex_converter.php">http://www.digole.com/tools/PicturetoC_Hex_converter.php</a>
     * @param lon is the length of data
     * @param data is the binary data
     */
    void uploadStartScreen(int lon, const unsigned char *data); //upload start screen
    
    /** Upload a user font
     * @param lon is the length of data
     * @param data is the user font data
     * @param sect is the section of memory you want to upload to
     */
    void uploadUserFont(int lon, const unsigned char *data, uint8_t sect); //upload user font
 
    /** Send a Byte to output head on board
     * @param x is the byte to output
     */
    void digitalOutput(uint8_t x);
 
private:
    I2C _device;
    uint8_t _address;
    uint8_t _Comdelay;
 
    size_t printNumber(unsigned long n, uint8_t base);
    size_t printFloat(double number, uint8_t digits);
};
 
#endif

Hope this helps, don't forget to add pullups on SDA and SCL I2C lines on the KL25Z, non required on the LPC1768. Regards Phil.

When you have a thousand lines of code it is handier to publish a program than to copy the code. Then others can easily import it.

posted by Erik - 19 Jun 2013

Thank you Phil, I finally got it working after I found the producers fitted 75k resistors on the SDA and CLK inputs instead of 3k2 and modified the contrast input pin levels on the LCD display. The 7 bit I2c had me going for a bit, I used an I2c scanner that gave me address 0x4E instead of 0x27, due to 8 bit I2c comms.. I agree with Eric, would be helpfull if you were to publish you're KL25Z version library with the 'hello world' program to help others get started. Regards. Paul

posted by Paul Staron 21 Jun 2013

Here is the published test program:-

Import programFRDM_OLED_Test

Digole Serial Display FRDM-KL25Z Test Program Requires pull-ups on the SDA & SCL data lines. Digole Serial modified with extra Stop commands so that it works with the FRDM-KL25Z I2C library functions. Works fine on LPC1768 without extra Stop commands.

posted by Phil Green 22 Jun 2013

Paul, hi - sorry to revive this, but I'm trying to get the Digole module to work with an ESP8266. Module works fine with AVR Arduino (5V). On ESP, I'm having no luck with either SPI (tried briefly) or I2C. On I2C the data is corrupt (some transmissions go though, but it's mostly bus errors). Other I2C modules work fine on ESP. I suspect the problem is electrical.

Your comment on the 75k resistors caught my attention. I tried 2k2 external pullups, that made no difference (in fact, I2C also stopped working with the AVR). I know it's been a while, but do you perhaps remember how you got it working? Thanks!

posted by Spiros Papadimitriou 26 Aug 2015