diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt index 499f63e8..a2433f1a 100644 --- a/examples/c++/CMakeLists.txt +++ b/examples/c++/CMakeLists.txt @@ -336,14 +336,14 @@ add_example (abpdrrt005pg2a5) # These are special cases where you specify example binary, source file and module(s) include_directories (${PROJECT_SOURCE_DIR}/src) add_custom_example (groveled-multi-example-cxx groveled-multi.cxx grove) -add_custom_example (lcm1602-i2c-example-cxx lcm1602-i2c.cxx lcd) -add_custom_example (lcm1602-parallel-example-cxx lcm1602-parallel.cxx lcd) -add_custom_example (jhd1313m1-lcd-example-cxx jhd1313m1-lcd.cxx lcd) +add_custom_example (lcm1602-i2c-example-cxx lcm1602-i2c.cxx lcm1602) +add_custom_example (lcm1602-parallel-example-cxx lcm1602-parallel.cxx lcm1602) +add_custom_example (jhd1313m1-lcd-example-cxx jhd1313m1-lcd.cxx jhd1313m1) 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 (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) diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt index 2e411c26..abc73534 100644 --- a/examples/java/CMakeLists.txt +++ b/examples/java/CMakeLists.txt @@ -167,10 +167,10 @@ add_example(Ads1115Sample ads1x15) add_example(SensorTemplateSample sensortemplate) add_example(P9813Sample p9813) -add_example_with_path(Jhd1313m1_lcdSample lcd i2clcd) -add_example_with_path(Jhd1313m1Sample lcd i2clcd) -add_example_with_path(Lcm1602_i2cSample lcd i2clcd) -add_example_with_path(Lcm1602_parallelSample lcd i2clcd) +add_example_with_path(Jhd1313m1_lcdSample jhd1313m1 jhd1313m1) +add_example_with_path(Jhd1313m1Sample jhd1313m1 jhd1313m1) +add_example_with_path(Lcm1602_i2cSample lcm1602 lcm1602) +add_example_with_path(Lcm1602_parallelSample lcm1602 lcm1602) add_example_with_path(SSD1308_oledSample lcd i2clcd) add_example_with_path(SSD1327_oledSample lcd i2clcd) add_example_with_path(BME280_Example bmp280 bmp280) diff --git a/examples/java/Jhd1313m1Sample.java b/examples/java/Jhd1313m1Sample.java index db84426e..a4b02a08 100644 --- a/examples/java/Jhd1313m1Sample.java +++ b/examples/java/Jhd1313m1Sample.java @@ -24,19 +24,19 @@ public class Jhd1313m1Sample { - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_i2clcd.Jhd1313m1 lcd = new upm_i2clcd.Jhd1313m1(0); + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_jhd1313m1.Jhd1313m1 lcd = new upm_jhd1313m1.Jhd1313m1(0); - lcd.setCursor(0, 0); - lcd.write("Hello World"); - lcd.setCursor(1, 2); - lcd.write("Hello World"); + lcd.setCursor(0, 0); + lcd.write("Hello World"); + lcd.setCursor(1, 2); + lcd.write("Hello World"); - System.out.println("Sleeping for 5 seconds"); - Thread.sleep(5000); - lcd.clear(); - // ! [Interesting] - } + System.out.println("Sleeping for 5 seconds"); + Thread.sleep(5000); + lcd.clear(); + // ! [Interesting] + } -} \ No newline at end of file +} diff --git a/examples/java/Jhd1313m1_lcdSample.java b/examples/java/Jhd1313m1_lcdSample.java index bda19946..803b50f3 100644 --- a/examples/java/Jhd1313m1_lcdSample.java +++ b/examples/java/Jhd1313m1_lcdSample.java @@ -24,19 +24,20 @@ public class Jhd1313m1_lcdSample{ - public static void main(String[] args) throws InterruptedException { - //! [Interesting] - upm_i2clcd.Jhd1313m1 lcd = new upm_i2clcd.Jhd1313m1(1, 0x3E, 0x62); - - lcd.setCursor(0,0); - lcd.write("Hello World"); - lcd.setCursor(1,2); - lcd.write("Hello World"); + public static void main(String[] args) throws InterruptedException { + //! [Interesting] + upm_jhd1313m1.Jhd1313m1 lcd = + new upm_jhd1313m1.Jhd1313m1(1, 0x3E, 0x62); + + lcd.setCursor(0,0); + lcd.write("Hello World"); + lcd.setCursor(1,2); + lcd.write("Hello World"); + + System.out.println("Sleeping for 5 seconds"); + Thread.sleep(5000); + lcd.clear(); + //! [Interesting] + } - System.out.println("Sleeping for 5 seconds"); - Thread.sleep(5000); - lcd.clear(); - //! [Interesting] - } - } diff --git a/examples/java/Lcm1602_i2cSample.java b/examples/java/Lcm1602_i2cSample.java index 53b8ba43..a38619a0 100644 --- a/examples/java/Lcm1602_i2cSample.java +++ b/examples/java/Lcm1602_i2cSample.java @@ -25,25 +25,18 @@ //NOT TESTED!!! public class Lcm1602_i2cSample { - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - upm_i2clcd.Lcm1602 lcd = new upm_i2clcd.Lcm1602(0, 0x27); + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + upm_lcm1602.Lcm1602 lcd = new upm_lcm1602.Lcm1602(0, 0x27); - lcd.setCursor(0, 0); - lcd.write("Hello World"); - Thread.sleep(3000); + lcd.setCursor(0, 0); + lcd.write("Hello World"); + Thread.sleep(3000); - lcd.setCursor(1, 2); - lcd.write("Hello World"); - Thread.sleep(3000); + lcd.setCursor(1, 2); + lcd.write("Hello World"); + Thread.sleep(3000); - lcd.setCursor(2, 4); - lcd.write("Hello World"); - Thread.sleep(3000); - - lcd.setCursor(3, 6); - lcd.write("Hello World"); - Thread.sleep(3000); - // ! [Interesting] - } -} \ No newline at end of file + // ! [Interesting] + } +} diff --git a/examples/java/Lcm1602_parallelSample.java b/examples/java/Lcm1602_parallelSample.java index e720d237..35487753 100644 --- a/examples/java/Lcm1602_parallelSample.java +++ b/examples/java/Lcm1602_parallelSample.java @@ -25,28 +25,29 @@ //NOT TESTED!!! public class Lcm1602_parallelSample { - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // LCD connection: - // LCD RS pin to digital pin 8 - // LCD Enable pin to digital pin 13 - // LCD D4 pin to digital pin 2 - // LCD D5 pin to digital pin 3 - // LCD D6 pin to digital pin 4 - // LCD D7 pin to digital pin 5 - // LCD R/W pin to ground - // 10K trimmer potentiometer: - // ends to +5V and ground - // wiper to LCD VO pin (pin 3) - upm_i2clcd.Lcm1602 lcd = new upm_i2clcd.Lcm1602((short) 8, (short) 13, (short) 2, (short) 3, (short) 4, (short) 5, (short) 20, (short) 2); + public static void main(String[] args) throws InterruptedException { + // ! [Interesting] + // LCD connection: + // LCD RS pin to digital pin 8 + // LCD Enable pin to digital pin 13 + // LCD D4 pin to digital pin 2 + // LCD D5 pin to digital pin 3 + // LCD D6 pin to digital pin 4 + // LCD D7 pin to digital pin 5 + // LCD R/W pin to ground + // 10K trimmer potentiometer: + // ends to +5V and ground + // wiper to LCD VO pin (pin 3) + upm_lcm1602.Lcm1602 lcd = + new upm_lcm1602.Lcm1602(8, 13, 2, 3, 4, 5, (short) 16, (short) 2); - lcd.setCursor(0, 0); - lcd.write("Hello World"); - lcd.setCursor(1, 2); - lcd.write("Hello World"); + lcd.setCursor(0, 0); + lcd.write("Hello World"); + lcd.setCursor(1, 2); + lcd.write("Hello World"); - System.out.println("Sleeping for 5 seconds"); - Thread.sleep(5000); - // ! [Interesting] - } + System.out.println("Sleeping for 5 seconds"); + Thread.sleep(5000); + // ! [Interesting] + } } diff --git a/examples/javascript/jhd1313m1-lcd.js b/examples/javascript/jhd1313m1-lcd.js index 0562bbc8..aefebd52 100644 --- a/examples/javascript/jhd1313m1-lcd.js +++ b/examples/javascript/jhd1313m1-lcd.js @@ -23,7 +23,7 @@ */ // Load lcd module on I2C -var LCD = require('jsupm_i2clcd'); +var LCD = require('jsupm_jhd1313m1'); // Initialize Jhd1313m1 at 0x62 (RGB_ADDRESS) and 0x3E (LCD_ADDRESS) var myLcd = new LCD.Jhd1313m1 (0, 0x3E, 0x62); diff --git a/examples/python/jhd1313m1-lcd.py b/examples/python/jhd1313m1-lcd.py index 7c76f290..9ad6cd8a 100755 --- a/examples/python/jhd1313m1-lcd.py +++ b/examples/python/jhd1313m1-lcd.py @@ -21,7 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from upm import pyupm_i2clcd as lcd +from upm import pyupm_jhd1313m1 as lcd def main(): # Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS) diff --git a/src/jhd1313m1/CMakeLists.txt b/src/jhd1313m1/CMakeLists.txt index f506cf14..374322a3 100644 --- a/src/jhd1313m1/CMakeLists.txt +++ b/src/jhd1313m1/CMakeLists.txt @@ -2,8 +2,7 @@ upm_mixed_module_init (NAME jhd1313m1 DESCRIPTION "LCD Display Driver for the JHD1313M1 Controller for HD44780-based Displays" C_HDR jhd1313m1.h C_SRC jhd1313m1.c - CPP_HDR jhd1313m1.hxx + CPP_HDR jhd1313m1.hpp CPP_SRC jhd1313m1.cxx -# FTI_SRC jhd1313m1_fti.c CPP_WRAPS_C REQUIRES mraa lcm1602) diff --git a/src/jhd1313m1/javaupm_jhd1313m1.i b/src/jhd1313m1/javaupm_jhd1313m1.i index 6e6de738..00c0cc5b 100644 --- a/src/jhd1313m1/javaupm_jhd1313m1.i +++ b/src/jhd1313m1/javaupm_jhd1313m1.i @@ -1,31 +1,11 @@ %module javaupm_jhd1313m1 %include "../upm.i" -%include "stdint.i" +%include "../upm_vectortypes.i" %include "typemaps.i" -%include "arrays_java.i"; -%apply signed char[] {uint8_t []}; -%ignore BasicFont; - -%typemap(jni) (uint8_t *data, int bytes) "jbyteArray"; -%typemap(jtype) (uint8_t *data, int bytes) "byte[]"; -%typemap(jstype) (uint8_t *data, int bytes) "byte[]"; - -%typemap(javain) (uint8_t *data, int bytes) "$javainput"; - -%typemap(in) (uint8_t *data, int bytes) { - $1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL); - $2 = JCALL1(GetArrayLength, jenv, $input); -} - -%typemap(freearg) (uint8_t *data, int bytes) { - JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); -} - -%include "jhd1313m1.h" -%include "jhd1313m1.hxx" +%include "jhd1313m1.hpp" %{ - #include "jhd1313m1.hxx" + #include "jhd1313m1.hpp" %} %pragma(java) jniclasscode=%{ diff --git a/src/jhd1313m1/jhd1313m1.c b/src/jhd1313m1/jhd1313m1.c index 2ebc01fd..0faaa6df 100644 --- a/src/jhd1313m1/jhd1313m1.c +++ b/src/jhd1313m1/jhd1313m1.c @@ -216,7 +216,7 @@ upm_result_t jhd1313m1_home(const jhd1313m1_context dev) upm_result_t jhd1313m1_create_char(const jhd1313m1_context dev, unsigned int slot, - jhd1313m1_custom_char_t data) + char *data) { assert(dev != NULL); diff --git a/src/jhd1313m1/jhd1313m1.cxx b/src/jhd1313m1/jhd1313m1.cxx index 297c31c7..fb79ea9b 100644 --- a/src/jhd1313m1/jhd1313m1.cxx +++ b/src/jhd1313m1/jhd1313m1.cxx @@ -35,7 +35,7 @@ #include #include -#include "jhd1313m1.hxx" +#include "jhd1313m1.hpp" using namespace upm; @@ -83,9 +83,10 @@ upm_result_t Jhd1313m1::home() } upm_result_t Jhd1313m1::createChar(uint8_t charSlot, - jhd1313m1_custom_char_t charData) + std::vector charData) { - return jhd1313m1_create_char(m_jhd1313m1, charSlot, charData); + return jhd1313m1_create_char(m_jhd1313m1, charSlot, + (char *)charData.data()); } upm_result_t Jhd1313m1::displayOn() diff --git a/src/jhd1313m1/jhd1313m1.h b/src/jhd1313m1/jhd1313m1.h index 48e63eee..db1aa69c 100644 --- a/src/jhd1313m1/jhd1313m1.h +++ b/src/jhd1313m1/jhd1313m1.h @@ -63,11 +63,6 @@ extern "C" { uint8_t entryDisplayMode; } *jhd1313m1_context; - /** - * Custom character. - */ - typedef char jhd1313m1_custom_char_t[8]; - /** * JHD1313M1 I2C initialization. * @@ -147,7 +142,7 @@ extern "C" { */ upm_result_t jhd1313m1_create_char(const jhd1313m1_context dev, unsigned int slot, - jhd1313m1_custom_char_t data); + char *data); /** * Turn the display on. diff --git a/src/jhd1313m1/jhd1313m1.hxx b/src/jhd1313m1/jhd1313m1.hpp similarity index 97% rename from src/jhd1313m1/jhd1313m1.hxx rename to src/jhd1313m1/jhd1313m1.hpp index f36dd9ff..042e226f 100644 --- a/src/jhd1313m1/jhd1313m1.hxx +++ b/src/jhd1313m1/jhd1313m1.hpp @@ -34,6 +34,7 @@ #pragma once #include +#include #include "jhd1313m1.h" namespace upm @@ -140,11 +141,11 @@ namespace upm * Create a custom character * * @param charSlot the character slot to write, only 8 are available - * @param charData The character data (8 bytes) making up the character + * @param charData A vector containing 8 bytes making up the character * @return Result of operation */ upm_result_t createChar(uint8_t charSlot, - jhd1313m1_custom_char_t charData); + std::vector charData); /** * Turn the display on diff --git a/src/jhd1313m1/jsupm_jhd1313m1.i b/src/jhd1313m1/jsupm_jhd1313m1.i index 84d56729..af0767d3 100644 --- a/src/jhd1313m1/jsupm_jhd1313m1.i +++ b/src/jhd1313m1/jsupm_jhd1313m1.i @@ -1,9 +1,8 @@ %module jsupm_jhd1313m1 %include "../upm.i" -%include "../carrays_uint8_t.i" +%include "../upm_vectortypes.i" -%include "jhd1313m1.h" -%include "jhd1313m1.hxx" +%include "jhd1313m1.hpp" %{ - #include "jhd1313m1.hxx" + #include "jhd1313m1.hpp" %} diff --git a/src/jhd1313m1/pyupm_jhd1313m1.i b/src/jhd1313m1/pyupm_jhd1313m1.i index dae5fc5e..2dae965d 100644 --- a/src/jhd1313m1/pyupm_jhd1313m1.i +++ b/src/jhd1313m1/pyupm_jhd1313m1.i @@ -2,12 +2,11 @@ %include "pyupm_doxy2swig.i" %module pyupm_jhd1313m1 %include "../upm.i" -%include "../carrays_uint8_t.i" +%include "../upm_vectortypes.i" %feature("autodoc", "3"); -%include "jhd1313m1.h" -%include "jhd1313m1.hxx" +%include "jhd1313m1.hpp" %{ - #include "jhd1313m1.hxx" + #include "jhd1313m1.hpp" %} diff --git a/src/lcd/CMakeLists.txt b/src/lcd/CMakeLists.txt index 1192c99e..d0ad2875 100644 --- a/src/lcd/CMakeLists.txt +++ b/src/lcd/CMakeLists.txt @@ -1,5 +1,5 @@ set (libname "i2clcd") -set (libdescription "LCD and OLED Display Library") -set (module_src lcd.cxx lcm1602.cxx jhd1313m1.cxx ssd1308.cxx eboled.cxx ssd1327.cxx sainsmartks.cxx ssd1306.cxx) -set (module_hpp lcd.hpp lcm1602.hpp jhd1313m1.hpp ssd1308.hpp eboled.hpp ssd1327.hpp ssd.hpp sainsmartks.hpp ssd1306.hpp) +set (libdescription "OLED Display Library") +set (module_src lcd.cxx ssd1308.cxx eboled.cxx ssd1327.cxx ssd1306.cxx) +set (module_hpp lcd.hpp ssd1308.hpp eboled.hpp ssd1327.hpp ssd.hpp ssd1306.hpp) upm_module_init(mraa) diff --git a/src/lcd/javaupm_i2clcd.i b/src/lcd/javaupm_i2clcd.i index 2bf10d4b..7c630256 100644 --- a/src/lcd/javaupm_i2clcd.i +++ b/src/lcd/javaupm_i2clcd.i @@ -29,9 +29,6 @@ #include "ssd1308.hpp" #include "ssd1306.hpp" #include "eboled.hpp" - #include "lcm1602.hpp" - #include "jhd1313m1.hpp" - #include "sainsmartks.hpp" %} %include "lcd.hpp" @@ -40,9 +37,6 @@ %include "ssd1308.hpp" %include "ssd1306.hpp" %include "eboled.hpp" -%include "lcm1602.hpp" -%include "jhd1313m1.hpp" -%include "sainsmartks.hpp" %pragma(java) jniclasscode=%{ static { @@ -53,4 +47,4 @@ System.exit(1); } } -%} \ No newline at end of file +%} diff --git a/src/lcd/jhd1313m1.cxx b/src/lcd/jhd1313m1.cxx deleted file mode 100644 index 3a547fb6..00000000 --- a/src/lcd/jhd1313m1.cxx +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha - * Copyright (c) 2014 Intel Corporation. - * - * Contributions: Jon Trulson - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include - -#include "lcd_private.hpp" -#include "hd44780_bits.hpp" -#include "jhd1313m1.hpp" - -using namespace upm; - -Jhd1313m1::Jhd1313m1(int bus, int lcdAddress, int rgbAddress) - : Lcm1602(bus, lcdAddress, false), m_i2c_lcd_rgb(bus) -{ - m_rgb_address = rgbAddress; - m_name = "Jhd1313m1"; - - mraa::Result ret = m_i2c_lcd_rgb.address(m_rgb_address); - if (ret != mraa::SUCCESS) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": I2c.address() failed"); - } - - /* HD44780 requires writing three times to initialize or reset - according to the hardware errata on page 45 figure 23 of - the Hitachi HD44780 datasheet */ - /* First try */ - usleep(50000); - ret = command(LCD_FUNCTIONSET | LCD_8BITMODE); - /* Second try */ - usleep(4500); - ret = command(LCD_FUNCTIONSET | LCD_8BITMODE); - /* Third try */ - usleep(150); - ret = command(LCD_FUNCTIONSET | LCD_8BITMODE); - UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller"); - - /* Set 2 row mode and font size */ - ret = command(LCD_FUNCTIONSET | LCD_8BITMODE | LCD_2LINE | LCD_5x10DOTS); - UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller"); - - usleep(100); - ret = displayOn(); - - UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller"); - - usleep(100); - ret = clear(); - UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller"); - - usleep(2000); - ret = command(LCD_ENTRYMODESET | LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT); - UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller"); - - ret = setColor(0xFF, 0xFF, 0xFF); - UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller"); - ret = backlightOn(); - UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller"); -} - -Jhd1313m1::~Jhd1313m1() -{ - clear(); - setColor(0x00, 0x00, 0x00); -} - -mraa::Result -Jhd1313m1::setColor(uint8_t r, uint8_t g, uint8_t b) -{ - mraa::Result ret; - - ret = m_i2c_lcd_rgb.writeReg(0, 0); - UPM_GOTO_ON_MRAA_FAIL(ret, beach); - ret = m_i2c_lcd_rgb.writeReg(1, 0); - UPM_GOTO_ON_MRAA_FAIL(ret, beach); - - ret = m_i2c_lcd_rgb.writeReg(0x04, r); - UPM_GOTO_ON_MRAA_FAIL(ret, beach); - ret = m_i2c_lcd_rgb.writeReg(0x03, g); - UPM_GOTO_ON_MRAA_FAIL(ret, beach); - ret = m_i2c_lcd_rgb.writeReg(0x02, b); - -beach: - return ret; -} - -mraa::Result -Jhd1313m1::backlightOn() -{ - return m_i2c_lcd_rgb.writeReg(0x08, 0xAA); -} - -mraa::Result -Jhd1313m1::backlightOff() -{ - return m_i2c_lcd_rgb.writeReg(0x08, 0x00); -} - -mraa::Result -Jhd1313m1::scroll(bool direction) -{ - if (direction) { - return scrollDisplayLeft(); - } else { - return scrollDisplayRight(); - } -} - -mraa::Result Jhd1313m1::command(uint8_t cmd) -{ - return m_i2c_lcd_control->writeReg(LCD_CMD, cmd); - -} -mraa::Result Jhd1313m1::data(uint8_t cmd) -{ - return m_i2c_lcd_control->writeReg(LCD_DATA, cmd); -} diff --git a/src/lcd/jhd1313m1.hpp b/src/lcd/jhd1313m1.hpp deleted file mode 100644 index 76f74770..00000000 --- a/src/lcd/jhd1313m1.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Author: Yevgeniy Kiveisha - * Copyright (c) 2014 Intel Corporation. - * - * Contributions: Jon Trulson - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#pragma once - -#include -#include "lcm1602.hpp" - -namespace upm -{ -/** - * @library i2clcd - * @sensor jhd1313m1 - * @comname RGB Backlight 16x2 LCD Display - * @altname Grove RGB LCD - * @type display - * @man seeed adafruit sparkfun - * @web http://www.seeedstudio.com/depot/Grove-LCD-RGB-Backlight-p-1643.html?cPath=34_36 - * @con i2c - * @kit gsk - * - * @brief API for the JHD1313M1 I2C controller for HD44780-based displays with - * an RGB backlight, such as a Grove RGB I2C LCD display - * - * JHD1313M1 has two I2C addreses: one belongs to a controller, very similar - * to the upm::Lcm1602 LCD driver, that controls the HD44780-based display, and the - * other controls only the backlight. This module was tested with the Seeed - * Grove LCD RGB Backlight v2.0 display that requires 5V to operate. - * - * @image html grovergblcd.jpg - * @snippet jhd1313m1-lcd.cxx Interesting - */ -class Jhd1313m1 : public Lcm1602 -{ - public: - /** - * Jhd1313m1 constructor - * - * @param bus I2C bus to use - * @param address Slave address the LCD is registered on - * @param address Slave address the RGB backlight is registered on - */ - Jhd1313m1(int bus, int lcdAddress = 0x3E, int rgbAddress = 0x62); - /** - * Jhd1313m1 destructor - */ - ~Jhd1313m1(); - /** - * Makes the LCD scroll text - * - * @param direction True if scrolling to the right - * @return Result of the operation - */ - mraa::Result scroll(bool direction); - /** - * Sets the color of the backlight - * Can be used to change the color even when the backlight is off - * - * @param r 0-255 value for red - * @param g 0-255 value for green - * @param b 0-255 value for blue - * @return Result of the operation - */ - mraa::Result setColor(uint8_t r, uint8_t g, uint8_t b); - /** - * Turns backlight on - * - * @return Result of operation - */ - mraa::Result backlightOn(); - /** - * Turns backlight off, background color is saved - * - * @return Result of operation - */ - mraa::Result backlightOff(); - - protected: - virtual mraa::Result command(uint8_t cmd); - virtual mraa::Result data(uint8_t data); - - private: - int m_rgb_address; - mraa::I2c m_i2c_lcd_rgb; -}; -} diff --git a/src/lcd/jsupm_i2clcd.i b/src/lcd/jsupm_i2clcd.i index 3999a90c..c084b21c 100644 --- a/src/lcd/jsupm_i2clcd.i +++ b/src/lcd/jsupm_i2clcd.i @@ -8,16 +8,6 @@ #include "lcd.hpp" %} -%include "lcm1602.hpp" -%{ - #include "lcm1602.hpp" -%} - -%include "jhd1313m1.hpp" -%{ - #include "jhd1313m1.hpp" -%} - %include "ssd1327.hpp" %{ #include "ssd1327.hpp" @@ -33,11 +23,6 @@ #include "eboled.hpp" %} -%include "sainsmartks.hpp" -%{ - #include "sainsmartks.hpp" -%} - %include "ssd1306.hpp" %{ #include "ssd1306.hpp" diff --git a/src/lcd/lcm1602.cxx b/src/lcd/lcm1602.cxx deleted file mode 100644 index 2d98c151..00000000 --- a/src/lcd/lcm1602.cxx +++ /dev/null @@ -1,474 +0,0 @@ -/* - * The MIT License (MIT) - * - * Author: Daniel Mosquera - * Copyright (c) 2013 Daniel Mosquera - * - * Author: Thomas Ingleby - * Copyright (c) 2014 Intel Corporation. - * - * Contributions: Jon Trulson - * Sergey Kiselev - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#include "hd44780_bits.hpp" -#include "lcm1602.hpp" - -using namespace upm; - -Lcm1602::Lcm1602(int bus_in, int addr_in, bool isExpander, - uint8_t numColumns, uint8_t numRows) : - m_numColumns(numColumns), m_numRows(numRows), - m_i2c_lcd_control(new mraa::I2c(bus_in)), - m_gpioRS(0), m_gpioEnable(0), m_gpioD0(0), - m_gpioD1(0), m_gpioD2(0), m_gpioD3(0) -{ - mraa::Result error = mraa::SUCCESS; - m_name = "Lcm1602 (I2C)"; - m_isI2C = true; - m_backlight = LCD_BACKLIGHT; - - m_lcd_control_address = addr_in; - - error = m_i2c_lcd_control->address(m_lcd_control_address); - if (error != mraa::SUCCESS) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": I2c.address() failed"); - return; - } - - // default display control - m_displayControl = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; - - // if we are not dealing with an expander (say via a derived class - // like Jhd1313m1), then we do not want to execute the rest of the - // code below. Rather, the derived class's constructor should - // follow up with any setup required -- we will only initialize - // the I2C context and bail. - - if (!isExpander) - return; - - usleep(50000); - backlightOn(); - usleep(100000); - - write4bits(0x03 << 4); - usleep(4500); - write4bits(0x30); - usleep(4500); - write4bits(0x30); - usleep(150); - - // Put into 4 bit mode - write4bits(0x20); - - m_displayControl = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; - // Set numeber of lines - command(LCD_FUNCTIONSET | 0x0f); - command(LCD_DISPLAYCONTROL | m_displayControl); - clear(); - - // Set entry mode. - m_entryDisplayMode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; - command(LCD_ENTRYMODESET | m_entryDisplayMode); - - home(); -} - -Lcm1602::Lcm1602(int rs, int enable, int d0, - int d1, int d2, int d3, - uint8_t numColumns, uint8_t numRows) : - m_numColumns(numColumns), m_numRows(numRows), - m_i2c_lcd_control(0), - m_gpioRS(new mraa::Gpio(rs)), m_gpioEnable(new mraa::Gpio(enable)), - m_gpioD0(new mraa::Gpio(d0)), m_gpioD1(new mraa::Gpio(d1)), - m_gpioD2(new mraa::Gpio(d2)), m_gpioD3(new mraa::Gpio(d3)) -{ - m_name = "Lcm1602 (4-bit GPIO)"; - m_isI2C = false; - m_backlight = LCD_BACKLIGHT; - - // setup our gpios - - m_gpioRS->dir(mraa::DIR_OUT); - m_gpioEnable->dir(mraa::DIR_OUT); - - m_gpioD0->dir(mraa::DIR_OUT); - m_gpioD1->dir(mraa::DIR_OUT); - m_gpioD2->dir(mraa::DIR_OUT); - m_gpioD3->dir(mraa::DIR_OUT); - - - // set RS and Enable low to begin issuing commands - m_gpioRS->write(0); - m_gpioEnable->write(0); - - // wait to stabilize - usleep(100000); - - // set 4bit mode - - // These steps are adapted from the HD44780 datasheet, figure 24 - - // try 1 - write4bits(0x03); - usleep(4500); - - // try 2 - write4bits(0x03); - usleep(4500); - - // try 3 - write4bits(0x03); - usleep(150); - - // Finally, put into 4 bit mode - write4bits(0x02); - - // Set number of lines - command(LCD_FUNCTIONSET | LCD_2LINE | LCD_4BITMODE | LCD_5x8DOTS); - m_displayControl = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; - command(LCD_DISPLAYCONTROL | m_displayControl); - usleep(2000); - clear(); - - // Set entry mode. - m_entryDisplayMode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; - command(LCD_ENTRYMODESET | m_entryDisplayMode); - - home(); -} - -Lcm1602::~Lcm1602() -{ - // clean up after ourselves - if (m_isI2C) - { - delete m_i2c_lcd_control; - } - else - { - delete m_gpioRS; - delete m_gpioEnable; - - delete m_gpioD0; - delete m_gpioD1; - delete m_gpioD2; - delete m_gpioD3; - } -} - -/* - * ************** - * virtual area - * ************** - */ -mraa::Result -Lcm1602::write(std::string msg) -{ - mraa::Result error = mraa::SUCCESS; - for (std::string::size_type i = 0; i < msg.size(); ++i) { - error = data(msg[i]); - } - return error; -} - -mraa::Result -Lcm1602::setCursor(int row, int column) -{ - column = column % m_numColumns; - uint8_t offset = column; - - switch (m_numRows) - { - case 1: - // Single row displays with more than 8 columns usually have their - // DDRAM split in two halves. The first half starts at address 00. - // The second half starts at address 40. E.g. 16x2 DDRAM mapping: - // 00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47 - if (m_numColumns > 8) - { - offset = (column % (m_numColumns / 2)) + - (column / (m_numColumns / 2)) * 0x40; - } - break; - case 2: - // this should work for any display with two rows - // DDRAM mapping: - // 00 .. 27 - // 40 .. 67 - offset += row * 0x40; - break; - case 4: - if (m_numColumns == 16) - { - // 16x4 display - // DDRAM mapping: - // 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F - // 40 41 42 43 43 45 46 47 48 49 4A 4B 4C 4D 4E 4F - // 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F - // 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F - int row_addr[] = { 0x00, 0x40, 0x10, 0x50 }; - offset += row_addr[row]; - } - else - { - // 20x4 display - // DDRAM mapping: - // 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 - // 40 41 42 43 43 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 - // 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 - // 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 - int row_addr[] = { 0x00, 0x40, 0x14, 0x54 }; - offset += row_addr[row]; - } - break; - } - - return command(LCD_CMD | offset); -} - -mraa::Result -Lcm1602::clear() -{ - mraa::Result ret; - ret = command(LCD_CLEARDISPLAY); - usleep(2000); // this command takes awhile - return ret; -} - -mraa::Result -Lcm1602::home() -{ - mraa::Result ret; - ret = command(LCD_RETURNHOME); - usleep(2000); // this command takes awhile - return ret; -} - -mraa::Result -Lcm1602::createChar(uint8_t charSlot, uint8_t charData[]) -{ - mraa::Result error = mraa::SUCCESS; - charSlot &= 0x07; // only have 8 positions we can set - error = command(LCD_SETCGRAMADDR | (charSlot << 3)); - if (error == mraa::SUCCESS) { - for (int i = 0; i < 8; i++) { - error = data(charData[i]); - } - } - - return error; -} - -mraa::Result Lcm1602::displayOn() -{ - m_displayControl |= LCD_DISPLAYON; - return command(LCD_DISPLAYCONTROL | m_displayControl); -} - -mraa::Result Lcm1602::displayOff() -{ - m_displayControl &= ~LCD_DISPLAYON; - return command(LCD_DISPLAYCONTROL | m_displayControl); -} - -mraa::Result Lcm1602::cursorOn() -{ - m_displayControl |= LCD_CURSORON; - return command(LCD_DISPLAYCONTROL | m_displayControl); -} - -mraa::Result Lcm1602::cursorOff() -{ - m_displayControl &= ~LCD_CURSORON; - return command(LCD_DISPLAYCONTROL | m_displayControl); -} - -mraa::Result Lcm1602::cursorBlinkOn() -{ - m_displayControl |= LCD_BLINKON; - return command(LCD_DISPLAYCONTROL | m_displayControl); -} - -mraa::Result Lcm1602::cursorBlinkOff() -{ - m_displayControl &= ~LCD_BLINKON; - return command(LCD_DISPLAYCONTROL | m_displayControl); -} - -mraa::Result Lcm1602::backlightOn() -{ - m_backlight = LCD_BACKLIGHT; - return expandWrite(m_backlight); -} - -mraa::Result Lcm1602::backlightOff() -{ - m_backlight = LCD_NOBACKLIGHT; - return expandWrite(m_backlight); -} - -mraa::Result Lcm1602::scrollDisplayLeft() -{ - return command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); -} - -mraa::Result Lcm1602::scrollDisplayRight() -{ - return command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); -} - -mraa::Result Lcm1602::entryLeftToRight() -{ - m_entryDisplayMode |= LCD_ENTRYLEFT; - return command(LCD_ENTRYMODESET | m_entryDisplayMode); -} - -mraa::Result Lcm1602::entryRightToLeft() -{ - m_entryDisplayMode &= ~LCD_ENTRYLEFT; - return command(LCD_ENTRYMODESET | m_entryDisplayMode); -} - -mraa::Result Lcm1602::autoscrollOn() -{ - m_entryDisplayMode |= LCD_ENTRYSHIFTINCREMENT; - return command(LCD_ENTRYMODESET | m_entryDisplayMode); -} - -mraa::Result Lcm1602::autoscrollOff() -{ - m_entryDisplayMode &= ~LCD_ENTRYSHIFTINCREMENT; - return command(LCD_ENTRYMODESET | m_entryDisplayMode); -} - -mraa::Result Lcm1602::command(uint8_t cmd) -{ - return send(cmd, 0); -} - -mraa::Result Lcm1602::data(uint8_t cmd) -{ - return send(cmd, LCD_RS); // 1 -} - - -/* - * ************** - * private area - * ************** - */ -mraa::Result -Lcm1602::send(uint8_t value, int mode) -{ - mraa::Result ret = mraa::SUCCESS; - uint8_t h; - uint8_t l; - - if (m_isI2C) - { - h = value & 0xf0; - l = (value << 4) & 0xf0; - ret = write4bits(h | mode); - ret = write4bits(l | mode); - return ret; - } - - // else, gpio (4 bit) - - // register select - m_gpioRS->write(mode); - - h = value >> 4; - l = value & 0x0f; - - ret = write4bits(h); - ret = write4bits(l); - return ret; -} - -mraa::Result -Lcm1602::write4bits(uint8_t value) -{ - mraa::Result ret = mraa::SUCCESS; - - if (m_isI2C) - { - ret = expandWrite(value); - ret = pulseEnable(value); - return ret; - } - - // else gpio - ret = m_gpioD0->write( ((value >> 0) & 0x01) ); - ret = m_gpioD1->write( ((value >> 1) & 0x01) ); - ret = m_gpioD2->write( ((value >> 2) & 0x01) ); - ret = m_gpioD3->write( ((value >> 3) & 0x01) ); - - ret = pulseEnable(value); // value is ignored here for gpio - - return ret; -} - -mraa::Result -Lcm1602::expandWrite(uint8_t value) -{ - // invalid for gpio - if (!m_isI2C) - return mraa::ERROR_INVALID_RESOURCE; - - uint8_t buffer = value | m_backlight; - return m_i2c_lcd_control->writeByte(buffer); -} - -mraa::Result -Lcm1602::pulseEnable(uint8_t value) -{ - mraa::Result ret = mraa::SUCCESS; - - if (m_isI2C) - { - ret = expandWrite(value | LCD_EN); - usleep(1); - ret = expandWrite(value & ~LCD_EN); - usleep(50); - return ret; - } - - // else gpio - - ret = m_gpioEnable->write(0); - usleep(1); - ret = m_gpioEnable->write(1); - usleep(1); // must be > 450ns - ret = m_gpioEnable->write(0); - usleep(100); // must be >37us - - return ret; -} diff --git a/src/lcd/lcm1602.hpp b/src/lcd/lcm1602.hpp deleted file mode 100644 index 9f05d994..00000000 --- a/src/lcd/lcm1602.hpp +++ /dev/null @@ -1,285 +0,0 @@ -/* - * The MIT License (MIT) - * - * Author: Daniel Mosquera - * Copyright (c) 2013 Daniel Mosquera - * - * Author: Thomas Ingleby - * Copyright (c) 2014 Intel Corporation. - * - * Contributions: Jon Trulson - * Sergey Kiselev - * - * Permission is hereby granted, free of uint8_tge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#include - -#include "lcd.hpp" - -namespace upm -{ -/** - * @library i2clcd - * @sensor lcm1602 - * @comname 16x2 and 20x4 LCD Display - * @type display - * @man adafruit sparkfun seeed - * @web https://www.adafruit.com/datasheets/TC1602A-01T.pdf - * @con i2c gpio - * - * @brief API for the LCM1602 I2C controller for HD44780-based displays - * - * This supports all sizes of HD44780 displays, from 16x2 to 4x20. The - * controller has no idea of the actual display hardware, so it lets you write - * farther than you can see. These displays with such controllers are available - * from various manufacturers with different I2C addresses. Adafruit* - * TC1602A-01T seems to be a well-documented example. The driver also supports - * parallel GPIO connections directly to the HD44780 in case you are not using - * an I2C expander/backpack. - * - * @image html lcm1602.jpeg - * Example for LCM1602 displays that use the I2C bus - * @snippet lcm1602-i2c.cxx Interesting - * Code sample for GPIO based LCM1602 displays - * @snippet lcm1602-parallel.cxx Interesting - */ -class Lcm1602 : public LCD -{ - public: - /** - * Lcm1602 constructor; calls libmraa initialisation functions - * - * @param bus I2C bus to use. Default 0 (autodetect). - * @param address Slave address the LCD is registered on. Default 0x27 - * @param isExpander True if we are dealing with an I2C expander, - * false otherwise. Default is true. - * @param numColumns Number of columns the display has. Default 16. - * @param numRows Number of rows the display has. Default 2. - */ - Lcm1602(int bus = 0, int address = 0x27, bool isExpander=true, - uint8_t numColumns = 16, uint8_t numRows = 2); - - /** - * Lcm1602 alternate constructor, used for GPIO based HD44780 - * controllers supporting RS, Enable, and 4 data pins in 4-bit - * mode. - * - * @param rs Register select pin - * @param enable Enable pin - * @param d0 Data 0 pin - * @param d1 Data 1 pin - * @param d2 Data 2 pin - * @param d3 Data 3 pin - * @param numColumns Number of columns the display has. Default 16. - * @param numRows Number of rows the display has. Default 2. - */ - Lcm1602(int rs, int enable, - int d0, int d1, int d2, int d3, - uint8_t numColumns = 16, uint8_t numRows = 2); - - /** - * Lcm1602 destructor - */ - ~Lcm1602(); - /** - * Writes a string to the LCD - * - * @param msg std::string to write to the display; note: only ASCII - * characters are supported - * @return Result of the operation - */ - mraa::Result write(std::string msg); - /** - * Sets the cursor to specified coordinates - * - * @param row Row to set the cursor to - * @param column Column to set the cursor to - * @return Result of the operation - */ - mraa::Result setCursor(int row, int column); - /** - * Clears the display of all characters - * - * @return Result of the operation - */ - mraa::Result clear(); - /** - * Returns to the original coordinates (0,0) - * - * @return Result of the operation - */ - mraa::Result home(); - - /** - * Create a custom character - * - * @param charSlot the character slot to write, only 8 are available - * @param charData The character data (8 bytes) making up the character - * @return Result of operation - */ - mraa::Result createChar(uint8_t charSlot, uint8_t charData[]); - - /** - * Turn the display on - * - * @return Result of operation - */ - mraa::Result displayOn(); - - /** - * Turn the display off - * - * @return Result of operation - */ - mraa::Result displayOff(); - - /** - * Turn the cursor on - * - * @return Result of operation - */ - mraa::Result cursorOn(); - - /** - * Turn the cursor off - * - * @return Result of operation - */ - mraa::Result cursorOff(); - - /** - * Turn cursor blink on - * - * @return Result of operation - */ - mraa::Result cursorBlinkOn(); - - /** - * Turn cursor blink off - * - * @return Result of operation - */ - mraa::Result cursorBlinkOff(); - - /** - * Turn backlight on - * - * @return Result of operation - */ - mraa::Result backlightOn(); - - /** - * Turn backlight off - * - * @return Result of operation - */ - mraa::Result backlightOff(); - - /** - * Scroll the display left, without changing the character RAM - * - * @return Result of operation - */ - mraa::Result scrollDisplayLeft(); - - /** - * Scroll the display right, without changing the character RAM - * - * @return Result of operation - */ - mraa::Result scrollDisplayRight(); - - /** - * set the entry mode so that characters are added left to right - * - * @return Result of operation - */ - mraa::Result entryLeftToRight(); - - /** - * set the entry mode so that characters are added right to left - * - * @return Result of operation - */ - mraa::Result entryRightToLeft(); - - /** - * Right justify text entered from the cursor - * - * @return Result of operation - */ - mraa::Result autoscrollOn(); - - /** - * Left justify text entered from the cursor - * - * @return Result of operation - */ - mraa::Result autoscrollOff(); - - - protected: - mraa::Result send(uint8_t value, int mode); - mraa::Result write4bits(uint8_t value); - mraa::Result expandWrite(uint8_t value); - mraa::Result pulseEnable(uint8_t value); - - uint8_t m_displayControl; - uint8_t m_entryDisplayMode; - - // Display size - uint8_t m_numColumns; - uint8_t m_numRows; - - mraa::I2c* m_i2c_lcd_control; - - // gpio operation - mraa::Gpio* m_gpioRS; - mraa::Gpio* m_gpioEnable; - mraa::Gpio* m_gpioD0; - mraa::Gpio* m_gpioD1; - mraa::Gpio* m_gpioD2; - mraa::Gpio* m_gpioD3; - - // Backlight - uint8_t m_backlight; - - // Add a command() and data() virtual member functions, with a - // default implementation in lcm1602. This is expected to be - // implemented by derived classes with different needs (Jhd1313m1, - // for example). - virtual mraa::Result command(uint8_t cmd); - virtual mraa::Result data(uint8_t data); - - int m_lcd_control_address; - - private: - - // true if using i2c, false otherwise (gpio) - bool m_isI2C; -}; -} diff --git a/src/lcd/pyupm_i2clcd.i b/src/lcd/pyupm_i2clcd.i index 7de2f554..3ad92ab7 100644 --- a/src/lcd/pyupm_i2clcd.i +++ b/src/lcd/pyupm_i2clcd.i @@ -12,16 +12,6 @@ #include "lcd.hpp" %} -%include "lcm1602.hpp" -%{ - #include "lcm1602.hpp" -%} - -%include "jhd1313m1.hpp" -%{ - #include "jhd1313m1.hpp" -%} - %include "ssd1327.hpp" %{ #include "ssd1327.hpp" @@ -37,11 +27,6 @@ #include "eboled.hpp" %} -%include "sainsmartks.hpp" -%{ - #include "sainsmartks.hpp" -%} - %include "ssd1306.hpp" %{ #include "ssd1306.hpp" diff --git a/src/lcd/sainsmartks.cxx b/src/lcd/sainsmartks.cxx deleted file mode 100644 index ef3469bb..00000000 --- a/src/lcd/sainsmartks.cxx +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Author: Jon Trulson - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include - -#include "sainsmartks.hpp" - -using namespace upm; - -SAINSMARTKS::SAINSMARTKS(int rs, int enable, - int d0, int d1, int d2, int d3, - int keypad) - : Lcm1602(rs, enable, d0, d1, d2, d3), - m_aioKeypad(keypad) -{ - m_name = "Sainsmart LCD Keypad Shield"; -} - -SAINSMARTKS::~SAINSMARTKS() -{ -} - -float SAINSMARTKS::getRawKeyValue() -{ - return m_aioKeypad.readFloat(); -} diff --git a/src/lcd/sainsmartks.hpp b/src/lcd/sainsmartks.hpp deleted file mode 100644 index 6ce42fdd..00000000 --- a/src/lcd/sainsmartks.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Author: Jon Trulson - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#pragma once - -#include -#include -#include "lcm1602.hpp" - -namespace upm -{ - /** - * @library i2clcd - * @sensor sainsmartks - * @comname LCD Keypad Shield - * @type display - * @man sainsmart dfrobot sparkfun - * @web http://www.sainsmart.com/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html - * @web http://www.dfrobot.com/index.php?route=product/product&product_id=51 - * @web https://www.sparkfun.com/products/13293 - * @con gpio analog - * - * @brief API for Sainsmart LCD Keypad Shield - * - * The Sainsmart LCD Keypad Shield uses 6 digital outputs and 1 analog input - * (for the keypad). The outputs are used to drive an attached LCM1602 LCD - * controller. This driver should also be compatible with the similar LCD - * keypad shields from DFRobot and Sparkfun. - * - * @image html keypadlcd.jpg - * @snippet sainsmartks.cxx Interesting - */ - class SAINSMARTKS : public Lcm1602 - { - public: - /** - * SAINSMARTKS constructor - * - * As this is a shield, you will not likely have any choice over - * the pins that are used. For this reason, we provide defaults - * for all of them -- of course they can be changed if your device - * is different. - * - * @param rs register select pin - * @param enable enable pin - * @param d0 data 0 pin - * @param d1 data 1 pin - * @param d2 data 2 pin - * @param d3 data 3 pin - * @param keypad analog pin of the keypad - */ - SAINSMARTKS(int rs=8, int enable=9, - int d0=4, int d1=5, int d2=6, int d3=7, - int keypad=0); - /** - * SAINSMARTKS destructor - */ - ~SAINSMARTKS(); - - /** - * returns the floating point representation of the key that is - * being pushed. Each key produces a different value between 0.0 - * and 1.0, and only one key can be read at a time. - * - * @return the floating point value representing a key - */ - float getRawKeyValue(); - - private: - mraa::Aio m_aioKeypad; - }; -} diff --git a/src/lcm1602/CMakeLists.txt b/src/lcm1602/CMakeLists.txt index c9ade019..8dad3da0 100644 --- a/src/lcm1602/CMakeLists.txt +++ b/src/lcm1602/CMakeLists.txt @@ -2,8 +2,7 @@ upm_mixed_module_init (NAME lcm1602 DESCRIPTION "LCD Display Driver for the LCM1602 Controller for HD44780-based Displays" C_HDR lcm1602.h C_SRC lcm1602.c - CPP_HDR lcm1602.hxx + CPP_HDR lcm1602.hpp CPP_SRC lcm1602.cxx -# FTI_SRC lcm1602_fti.c CPP_WRAPS_C REQUIRES mraa) diff --git a/src/lcm1602/javaupm_lcm1602.i b/src/lcm1602/javaupm_lcm1602.i index ccb488e6..6528b385 100644 --- a/src/lcm1602/javaupm_lcm1602.i +++ b/src/lcm1602/javaupm_lcm1602.i @@ -1,32 +1,11 @@ %module javaupm_lcm1602 %include "../upm.i" -%include "stdint.i" +%include "../upm_vectortypes.i" %include "typemaps.i" -%include "arrays_java.i"; - -%apply signed char[] {uint8_t []}; -%ignore BasicFont; - -%typemap(jni) (uint8_t *data, int bytes) "jbyteArray"; -%typemap(jtype) (uint8_t *data, int bytes) "byte[]"; -%typemap(jstype) (uint8_t *data, int bytes) "byte[]"; - -%typemap(javain) (uint8_t *data, int bytes) "$javainput"; - -%typemap(in) (uint8_t *data, int bytes) { - $1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL); - $2 = JCALL1(GetArrayLength, jenv, $input); -} - -%typemap(freearg) (uint8_t *data, int bytes) { - JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); -} - -%include "lcm1602.h" -%include "lcm1602.hxx" +%include "lcm1602.hpp" %{ - #include "lcm1602.hxx" + #include "lcm1602.hpp" %} %pragma(java) jniclasscode=%{ diff --git a/src/lcm1602/jsupm_lcm1602.i b/src/lcm1602/jsupm_lcm1602.i index d8cf332c..63f01d8f 100644 --- a/src/lcm1602/jsupm_lcm1602.i +++ b/src/lcm1602/jsupm_lcm1602.i @@ -1,9 +1,8 @@ %module jsupm_lcm1602 %include "../upm.i" -%include "../carrays_uint8_t.i" +%include "../upm_vectortypes.i" -%include "lcm1602.h" -%include "lcm1602.hxx" +%include "lcm1602.hpp" %{ - #include "lcm1602.hxx" + #include "lcm1602.hpp" %} diff --git a/src/lcm1602/lcm1602.c b/src/lcm1602/lcm1602.c index d917206b..1718d79d 100644 --- a/src/lcm1602/lcm1602.c +++ b/src/lcm1602/lcm1602.c @@ -377,7 +377,7 @@ upm_result_t lcm1602_home(const lcm1602_context dev) upm_result_t lcm1602_create_char(const lcm1602_context dev, unsigned int slot, - lcm1602_custom_char_t data) + char *data) { assert(dev != NULL); diff --git a/src/lcm1602/lcm1602.cxx b/src/lcm1602/lcm1602.cxx index e8c84b0e..26a94af6 100644 --- a/src/lcm1602/lcm1602.cxx +++ b/src/lcm1602/lcm1602.cxx @@ -35,7 +35,7 @@ #include #include -#include "lcm1602.hxx" +#include "lcm1602.hpp" using namespace upm; @@ -86,9 +86,9 @@ upm_result_t Lcm1602::home() } upm_result_t Lcm1602::createChar(uint8_t charSlot, - lcm1602_custom_char_t charData) + std::vector charData) { - return lcm1602_create_char(m_lcm1602, charSlot, charData); + return lcm1602_create_char(m_lcm1602, charSlot, (char *)charData.data()); } upm_result_t Lcm1602::displayOn() diff --git a/src/lcm1602/lcm1602.h b/src/lcm1602/lcm1602.h index 1939d7af..2fafbcf4 100644 --- a/src/lcm1602/lcm1602.h +++ b/src/lcm1602/lcm1602.h @@ -81,11 +81,6 @@ extern "C" { uint8_t backlight; } *lcm1602_context; - /** - * Custom character. - */ - typedef char lcm1602_custom_char_t[8]; - /** * LCM1602 I2C initialization. This is used for those devices * using an I2C expander, or other I2C interface. If you are @@ -181,7 +176,7 @@ extern "C" { */ upm_result_t lcm1602_create_char(const lcm1602_context dev, unsigned int slot, - lcm1602_custom_char_t data); + char *data); /** * Turn the display on. diff --git a/src/lcm1602/lcm1602.hxx b/src/lcm1602/lcm1602.hpp similarity index 97% rename from src/lcm1602/lcm1602.hxx rename to src/lcm1602/lcm1602.hpp index faae0d09..dfccaa4b 100644 --- a/src/lcm1602/lcm1602.hxx +++ b/src/lcm1602/lcm1602.hpp @@ -34,6 +34,7 @@ #pragma once #include +#include #include "lcm1602.h" namespace upm @@ -144,11 +145,11 @@ namespace upm * Create a custom character * * @param charSlot the character slot to write, only 8 are available - * @param charData The character data (8 bytes) making up the character + * @param charData A vector containing 8 bytes making up the character * @return Result of operation */ upm_result_t createChar(uint8_t charSlot, - lcm1602_custom_char_t charData); + std::vector charData); /** * Turn the display on diff --git a/src/lcm1602/pyupm_lcm1602.i b/src/lcm1602/pyupm_lcm1602.i index 9cfe88bf..08e1a459 100644 --- a/src/lcm1602/pyupm_lcm1602.i +++ b/src/lcm1602/pyupm_lcm1602.i @@ -2,12 +2,11 @@ %include "pyupm_doxy2swig.i" %module pyupm_lcm1602 %include "../upm.i" -%include "../carrays_uint8_t.i" +%include "../upm_vectortypes.i" %feature("autodoc", "3"); -%include "lcm1602.h" -%include "lcm1602.hxx" +%include "lcm1602.hpp" %{ - #include "lcm1602.hxx" + #include "lcm1602.hpp" %}