You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
6.0 KiB
174 lines
6.0 KiB
/*********************************************************************
|
|
SSD1306 I2C Library for Raspberry Pi.
|
|
Based on Adafruit SSD1306 Arduino library. Some functions came from Adafruit GFX lib.
|
|
|
|
Modified by Ilia Penev
|
|
Tested on Raspberry Pi 2 with 0.96 Yellow/Blue OLED
|
|
*********************************************************************/
|
|
|
|
/*********************************************************************
|
|
This is a library for our Monochrome OLEDs based on SSD1306 drivers
|
|
|
|
Pick one up today in the adafruit shop!
|
|
------> http://www.adafruit.com/category/63_98
|
|
|
|
These displays use SPI to communicate, 4 or 5 pins are required to
|
|
interface
|
|
|
|
Adafruit invests time and resources providing this open source code,
|
|
please support Adafruit and open-source hardware by purchasing
|
|
products from Adafruit!
|
|
|
|
Written by Limor Fried/Ladyada for Adafruit Industries.
|
|
BSD license, check license.txt for more information
|
|
All text above, and the splash screen must be included in any redistribution
|
|
*********************************************************************/
|
|
#ifndef SSD1306_I2C_H_
|
|
#define SSD1306_I2C_H_
|
|
|
|
#include "i2c.h"
|
|
|
|
#define BLACK 0
|
|
#define WHITE 1
|
|
#define INVERSE 2
|
|
|
|
#define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D
|
|
// Address for 128x32 is 0x3C
|
|
// Address for 128x64 is 0x3D (default) or 0x3C (if SA0 is grounded)
|
|
|
|
/*=========================================================================
|
|
SSD1306 Displays
|
|
-----------------------------------------------------------------------
|
|
The driver is used in multiple displays (128x64, 128x32, etc.).
|
|
Select the appropriate display below to create an appropriately
|
|
sized framebuffer, etc.
|
|
|
|
SSD1306_128_64 128x64 pixel display
|
|
|
|
SSD1306_128_32 128x32 pixel display
|
|
|
|
SSD1306_96_16
|
|
|
|
-----------------------------------------------------------------------*/
|
|
#define SSD1306_128_64
|
|
// #define SSD1306_128_32
|
|
// #define SSD1306_96_16
|
|
/*=========================================================================*/
|
|
|
|
#if defined SSD1306_128_32
|
|
#define WIDTH 128
|
|
#define HEIGHT 32
|
|
#endif
|
|
|
|
#if defined SSD1306_128_64
|
|
#define WIDTH 128
|
|
#define HEIGHT 64
|
|
#endif
|
|
|
|
#if defined SSD1306_96_16
|
|
#define WIDTH 96
|
|
#define HEIGHT 16
|
|
#endif
|
|
|
|
#if defined SSD1306_128_64 && defined SSD1306_128_32
|
|
#error "Only one SSD1306 display can be specified at once in SSD1306.h"
|
|
#endif
|
|
#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16
|
|
#error "At least one SSD1306 display must be specified in SSD1306.h"
|
|
#endif
|
|
|
|
#if defined SSD1306_128_64
|
|
#define SSD1306_LCDWIDTH 128
|
|
#define SSD1306_LCDHEIGHT 64
|
|
#endif
|
|
#if defined SSD1306_128_32
|
|
#define SSD1306_LCDWIDTH 128
|
|
#define SSD1306_LCDHEIGHT 32
|
|
#endif
|
|
#if defined SSD1306_96_16
|
|
#define SSD1306_LCDWIDTH 96
|
|
#define SSD1306_LCDHEIGHT 16
|
|
#endif
|
|
|
|
#define SSD1306_SETCONTRAST 0x81
|
|
#define SSD1306_DISPLAYALLON_RESUME 0xA4
|
|
#define SSD1306_DISPLAYALLON 0xA5
|
|
#define SSD1306_NORMALDISPLAY 0xA6
|
|
#define SSD1306_INVERTDISPLAY 0xA7
|
|
#define SSD1306_DISPLAYOFF 0xAE
|
|
#define SSD1306_DISPLAYON 0xAF
|
|
|
|
#define SSD1306_SETDISPLAYOFFSET 0xD3
|
|
#define SSD1306_SETCOMPINS 0xDA
|
|
|
|
#define SSD1306_SETVCOMDETECT 0xDB
|
|
|
|
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
|
|
#define SSD1306_SETPRECHARGE 0xD9
|
|
|
|
#define SSD1306_SETMULTIPLEX 0xA8
|
|
|
|
#define SSD1306_SETLOWCOLUMN 0x00
|
|
#define SSD1306_SETHIGHCOLUMN 0x10
|
|
|
|
#define SSD1306_SETSTARTLINE 0x40
|
|
|
|
#define SSD1306_MEMORYMODE 0x20
|
|
#define SSD1306_MEMORY_MODE_PAGE 0x04
|
|
#define SSD1306_MEMORY_MODE_HORIZONTAL 0x00
|
|
#define SSD1306_MEMORY_MODE_VERTICAL 0x01
|
|
|
|
#define SSD1306_COLUMNADDR 0x21
|
|
#define SSD1306_PAGEADDR 0x22
|
|
|
|
#define SSD1306_COMSCANINC 0xC0
|
|
#define SSD1306_COMSCANDEC 0xC8
|
|
#define SSD1306_COM_SEQ_LR_REMAP_OFF 0x02
|
|
#define SSD1306_COM_SEQ_LR_REMAP_ON 0x12
|
|
#define SSD1306_COM_ALT_LR_REMAP_OFF 0x0A
|
|
#define SSD1306_COM_ALT_LR_REMAP_ON 0x1A
|
|
|
|
#define SSD1306_SEGREMAP 0xA0
|
|
|
|
#define SSD1306_CHARGEPUMP 0x8D
|
|
#define SSD1306_ENABLE_CHAGE_PUMP 0x14
|
|
#define SSD1306_EXTERNALVCC 0x1
|
|
#define SSD1306_SWITCHCAPVCC 0x2
|
|
|
|
|
|
|
|
// Scrolling #defines
|
|
#define SSD1306_ACTIVATE_SCROLL 0x2F
|
|
#define SSD1306_DEACTIVATE_SCROLL 0x2E
|
|
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
|
|
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
|
|
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
|
|
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
|
|
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
|
|
|
|
void ssd1306_startscrolldiagright(i2c_t *i2c_dev, uint16_t start, uint16_t stop);
|
|
void ssd1306_startscrolldiagleft(i2c_t *i2c_dev, uint16_t start, uint16_t stop);
|
|
void ssd1306_stopscroll(i2c_t *i2c_dev);
|
|
|
|
void ssd1306_i2c_send_command(i2c_t *i2c_dev,uint8_t c);
|
|
void ssd1306_i2c_set_display_off(i2c_t *i2c_dev);
|
|
void ssd1306_i2c_set_display_on(i2c_t *i2c_dev);
|
|
void ssd1306_i2c_set_display_clkDiv_oscFreq(i2c_t *i2c_dev, uint8_t clockDivider, uint8_t oscillatorFreq);
|
|
void ssd1306_i2c_set_multiplex_ratio(i2c_t *i2c_dev, uint8_t ratio);
|
|
void ssd1306_i2c_set_display_offset(i2c_t *i2c_dev, uint8_t offset);
|
|
void ssd1306_i2c_set_display_start_line(i2c_t *i2c_dev, uint8_t start);
|
|
void ssd1306_i2c_set_chage_pump(i2c_t *i2c_dev, uint8_t voltageSource);
|
|
void ssd1306_i2c_set_memory_addressing_mode(i2c_t *i2c_dev, uint8_t mode);
|
|
void ssd1306_i2c_set_segment_remap(i2c_t *i2c_dev, uint8_t enable);
|
|
void ssd1306_i2c_set_com_scan_direction(i2c_t *i2c_dev, uint8_t incremental);
|
|
void ssd1306_i2c_set_com_pins(i2c_t *i2c_dev, uint8_t alignment);
|
|
void ssd1306_i2c_set_contrast(i2c_t *i2c_dev, uint8_t contrast);
|
|
void ssd1306_i2c_set_dimm(i2c_t *i2c_dev, uint8_t dimm);
|
|
void ssd1306_i2c_set_prechage_period(i2c_t *i2c_dev, uint8_t period);
|
|
void ssd1306_i2c_set_com_deselect_level(i2c_t *i2c_dev, uint8_t voltageLevel);
|
|
void ssd1306_i2c_set_display_entire_on(i2c_t *i2c_dev, uint8_t resumeOrForce);
|
|
void ssd1306_i2c_set_display_invert_pixel(i2c_t *i2c_dev, uint8_t inverted);
|
|
void ssd1306_i2c_set_scroll(i2c_t *i2c_dev, uint8_t onOff);
|
|
|
|
#endif /* _SSD1306_I2C_H_ */
|