mirror of
https://github.com/adafruit/Adafruit_SSD1306.git
synced 2026-07-27 20:05:50 +00:00
Incorporate edwinm's dim() method
This commit is contained in:
@@ -143,6 +143,7 @@ Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
|
||||
|
||||
|
||||
void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr) {
|
||||
_vccstate = vccstate;
|
||||
_i2caddr = i2caddr;
|
||||
|
||||
// set pin directions
|
||||
@@ -357,6 +358,27 @@ void Adafruit_SSD1306::stopscroll(void){
|
||||
ssd1306_command(SSD1306_DEACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// Dim the display
|
||||
// dim = true: display is dimmed
|
||||
// dim = false: display is normal
|
||||
void Adafruit_SSD1306::dim(boolean dim) {
|
||||
uint8_t contrast;
|
||||
|
||||
if (dim) {
|
||||
contrast = 0; // Dimmed display
|
||||
} else {
|
||||
if (_vccstate == SSD1306_EXTERNALVCC) {
|
||||
contrast = 0x9F;
|
||||
} else {
|
||||
contrast = 0xCF;
|
||||
}
|
||||
}
|
||||
// the range of contrast to too small to be really useful
|
||||
// it is useful to dim the display
|
||||
ssd1306_command(SSD1306_SETCONTRAST);
|
||||
ssd1306_command(contrast);
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::ssd1306_data(uint8_t c) {
|
||||
if (sid != -1)
|
||||
{
|
||||
|
||||
+4
-2
@@ -29,7 +29,7 @@ All text above, and the splash screen must be included in any redistribution
|
||||
|
||||
#define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D
|
||||
// Address for 128x32 is 0x3C
|
||||
// Address for 128x32 is 0x3D (default) or 0x3C (if SA0 is grounded)
|
||||
// Address for 128x64 is 0x3D (default) or 0x3C (if SA0 is grounded)
|
||||
|
||||
/*=========================================================================
|
||||
SSD1306 Displays
|
||||
@@ -129,10 +129,12 @@ class Adafruit_SSD1306 : public Adafruit_GFX {
|
||||
void startscrolldiagleft(uint8_t start, uint8_t stop);
|
||||
void stopscroll(void);
|
||||
|
||||
void dim(uint8_t contrast);
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
private:
|
||||
int8_t _i2caddr, sid, sclk, dc, rst, cs;
|
||||
int8_t _i2caddr, _vccstate, sid, sclk, dc, rst, cs;
|
||||
void fastSPIwrite(uint8_t c);
|
||||
void slowSPIwrite(uint8_t c);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user