philippe44 / esp32-gds Goto Github PK
View Code? Open in Web Editor NEWGraphic Library for ESP32
Graphic Library for ESP32
Although the BitReverseTable is only used in a single function, it's possible to optimize it away either by doing the bit test in the function itself, or to use this code:
uint8_t reverseByte(const uint8_t a)
{
uint8 v = a;
v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1);
v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2);
v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4);
return (uint8)v;
}
This compiles to a lot less than 256 bytes, it's using 15 cycles with no multiply or division, so is probably faster than accessing the SPI flash for the table.
There's also a version with 2 multiplication:
uint8_t reverveByte2(const uint8_t b)
{
return ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
}
It's using only 7 operations. Those operations are described in Bit Twiddling Hacks
By the way, even better the code could probably be replaced by:
for (int r = Height >> 3; --r >= 0;) {
uint8_t Byte = *Data++;
*optr = (*optr & bit) | ((Byte & 0x80) >> shift); optr += DWidth; Byte <<= 1;
*optr = (*optr & bit) | ((Byte & 0x80) >> shift); optr += DWidth; Byte <<= 1;
*optr = (*optr & bit) | ((Byte & 0x80) >> shift); optr += DWidth; Byte <<= 1;
*optr = (*optr & bit) | ((Byte & 0x80) >> shift); optr += DWidth; Byte <<= 1;
*optr = (*optr & bit) | ((Byte & 0x80) >> shift); optr += DWidth; Byte <<= 1;
*optr = (*optr & bit) | ((Byte & 0x80) >> shift); optr += DWidth; Byte <<= 1;
*optr = (*optr & bit) | ((Byte & 0x80) >> shift); optr += DWidth; Byte <<= 1;
*optr = (*optr & bit) | ((Byte & 0x80) >> shift); optr += DWidth;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.