lcdks: renamed from sainsmartks, added backlight support

The sainsmartks driver has been reimplemented in it's own, new C/C++
library: lcdks (LCD Keypad Shield).

In addition, support for an optional backlight GPIO was added.

This was tested with the SainsmartKS and DFRobot LCD Keypad Shields.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson
2017-03-16 12:12:01 -06:00
parent ab171573f9
commit 4ea01180a1
15 changed files with 1107 additions and 43 deletions

View File

@ -332,6 +332,7 @@ add_example (max30100)
add_example (sensortemplate)
add_example (p9813)
add_example (abpdrrt005pg2a5)
add_example (lcdks)
# These are special cases where you specify example binary, source file and module(s)
include_directories (${PROJECT_SOURCE_DIR}/src)
@ -343,7 +344,6 @@ add_custom_example (es08a-example-cxx es08a.cxx servo)
add_custom_example (ssd1306-oled-example-cxx ssd1306-oled.cxx lcd)
add_custom_example (ssd1308-oled-example-cxx ssd1308-oled.cxx lcd)
add_custom_example (ssd1327-oled-example-cxx ssd1327-oled.cxx lcd)
#add_custom_example (sainsmartks-example-cxx sainsmartks.cxx lcd)
add_custom_example (eboled-example-cxx eboled.cxx lcd)
add_custom_example (mpu60x0-example-cxx mpu60x0.cxx mpu9150)
add_custom_example (ak8975-example-cxx ak8975.cxx mpu9150)

View File

@ -1,6 +1,8 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2017 Intel Corporation.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -26,41 +28,46 @@
#include <signal.h>
#include <iostream>
#include "sainsmartks.hpp"
#include "lcdks.hpp"
using namespace std;
int shouldRun = true;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// use default pins
upm::SAINSMARTKS* lcd = new upm::SAINSMARTKS();
lcd->setCursor(0,0);
lcd->write("Sainsmart KS");
lcd->setCursor(1,2);
lcd->write("Hello World");
// output current key value every second.
while (shouldRun)
{
cout << "Button value: " << lcd->getRawKeyValue() << endl;
sleep(1);
}
signal(SIGINT, sig_handler);
//! [Interesting]
delete lcd;
return 0;
// Instantiate a LCDKS (LCD Keypad Shield) using default pins
// NOTE: The default pins do not include support for a gpio
// controlled backlight. If you need one, you will need to specify
// all neccessary pins to the constructor.
upm::LCDKS* lcd = new upm::LCDKS();
lcd->setCursor(0,0);
lcd->write("LCDKS driver");
lcd->setCursor(1,2);
lcd->write("Hello World");
// output current key value every second.
while (shouldRun)
{
cout << "Button value: " << lcd->getKeyValue() << endl;
sleep(1);
}
delete lcd;
//! [Interesting]
return 0;
}