Clean up preprocessor definitions

This commit is contained in:
Zuckerberg 2023-11-09 23:29:52 -07:00
parent 473efc8003
commit ab1a1ce16e
5 changed files with 41 additions and 37 deletions

View File

@ -36,14 +36,11 @@
Epd::~Epd(){};
Epd::Epd()
Epd::Epd(UWORD width, UWORD height, int busyPin, int restPin, int dcPin, int csPin)
: EpdIf(busyPin, restPin, dcPin, csPin)
{
reset_pin = RST_PIN;
dc_pin = DC_PIN;
cs_pin = CS_PIN;
busy_pin = BUSY_PIN;
width = EPD_WIDTH;
height = EPD_HEIGHT;
width = width;
height = height;
};
/******************************************************************************
@ -168,7 +165,7 @@ void Epd::SendData(unsigned char data)
void Epd::EPD_7IN3F_BusyHigh(void) // If BUSYN=0 then waiting
{
while (!DigitalRead(BUSY_PIN))
while (!DigitalRead(busy_pin))
{
DelayMs(1);
}
@ -317,7 +314,7 @@ void Epd::Sleep(void)
SendCommand(0x07);
SendData(0xA5);
DelayMs(10);
DigitalWrite(RST_PIN, 0); // Reset
DigitalWrite(reset_pin, 0); // Reset
}
#endif

View File

@ -34,10 +34,6 @@
#include "epdif.h"
// Display resolution
#define EPD_WIDTH 800
#define EPD_HEIGHT 480
#define UWORD unsigned int
#define UBYTE unsigned char
#define UDOUBLE unsigned long
@ -57,7 +53,7 @@ Color Index
class Epd : EpdIf
{
public:
Epd();
Epd(UWORD width, UWORD height, int busyPin, int restPin, int dcPin, int csPin);
~Epd();
int Init(void);
void EPD_7IN3F_BusyHigh(void);
@ -73,10 +69,6 @@ public:
void Clear(UBYTE color);
private:
unsigned int reset_pin;
unsigned int dc_pin;
unsigned int cs_pin;
unsigned int busy_pin;
unsigned long width;
unsigned long height;
};

View File

@ -30,7 +30,13 @@
#ifdef EPD7IN3F
EpdIf::EpdIf(){};
EpdIf::EpdIf(int busyPin, int restPin, int dcPin, int csPin)
{
reset_pin = restPin;
dc_pin = dcPin;
cs_pin = csPin;
busy_pin = busyPin;
};
EpdIf::~EpdIf(){};
@ -51,17 +57,17 @@ void EpdIf::DelayMs(unsigned int delaytime)
void EpdIf::SpiTransfer(unsigned char data)
{
digitalWrite(CS_PIN, LOW);
digitalWrite(cs_pin, LOW);
SPI.transfer(data);
digitalWrite(CS_PIN, HIGH);
digitalWrite(cs_pin, HIGH);
}
int EpdIf::IfInit(void)
{
pinMode(CS_PIN, OUTPUT);
pinMode(RST_PIN, OUTPUT);
pinMode(DC_PIN, OUTPUT);
pinMode(BUSY_PIN, INPUT);
pinMode(cs_pin, OUTPUT);
pinMode(reset_pin, OUTPUT);
pinMode(dc_pin, OUTPUT);
pinMode(busy_pin, INPUT);
SPI.begin();
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));

View File

@ -30,22 +30,23 @@
#include <Arduino.h>
#define BUSY_PIN 26
#define RST_PIN 27
#define DC_PIN 15
#define CS_PIN 14
class EpdIf
{
public:
EpdIf(void);
EpdIf(int busyPin, int restPin, int dcPin, int csPin);
~EpdIf(void);
static int IfInit(void);
static void DigitalWrite(int pin, int value);
static int DigitalRead(int pin);
static void DelayMs(unsigned int delaytime);
static void SpiTransfer(unsigned char data);
int IfInit(void);
void DigitalWrite(int pin, int value);
int DigitalRead(int pin);
void DelayMs(unsigned int delaytime);
void SpiTransfer(unsigned char data);
protected:
unsigned int reset_pin;
unsigned int dc_pin;
unsigned int cs_pin;
unsigned int busy_pin;
};
#endif

View File

@ -4,6 +4,14 @@
#include "epd7in3f.h"
#define DISPLAY_WIDTH 800
#define DISPLAY_HEIGHT 480
#define BUSY_PIN 26
#define RST_PIN 27
#define DC_PIN 15
#define CS_PIN 14
const char *einkDisplayProperties = R"json(
{
"width": 800,
@ -41,7 +49,7 @@ const char *einkDisplayProperties = R"json(
}
)json";
Epd epd;
Epd epd(DISPLAY_WIDTH, DISPLAY_HEIGHT, BUSY_PIN, RST_PIN, DC_PIN, CS_PIN);
void initDisplay()
{