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 <Wire.h>
|
||||
|
||||
#define WIRE_MAX 32
|
||||
#define TRANSACTION_START wire->setClock(400000UL);
|
||||
#define TRANSACTION_END wire->setClock(100000UL);
|
||||
#include <Arduino.h>
|
||||
#include <string.h>
|
||||
|
||||
void temporary(){
|
||||
|
||||
|
@ -21,7 +16,7 @@ void temporary(){
|
|||
display.begin();
|
||||
|
||||
// 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_BLACK)
|
||||
|
@ -36,11 +31,9 @@ void Display::send_command(const uint8_t c){
|
|||
_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->write((uint8_t) 0x00);
|
||||
_wire->write(c);
|
||||
_wire->endTransmission();
|
||||
uint8_t written = 1;
|
||||
while(n--){
|
||||
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;
|
||||
_wire = &Wire;
|
||||
}
|
||||
|
||||
void Display::begin(){
|
||||
_wire.begin();
|
||||
_wire->begin();
|
||||
|
||||
// reset sequence
|
||||
if( _rstPin >= 0 ){
|
||||
pinMode(rstPin, OUTPUT);
|
||||
digitalWrite(rstPin, HIGH);
|
||||
pinMode(_rstPin, OUTPUT);
|
||||
digitalWrite(_rstPin, HIGH);
|
||||
delay(1);
|
||||
digitalWrite(rstPin, LOW);
|
||||
digitalWrite(_rstPin, LOW);
|
||||
delay(10);
|
||||
digitalWrite(rstPin, HIGH);
|
||||
digitalWrite(_rstPin, HIGH);
|
||||
}
|
||||
|
||||
TRANSACTION_START
|
||||
|
@ -92,7 +85,7 @@ void Display::begin(){
|
|||
DSP_SETSTARTLINE | 0x0,
|
||||
DSP_CHARGEPUMP
|
||||
};
|
||||
sendcommands(init2, sizeof(init2));
|
||||
send_commands(init2, sizeof(init2));
|
||||
send_command(0x14);
|
||||
|
||||
static const uint8_t PROGMEM init3[] = {
|
||||
|
@ -101,24 +94,24 @@ void Display::begin(){
|
|||
DSP_SEGREMAP | 0x1,
|
||||
DSP_COMSCANDEC
|
||||
};
|
||||
sendcommands(init3, sizeof(init3));
|
||||
send_commands(init3, sizeof(init3));
|
||||
|
||||
sendcommand(DSP_SETCOMPINS);
|
||||
sendcommand(_comPin);
|
||||
sendcommand(DSP_SETCONTRAST);
|
||||
sendcommand(_contrast);
|
||||
send_command(DSP_SETCOMPINS);
|
||||
send_command(_comPin);
|
||||
send_command(DSP_SETCONTRAST);
|
||||
send_command(_contrast);
|
||||
send_command(DSP_SETPRECHARGE);
|
||||
send_command(0xF1);
|
||||
|
||||
static const uint8_t PROGMEM init5[] = {
|
||||
DSP_SETVCOMPDETECT,
|
||||
DSP_SETVCOMDETECT,
|
||||
0x40,
|
||||
DSP_DISPLAYALLON_RESUME,
|
||||
DSP_NORMALDISPLAY,
|
||||
DSP_DEACTIVATE_SCROLL,
|
||||
DSP_DISPLAYON
|
||||
};
|
||||
sendcommands(init5, sizeof(init5));
|
||||
send_commands(init5, sizeof(init5));
|
||||
|
||||
TRANSACTION_END
|
||||
|
||||
|
@ -155,3 +148,9 @@ void Display::clear(){
|
|||
|
||||
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_
|
||||
#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_COLUMNADDR 0x21 ///< See datasheet
|
||||
#define DSP_PAGEADDR 0x22 ///< See datasheet
|
||||
|
@ -39,9 +46,10 @@
|
|||
|
||||
class Display {
|
||||
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 clear();
|
||||
void progress(const uint8_t progress);
|
||||
|
||||
protected:
|
||||
void send_command(const uint8_t c);
|
||||
|
|
Loading…
Reference in New Issue