Update Inkplate.h
This commit is contained in:
parent
8d19ff62ce
commit
42b5494400
141
Inkplate.h
141
Inkplate.h
|
@ -11,10 +11,11 @@
|
|||
#endif
|
||||
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_MCP23017.h"
|
||||
#include "SPI.h"
|
||||
#include "SdFat.h"
|
||||
#include "Wire.h"
|
||||
#include "SPI.h"
|
||||
#include "Adafruit_MCP23017.h"
|
||||
#include "SdFat.h"
|
||||
#include "WiFiClient.h"
|
||||
|
||||
#define INKPLATE_GAMMA 1.45
|
||||
#define E_INK_WIDTH 800
|
||||
|
@ -31,44 +32,20 @@
|
|||
#define DATA 0x0E8C0030 //D0-D7 = GPIO4 GPIO5 GPIO18 GPIO19 GPIO23 GPIO25 GPIO26 GPIO27
|
||||
|
||||
#define CL 0x01 //GPIO0
|
||||
#define CL_SET \
|
||||
{ \
|
||||
GPIO.out_w1ts = CL; \
|
||||
}
|
||||
#define CL_CLEAR \
|
||||
{ \
|
||||
GPIO.out_w1tc = CL; \
|
||||
}
|
||||
#define CL_SET {GPIO.out_w1ts = CL;}
|
||||
#define CL_CLEAR {GPIO.out_w1tc = CL;}
|
||||
|
||||
#define LE 0x04 //GPIO2
|
||||
#define LE_SET \
|
||||
{ \
|
||||
GPIO.out_w1ts = LE; \
|
||||
}
|
||||
#define LE_CLEAR \
|
||||
{ \
|
||||
GPIO.out_w1tc = LE; \
|
||||
}
|
||||
#define LE_SET {GPIO.out_w1ts = LE;}
|
||||
#define LE_CLEAR {GPIO.out_w1tc = LE;}
|
||||
|
||||
#define CKV 0x01 //GPIO32
|
||||
#define CKV_SET \
|
||||
{ \
|
||||
GPIO.out1_w1ts.val = CKV; \
|
||||
}
|
||||
#define CKV_CLEAR \
|
||||
{ \
|
||||
GPIO.out1_w1tc.val = CKV; \
|
||||
}
|
||||
#define CKV_SET {GPIO.out1_w1ts.val = CKV;}
|
||||
#define CKV_CLEAR {GPIO.out1_w1tc.val = CKV;}
|
||||
|
||||
#define SPH 0x02 //GPIO33
|
||||
#define SPH_SET \
|
||||
{ \
|
||||
GPIO.out1_w1ts.val = SPH; \
|
||||
}
|
||||
#define SPH_CLEAR \
|
||||
{ \
|
||||
GPIO.out1_w1tc.val = SPH; \
|
||||
}
|
||||
#define SPH_SET {GPIO.out1_w1ts.val = SPH;}
|
||||
#define SPH_CLEAR {GPIO.out1_w1tc.val = SPH;}
|
||||
|
||||
//#define SPV 15 //GPIO15
|
||||
//#define SPV_SET {digitalWrite(SPV, HIGH);}
|
||||
|
@ -76,74 +53,33 @@
|
|||
|
||||
//I/O Expander - A Channel
|
||||
#define GMOD 1 //GPIOA1
|
||||
#define GMOD_SET \
|
||||
{ \
|
||||
mcp.digitalWrite(GMOD, HIGH); \
|
||||
}
|
||||
#define GMOD_CLEAR \
|
||||
{ \
|
||||
mcp.digitalWrite(GMOD, LOW); \
|
||||
}
|
||||
#define GMOD_SET {mcp.digitalWrite(GMOD, HIGH);}
|
||||
#define GMOD_CLEAR {mcp.digitalWrite(GMOD, LOW);}
|
||||
|
||||
#define OE 0 //GPIOA0
|
||||
#define OE_SET \
|
||||
{ \
|
||||
mcp.digitalWrite(OE, HIGH); \
|
||||
}
|
||||
#define OE_CLEAR \
|
||||
{ \
|
||||
mcp.digitalWrite(OE, LOW); \
|
||||
}
|
||||
#define OE_SET {mcp.digitalWrite(OE, HIGH);}
|
||||
#define OE_CLEAR {mcp.digitalWrite(OE, LOW);}
|
||||
|
||||
#define SPV 2 //GPIOA5
|
||||
#define SPV_SET \
|
||||
{ \
|
||||
mcp.digitalWrite(SPV, HIGH); \
|
||||
}
|
||||
#define SPV_CLEAR \
|
||||
{ \
|
||||
mcp.digitalWrite(SPV, LOW); \
|
||||
}
|
||||
#define SPV_SET {mcp.digitalWrite(SPV, HIGH);}
|
||||
#define SPV_CLEAR {mcp.digitalWrite(SPV, LOW);}
|
||||
|
||||
#define WAKEUP 3 //GPIOA3
|
||||
#define WAKEUP_SET \
|
||||
{ \
|
||||
mcp.digitalWrite(WAKEUP, HIGH); \
|
||||
}
|
||||
#define WAKEUP_CLEAR \
|
||||
{ \
|
||||
mcp.digitalWrite(WAKEUP, LOW); \
|
||||
}
|
||||
#define WAKEUP_SET {mcp.digitalWrite(WAKEUP, HIGH);}
|
||||
#define WAKEUP_CLEAR {mcp.digitalWrite(WAKEUP, LOW);}
|
||||
|
||||
#define PWRUP 4 //GPIOA4
|
||||
#define PWRUP_SET \
|
||||
{ \
|
||||
mcp.digitalWrite(PWRUP, HIGH); \
|
||||
}
|
||||
#define PWRUP_CLEAR \
|
||||
{ \
|
||||
mcp.digitalWrite(PWRUP, LOW); \
|
||||
}
|
||||
#define PWRUP_SET {mcp.digitalWrite(PWRUP, HIGH);}
|
||||
#define PWRUP_CLEAR {mcp.digitalWrite(PWRUP, LOW);}
|
||||
|
||||
#define VCOM 5 //GPIOA6
|
||||
#define VCOM_SET \
|
||||
{ \
|
||||
mcp.digitalWrite(VCOM, HIGH); \
|
||||
}
|
||||
#define VCOM_CLEAR \
|
||||
{ \
|
||||
mcp.digitalWrite(VCOM, LOW); \
|
||||
}
|
||||
#define VCOM_SET {mcp.digitalWrite(VCOM, HIGH);}
|
||||
#define VCOM_CLEAR {mcp.digitalWrite(VCOM, LOW);}
|
||||
|
||||
#define CKV_CLOCK ckvClock();
|
||||
|
||||
#ifndef _swap_int16_t
|
||||
#define _swap_int16_t(a, b) \
|
||||
{ \
|
||||
int16_t t = a; \
|
||||
a = b; \
|
||||
b = t; \
|
||||
}
|
||||
#define _swap_int16_t(a, b) { int16_t t = a; a = b; b = t; }
|
||||
#endif
|
||||
|
||||
extern Adafruit_MCP23017 mcp;
|
||||
|
@ -152,8 +88,7 @@ extern SdFat sd;
|
|||
static void ckvClock();
|
||||
static void usleep1();
|
||||
|
||||
class Inkplate : public Adafruit_GFX
|
||||
{
|
||||
class Inkplate : public Adafruit_GFX {
|
||||
public:
|
||||
uint8_t* D_memory_new;
|
||||
uint8_t* _partial;
|
||||
|
@ -173,8 +108,7 @@ public:
|
|||
//PVI waveform for cleaning screen, not sure if it is correct, but it cleans screen properly.
|
||||
const uint32_t waveform[50] = {0x00000008, 0x00000008, 0x00200408, 0x80281888, 0x60a81898, 0x60a8a8a8, 0x60a8a8a8, 0x6068a868, 0x6868a868, 0x6868a868, 0x68686868, 0x6a686868, 0x5a686868, 0x5a686868, 0x5a586a68, 0x5a5a6a68, 0x5a5a6a68, 0x55566a68, 0x55565a64, 0x55555654, 0x55555556, 0x55555556, 0x55555556, 0x55555516, 0x55555596, 0x15555595, 0x95955595, 0x95959595, 0x95949495, 0x94949495, 0x94949495, 0xa4949494, 0x9494a4a4, 0x84a49494, 0x84948484, 0x84848484, 0x84848484, 0x84848484, 0xa5a48484, 0xa9a4a4a8, 0xa9a8a8a8, 0xa5a9a9a4, 0xa5a5a5a4, 0xa1a5a5a1, 0xa9a9a9a9, 0xa9a9a9a9, 0xa9a9a9a9, 0xa9a9a9a9, 0x15151515, 0x11111111};
|
||||
|
||||
struct bitmapHeader
|
||||
{
|
||||
struct bitmapHeader {
|
||||
uint16_t signature;
|
||||
uint32_t fileSize;
|
||||
uint32_t startRAW;
|
||||
|
@ -197,10 +131,10 @@ public:
|
|||
void einkOn(void);
|
||||
void selectDisplayMode(uint8_t _mode);
|
||||
uint8_t getDisplayMode();
|
||||
int drawBitmapFromSD(SdFile *p, int x, int y);
|
||||
int drawBitmapFromSD(char *fileName, int x, int y);
|
||||
void drawThickLine(int x1, int y1, int x2, int y2, int color, float thickness);
|
||||
void drawGradientLine(int x1, int y1, int x2, int y2, int color1, int color2, float thickness = -1);
|
||||
int drawBitmapFromSD(SdFile* p, int x, int y, bool invert = false);
|
||||
int drawBitmapFromSD(char* fileName, int x, int y, bool invert = false);
|
||||
int drawBitmapFromWeb(WiFiClient* s, int x, int y, int len, bool invert = false);
|
||||
int drawBitmapFromWeb(char* url, int x, int y, bool invert = false);
|
||||
int sdCardInit();
|
||||
SdFat getSdFat();
|
||||
SPIClass getSPI();
|
||||
|
@ -232,9 +166,16 @@ private:
|
|||
void display3b();
|
||||
uint32_t read32(uint8_t* c);
|
||||
uint16_t read16(uint8_t* c);
|
||||
void readBmpHeader(SdFile *_f, struct bitmapHeader *_h);
|
||||
int drawMonochromeBitmap(SdFile *f, struct bitmapHeader bmpHeader, int x, int y);
|
||||
int drawGrayscaleBitmap24(SdFile *f, struct bitmapHeader bmpHeader, int x, int y);
|
||||
void readBmpHeaderSd(SdFile *_f, struct bitmapHeader *_h);
|
||||
void readBmpHeaderWeb(WiFiClient *_s, struct bitmapHeader *_h);
|
||||
int drawMonochromeBitmapSd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert);
|
||||
int drawGrayscaleBitmap4Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert);
|
||||
int drawGrayscaleBitmap8Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert);
|
||||
int drawGrayscaleBitmap24Sd(SdFile *f, struct bitmapHeader bmpHeader, int x, int y, bool invert);
|
||||
int drawMonochromeBitmapWeb(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert);
|
||||
int drawGrayscaleBitmap4Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert);
|
||||
int drawGrayscaleBitmap8Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert);
|
||||
int drawGrayscaleBitmap24Web(WiFiClient *s, struct bitmapHeader bmpHeader, int x, int y, int len, bool invert);
|
||||
void precalculateGamma(uint8_t* c, float gamma);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue