Merge branch 'master' of github.com:adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino
This commit is contained in:
commit
cd3c3d4863
3 changed files with 451 additions and 126 deletions
46
.github/ISSUE_TEMPLATE.md
vendored
Normal file
46
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
||||
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
||||
|
|
@ -1,126 +1,379 @@
|
|||
/***************************************************
|
||||
This is a library for the 0.96" 16-bit Color OLED with SSD1331 driver chip
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/products/684
|
||||
|
||||
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, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include "Adafruit_SSD1331.h"
|
||||
#include "pins_arduino.h"
|
||||
#include "wiring_private.h"
|
||||
|
||||
/***********************************/
|
||||
|
||||
|
||||
void Adafruit_SSD1331::setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||
|
||||
uint8_t x1 = x;
|
||||
uint8_t y1 = y;
|
||||
if (x1 > 95) x1 = 95;
|
||||
if (y1 > 63) y1 = 63;
|
||||
|
||||
uint8_t x2 = (x+w-1);
|
||||
uint8_t y2 = (y+h-1);
|
||||
if (x2 > 95) x2 = 95;
|
||||
if (y2 > 63) y2 = 63;
|
||||
|
||||
if (x1 > x2) {
|
||||
uint8_t t = x2;
|
||||
x2 = x1;
|
||||
x1 = t;
|
||||
}
|
||||
if (y1 > y2) {
|
||||
uint8_t t = y2;
|
||||
y2 = y1;
|
||||
y1 = t;
|
||||
}
|
||||
|
||||
|
||||
startWrite();
|
||||
writeCommand(0x15); // Column addr set
|
||||
writeCommand(x1);
|
||||
writeCommand(x2);
|
||||
endWrite();
|
||||
|
||||
startWrite();
|
||||
writeCommand(0x75); // Column addr set
|
||||
writeCommand(y1);
|
||||
writeCommand(y2);
|
||||
endWrite();
|
||||
|
||||
startWrite();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Adafruit_SSD1331::begin(uint32_t freq) {
|
||||
initSPI(freq);
|
||||
|
||||
startWrite();
|
||||
|
||||
// Initialization Sequence
|
||||
writeCommand(SSD1331_CMD_DISPLAYOFF); // 0xAE
|
||||
writeCommand(SSD1331_CMD_SETREMAP); // 0xA0
|
||||
#if defined SSD1331_COLORORDER_RGB
|
||||
writeCommand(0x72); // RGB Color
|
||||
#else
|
||||
writeCommand(0x76); // BGR Color
|
||||
#endif
|
||||
writeCommand(SSD1331_CMD_STARTLINE); // 0xA1
|
||||
writeCommand(0x0);
|
||||
writeCommand(SSD1331_CMD_DISPLAYOFFSET); // 0xA2
|
||||
writeCommand(0x0);
|
||||
writeCommand(SSD1331_CMD_NORMALDISPLAY); // 0xA4
|
||||
writeCommand(SSD1331_CMD_SETMULTIPLEX); // 0xA8
|
||||
writeCommand(0x3F); // 0x3F 1/64 duty
|
||||
writeCommand(SSD1331_CMD_SETMASTER); // 0xAD
|
||||
writeCommand(0x8E);
|
||||
writeCommand(SSD1331_CMD_POWERMODE); // 0xB0
|
||||
writeCommand(0x0B);
|
||||
writeCommand(SSD1331_CMD_PRECHARGE); // 0xB1
|
||||
writeCommand(0x31);
|
||||
writeCommand(SSD1331_CMD_CLOCKDIV); // 0xB3
|
||||
writeCommand(0xF0); // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16)
|
||||
writeCommand(SSD1331_CMD_PRECHARGEA); // 0x8A
|
||||
writeCommand(0x64);
|
||||
writeCommand(SSD1331_CMD_PRECHARGEB); // 0x8B
|
||||
writeCommand(0x78);
|
||||
writeCommand(SSD1331_CMD_PRECHARGEA); // 0x8C
|
||||
writeCommand(0x64);
|
||||
writeCommand(SSD1331_CMD_PRECHARGELEVEL); // 0xBB
|
||||
writeCommand(0x3A);
|
||||
writeCommand(SSD1331_CMD_VCOMH); // 0xBE
|
||||
writeCommand(0x3E);
|
||||
writeCommand(SSD1331_CMD_MASTERCURRENT); // 0x87
|
||||
writeCommand(0x06);
|
||||
writeCommand(SSD1331_CMD_CONTRASTA); // 0x81
|
||||
writeCommand(0x91);
|
||||
writeCommand(SSD1331_CMD_CONTRASTB); // 0x82
|
||||
writeCommand(0x50);
|
||||
writeCommand(SSD1331_CMD_CONTRASTC); // 0x83
|
||||
writeCommand(0x7D);
|
||||
writeCommand(SSD1331_CMD_DISPLAYON); //--turn on oled panel
|
||||
|
||||
endWrite();
|
||||
_width = TFTWIDTH;
|
||||
_height = TFTHEIGHT;
|
||||
}
|
||||
|
||||
/********************************* low level pin initialization */
|
||||
|
||||
Adafruit_SSD1331::Adafruit_SSD1331(uint8_t cs, uint8_t dc, uint8_t mosi, uint8_t sclk, uint8_t rst) : Adafruit_SPITFT(TFTWIDTH, TFTHEIGHT, cs, dc, mosi, sclk, rst, -1) {
|
||||
}
|
||||
|
||||
Adafruit_SSD1331::Adafruit_SSD1331(uint8_t cs, uint8_t dc, uint8_t rst) : Adafruit_SPITFT(TFTWIDTH, TFTHEIGHT, cs, dc, rst) {
|
||||
|
||||
}
|
||||
/***************************************************
|
||||
This is a library for the 0.96" 16-bit Color OLED with SSD1331 driver chip
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/products/684
|
||||
|
||||
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, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_SSD1331.h"
|
||||
#include "glcdfont.c"
|
||||
|
||||
#ifdef __AVR
|
||||
#include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266)
|
||||
#include <pgmspace.h>
|
||||
#endif
|
||||
|
||||
#include "pins_arduino.h"
|
||||
#include "wiring_private.h"
|
||||
#include <SPI.h>
|
||||
|
||||
/********************************** low level pin interface */
|
||||
|
||||
inline void Adafruit_SSD1331::spiwrite(uint8_t c) {
|
||||
|
||||
if (!_sid) {
|
||||
SPI.transfer(c);
|
||||
return;
|
||||
}
|
||||
|
||||
int8_t i;
|
||||
|
||||
*sclkportreg |= sclkpin;
|
||||
|
||||
for (i=7; i>=0; i--) {
|
||||
*sclkportreg &= ~sclkpin;
|
||||
//SCLK_PORT &= ~_BV(SCLK);
|
||||
|
||||
if (c & _BV(i)) {
|
||||
*sidportreg |= sidpin;
|
||||
//digitalWrite(_sid, HIGH);
|
||||
//SID_PORT |= _BV(SID);
|
||||
} else {
|
||||
*sidportreg &= ~sidpin;
|
||||
//digitalWrite(_sid, LOW);
|
||||
//SID_PORT &= ~_BV(SID);
|
||||
}
|
||||
|
||||
*sclkportreg |= sclkpin;
|
||||
//SCLK_PORT |= _BV(SCLK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_SSD1331::writeCommand(uint8_t c) {
|
||||
*rsportreg &= ~ rspin;
|
||||
//digitalWrite(_rs, LOW);
|
||||
|
||||
*csportreg &= ~ cspin;
|
||||
//digitalWrite(_cs, LOW);
|
||||
|
||||
//Serial.print("C ");
|
||||
spiwrite(c);
|
||||
|
||||
*csportreg |= cspin;
|
||||
//digitalWrite(_cs, HIGH);
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_SSD1331::writeData(uint8_t c) {
|
||||
*rsportreg |= rspin;
|
||||
//digitalWrite(_rs, HIGH);
|
||||
|
||||
*csportreg &= ~ cspin;
|
||||
//digitalWrite(_cs, LOW);
|
||||
|
||||
//Serial.print("D ");
|
||||
spiwrite(c);
|
||||
|
||||
*csportreg |= cspin;
|
||||
//digitalWrite(_cs, HIGH);
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
void Adafruit_SSD1331::goHome(void) {
|
||||
goTo(0,0);
|
||||
}
|
||||
|
||||
void Adafruit_SSD1331::goTo(int x, int y) {
|
||||
if ((x >= WIDTH) || (y >= HEIGHT)) return;
|
||||
|
||||
// set x and y coordinate
|
||||
writeCommand(SSD1331_CMD_SETCOLUMN);
|
||||
writeCommand(x);
|
||||
writeCommand(WIDTH-1);
|
||||
|
||||
writeCommand(SSD1331_CMD_SETROW);
|
||||
writeCommand(y);
|
||||
writeCommand(HEIGHT-1);
|
||||
}
|
||||
|
||||
uint16_t Adafruit_SSD1331::Color565(uint8_t r, uint8_t g, uint8_t b) {
|
||||
uint16_t c;
|
||||
c = r >> 3;
|
||||
c <<= 6;
|
||||
c |= g >> 2;
|
||||
c <<= 5;
|
||||
c |= b >> 3;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draws a filled rectangle using HW acceleration
|
||||
*/
|
||||
/**************************************************************************/
|
||||
/*
|
||||
void Adafruit_SSD1331::fillRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t fillcolor)
|
||||
{
|
||||
//Serial.println("fillRect");
|
||||
// check rotation, move rect around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
swap(x, y);
|
||||
swap(w, h);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
swap(x, y);
|
||||
swap(w, h);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// Bounds check
|
||||
if ((x >= TFTWIDTH) || (y >= TFTHEIGHT))
|
||||
return;
|
||||
|
||||
// Y bounds check
|
||||
if (y+h > TFTHEIGHT)
|
||||
{
|
||||
h = TFTHEIGHT - y;
|
||||
}
|
||||
|
||||
// X bounds check
|
||||
if (x+w > TFTWIDTH)
|
||||
{
|
||||
w = TFTWIDTH - x;
|
||||
}
|
||||
|
||||
// fill!
|
||||
writeCommand(SSD1331_CMD_FILL);
|
||||
writeCommand(0x01);
|
||||
|
||||
writeCommand(SSD1331_CMD_DRAWRECT);
|
||||
writeCommand(x & 0xFF); // Starting column
|
||||
writeCommand(y & 0xFF); // Starting row
|
||||
writeCommand((x+w-1) & 0xFF); // End column
|
||||
writeCommand((y+h-1) & 0xFF); // End row
|
||||
|
||||
// Outline color
|
||||
writeCommand((uint8_t)((fillcolor >> 11) << 1));
|
||||
writeCommand((uint8_t)((fillcolor >> 5) & 0x3F));
|
||||
writeCommand((uint8_t)((fillcolor << 1) & 0x3F));
|
||||
// Fill color
|
||||
writeCommand((uint8_t)((fillcolor >> 11) << 1));
|
||||
writeCommand((uint8_t)((fillcolor >> 5) & 0x3F));
|
||||
writeCommand((uint8_t)((fillcolor << 1) & 0x3F));
|
||||
|
||||
// Delay while the fill completes
|
||||
delay(SSD1331_DELAYS_HWFILL);
|
||||
}
|
||||
*/
|
||||
|
||||
void Adafruit_SSD1331::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) {
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
gfx_swap(x0, y0);
|
||||
gfx_swap(x1, y1);
|
||||
x0 = WIDTH - x0 - 1;
|
||||
x1 = WIDTH - x1 - 1;
|
||||
break;
|
||||
case 2:
|
||||
x0 = WIDTH - x0 - 1;
|
||||
y0 = HEIGHT - y0 - 1;
|
||||
x1 = WIDTH - x1 - 1;
|
||||
y1 = HEIGHT - y1 - 1;
|
||||
break;
|
||||
case 3:
|
||||
gfx_swap(x0, y0);
|
||||
gfx_swap(x1, y1);
|
||||
y0 = HEIGHT - y0 - 1;
|
||||
y1 = HEIGHT - y1 - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// Boundary check
|
||||
if ((y0 >= TFTHEIGHT) && (y1 >= TFTHEIGHT))
|
||||
return;
|
||||
if ((x0 >= TFTWIDTH) && (x1 >= TFTWIDTH))
|
||||
return;
|
||||
if (x0 >= TFTWIDTH)
|
||||
x0 = TFTWIDTH - 1;
|
||||
if (y0 >= TFTHEIGHT)
|
||||
y0 = TFTHEIGHT - 1;
|
||||
if (x1 >= TFTWIDTH)
|
||||
x1 = TFTWIDTH - 1;
|
||||
if (y1 >= TFTHEIGHT)
|
||||
y1 = TFTHEIGHT - 1;
|
||||
|
||||
writeCommand(SSD1331_CMD_DRAWLINE);
|
||||
writeCommand(x0);
|
||||
writeCommand(y0);
|
||||
writeCommand(x1);
|
||||
writeCommand(y1);
|
||||
delay(SSD1331_DELAYS_HWLINE);
|
||||
writeCommand((uint8_t)((color >> 11) << 1));
|
||||
writeCommand((uint8_t)((color >> 5) & 0x3F));
|
||||
writeCommand((uint8_t)((color << 1) & 0x3F));
|
||||
delay(SSD1331_DELAYS_HWLINE);
|
||||
}
|
||||
|
||||
void Adafruit_SSD1331::drawPixel(int16_t x, int16_t y, uint16_t color)
|
||||
{
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height())) return;
|
||||
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
gfx_swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
gfx_swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
goTo(x, y);
|
||||
|
||||
// setup for data
|
||||
*rsportreg |= rspin;
|
||||
*csportreg &= ~ cspin;
|
||||
|
||||
spiwrite(color >> 8);
|
||||
spiwrite(color);
|
||||
|
||||
*csportreg |= cspin;
|
||||
}
|
||||
|
||||
void Adafruit_SSD1331::pushColor(uint16_t color) {
|
||||
// setup for data
|
||||
*rsportreg |= rspin;
|
||||
*csportreg &= ~ cspin;
|
||||
|
||||
spiwrite(color >> 8);
|
||||
spiwrite(color);
|
||||
|
||||
*csportreg |= cspin;
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_SSD1331::begin(void) {
|
||||
// set pin directions
|
||||
pinMode(_rs, OUTPUT);
|
||||
|
||||
if (_sclk) {
|
||||
pinMode(_sclk, OUTPUT);
|
||||
sclkportreg = portOutputRegister(digitalPinToPort(_sclk));
|
||||
sclkpin = digitalPinToBitMask(_sclk);
|
||||
|
||||
pinMode(_sid, OUTPUT);
|
||||
sidportreg = portOutputRegister(digitalPinToPort(_sid));
|
||||
sidpin = digitalPinToBitMask(_sid);
|
||||
} else {
|
||||
// using the hardware SPI
|
||||
SPI.begin();
|
||||
SPI.setDataMode(SPI_MODE3);
|
||||
}
|
||||
|
||||
// Toggle RST low to reset; CS low so it'll listen to us
|
||||
pinMode(_cs, OUTPUT);
|
||||
digitalWrite(_cs, LOW);
|
||||
cspin = digitalPinToBitMask(_cs);
|
||||
csportreg = portOutputRegister(digitalPinToPort(_cs));
|
||||
|
||||
rspin = digitalPinToBitMask(_rs);
|
||||
rsportreg = portOutputRegister(digitalPinToPort(_rs));
|
||||
|
||||
if (_rst) {
|
||||
pinMode(_rst, OUTPUT);
|
||||
digitalWrite(_rst, HIGH);
|
||||
delay(500);
|
||||
digitalWrite(_rst, LOW);
|
||||
delay(500);
|
||||
digitalWrite(_rst, HIGH);
|
||||
delay(500);
|
||||
}
|
||||
// Initialization Sequence
|
||||
writeCommand(SSD1331_CMD_DISPLAYOFF); // 0xAE
|
||||
writeCommand(SSD1331_CMD_SETREMAP); // 0xA0
|
||||
#if defined SSD1331_COLORORDER_RGB
|
||||
writeCommand(0x72); // RGB Color
|
||||
#else
|
||||
writeCommand(0x76); // BGR Color
|
||||
#endif
|
||||
writeCommand(SSD1331_CMD_STARTLINE); // 0xA1
|
||||
writeCommand(0x0);
|
||||
writeCommand(SSD1331_CMD_DISPLAYOFFSET); // 0xA2
|
||||
writeCommand(0x0);
|
||||
writeCommand(SSD1331_CMD_NORMALDISPLAY); // 0xA4
|
||||
writeCommand(SSD1331_CMD_SETMULTIPLEX); // 0xA8
|
||||
writeCommand(0x3F); // 0x3F 1/64 duty
|
||||
writeCommand(SSD1331_CMD_SETMASTER); // 0xAD
|
||||
writeCommand(0x8E);
|
||||
writeCommand(SSD1331_CMD_POWERMODE); // 0xB0
|
||||
writeCommand(0x0B);
|
||||
writeCommand(SSD1331_CMD_PRECHARGE); // 0xB1
|
||||
writeCommand(0x31);
|
||||
writeCommand(SSD1331_CMD_CLOCKDIV); // 0xB3
|
||||
writeCommand(0xF0); // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16)
|
||||
writeCommand(SSD1331_CMD_PRECHARGEA); // 0x8A
|
||||
writeCommand(0x64);
|
||||
writeCommand(SSD1331_CMD_PRECHARGEB); // 0x8B
|
||||
writeCommand(0x78);
|
||||
writeCommand(SSD1331_CMD_PRECHARGEC); // 0x8C
|
||||
writeCommand(0x64);
|
||||
writeCommand(SSD1331_CMD_PRECHARGELEVEL); // 0xBB
|
||||
writeCommand(0x3A);
|
||||
writeCommand(SSD1331_CMD_VCOMH); // 0xBE
|
||||
writeCommand(0x3E);
|
||||
writeCommand(SSD1331_CMD_MASTERCURRENT); // 0x87
|
||||
writeCommand(0x06);
|
||||
writeCommand(SSD1331_CMD_CONTRASTA); // 0x81
|
||||
writeCommand(0x91);
|
||||
writeCommand(SSD1331_CMD_CONTRASTB); // 0x82
|
||||
writeCommand(0x50);
|
||||
writeCommand(SSD1331_CMD_CONTRASTC); // 0x83
|
||||
writeCommand(0x7D);
|
||||
writeCommand(SSD1331_CMD_DISPLAYON); //--turn on oled panel
|
||||
}
|
||||
|
||||
/********************************* low level pin initialization */
|
||||
|
||||
Adafruit_SSD1331::Adafruit_SSD1331(uint8_t cs, uint8_t rs, uint8_t sid, uint8_t sclk, uint8_t rst) : Adafruit_GFX(TFTWIDTH, TFTHEIGHT) {
|
||||
_cs = cs;
|
||||
_rs = rs;
|
||||
_sid = sid;
|
||||
_sclk = sclk;
|
||||
_rst = rst;
|
||||
}
|
||||
|
||||
Adafruit_SSD1331::Adafruit_SSD1331(uint8_t cs, uint8_t rs, uint8_t rst) : Adafruit_GFX(TFTWIDTH, TFTHEIGHT) {
|
||||
_cs = cs;
|
||||
_rs = rs;
|
||||
_sid = 0;
|
||||
_sclk = 0;
|
||||
_rst = rst;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue