2015-08-09 22:51:25 +03:00
|
|
|
|
/*
|
2014-06-05 13:02:49 +00:00
|
|
|
|
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
|
|
|
|
* Copyright (c) 2014 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 <string>
|
2015-07-09 13:54:49 -06:00
|
|
|
|
#include <mraa/i2c.hpp>
|
2015-07-09 12:25:04 -06:00
|
|
|
|
#include "lcd.h"
|
2014-09-22 17:07:00 +01:00
|
|
|
|
#include "ssd.h"
|
2014-06-05 13:02:49 +00:00
|
|
|
|
|
2015-04-08 14:06:49 +01:00
|
|
|
|
namespace upm
|
|
|
|
|
{
|
2015-04-20 16:35:19 +01:00
|
|
|
|
const uint8_t DISPLAY_CMD_SET_NORMAL_1308 = 0xA6;
|
2014-06-05 13:02:49 +00:00
|
|
|
|
|
2014-08-07 19:15:49 +01:00
|
|
|
|
/**
|
2015-04-13 16:34:57 -07:00
|
|
|
|
* @library i2clcd
|
|
|
|
|
* @sensor ssd1308
|
|
|
|
|
* @comname SSD1308 OLED Display
|
|
|
|
|
* @altname Grove OLED Display 0.96"
|
|
|
|
|
* @type display
|
|
|
|
|
* @man seeed adafruit
|
|
|
|
|
* @web http://garden.seeedstudio.com/images/4/46/SSD1308_1.0.pdf
|
|
|
|
|
* @web http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_0.96%22
|
|
|
|
|
* @con i2c
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* @brief API for SSD1308 I2C-controlled OLED displays
|
2014-08-07 19:15:49 +01:00
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* SSD1308 is a 128x64 dot-matrix OLED/PLED segment driver with a
|
2015-04-13 16:34:57 -07:00
|
|
|
|
* controller. This implementation was tested using the Grove LED 128×64
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* Display module, which is an OLED monochrome display.
|
2014-09-01 15:31:55 +01:00
|
|
|
|
*
|
|
|
|
|
* @image html ssd1308.jpeg
|
2015-04-13 16:34:57 -07:00
|
|
|
|
* @snippet ssd1308-oled.cxx Interesting
|
2014-08-07 19:15:49 +01:00
|
|
|
|
*/
|
2015-07-09 12:38:22 -06:00
|
|
|
|
class SSD1308 : public LCD
|
2015-04-08 14:06:49 +01:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* SSD1308 constructor; calls libmraa initialisation functions
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* @param bus I2C bus to use
|
|
|
|
|
* @param address Slave address the LCD is registered on
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*/
|
|
|
|
|
SSD1308(int bus, int address = 0x3C);
|
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* SSD1308 destructor
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*/
|
|
|
|
|
~SSD1308();
|
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* Draws an image; see examples/python/make_oled_pic.py for an
|
|
|
|
|
* explanation of how pixels are mapped to bytes
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* @param data Buffer to read
|
|
|
|
|
* @param bytes Number of bytes to read from the pointer
|
|
|
|
|
* @return Result of the operation
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*/
|
|
|
|
|
mraa_result_t draw(uint8_t* data, int bytes);
|
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* Writes a string to the LCD
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* @param msg std::string to write to the display; note: only ASCII
|
|
|
|
|
* characters are supported
|
|
|
|
|
* @return Result of the operation
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*/
|
|
|
|
|
mraa_result_t write(std::string msg);
|
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* Sets the cursor to specified coordinates
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* @param row Row to set the cursor to
|
|
|
|
|
* @param column Column to set the cursor to
|
|
|
|
|
* @return Result of the operation
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*/
|
|
|
|
|
mraa_result_t setCursor(int row, int column);
|
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* Clears the display of all characters
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* @return Result of the operation
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*/
|
|
|
|
|
mraa_result_t clear();
|
|
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* Returns to the original coordinates (0,0)
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
|
* @return Result of the operation
|
2015-04-08 14:06:49 +01:00
|
|
|
|
*/
|
|
|
|
|
mraa_result_t home();
|
|
|
|
|
|
|
|
|
|
private:
|
2015-04-20 14:11:54 +01:00
|
|
|
|
mraa_result_t writeChar(uint8_t value);
|
2015-04-08 14:06:49 +01:00
|
|
|
|
mraa_result_t setNormalDisplay();
|
|
|
|
|
mraa_result_t setAddressingMode(displayAddressingMode mode);
|
2015-07-09 13:54:49 -06:00
|
|
|
|
|
|
|
|
|
int m_lcd_control_address;
|
|
|
|
|
mraa::I2c m_i2c_lcd_control;
|
2015-04-08 14:06:49 +01:00
|
|
|
|
};
|
2014-06-05 13:02:49 +00:00
|
|
|
|
}
|