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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,14 @@
#include "epd7in3f.h" #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( const char *einkDisplayProperties = R"json(
{ {
"width": 800, "width": 800,
@ -41,7 +49,7 @@ const char *einkDisplayProperties = R"json(
} }
)json"; )json";
Epd epd; Epd epd(DISPLAY_WIDTH, DISPLAY_HEIGHT, BUSY_PIN, RST_PIN, DC_PIN, CS_PIN);
void initDisplay() void initDisplay()
{ {