You've already forked TEF6686_ESP32
updates, and on dp666 the date should be wrong on startup
This commit is contained in:
@@ -27,11 +27,7 @@
|
||||
#include <sys/time.h>
|
||||
#include "esp_attr.h"
|
||||
|
||||
#ifdef RTC_DATA_ATTR
|
||||
RTC_DATA_ATTR static bool overflow;
|
||||
#else
|
||||
static bool overflow;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief set the internal RTC time
|
||||
|
||||
@@ -38,33 +38,11 @@ extern "C" {
|
||||
* @param hash uint8_t[20]
|
||||
*/
|
||||
void sha1(uint8_t * data, uint32_t size, uint8_t hash[20]) {
|
||||
|
||||
SHA1_CTX ctx;
|
||||
|
||||
#ifdef DEBUG_SHA1
|
||||
os_printf("DATA:");
|
||||
for(uint16_t i = 0; i < size; i++) {
|
||||
os_printf("%02X", data[i]);
|
||||
}
|
||||
os_printf("\n");
|
||||
os_printf("DATA:");
|
||||
for(uint16_t i = 0; i < size; i++) {
|
||||
os_printf("%c", data[i]);
|
||||
}
|
||||
os_printf("\n");
|
||||
#endif
|
||||
|
||||
SHA1Init(&ctx);
|
||||
SHA1Update(&ctx, data, size);
|
||||
SHA1Final(hash, &ctx);
|
||||
|
||||
#ifdef DEBUG_SHA1
|
||||
os_printf("SHA1:");
|
||||
for(uint16_t i = 0; i < 20; i++) {
|
||||
os_printf("%02X", hash[i]);
|
||||
}
|
||||
os_printf("\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void sha1(char * data, uint32_t size, uint8_t hash[20]) {
|
||||
|
||||
@@ -22,10 +22,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HASH_H_
|
||||
#define HASH_H_
|
||||
|
||||
//#define DEBUG_SHA1
|
||||
#pragma once
|
||||
|
||||
void sha1(uint8_t * data, uint32_t size, uint8_t hash[20]);
|
||||
void sha1(char * data, uint32_t size, uint8_t hash[20]);
|
||||
@@ -38,5 +35,3 @@ String sha1(char* data, uint32_t size);
|
||||
String sha1(const uint8_t* data, uint32_t size);
|
||||
String sha1(const char* data, uint32_t size);
|
||||
String sha1(String data);
|
||||
|
||||
#endif /* HASH_H_ */
|
||||
|
||||
@@ -23,34 +23,18 @@
|
||||
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
||||
*/
|
||||
|
||||
/* #define LITTLE_ENDIAN * This should be #define'd already, if true. */
|
||||
/* #define SHA1HANDSOFF * Copies data before messing with it. */
|
||||
|
||||
#define SHA1HANDSOFF
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#ifndef ESP32
|
||||
#include <c_types.h>
|
||||
#endif
|
||||
|
||||
#include "sha1.h"
|
||||
|
||||
//#include <endian.h>
|
||||
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
/* blk0() and blk() perform the initial expand. */
|
||||
/* I got the idea of expanding during the round function from SSLeay */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|
||||
|(rol(block->l[i],8)&0x00FF00FF))
|
||||
#elif BYTE_ORDER == BIG_ENDIAN
|
||||
#define blk0(i) block->l[i]
|
||||
#else
|
||||
#error "Endianness not defined!"
|
||||
#endif
|
||||
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
||||
^block->l[(i+2)&15]^block->l[i&15],1))
|
||||
|
||||
@@ -61,26 +45,14 @@
|
||||
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
|
||||
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
|
||||
|
||||
|
||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||
STATIC void ICACHE_FLASH_ATTR SHA1Transform(uint32_t state[5], uint8_t buffer[64])
|
||||
{
|
||||
STATIC void ICACHE_FLASH_ATTR SHA1Transform(uint32_t state[5], uint8_t buffer[64]) {
|
||||
uint32_t a, b, c, d, e;
|
||||
typedef union {
|
||||
unsigned char c[64];
|
||||
uint32_t l[16];
|
||||
} CHAR64LONG16;
|
||||
#ifdef SHA1HANDSOFF
|
||||
CHAR64LONG16 block[1]; /* use array to appear as a pointer */
|
||||
memcpy(block, buffer, 64);
|
||||
#else
|
||||
/* The following had better never be used because it causes the
|
||||
* pointer-to-const buffer to be cast into a pointer to non-const.
|
||||
* And the result is written through. I threw a "const" in, hoping
|
||||
* this will cause a diagnostic.
|
||||
*/
|
||||
CHAR64LONG16* block = (const CHAR64LONG16*)buffer;
|
||||
#endif
|
||||
/* Copy context->state[] to working vars */
|
||||
a = state[0];
|
||||
b = state[1];
|
||||
@@ -116,18 +88,11 @@ CHAR64LONG16* block = (const CHAR64LONG16*)buffer;
|
||||
state[4] += e;
|
||||
/* Wipe variables */
|
||||
a = b = c = d = e = 0;
|
||||
#ifdef SHA1HANDSOFF
|
||||
memset(block, '\0', sizeof(block));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* SHA1Init - Initialize new context */
|
||||
|
||||
STATIC void ICACHE_FLASH_ATTR SHA1Init(SHA1_CTX* context)
|
||||
{
|
||||
/* SHA1 initialization constants */
|
||||
context->state[0] = 0x67452301;
|
||||
STATIC void ICACHE_FLASH_ATTR SHA1Init(SHA1_CTX* context) {
|
||||
context->state[0] = 0x67452301; // six seven
|
||||
context->state[1] = 0xEFCDAB89;
|
||||
context->state[2] = 0x98BADCFE;
|
||||
context->state[3] = 0x10325476;
|
||||
@@ -135,13 +100,8 @@ STATIC void ICACHE_FLASH_ATTR SHA1Init(SHA1_CTX* context)
|
||||
context->count[0] = context->count[1] = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Run your data through this. */
|
||||
|
||||
STATIC void ICACHE_FLASH_ATTR SHA1Update(SHA1_CTX* context, uint8_t* data, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t j;
|
||||
STATIC void ICACHE_FLASH_ATTR SHA1Update(SHA1_CTX* context, uint8_t* data, uint32_t len) {
|
||||
uint32_t i, j;
|
||||
|
||||
j = context->count[0];
|
||||
if ((context->count[0] += len << 3) < j)
|
||||
@@ -151,9 +111,7 @@ STATIC void ICACHE_FLASH_ATTR SHA1Update(SHA1_CTX* context, uint8_t* data, uint3
|
||||
if ((j + len) > 63) {
|
||||
memcpy(&context->buffer[j], data, (i = 64-j));
|
||||
SHA1Transform(context->state, context->buffer);
|
||||
for ( ; i + 63 < len; i += 64) {
|
||||
SHA1Transform(context->state, &data[i]);
|
||||
}
|
||||
for ( ; i + 63 < len; i += 64) SHA1Transform(context->state, &data[i]);
|
||||
j = 0;
|
||||
}
|
||||
else i = 0;
|
||||
@@ -163,38 +121,19 @@ STATIC void ICACHE_FLASH_ATTR SHA1Update(SHA1_CTX* context, uint8_t* data, uint3
|
||||
|
||||
/* Add padding and return the message digest. */
|
||||
|
||||
STATIC void ICACHE_FLASH_ATTR SHA1Final(unsigned char digest[20], SHA1_CTX* context)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned char finalcount[8];
|
||||
unsigned char c;
|
||||
STATIC void ICACHE_FLASH_ATTR SHA1Final(unsigned char digest[20], SHA1_CTX* context) {
|
||||
unsigned i;
|
||||
unsigned char finalcount[8];
|
||||
unsigned char c;
|
||||
|
||||
#if 0 /* untested "improvement" by DHR */
|
||||
/* Convert context->count to a sequence of bytes
|
||||
* in finalcount. Second element first, but
|
||||
* big-endian order within element.
|
||||
* But we do it all backwards.
|
||||
*/
|
||||
unsigned char *fcp = &finalcount[8];
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
uint32_t t = context->count[i];
|
||||
int j;
|
||||
|
||||
for (j = 0; j < 4; t >>= 8, j++)
|
||||
*--fcp = (unsigned char) t;
|
||||
}
|
||||
#else
|
||||
for (i = 0; i < 8; i++) {
|
||||
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
|
||||
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
|
||||
}
|
||||
#endif
|
||||
c = 0200;
|
||||
SHA1Update(context, &c, 1);
|
||||
while ((context->count[0] & 504) != 448) {
|
||||
c = 0000;
|
||||
c = 0000;
|
||||
SHA1Update(context, &c, 1);
|
||||
}
|
||||
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
|
||||
@@ -206,4 +145,3 @@ unsigned char c;
|
||||
memset(context, '\0', sizeof(*context));
|
||||
memset(&finalcount, '\0', sizeof(finalcount));
|
||||
}
|
||||
/* ================ end of sha1.c ================ */
|
||||
|
||||
@@ -13,15 +13,10 @@
|
||||
100% Public Domain
|
||||
*/
|
||||
|
||||
#ifndef SHA1_H_
|
||||
#define SHA1_H_
|
||||
#pragma once
|
||||
|
||||
#ifdef ESP32
|
||||
#define ICACHE_FLASH_ATTR
|
||||
#define STATIC static
|
||||
#else
|
||||
#define STATIC
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint32_t state[5];
|
||||
@@ -32,8 +27,4 @@ typedef struct {
|
||||
STATIC void SHA1Transform(uint32_t state[5], uint8_t buffer[64]);
|
||||
STATIC void SHA1Init(SHA1_CTX* context);
|
||||
STATIC void SHA1Update(SHA1_CTX* context, uint8_t* data, uint32_t len);
|
||||
STATIC void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
|
||||
|
||||
#endif /* SHA1_H_ */
|
||||
|
||||
/* ================ end of sha1.h ================ */
|
||||
STATIC void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
|
||||
@@ -1,48 +0,0 @@
|
||||
#define TFT_NOP 0x00
|
||||
|
||||
#define TFT_INVOFF 0x20
|
||||
#define TFT_INVON 0x21
|
||||
|
||||
#define TFT_CASET 0x2A
|
||||
#define TFT_PASET 0x2B
|
||||
#define TFT_RAMWR 0x2C
|
||||
|
||||
#define TFT_RAMRD 0x2E
|
||||
#define TFT_IDXRD 0xDD
|
||||
|
||||
#define TFT_MADCTL 0x36
|
||||
#define TFT_MAD_MY 0x80
|
||||
#define TFT_MAD_MX 0x40
|
||||
#define TFT_MAD_MV 0x20
|
||||
#define TFT_MAD_ML 0x10
|
||||
#define TFT_MAD_BGR 0x08
|
||||
#define TFT_MAD_MH 0x04
|
||||
#define TFT_MAD_RGB 0x00
|
||||
|
||||
#define ILI9341_SLPOUT 0x11
|
||||
#define ILI9341_NORON 0x13
|
||||
|
||||
#define ILI9341_GAMMASET 0x26
|
||||
#define ILI9341_DISPON 0x29
|
||||
|
||||
#define ILI9341_MADCTL 0x36
|
||||
#define ILI9341_PIXFMT 0x3A
|
||||
|
||||
#define ILI9341_FRMCTR1 0xB1
|
||||
#define ILI9341_DFUNCTR 0xB6
|
||||
|
||||
#define ILI9341_PWCTR1 0xC0
|
||||
#define ILI9341_PWCTR2 0xC1
|
||||
#define ILI9341_VMCTR1 0xC5
|
||||
#define ILI9341_VMCTR2 0xC7
|
||||
|
||||
#define ILI9341_GMCTRP1 0xE0
|
||||
#define ILI9341_GMCTRN1 0xE1
|
||||
|
||||
#define ILI9341_MADCTL_MY 0x80
|
||||
#define ILI9341_MADCTL_MX 0x40
|
||||
#define ILI9341_MADCTL_MV 0x20
|
||||
#define ILI9341_MADCTL_ML 0x10
|
||||
#define ILI9341_MADCTL_RGB 0x00
|
||||
#define ILI9341_MADCTL_BGR 0x08
|
||||
#define ILI9341_MADCTL_MH 0x04
|
||||
@@ -105,7 +105,7 @@
|
||||
writecommand(ILI9341_SLPOUT); //Exit Sleep
|
||||
|
||||
end_tft_write();
|
||||
delay(80);
|
||||
delay(60);
|
||||
begin_tft_write();
|
||||
|
||||
writecommand(ILI9341_DISPON); //Display on
|
||||
|
||||
@@ -316,7 +316,7 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h) {
|
||||
textwrapX = false;
|
||||
textdatum = TL_DATUM;
|
||||
|
||||
_swapBytes = false;
|
||||
_swapBytes = true;
|
||||
|
||||
booted = true;
|
||||
|
||||
@@ -404,7 +404,7 @@ void TFT_eSPI::init() {
|
||||
gpio_set_level((gpio_num_t)TFT_RST, 1);
|
||||
}
|
||||
|
||||
delay(50); // Wait for reset to complete
|
||||
delay(35); // Wait for reset to complete
|
||||
|
||||
begin_tft_write();
|
||||
|
||||
@@ -3079,7 +3079,7 @@ TFT_eSprite::TFT_eSprite(TFT_eSPI *tft) {
|
||||
_iwidth = 0; // Initialise width and height to 0 (it does not exist yet)
|
||||
_iheight = 0;
|
||||
_bpp = 16;
|
||||
_swapBytes = false; // Do not swap pushImage colour bytes by default
|
||||
_swapBytes = true; // Do not swap pushImage colour bytes by default
|
||||
|
||||
_created = false;
|
||||
_vpOoB = true;
|
||||
@@ -3310,40 +3310,29 @@ void TFT_eSprite::pushSprite(int32_t x, int32_t y)
|
||||
{
|
||||
if (!_created) return;
|
||||
|
||||
if (_bpp == 16)
|
||||
{
|
||||
if (_bpp == 16) {
|
||||
bool oldSwapBytes = _tft->getSwapBytes();
|
||||
_tft->setSwapBytes(false);
|
||||
_tft->pushImage(x, y, _dwidth, _dheight, _img );
|
||||
_tft->setSwapBytes(oldSwapBytes);
|
||||
}
|
||||
else if (_bpp == 4)
|
||||
{
|
||||
} else if (_bpp == 4) {
|
||||
_tft->pushImage(x, y, _dwidth, _dheight, _img4, false, _colorMap);
|
||||
}
|
||||
else _tft->pushImage(x, y, _dwidth, _dheight, _img8, (bool)(_bpp == 8));
|
||||
} else _tft->pushImage(x, y, _dwidth, _dheight, _img8, (bool)(_bpp == 8));
|
||||
}
|
||||
|
||||
void TFT_eSprite::pushSprite(int32_t x, int32_t y, uint16_t transp)
|
||||
{
|
||||
if (!_created) return;
|
||||
|
||||
if (_bpp == 16)
|
||||
{
|
||||
if (_bpp == 16) {
|
||||
bool oldSwapBytes = _tft->getSwapBytes();
|
||||
_tft->setSwapBytes(false);
|
||||
_tft->pushImage(x, y, _dwidth, _dheight, _img, transp );
|
||||
_tft->setSwapBytes(oldSwapBytes);
|
||||
}
|
||||
else if (_bpp == 8)
|
||||
{
|
||||
} else if (_bpp == 8) {
|
||||
transp = (uint8_t)((transp & 0xE000)>>8 | (transp & 0x0700)>>6 | (transp & 0x0018)>>3);
|
||||
_tft->pushImage(x, y, _dwidth, _dheight, _img8, (uint8_t)transp, (bool)true);
|
||||
}
|
||||
else if (_bpp == 4)
|
||||
{
|
||||
_tft->pushImage(x, y, _dwidth, _dheight, _img4, (uint8_t)(transp & 0x0F), false, _colorMap);
|
||||
}
|
||||
} else if (_bpp == 4) _tft->pushImage(x, y, _dwidth, _dheight, _img4, (uint8_t)(transp & 0x0F), false, _colorMap);
|
||||
else _tft->pushImage(x, y, _dwidth, _dheight, _img8, 0, (bool)false);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,54 @@
|
||||
#define TFT_WIDTH 240
|
||||
#define TFT_HEIGHT 320
|
||||
|
||||
#include <ILI9341_Defines.h>
|
||||
#define TFT_NOP 0x00
|
||||
|
||||
#define TFT_INVOFF 0x20
|
||||
#define TFT_INVON 0x21
|
||||
|
||||
#define TFT_CASET 0x2A
|
||||
#define TFT_PASET 0x2B
|
||||
#define TFT_RAMWR 0x2C
|
||||
|
||||
#define TFT_RAMRD 0x2E
|
||||
#define TFT_IDXRD 0xDD
|
||||
|
||||
#define TFT_MADCTL 0x36
|
||||
#define TFT_MAD_MY 0x80
|
||||
#define TFT_MAD_MX 0x40
|
||||
#define TFT_MAD_MV 0x20
|
||||
#define TFT_MAD_ML 0x10
|
||||
#define TFT_MAD_BGR 0x08
|
||||
#define TFT_MAD_MH 0x04
|
||||
#define TFT_MAD_RGB 0x00
|
||||
|
||||
#define ILI9341_SLPOUT 0x11
|
||||
#define ILI9341_NORON 0x13
|
||||
|
||||
#define ILI9341_GAMMASET 0x26
|
||||
#define ILI9341_DISPON 0x29
|
||||
|
||||
#define ILI9341_MADCTL 0x36
|
||||
#define ILI9341_PIXFMT 0x3A
|
||||
|
||||
#define ILI9341_FRMCTR1 0xB1
|
||||
#define ILI9341_DFUNCTR 0xB6
|
||||
|
||||
#define ILI9341_PWCTR1 0xC0
|
||||
#define ILI9341_PWCTR2 0xC1
|
||||
#define ILI9341_VMCTR1 0xC5
|
||||
#define ILI9341_VMCTR2 0xC7
|
||||
|
||||
#define ILI9341_GMCTRP1 0xE0
|
||||
#define ILI9341_GMCTRN1 0xE1
|
||||
|
||||
#define ILI9341_MADCTL_MY 0x80
|
||||
#define ILI9341_MADCTL_MX 0x40
|
||||
#define ILI9341_MADCTL_MV 0x20
|
||||
#define ILI9341_MADCTL_ML 0x10
|
||||
#define ILI9341_MADCTL_RGB 0x00
|
||||
#define ILI9341_MADCTL_BGR 0x08
|
||||
#define ILI9341_MADCTL_MH 0x04
|
||||
|
||||
#include <pgmspace.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user