Code Monkey home page Code Monkey logo

sparkfun_micro_oled_particle_library's Introduction

SparkFun Photon Micro OLED Shield Library

Firmware library SparkFun's Photon Micro OLED Shield.

About

This is a firmware library for SparkFun's Photon Micro OLED Shield.

Photon Micro OLED Shield

With a bit of extra setup, it'll also work with the Micro OELD Breakout.

You can use this library to draw pixels, lines, circles, squares, and text on the micro OLED's 64x48 display.

Repository Contents

  • /firmware - Source files for the library (.cpp, .h).
  • /firmware/examples - Example sketches for the library (.cpp). Run these from the Particle IDE.
  • spark.json - General library properties for the Particel library manager.

Example Usage

Include the library, declare a MicroOLED object, and set the display up with these snippets of code:

#include "SparkFunMicroOLED.h"  // Include the SFE_MicroOLED library
...
//////////////////////////
// MicroOLED Definition //
//////////////////////////
#define PIN_RESET D7  // Connect RST to pin 7 (req. for SPI and I2C)
#define PIN_DC    D3  // Connect DC to pin 3 (required for SPI)
#define PIN_CS    A2 // Connect CS to pin A2 (required for SPI)

//////////////////////////////////
// MicroOLED Object Declaration //
//////////////////////////////////
// Declare a MicroOLED object. The parameters include:
// 1 - Mode: Should be either MODE_SPI or MODE_I2C
// 2 - Reset pin: Any digital pin
// 3 - D/C pin: Any digital pin (SPI mode only)
// 4 - CS pin: Any digital pin (SPI mode only, 10 recommended)
MicroOLED oled(MODE_SPI, PIN_RESET, PIN_DC, PIN_CS);
...
void setup()
{
	oled.begin(); // Initialize the OLED
	oled.clear(ALL); // Clear the OLED's internal display buffer
	oled.display(); // Display whatever is in the firmware display buffer (SparkFun logo by default)
}

Check out the example files in the examples directory for more guidance.

Recommended Components

Generating Images

License Information

This product is open source!

Please review the LICENSE.md file for license information.

If you have any questions or concerns on licensing, please contact [email protected].

Distributed as-is; no warranty is given.

  • Your friends at SparkFun.

sparkfun_micro_oled_particle_library's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkfun_micro_oled_particle_library's Issues

Improve I2C Speed

Just tried this lib on photon, works fine, I used a cheap ebay SSD1306 128x64 Oled without any issue.

As SSD1306 spec says it can works until 400 KHz in I2C mode, I suggest to add the following line in the i2csetup() just before Wire.begin();

Wire.setSpeed(CLOCK_SPEED_400KHZ);

this becomes

void MicroOLED::i2cSetup()
{
Wire.setSpeed(CLOCK_SPEED_400KHZ);
Wire.begin();

// SCL frequency = (F_CPU) / (16 + 2(TWBR) * (prescalar))
//TWBR = ((F_CPU / I2C_FREQ) - 16) / 2;
}

For information I was able to push my OLED until 1 MHz I2C, just 10 x faster than original code by using Wire.setSpeed(1000000); instead of Wire.setSpeed(CLOCK_SPEED_400KHZ);
Worth it

display() sends data for pages 0-5, clear(ALL) sends zeros for pages 0-7

I noticed this when I was working with the library - display() outer loop for sending data is for (i = 0; i < 6; i++) but clear(uint8_t mode) (and clear(uint8_t mode, uint8_t c)) outer loop for sending zeros/values is for (int i = 0; i < 8; i++)
Note that display is looping through the range 0...5, but clear is looping through the range 0...7.

'CLOCK_SPEED_400KHZ' was not declared in this scope

Veryfing code using this library in Particle Build fails with this error:

SparkFunMicroOLED/SparkFunMicroOLED.cpp:879:16: error: 'CLOCK_SPEED_400KHZ' was not declared in this scope
  Wire.setSpeed(CLOCK_SPEED_400KHZ)

_this was running the default script with the shield._

File not found when used in Particle Web IDE

Error message is :

test.ino:2:62: SparkFunMicroOLED.h: No such file or directory

The import statement was created automatically by the particle IDE, but I have edited it to try quote as well as angle brackets.

// This #include statement was automatically added by the Particle IDE.
#include "SparkFunMicroOLED.h" // Include Micro OLED library

I have also cleared the cache.

The example code from the library works fine!

All very frustrating.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.