fix: compilation errors
This commit is contained in:
parent
510517d90b
commit
059a5dfb9f
|
@ -1,12 +1,7 @@
|
||||||
#include <Arduino.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
#include <Wire.h>
|
#include <Arduino.h>
|
||||||
|
#include <string.h>
|
||||||
#define WIRE_MAX 32
|
|
||||||
#define TRANSACTION_START wire->setClock(400000UL);
|
|
||||||
#define TRANSACTION_END wire->setClock(100000UL);
|
|
||||||
|
|
||||||
void temporary(){
|
void temporary(){
|
||||||
|
|
||||||
|
@ -21,7 +16,7 @@ void temporary(){
|
||||||
display.begin();
|
display.begin();
|
||||||
|
|
||||||
// display.clearDisplay();
|
// display.clearDisplay();
|
||||||
display.clear(true); // no need to call display() after to apply
|
display.clear(); // no need to call display() after to apply
|
||||||
|
|
||||||
// display.drawPixel(x, y, SSD1306_WHITE)
|
// display.drawPixel(x, y, SSD1306_WHITE)
|
||||||
// display.drawPixel(x, y, SSD1306_BLACK)
|
// display.drawPixel(x, y, SSD1306_BLACK)
|
||||||
|
@ -36,11 +31,9 @@ void Display::send_command(const uint8_t c){
|
||||||
_wire->endTransmission();
|
_wire->endTransmission();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::send_commands(const uint8_t *cc, const uint8_t n){
|
void Display::send_commands(const uint8_t *cc, uint8_t n){
|
||||||
_wire->beginTransmission(_i2caddr);
|
_wire->beginTransmission(_i2caddr);
|
||||||
_wire->write((uint8_t) 0x00);
|
_wire->write((uint8_t) 0x00);
|
||||||
_wire->write(c);
|
|
||||||
_wire->endTransmission();
|
|
||||||
uint8_t written = 1;
|
uint8_t written = 1;
|
||||||
while(n--){
|
while(n--){
|
||||||
if( written >= WIRE_MAX ){
|
if( written >= WIRE_MAX ){
|
||||||
|
@ -56,22 +49,22 @@ void Display::send_commands(const uint8_t *cc, const uint8_t n){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Display::Display(const resetPin){
|
Display::Display(const uint8_t resetPin){
|
||||||
_rstPin = resetPin;
|
_rstPin = resetPin;
|
||||||
_wire = &Wire;
|
_wire = &Wire;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::begin(){
|
void Display::begin(){
|
||||||
_wire.begin();
|
_wire->begin();
|
||||||
|
|
||||||
// reset sequence
|
// reset sequence
|
||||||
if( _rstPin >= 0 ){
|
if( _rstPin >= 0 ){
|
||||||
pinMode(rstPin, OUTPUT);
|
pinMode(_rstPin, OUTPUT);
|
||||||
digitalWrite(rstPin, HIGH);
|
digitalWrite(_rstPin, HIGH);
|
||||||
delay(1);
|
delay(1);
|
||||||
digitalWrite(rstPin, LOW);
|
digitalWrite(_rstPin, LOW);
|
||||||
delay(10);
|
delay(10);
|
||||||
digitalWrite(rstPin, HIGH);
|
digitalWrite(_rstPin, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRANSACTION_START
|
TRANSACTION_START
|
||||||
|
@ -92,7 +85,7 @@ void Display::begin(){
|
||||||
DSP_SETSTARTLINE | 0x0,
|
DSP_SETSTARTLINE | 0x0,
|
||||||
DSP_CHARGEPUMP
|
DSP_CHARGEPUMP
|
||||||
};
|
};
|
||||||
sendcommands(init2, sizeof(init2));
|
send_commands(init2, sizeof(init2));
|
||||||
send_command(0x14);
|
send_command(0x14);
|
||||||
|
|
||||||
static const uint8_t PROGMEM init3[] = {
|
static const uint8_t PROGMEM init3[] = {
|
||||||
|
@ -101,24 +94,24 @@ void Display::begin(){
|
||||||
DSP_SEGREMAP | 0x1,
|
DSP_SEGREMAP | 0x1,
|
||||||
DSP_COMSCANDEC
|
DSP_COMSCANDEC
|
||||||
};
|
};
|
||||||
sendcommands(init3, sizeof(init3));
|
send_commands(init3, sizeof(init3));
|
||||||
|
|
||||||
sendcommand(DSP_SETCOMPINS);
|
send_command(DSP_SETCOMPINS);
|
||||||
sendcommand(_comPin);
|
send_command(_comPin);
|
||||||
sendcommand(DSP_SETCONTRAST);
|
send_command(DSP_SETCONTRAST);
|
||||||
sendcommand(_contrast);
|
send_command(_contrast);
|
||||||
send_command(DSP_SETPRECHARGE);
|
send_command(DSP_SETPRECHARGE);
|
||||||
send_command(0xF1);
|
send_command(0xF1);
|
||||||
|
|
||||||
static const uint8_t PROGMEM init5[] = {
|
static const uint8_t PROGMEM init5[] = {
|
||||||
DSP_SETVCOMPDETECT,
|
DSP_SETVCOMDETECT,
|
||||||
0x40,
|
0x40,
|
||||||
DSP_DISPLAYALLON_RESUME,
|
DSP_DISPLAYALLON_RESUME,
|
||||||
DSP_NORMALDISPLAY,
|
DSP_NORMALDISPLAY,
|
||||||
DSP_DEACTIVATE_SCROLL,
|
DSP_DEACTIVATE_SCROLL,
|
||||||
DSP_DISPLAYON
|
DSP_DISPLAYON
|
||||||
};
|
};
|
||||||
sendcommands(init5, sizeof(init5));
|
send_commands(init5, sizeof(init5));
|
||||||
|
|
||||||
TRANSACTION_END
|
TRANSACTION_END
|
||||||
|
|
||||||
|
@ -154,4 +147,10 @@ void Display::clear(){
|
||||||
_wire->endTransmission();
|
_wire->endTransmission();
|
||||||
|
|
||||||
TRANSACTION_END
|
TRANSACTION_END
|
||||||
|
}
|
||||||
|
|
||||||
|
// draws a progress bar to a fixed location
|
||||||
|
// the progress value is between 0 and 255
|
||||||
|
void Display::progress(const uint8_t progress){
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,13 @@
|
||||||
#ifndef _DISPLAY_H_DEF_
|
#ifndef _DISPLAY_H_DEF_
|
||||||
#define _DISPLAY_H_DEF_
|
#define _DISPLAY_H_DEF_
|
||||||
|
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
#define WIRE_MAX 32
|
||||||
|
#define TRANSACTION_START _wire->setClock(400000UL);
|
||||||
|
#define TRANSACTION_END _wire->setClock(100000UL);
|
||||||
|
|
||||||
|
|
||||||
#define DSP_MEMORYMODE 0x20 ///< See datasheet
|
#define DSP_MEMORYMODE 0x20 ///< See datasheet
|
||||||
#define DSP_COLUMNADDR 0x21 ///< See datasheet
|
#define DSP_COLUMNADDR 0x21 ///< See datasheet
|
||||||
#define DSP_PAGEADDR 0x22 ///< See datasheet
|
#define DSP_PAGEADDR 0x22 ///< See datasheet
|
||||||
|
@ -39,9 +46,10 @@
|
||||||
|
|
||||||
class Display {
|
class Display {
|
||||||
public:
|
public:
|
||||||
void Display(const uint8_t width=128, const uint8_t height=32, const resetPin=-1);
|
Display(const uint8_t resetPin=-1);
|
||||||
void begin();
|
void begin();
|
||||||
void clear();
|
void clear();
|
||||||
|
void progress(const uint8_t progress);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void send_command(const uint8_t c);
|
void send_command(const uint8_t c);
|
||||||
|
@ -52,8 +60,8 @@
|
||||||
const uint8_t _comPin { 0x02 };
|
const uint8_t _comPin { 0x02 };
|
||||||
const uint8_t _i2caddr { 0x3C };
|
const uint8_t _i2caddr { 0x3C };
|
||||||
const uint8_t _contrast { 0x8F };
|
const uint8_t _contrast { 0x8F };
|
||||||
uint8_t _rstPin { -1 };
|
uint8_t _rstPin { -1 };
|
||||||
TwoWire* _wire { nullptr };
|
TwoWire* _wire { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue