mirror of
https://github.com/eclipse/upm.git
synced 2025-07-06 03:41:13 +03:00
lcm1602: add 4-bit gpio support with RS and Enable pins
In addition, move the command/data sending methods into the protected block so that derived classes can use them if need be. Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
8462e8ce52
commit
5a6fb122ec
@ -7,6 +7,8 @@
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Contributions: Jon Trulson <jtrulson@ics.com>
|
||||
*
|
||||
* 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
|
||||
@ -29,6 +31,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <mraa/gpio.hpp>
|
||||
#include "lcd.h"
|
||||
|
||||
namespace upm
|
||||
@ -63,6 +66,22 @@ class Lcm1602 : public LCD
|
||||
* @param address the slave address the lcd is registered on
|
||||
*/
|
||||
Lcm1602(int bus, int address);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
Lcm1602(uint8_t rs, uint8_t enable,
|
||||
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
|
||||
|
||||
/**
|
||||
* Lcm1602 Destructor
|
||||
*/
|
||||
@ -105,14 +124,25 @@ class Lcm1602 : public LCD
|
||||
*/
|
||||
mraa_result_t createChar(uint8_t charSlot, uint8_t charData[]);
|
||||
|
||||
private:
|
||||
protected:
|
||||
mraa_result_t send(uint8_t value, int mode);
|
||||
mraa_result_t write4bits(uint8_t value);
|
||||
mraa_result_t expandWrite(uint8_t value);
|
||||
mraa_result_t pulseEnable(uint8_t value);
|
||||
|
||||
private:
|
||||
int m_lcd_control_address;
|
||||
mraa::I2c m_i2c_lcd_control;
|
||||
mraa::I2c* m_i2c_lcd_control;
|
||||
|
||||
// true if using i2c, false otherwise (gpio)
|
||||
bool m_isI2C;
|
||||
|
||||
// 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;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user