mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 17:30:01 +03:00
i2clcd: Reformat the lcd source code
Reformatted to prepare for improving the error handling. This reformatting was done using clang-format. Signed-off-by: Wouter van Verre <wouter.van.verre@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
3abd3a5ee9
commit
bb59d5db7a
@ -29,7 +29,8 @@
|
||||
|
||||
using namespace upm;
|
||||
|
||||
I2CLcd::I2CLcd (int bus, int lcdAddress) {
|
||||
I2CLcd::I2CLcd(int bus, int lcdAddress)
|
||||
{
|
||||
m_lcd_control_address = lcdAddress;
|
||||
m_bus = bus;
|
||||
|
||||
@ -42,13 +43,15 @@ I2CLcd::I2CLcd (int bus, int lcdAddress) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::write (int row, int column, std::string msg) {
|
||||
I2CLcd::write(int row, int column, std::string msg)
|
||||
{
|
||||
setCursor(row, column);
|
||||
write(msg);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::createChar(uint8_t charSlot, uint8_t charData[]) {
|
||||
I2CLcd::createChar(uint8_t charSlot, uint8_t charData[])
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
charSlot &= 0x07; // only have 8 positions we can set
|
||||
error = i2Cmd(m_i2c_lcd_control, LCD_SETCGRAMADDR | (charSlot << 3));
|
||||
@ -62,12 +65,20 @@ I2CLcd::createChar(uint8_t charSlot, uint8_t charData[]) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::close() {
|
||||
I2CLcd::close()
|
||||
{
|
||||
return mraa_i2c_stop(m_i2c_lcd_control);
|
||||
}
|
||||
|
||||
std::string
|
||||
I2CLcd::name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::i2cReg (mraa_i2c_context ctx, int deviceAdress, int addr, uint8_t value) {
|
||||
I2CLcd::i2cReg(mraa_i2c_context ctx, int deviceAdress, int addr, uint8_t value)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
uint8_t data[2] = { addr, value };
|
||||
@ -78,7 +89,8 @@ I2CLcd::i2cReg (mraa_i2c_context ctx, int deviceAdress, int addr, uint8_t value)
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::i2Cmd (mraa_i2c_context ctx, uint8_t value) {
|
||||
I2CLcd::i2Cmd(mraa_i2c_context ctx, uint8_t value)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
uint8_t data[2] = { LCD_CMD, value };
|
||||
@ -89,7 +101,8 @@ I2CLcd::i2Cmd (mraa_i2c_context ctx, uint8_t value) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
I2CLcd::i2cData (mraa_i2c_context ctx, uint8_t value) {
|
||||
I2CLcd::i2cData(mraa_i2c_context ctx, uint8_t value)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
uint8_t data[2] = { LCD_DATA, value };
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include <string>
|
||||
#include <mraa/i2c.h>
|
||||
|
||||
namespace upm {
|
||||
|
||||
namespace upm
|
||||
{
|
||||
// commands
|
||||
#define LCD_CLEARDISPLAY 0x01
|
||||
#define LCD_RETURNHOME 0x02
|
||||
@ -80,7 +80,8 @@ namespace upm {
|
||||
* @defgroup i2clcd libupm-i2clcd
|
||||
* @ingroup seeed sparkfun adafruit i2c display gsk
|
||||
*/
|
||||
class I2CLcd {
|
||||
class I2CLcd
|
||||
{
|
||||
public:
|
||||
I2CLcd(int bus, int lcdAddress);
|
||||
mraa_result_t write(int x, int y, std::string msg);
|
||||
@ -95,15 +96,12 @@ class I2CLcd {
|
||||
virtual mraa_result_t i2cData(mraa_i2c_context ctx, uint8_t value);
|
||||
|
||||
mraa_result_t close();
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
std::string name();
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
int m_lcd_control_address;
|
||||
int m_bus;
|
||||
mraa_i2c_context m_i2c_lcd_control;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,8 @@
|
||||
|
||||
using namespace upm;
|
||||
|
||||
Jhd1313m1::Jhd1313m1 (int bus, int lcdAddress, int rgbAddress) : I2CLcd(bus, lcdAddress) {
|
||||
Jhd1313m1::Jhd1313m1(int bus, int lcdAddress, int rgbAddress) : I2CLcd(bus, lcdAddress)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
m_rgb_address = rgbAddress;
|
||||
@ -53,9 +54,7 @@ Jhd1313m1::Jhd1313m1 (int bus, int lcdAddress, int rgbAddress) : I2CLcd(bus, lcd
|
||||
clear();
|
||||
usleep(4500);
|
||||
|
||||
i2Cmd (m_i2c_lcd_control, LCD_ENTRYMODESET |
|
||||
LCD_ENTRYLEFT |
|
||||
LCD_ENTRYSHIFTDECREMENT);
|
||||
i2Cmd(m_i2c_lcd_control, LCD_ENTRYMODESET | LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT);
|
||||
|
||||
i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0, 0);
|
||||
i2cReg(m_i2c_lcd_rgb, m_rgb_address, 1, 0);
|
||||
@ -66,8 +65,8 @@ Jhd1313m1::Jhd1313m1 (int bus, int lcdAddress, int rgbAddress) : I2CLcd(bus, lcd
|
||||
i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x02, 255);
|
||||
}
|
||||
|
||||
Jhd1313m1::~Jhd1313m1() {
|
||||
|
||||
Jhd1313m1::~Jhd1313m1()
|
||||
{
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
@ -98,7 +97,8 @@ Jhd1313m1::scroll(bool direction)
|
||||
* **************
|
||||
*/
|
||||
mraa_result_t
|
||||
Jhd1313m1::write (std::string msg) {
|
||||
Jhd1313m1::write(std::string msg)
|
||||
{
|
||||
usleep(1000);
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
for (std::string::size_type i = 0; i < msg.size(); ++i) {
|
||||
@ -109,7 +109,8 @@ Jhd1313m1::write (std::string msg) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
Jhd1313m1::setCursor (int row, int column) {
|
||||
Jhd1313m1::setCursor(int row, int column)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
int row_addr[] = { 0x80, 0xc0, 0x14, 0x54 };
|
||||
uint8_t offset = ((column % 16) + row_addr[row]);
|
||||
@ -119,11 +120,13 @@ Jhd1313m1::setCursor (int row, int column) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
Jhd1313m1::clear () {
|
||||
Jhd1313m1::clear()
|
||||
{
|
||||
return i2Cmd(m_i2c_lcd_control, LCD_CLEARDISPLAY);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
Jhd1313m1::home () {
|
||||
Jhd1313m1::home()
|
||||
{
|
||||
return i2Cmd(m_i2c_lcd_control, LCD_RETURNHOME);
|
||||
}
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include <string>
|
||||
#include "i2clcd.h"
|
||||
|
||||
namespace upm {
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @library i2clcd
|
||||
* @sensor jhd1313m1
|
||||
@ -50,7 +50,8 @@ namespace upm {
|
||||
* @image html grovergblcd.jpg
|
||||
* @snippet jhd1313m1-lcd.cxx Interesting
|
||||
*/
|
||||
class Jhd1313m1 : public I2CLcd {
|
||||
class Jhd1313m1 : public I2CLcd
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Jhd1313m1 constructor
|
||||
@ -113,5 +114,4 @@ class Jhd1313m1 : public I2CLcd {
|
||||
int m_rgb_address;
|
||||
mraa_i2c_context m_i2c_lcd_rgb;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,8 @@
|
||||
|
||||
using namespace upm;
|
||||
|
||||
Lcm1602::Lcm1602(int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
|
||||
Lcm1602::Lcm1602(int bus_in, int addr_in) : I2CLcd(bus_in, addr_in)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
usleep(50000);
|
||||
@ -60,8 +61,8 @@ Lcm1602::Lcm1602(int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
|
||||
home();
|
||||
}
|
||||
|
||||
Lcm1602::~Lcm1602 () {
|
||||
|
||||
Lcm1602::~Lcm1602()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
@ -70,7 +71,8 @@ Lcm1602::~Lcm1602 () {
|
||||
* **************
|
||||
*/
|
||||
mraa_result_t
|
||||
Lcm1602::write (std::string msg) {
|
||||
Lcm1602::write(std::string msg)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
for (std::string::size_type i = 0; i < msg.size(); ++i) {
|
||||
error = send(msg[i], LCD_RS);
|
||||
@ -79,7 +81,8 @@ Lcm1602::write (std::string msg) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
Lcm1602::setCursor (int row, int column) {
|
||||
Lcm1602::setCursor(int row, int column)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
int row_addr[] = { 0x80, 0xc0, 0x14, 0x54 };
|
||||
@ -89,12 +92,14 @@ Lcm1602::setCursor (int row, int column) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
Lcm1602::clear () {
|
||||
Lcm1602::clear()
|
||||
{
|
||||
return send(LCD_CLEARDISPLAY, 0);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
Lcm1602::home () {
|
||||
Lcm1602::home()
|
||||
{
|
||||
return send(LCD_RETURNHOME, 0);
|
||||
}
|
||||
|
||||
@ -104,7 +109,8 @@ Lcm1602::home () {
|
||||
* **************
|
||||
*/
|
||||
mraa_result_t
|
||||
Lcm1602::send (uint8_t value, int mode) {
|
||||
Lcm1602::send(uint8_t value, int mode)
|
||||
{
|
||||
mraa_result_t ret = MRAA_SUCCESS;
|
||||
uint8_t h = value & 0xf0;
|
||||
uint8_t l = (value << 4) & 0xf0;
|
||||
|
@ -30,7 +30,8 @@
|
||||
#include <string>
|
||||
#include "i2clcd.h"
|
||||
|
||||
namespace upm {
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @library i2clcd
|
||||
* @sensor lcm1602
|
||||
@ -51,7 +52,8 @@ namespace upm {
|
||||
* @image html lcm1602.jpeg
|
||||
* @snippet lcm1602-lcd.cxx Interesting
|
||||
*/
|
||||
class Lcm1602 : public I2CLcd {
|
||||
class Lcm1602 : public I2CLcd
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Lcm1602 Constructor, calls libmraa initialisation functions
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace upm {
|
||||
|
||||
namespace upm
|
||||
{
|
||||
#define DISPLAY_CMD_OFF 0xAE
|
||||
#define DISPLAY_CMD_ON 0xAF
|
||||
|
||||
@ -34,9 +34,7 @@ namespace upm {
|
||||
#define BASE_PAGE_START_ADDR 0xB0
|
||||
#define DISPLAY_CMD_MEM_ADDR_MODE 0x20
|
||||
|
||||
const uint8_t BasicFont[][8] =
|
||||
{
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
const uint8_t BasicFont[][8] = { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
{ 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00 },
|
||||
{ 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x00 },
|
||||
@ -131,13 +129,7 @@ const uint8_t BasicFont[][8] =
|
||||
{ 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
{ 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x00, 0x00 },
|
||||
{ 0x00, 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x00 },
|
||||
{0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
HORIZONTAL = 0,
|
||||
VERTICAL = 1,
|
||||
PAGE = 2
|
||||
} displayAddressingMode;
|
||||
{ 0x00, 0x02, 0x05, 0x05, 0x02, 0x00, 0x00, 0x00 } };
|
||||
|
||||
typedef enum { HORIZONTAL = 0, VERTICAL = 1, PAGE = 2 } displayAddressingMode;
|
||||
}
|
||||
|
@ -29,7 +29,8 @@
|
||||
|
||||
using namespace upm;
|
||||
|
||||
SSD1308::SSD1308 (int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
|
||||
SSD1308::SSD1308(int bus_in, int addr_in) : I2CLcd(bus_in, addr_in)
|
||||
{
|
||||
i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_OFF); // display off
|
||||
usleep(4500);
|
||||
i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_ON); // display on
|
||||
@ -40,12 +41,13 @@ SSD1308::SSD1308 (int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
|
||||
setAddressingMode(PAGE);
|
||||
}
|
||||
|
||||
SSD1308::~SSD1308 () {
|
||||
|
||||
SSD1308::~SSD1308()
|
||||
{
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1308::draw (uint8_t *data, int bytes) {
|
||||
SSD1308::draw(uint8_t* data, int bytes)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
setAddressingMode(HORIZONTAL);
|
||||
@ -62,7 +64,8 @@ SSD1308::draw (uint8_t *data, int bytes) {
|
||||
* **************
|
||||
*/
|
||||
mraa_result_t
|
||||
SSD1308::write (std::string msg) {
|
||||
SSD1308::write(std::string msg)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
uint8_t data[2] = { 0x40, 0 };
|
||||
|
||||
@ -75,18 +78,22 @@ SSD1308::write (std::string msg) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1308::setCursor (int row, int column) {
|
||||
SSD1308::setCursor(int row, int column)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
error = i2Cmd(m_i2c_lcd_control, BASE_PAGE_START_ADDR + row); // set page address
|
||||
error = i2Cmd (m_i2c_lcd_control, BASE_LOW_COLUMN_ADDR + (8 * column & 0x0F)); // set column lower address
|
||||
error = i2Cmd (m_i2c_lcd_control, BASE_HIGH_COLUMN_ADDR + ((8 * column >> 4) & 0x0F)); // set column higher address
|
||||
error = i2Cmd(m_i2c_lcd_control,
|
||||
BASE_LOW_COLUMN_ADDR + (8 * column & 0x0F)); // set column lower address
|
||||
error = i2Cmd(m_i2c_lcd_control,
|
||||
BASE_HIGH_COLUMN_ADDR + ((8 * column >> 4) & 0x0F)); // set column higher address
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1308::clear () {
|
||||
SSD1308::clear()
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
uint8_t columnIdx, rowIdx;
|
||||
|
||||
@ -106,7 +113,8 @@ SSD1308::clear () {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1308::home () {
|
||||
SSD1308::home()
|
||||
{
|
||||
return setCursor(0, 0);
|
||||
}
|
||||
|
||||
@ -116,7 +124,8 @@ SSD1308::home () {
|
||||
* **************
|
||||
*/
|
||||
mraa_result_t
|
||||
SSD1308::writeChar (mraa_i2c_context ctx, uint8_t value) {
|
||||
SSD1308::writeChar(mraa_i2c_context ctx, uint8_t value)
|
||||
{
|
||||
if (value < 0x20 || value > 0x7F) {
|
||||
value = 0x20; // space
|
||||
}
|
||||
@ -127,12 +136,14 @@ SSD1308::writeChar (mraa_i2c_context ctx, uint8_t value) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1308::setNormalDisplay () {
|
||||
SSD1308::setNormalDisplay()
|
||||
{
|
||||
return i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_SET_NORMAL_1308); // set to normal display '1' is ON
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1308::setAddressingMode (displayAddressingMode mode) {
|
||||
SSD1308::setAddressingMode(displayAddressingMode mode)
|
||||
{
|
||||
i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_MEM_ADDR_MODE); // set addressing mode
|
||||
i2Cmd(m_i2c_lcd_control, mode); // set page addressing mode
|
||||
}
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "i2clcd.h"
|
||||
#include "ssd.h"
|
||||
|
||||
namespace upm {
|
||||
|
||||
namespace upm
|
||||
{
|
||||
#define DISPLAY_CMD_SET_NORMAL_1308 0xA6
|
||||
|
||||
/**
|
||||
@ -52,7 +52,8 @@ namespace upm {
|
||||
* @image html ssd1308.jpeg
|
||||
* @snippet ssd1308-oled.cxx Interesting
|
||||
*/
|
||||
class SSD1308 : public I2CLcd {
|
||||
class SSD1308 : public I2CLcd
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* SSD1308 Constructor, calls libmraa initialisation functions
|
||||
@ -102,6 +103,7 @@ class SSD1308 : public I2CLcd {
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t home();
|
||||
|
||||
private:
|
||||
mraa_result_t writeChar(mraa_i2c_context ctx, uint8_t value);
|
||||
mraa_result_t setNormalDisplay();
|
||||
|
@ -32,10 +32,12 @@ using namespace upm;
|
||||
#define INIT_SLEEP 50000
|
||||
#define CMD_SLEEP 10000
|
||||
|
||||
SSD1327::SSD1327 (int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
|
||||
SSD1327::SSD1327(int bus_in, int addr_in) : I2CLcd(bus_in, addr_in)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
usleep(INIT_SLEEP);
|
||||
i2Cmd (m_i2c_lcd_control, 0xFD); // Unlock OLED driver IC MCU interface from entering command. i.e: Accept commands
|
||||
i2Cmd(m_i2c_lcd_control,
|
||||
0xFD); // Unlock OLED driver IC MCU interface from entering command. i.e: Accept commands
|
||||
usleep(INIT_SLEEP);
|
||||
i2Cmd(m_i2c_lcd_control, 0x12);
|
||||
usleep(INIT_SLEEP);
|
||||
@ -109,9 +111,11 @@ SSD1327::SSD1327 (int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
|
||||
// Column Address
|
||||
error = i2Cmd(m_i2c_lcd_control, 0x15); // Set Column Address
|
||||
usleep(INIT_SLEEP);
|
||||
error = i2Cmd (m_i2c_lcd_control, 0x08); // Start from 8th Column of driver IC. This is 0th Column for OLED
|
||||
error = i2Cmd(m_i2c_lcd_control,
|
||||
0x08); // Start from 8th Column of driver IC. This is 0th Column for OLED
|
||||
usleep(INIT_SLEEP);
|
||||
error = i2Cmd (m_i2c_lcd_control, 0x37); // End at (8 + 47)th column. Each Column has 2 pixels(segments)
|
||||
error = i2Cmd(m_i2c_lcd_control, 0x37); // End at (8 + 47)th column. Each Column has 2
|
||||
// pixels(segments)
|
||||
usleep(INIT_SLEEP);
|
||||
|
||||
clear();
|
||||
@ -119,12 +123,13 @@ SSD1327::SSD1327 (int bus_in, int addr_in) : I2CLcd (bus_in, addr_in) {
|
||||
setVerticalMode();
|
||||
}
|
||||
|
||||
SSD1327::~SSD1327 () {
|
||||
|
||||
SSD1327::~SSD1327()
|
||||
{
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::draw (uint8_t *data, int bytes) {
|
||||
SSD1327::draw(uint8_t* data, int bytes)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
setHorizontalMode();
|
||||
@ -152,7 +157,8 @@ SSD1327::draw (uint8_t *data, int bytes) {
|
||||
* **************
|
||||
*/
|
||||
mraa_result_t
|
||||
SSD1327::write (std::string msg) {
|
||||
SSD1327::write(std::string msg)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
setVerticalMode();
|
||||
@ -164,7 +170,8 @@ SSD1327::write (std::string msg) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::setCursor (int row, int column) {
|
||||
SSD1327::setCursor(int row, int column)
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
// Column Address
|
||||
@ -186,7 +193,8 @@ SSD1327::setCursor (int row, int column) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::clear () {
|
||||
SSD1327::clear()
|
||||
{
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
uint8_t columnIdx, rowIdx;
|
||||
|
||||
@ -201,12 +209,14 @@ SSD1327::clear () {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::home () {
|
||||
SSD1327::home()
|
||||
{
|
||||
return setCursor(0, 0);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::setGrayLevel (uint8_t level) {
|
||||
SSD1327::setGrayLevel(uint8_t level)
|
||||
{
|
||||
grayHigh = (level << 4) & 0xF0;
|
||||
grayLow = level & 0x0F;
|
||||
}
|
||||
@ -217,7 +227,8 @@ SSD1327::setGrayLevel (uint8_t level) {
|
||||
* **************
|
||||
*/
|
||||
mraa_result_t
|
||||
SSD1327::writeChar (mraa_i2c_context ctx, uint8_t value) {
|
||||
SSD1327::writeChar(mraa_i2c_context ctx, uint8_t value)
|
||||
{
|
||||
if (value < 0x20 || value > 0x7F) {
|
||||
value = 0x20; // space
|
||||
}
|
||||
@ -239,12 +250,14 @@ SSD1327::writeChar (mraa_i2c_context ctx, uint8_t value) {
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::setNormalDisplay () {
|
||||
SSD1327::setNormalDisplay()
|
||||
{
|
||||
return i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_SET_NORMAL); // set to normal display '1' is ON
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::setHorizontalMode () {
|
||||
SSD1327::setHorizontalMode()
|
||||
{
|
||||
i2Cmd(m_i2c_lcd_control, 0xA0); // remap to
|
||||
usleep(CMD_SLEEP);
|
||||
i2Cmd(m_i2c_lcd_control, 0x42); // horizontal mode
|
||||
@ -261,14 +274,17 @@ SSD1327::setHorizontalMode () {
|
||||
// Column Address
|
||||
i2Cmd(m_i2c_lcd_control, 0x15); // Set Column Address
|
||||
usleep(CMD_SLEEP);
|
||||
i2Cmd (m_i2c_lcd_control, 0x08); // Start from 8th Column of driver IC. This is 0th Column for OLED
|
||||
i2Cmd(m_i2c_lcd_control,
|
||||
0x08); // Start from 8th Column of driver IC. This is 0th Column for OLED
|
||||
usleep(CMD_SLEEP);
|
||||
i2Cmd (m_i2c_lcd_control, 0x37); // End at (8 + 47)th column. Each Column has 2 pixels(or segments)
|
||||
i2Cmd(m_i2c_lcd_control,
|
||||
0x37); // End at (8 + 47)th column. Each Column has 2 pixels(or segments)
|
||||
usleep(CMD_SLEEP);
|
||||
}
|
||||
|
||||
mraa_result_t
|
||||
SSD1327::setVerticalMode () {
|
||||
SSD1327::setVerticalMode()
|
||||
{
|
||||
i2Cmd(m_i2c_lcd_control, 0xA0); // remap to
|
||||
usleep(CMD_SLEEP);
|
||||
i2Cmd(m_i2c_lcd_control, 0x46); // Vertical mode
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "i2clcd.h"
|
||||
#include "ssd.h"
|
||||
|
||||
namespace upm {
|
||||
|
||||
namespace upm
|
||||
{
|
||||
#define DISPLAY_CMD_SET_NORMAL 0xA4
|
||||
|
||||
/**
|
||||
@ -52,7 +52,8 @@ namespace upm {
|
||||
* @image html ssd1327.jpeg
|
||||
* @snippet ssd1327-oled.cxx Interesting
|
||||
*/
|
||||
class SSD1327 : public I2CLcd {
|
||||
class SSD1327 : public I2CLcd
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* SSD1327 Constructor, calls libmraa initialisation functions
|
||||
|
Loading…
x
Reference in New Issue
Block a user