mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
i2clcd: remove the helper functions i2Cmd, i2cData & i2cReg
Remove calls to I2C helper functions (i2Cmd, i2cData, i2cReg) and call the raw MRAA function directly instead and remove the helper functions from the I2CLcd class 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
bcdaccf68d
commit
ae0d99369b
@ -55,10 +55,10 @@ I2CLcd::createChar(uint8_t charSlot, uint8_t charData[])
|
|||||||
{
|
{
|
||||||
mraa_result_t error = MRAA_SUCCESS;
|
mraa_result_t error = MRAA_SUCCESS;
|
||||||
charSlot &= 0x07; // only have 8 positions we can set
|
charSlot &= 0x07; // only have 8 positions we can set
|
||||||
error = i2Cmd(m_i2c_lcd_control, LCD_SETCGRAMADDR | (charSlot << 3));
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, LCD_SETCGRAMADDR | (charSlot << 3), LCD_CMD);
|
||||||
if (error == MRAA_SUCCESS) {
|
if (error == MRAA_SUCCESS) {
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
error = i2cData(m_i2c_lcd_control, charData[i]);
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, charData[i], LCD_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,43 +76,3 @@ I2CLcd::name()
|
|||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
|
||||||
I2CLcd::i2cReg(mraa_i2c_context ctx, int deviceAdress, int addr, uint8_t value)
|
|
||||||
{
|
|
||||||
mraa_result_t ret;
|
|
||||||
|
|
||||||
uint8_t data[2] = { addr, value };
|
|
||||||
ret = mraa_i2c_address(ctx, deviceAdress);
|
|
||||||
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
|
||||||
ret = mraa_i2c_write(ctx, data, 2);
|
|
||||||
|
|
||||||
beach:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
mraa_result_t
|
|
||||||
I2CLcd::i2Cmd(mraa_i2c_context ctx, uint8_t value)
|
|
||||||
{
|
|
||||||
mraa_result_t ret;
|
|
||||||
uint8_t data[2] = { LCD_CMD, value };
|
|
||||||
|
|
||||||
ret = mraa_i2c_address(ctx, m_lcd_control_address);
|
|
||||||
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
|
||||||
ret = mraa_i2c_write(ctx, data, 2);
|
|
||||||
|
|
||||||
beach:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
mraa_result_t
|
|
||||||
I2CLcd::i2cData(mraa_i2c_context ctx, uint8_t value)
|
|
||||||
{
|
|
||||||
mraa_result_t error = MRAA_SUCCESS;
|
|
||||||
|
|
||||||
uint8_t data[2] = { LCD_DATA, value };
|
|
||||||
error = mraa_i2c_address(ctx, m_lcd_control_address);
|
|
||||||
error = mraa_i2c_write(ctx, data, 2);
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
@ -91,9 +91,6 @@ class I2CLcd
|
|||||||
virtual mraa_result_t clear() = 0;
|
virtual mraa_result_t clear() = 0;
|
||||||
virtual mraa_result_t home() = 0;
|
virtual mraa_result_t home() = 0;
|
||||||
virtual mraa_result_t createChar(uint8_t charSlot, uint8_t charData[]);
|
virtual mraa_result_t createChar(uint8_t charSlot, uint8_t charData[]);
|
||||||
virtual mraa_result_t i2Cmd(mraa_i2c_context ctx, uint8_t value);
|
|
||||||
virtual mraa_result_t i2cReg(mraa_i2c_context ctx, int deviceAdress, int addr, uint8_t data);
|
|
||||||
virtual mraa_result_t i2cData(mraa_i2c_context ctx, uint8_t value);
|
|
||||||
|
|
||||||
mraa_result_t close();
|
mraa_result_t close();
|
||||||
std::string name();
|
std::string name();
|
||||||
|
@ -42,11 +42,11 @@ Jhd1313m1::Jhd1313m1(int bus, int lcdAddress, int rgbAddress) : I2CLcd(bus, lcdA
|
|||||||
}
|
}
|
||||||
|
|
||||||
usleep(50000);
|
usleep(50000);
|
||||||
ret = i2Cmd(m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_control, LCD_FUNCTIONSET | LCD_2LINE, LCD_CMD);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
|
||||||
|
|
||||||
usleep(100);
|
usleep(100);
|
||||||
ret = i2Cmd(m_i2c_lcd_control, LCD_DISPLAYCONTROL | LCD_DISPLAYON);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_control, LCD_DISPLAYCONTROL | LCD_DISPLAYON, LCD_CMD);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
|
||||||
|
|
||||||
usleep(100);
|
usleep(100);
|
||||||
@ -54,21 +54,23 @@ Jhd1313m1::Jhd1313m1(int bus, int lcdAddress, int rgbAddress) : I2CLcd(bus, lcdA
|
|||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
|
||||||
|
|
||||||
usleep(2000);
|
usleep(2000);
|
||||||
ret = i2Cmd(m_i2c_lcd_control, LCD_ENTRYMODESET | LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
|
LCD_ENTRYMODESET | LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT,
|
||||||
|
LCD_CMD);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
|
||||||
|
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0, 0);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0, 0);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 1, 0);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0, 1);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x08, 0xAA);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0xAA, 0x08);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
||||||
|
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x04, 255);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0xFF, 0x04);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x03, 255);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0xFF, 0x03);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x02, 255);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0xFF, 0x02);
|
||||||
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the RGB controller");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,18 +83,18 @@ Jhd1313m1::setColor(uint8_t r, uint8_t g, uint8_t b)
|
|||||||
{
|
{
|
||||||
mraa_result_t ret;
|
mraa_result_t ret;
|
||||||
|
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0, 0);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0, 0);
|
||||||
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 1, 0);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0, 1);
|
||||||
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x08, 0xAA);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, 0xAA, 0x08);
|
||||||
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
||||||
|
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x04, r);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, r, 0x04);
|
||||||
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x03, g);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, g, 0x03);
|
||||||
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
||||||
ret = i2cReg(m_i2c_lcd_rgb, m_rgb_address, 0x02, b);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_rgb, b, 0x02);
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
return ret;
|
return ret;
|
||||||
@ -101,9 +103,15 @@ beach:
|
|||||||
mraa_result_t
|
mraa_result_t
|
||||||
Jhd1313m1::scroll(bool direction)
|
Jhd1313m1::scroll(bool direction)
|
||||||
{
|
{
|
||||||
if (direction)
|
if (direction) {
|
||||||
return i2Cmd(m_i2c_lcd_control, (LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT));
|
return mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
return i2Cmd(m_i2c_lcd_control, (LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT));
|
LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT,
|
||||||
|
LCD_CMD);
|
||||||
|
} else {
|
||||||
|
return mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
|
LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT,
|
||||||
|
LCD_CMD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -120,7 +128,7 @@ Jhd1313m1::write(std::string msg)
|
|||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
|
||||||
for (std::string::size_type i = 0; i < msg.size(); ++i) {
|
for (std::string::size_type i = 0; i < msg.size(); ++i) {
|
||||||
ret = i2cData(m_i2c_lcd_control, msg[i]);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_control, msg[i], LCD_DATA);
|
||||||
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
UPM_GOTO_ON_MRAA_FAIL(ret, beach);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +144,7 @@ Jhd1313m1::setCursor(int row, int column)
|
|||||||
int row_addr[] = { 0x80, 0xc0, 0x14, 0x54 };
|
int row_addr[] = { 0x80, 0xc0, 0x14, 0x54 };
|
||||||
uint8_t offset = ((column % 16) + row_addr[row]);
|
uint8_t offset = ((column % 16) + row_addr[row]);
|
||||||
|
|
||||||
ret = i2Cmd(m_i2c_lcd_control, offset);
|
ret = mraa_i2c_write_byte_data(m_i2c_lcd_control, offset, LCD_CMD);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -144,11 +152,11 @@ Jhd1313m1::setCursor(int row, int column)
|
|||||||
mraa_result_t
|
mraa_result_t
|
||||||
Jhd1313m1::clear()
|
Jhd1313m1::clear()
|
||||||
{
|
{
|
||||||
return i2Cmd(m_i2c_lcd_control, LCD_CLEARDISPLAY);
|
return mraa_i2c_write_byte_data(m_i2c_lcd_control, LCD_CLEARDISPLAY, LCD_CMD);
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
Jhd1313m1::home()
|
Jhd1313m1::home()
|
||||||
{
|
{
|
||||||
return i2Cmd(m_i2c_lcd_control, LCD_RETURNHOME);
|
return mraa_i2c_write_byte_data(m_i2c_lcd_control, LCD_RETURNHOME, LCD_CMD);
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@ 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
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, DISPLAY_CMD_OFF, LCD_CMD); // display off
|
||||||
usleep(4500);
|
usleep(4500);
|
||||||
i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_ON); // display on
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, DISPLAY_CMD_ON, LCD_CMD); // display on
|
||||||
usleep(4500);
|
usleep(4500);
|
||||||
setNormalDisplay(); // set to normal display '1' is ON
|
setNormalDisplay(); // set to normal display '1' is ON
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ SSD1308::draw(uint8_t* data, int bytes)
|
|||||||
|
|
||||||
setAddressingMode(HORIZONTAL);
|
setAddressingMode(HORIZONTAL);
|
||||||
for (int idx = 0; idx < bytes; idx++) {
|
for (int idx = 0; idx < bytes; idx++) {
|
||||||
i2cData(m_i2c_lcd_control, data[idx]);
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, data[idx], LCD_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
@ -82,11 +82,15 @@ SSD1308::setCursor(int row, int column)
|
|||||||
{
|
{
|
||||||
mraa_result_t error = MRAA_SUCCESS;
|
mraa_result_t error = MRAA_SUCCESS;
|
||||||
|
|
||||||
error = i2Cmd(m_i2c_lcd_control, BASE_PAGE_START_ADDR + row); // set page address
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
error = i2Cmd(m_i2c_lcd_control,
|
BASE_PAGE_START_ADDR + row,
|
||||||
BASE_LOW_COLUMN_ADDR + (8 * column & 0x0F)); // set column lower address
|
LCD_CMD); // set page address
|
||||||
error = i2Cmd(m_i2c_lcd_control,
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
BASE_HIGH_COLUMN_ADDR + ((8 * column >> 4) & 0x0F)); // set column higher address
|
BASE_LOW_COLUMN_ADDR + (8 * column & 0x0F),
|
||||||
|
LCD_CMD); // set column lower address
|
||||||
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
|
BASE_HIGH_COLUMN_ADDR + ((8 * column >> 4) & 0x0F),
|
||||||
|
LCD_CMD); // set column higher address
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -97,7 +101,7 @@ SSD1308::clear()
|
|||||||
mraa_result_t error = MRAA_SUCCESS;
|
mraa_result_t error = MRAA_SUCCESS;
|
||||||
uint8_t columnIdx, rowIdx;
|
uint8_t columnIdx, rowIdx;
|
||||||
|
|
||||||
i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_OFF); // display off
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, DISPLAY_CMD_OFF, LCD_CMD); // display off
|
||||||
for (rowIdx = 0; rowIdx < 8; rowIdx++) {
|
for (rowIdx = 0; rowIdx < 8; rowIdx++) {
|
||||||
setCursor(rowIdx, 0);
|
setCursor(rowIdx, 0);
|
||||||
|
|
||||||
@ -106,7 +110,7 @@ SSD1308::clear()
|
|||||||
writeChar(m_i2c_lcd_control, ' ');
|
writeChar(m_i2c_lcd_control, ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_ON); // display on
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, DISPLAY_CMD_ON, LCD_CMD); // display on
|
||||||
home();
|
home();
|
||||||
|
|
||||||
return MRAA_SUCCESS;
|
return MRAA_SUCCESS;
|
||||||
@ -131,19 +135,23 @@ SSD1308::writeChar(mraa_i2c_context ctx, uint8_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t idx = 0; idx < 8; idx++) {
|
for (uint8_t idx = 0; idx < 8; idx++) {
|
||||||
i2cData(m_i2c_lcd_control, BasicFont[value - 32][idx]);
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, BasicFont[value - 32][idx], LCD_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
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
|
return mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
|
DISPLAY_CMD_SET_NORMAL_1308,
|
||||||
|
LCD_CMD); // set to normal display '1' is ON
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
SSD1308::setAddressingMode(displayAddressingMode mode)
|
SSD1308::setAddressingMode(displayAddressingMode mode)
|
||||||
{
|
{
|
||||||
i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_MEM_ADDR_MODE); // set addressing mode
|
mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
i2Cmd(m_i2c_lcd_control, mode); // set page addressing mode
|
DISPLAY_CMD_MEM_ADDR_MODE,
|
||||||
|
LCD_CMD); // set addressing mode
|
||||||
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, mode, LCD_CMD); // set page addressing mode
|
||||||
}
|
}
|
||||||
|
@ -36,86 +36,96 @@ SSD1327::SSD1327(int bus_in, int addr_in) : I2CLcd(bus_in, addr_in)
|
|||||||
{
|
{
|
||||||
mraa_result_t error = MRAA_SUCCESS;
|
mraa_result_t error = MRAA_SUCCESS;
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control,
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xFD, LCD_CMD); // Unlock OLED driver IC MCU
|
||||||
0xFD); // Unlock OLED driver IC MCU interface from entering command. i.e: Accept commands
|
// interface from entering command.
|
||||||
|
// i.e: Accept commands
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x12);
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x12, LCD_CMD);
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xAE); // Set display off
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xAE, LCD_CMD); // Set display off
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0xA8); // set multiplex ratio
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA8, LCD_CMD); // set multiplex ratio
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x5F); // 96
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x5F, LCD_CMD); // 96
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xA1); // set display start line
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA1, LCD_CMD); // set display start line
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x00); //
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x00, LCD_CMD); //
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xA2); // set display offset
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA2, LCD_CMD); // set display offset
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x60);
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x60, LCD_CMD);
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xA0); // set remap
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA0, LCD_CMD); // set remap
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x46);
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x46, LCD_CMD);
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xAB); // set vdd internal
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xAB, LCD_CMD); // set vdd internal
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x01); //
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x01, LCD_CMD); //
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x81); // set contrasr
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x81, LCD_CMD); // set contrasr
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x53); // 100 nit
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x53, LCD_CMD); // 100 nit
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xB1); // Set Phase Length
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xB1, LCD_CMD); // Set Phase Length
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0X51); //
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0X51, LCD_CMD); //
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xB3); // Set Display Clock Divide Ratio/Oscillator Frequency
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
|
0xB3,
|
||||||
|
LCD_CMD); // Set Display Clock Divide Ratio/Oscillator
|
||||||
|
// Frequency
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x01); //
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x01, LCD_CMD); //
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xB9); //
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xB9, LCD_CMD); //
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xBC); // set pre_charge voltage/VCOMH
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xBC, LCD_CMD); // set pre_charge
|
||||||
|
// voltage/VCOMH
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x08); // (0x08);
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x08, LCD_CMD); // (0x08);
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xBE); // set VCOMH
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xBE, LCD_CMD); // set VCOMH
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0X07); // (0x07);
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0X07, LCD_CMD); // (0x07);
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xB6); // Set second pre-charge period
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xB6, LCD_CMD); // Set second pre-charge
|
||||||
|
// period
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x01); //
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x01, LCD_CMD); //
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xD5); // enable second precharge and enternal vsl
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
|
0xD5,
|
||||||
|
LCD_CMD); // enable second precharge and enternal vsl
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0X62); // (0x62);
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0X62, LCD_CMD); // (0x62);
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xA4); // Set Normal Display Mode
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA4, LCD_CMD); // Set Normal Display Mode
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x2E); // Deactivate Scroll
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x2E, LCD_CMD); // Deactivate Scroll
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0xAF); // Switch on display
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xAF, LCD_CMD); // Switch on display
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
|
|
||||||
// Row Address
|
// Row Address
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x75); // Set Row Address
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x75, LCD_CMD); // Set Row Address
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x00); // Start 0
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x00, LCD_CMD); // Start 0
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x5f); // End 95
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x5f, LCD_CMD); // End 95
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
|
|
||||||
// Column Address
|
// Column Address
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x15); // Set Column Address
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x15, LCD_CMD); // Set Column Address
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control,
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x08, LCD_CMD); // Start from 8th Column of
|
||||||
0x08); // Start from 8th Column of driver IC. This is 0th Column for OLED
|
// driver IC. This is 0th
|
||||||
|
// Column for OLED
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
error = i2Cmd(m_i2c_lcd_control, 0x37); // End at (8 + 47)th column. Each Column has 2
|
error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x37, LCD_CMD); // End at (8 + 47)th
|
||||||
// pixels(segments)
|
// column. Each Column has 2
|
||||||
|
// pixels(segments)
|
||||||
usleep(INIT_SLEEP);
|
usleep(INIT_SLEEP);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
@ -143,7 +153,7 @@ SSD1327::draw(uint8_t* data, int bytes)
|
|||||||
value |= (bitOne) ? grayHigh : 0x00;
|
value |= (bitOne) ? grayHigh : 0x00;
|
||||||
value |= (bitTwo) ? grayLow : 0x00;
|
value |= (bitTwo) ? grayLow : 0x00;
|
||||||
|
|
||||||
i2cData(m_i2c_lcd_control, value);
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, value, LCD_DATA);
|
||||||
usleep(CMD_SLEEP - 2000);
|
usleep(CMD_SLEEP - 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,18 +185,19 @@ SSD1327::setCursor(int row, int column)
|
|||||||
mraa_result_t error = MRAA_SUCCESS;
|
mraa_result_t error = MRAA_SUCCESS;
|
||||||
|
|
||||||
// Column Address
|
// Column Address
|
||||||
i2Cmd(m_i2c_lcd_control, 0x15); /* Set Column Address */
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x15, LCD_CMD); /* Set Column Address */
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x08 + (column * 4)); /* Start Column: Start from 8 */
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x08 + (column * 4), LCD_CMD); /* Start Column:
|
||||||
|
Start from 8 */
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x37); /* End Column */
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x37, LCD_CMD); /* End Column */
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
// Row Address
|
// Row Address
|
||||||
i2Cmd(m_i2c_lcd_control, 0x75); /* Set Row Address */
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x75, LCD_CMD); /* Set Row Address */
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x00 + (row * 8)); /* Start Row*/
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x00 + (row * 8), LCD_CMD); /* Start Row*/
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x07 + (row * 8)); /* End Row*/
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x07 + (row * 8), LCD_CMD); /* End Row*/
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
@ -243,7 +254,7 @@ SSD1327::writeChar(mraa_i2c_context ctx, uint8_t value)
|
|||||||
data |= (bitOne) ? grayHigh : 0x00;
|
data |= (bitOne) ? grayHigh : 0x00;
|
||||||
data |= (bitTwo) ? grayLow : 0x00;
|
data |= (bitTwo) ? grayLow : 0x00;
|
||||||
|
|
||||||
i2cData(m_i2c_lcd_control, data);
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, data, LCD_DATA);
|
||||||
usleep(CMD_SLEEP - 2000);
|
usleep(CMD_SLEEP - 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,41 +263,43 @@ SSD1327::writeChar(mraa_i2c_context ctx, uint8_t value)
|
|||||||
mraa_result_t
|
mraa_result_t
|
||||||
SSD1327::setNormalDisplay()
|
SSD1327::setNormalDisplay()
|
||||||
{
|
{
|
||||||
return i2Cmd(m_i2c_lcd_control, DISPLAY_CMD_SET_NORMAL); // set to normal display '1' is ON
|
return mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
||||||
|
DISPLAY_CMD_SET_NORMAL,
|
||||||
|
LCD_CMD); // set to normal display '1' is ON
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
SSD1327::setHorizontalMode()
|
SSD1327::setHorizontalMode()
|
||||||
{
|
{
|
||||||
i2Cmd(m_i2c_lcd_control, 0xA0); // remap to
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA0, LCD_CMD); // remap to
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x42); // horizontal mode
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x42, LCD_CMD); // horizontal mode
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
|
|
||||||
// Row Address
|
// Row Address
|
||||||
i2Cmd(m_i2c_lcd_control, 0x75); // Set Row Address
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x75, LCD_CMD); // Set Row Address
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x00); // Start 0
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x00, LCD_CMD); // Start 0
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x5f); // End 95
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x5f, LCD_CMD); // End 95
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
|
|
||||||
// Column Address
|
// Column Address
|
||||||
i2Cmd(m_i2c_lcd_control, 0x15); // Set Column Address
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x15, LCD_CMD); // Set Column Address
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control,
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x08, LCD_CMD); // Start from 8th Column of driver
|
||||||
0x08); // Start from 8th Column of driver IC. This is 0th Column for OLED
|
// IC. This is 0th Column for OLED
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control,
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x37, LCD_CMD); // End at (8 + 47)th column. Each
|
||||||
0x37); // End at (8 + 47)th column. Each Column has 2 pixels(or segments)
|
// Column has 2 pixels(or segments)
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
SSD1327::setVerticalMode()
|
SSD1327::setVerticalMode()
|
||||||
{
|
{
|
||||||
i2Cmd(m_i2c_lcd_control, 0xA0); // remap to
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA0, LCD_CMD); // remap to
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
i2Cmd(m_i2c_lcd_control, 0x46); // Vertical mode
|
mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x46, LCD_CMD); // Vertical mode
|
||||||
usleep(CMD_SLEEP);
|
usleep(CMD_SLEEP);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user