Code Monkey home page Code Monkey logo

sparkcore-liquidcrystalspi's Introduction

SparkCore-LiquidCrystalSPI

A Hardware and Software SPI driven LiquidCrystal library for Spark Core.

Universally Supports:

  • Standard Hitachi HD44780 based LCDs in 4-bit mode
  • Adafruit's 16x2 OLED Display (Winstar)
  • Sparkfun's 16x2 OLED Display (ADH Technology Co. Ltd.)

Grab the RAW version of each file and place into your web IDE as follows:

image

If you are building locally, place the files here:

..\core-firmware\inc\liquid-crystal-spi.h
..\core-firmware\src\application.cpp (renamed from lcd-soft-spi.cpp)
..\core-firmware\src\liquid-crystal-spi.cpp
..\core-firmware\src\build.mk (optional, if you have your own make file going, just add the liquid-crystal-spi.cpp to it)

###Hardware SPI Wiring (default)### wiring

###Hardware SPI Example Code (default)###

// Create an instance of the library for HARDWARE SPI mode (define SS "latch" pin)
// Default SS pin is A2, but can be ANY of the A0 - A2, A6, A7 or D0 - D7 pins.
// Just make sure you don't redefine this pin as some other peripheral later in your code.
LiquidCrystal lcd(A2);

void setup() {
  // initialize the SPI ( Must call this before begin()! )
  lcd.initSPI();
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Hello, Sparky!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
  delay(100);
}

###Software SPI Wiring### wiring

###Software SPI Example Code###

// Create an instance of the library for SOFTWARE SPI mode (define SS "latch" pin, SCLK pin, SDAT pin)
// These can be ANY of the A0 - A7 or D0 - D7 pins. 
// Just make sure you don't redefine them as some other peripheral later in your code.
LiquidCrystal lcd(D2, D3, D4);

void setup() {
  // initialize the SPI ( Must call this before begin()! )
  lcd.initSPI();
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Hello, Sparky!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
  delay(100);
}

wiring

Software SPI is just as fast as 9MHz Hardware SPI so don't be afraid to use it!

Control the backlight via SPI if you have an Adafruit I2C/SPI LCD Backpack

// Create an instance of the library for SOFTWARE SPI mode (define SS "latch" pin, SCLK pin, SDAT pin)
// These can be ANY of the A0 - A7 or D0 - D7 pins. 
// Just make sure you don't redefine them as some other peripheral later in your code.
LiquidCrystal lcd(D2, D3, D4);

bool s = false;

void setup() {
  // initialize the SPI ( Must call this before begin()! )
  lcd.initSPI();
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // turn on the backlight ( Requires initSPI() to be called first )
  lcd.backlight();
  // Print a message to the LCD.
  lcd.print("Backlight Rave!");
}

void loop() {
  // Toggle the Backlight on and off, Backlight RAVE!
  if(s)
    lcd.backlight();
  else
    lcd.noBacklight();
  s = !s;
  delay(100);
}

sparkcore-liquidcrystalspi's People

Contributors

technobly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sparkcore-liquidcrystalspi's Issues

Backlight issue

Hi
Great library, thanks, but I have got an issue with the backlight not working by default. If I hard wire the lcd backlight pins A and K to the 5 volt and ground lines it works fine but without that there is display but no backlight. Not really a major problem as it works fine but the display cannot be so easily turned off through software.
I noticed that some people are directly driving the backlight in the same way and switching it with a mosfet:
http://www.ermicro.com/blog/?p=2215
It is definitely a HD44780 unit but I wonder if it might be different to what you have coded for. The fact that it displays Backlight Rave! suggests that there is not much out of sorts here.
Best regards

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.