Code Monkey home page Code Monkey logo

esp32-gds's People

Contributors

philippe44 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esp32-gds's Issues

Optimize bit reverse table

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;
		}	

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.