Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createChar from PROGMEM #34

Open
jweglinski opened this issue Jun 16, 2020 · 0 comments
Open

createChar from PROGMEM #34

jweglinski opened this issue Jun 16, 2020 · 0 comments
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@jweglinski
Copy link

Hello!
I think it would be useful to have PROGMEM ready createChar variant - creating custom characters is usually done only once, so wasting RAM for bitmap could be avoided by loading it directly from program memory. I wonder if something like this would be sufficient?

    void createCharProgMem(uint8_t location, const uint8_t charmap[]) {
      location &= 0x7; // we only have 8 locations 0-7
      command(LCD_SETCGRAMADDR | (location << 3));
      for (uint8_t i = 0; i < 8; i++) {
        write(pgm_read_byte_near(charmap + i));
      }
    }
    void createChar(uint8_t location, const __FlashStringHelper *buf) {
      location &= 0x7; // we only have 8 locations 0-7
      command(LCD_SETCGRAMADDR | (location << 3));
      for (uint8_t i = 0; i < 8; i++) {
        write(pgm_read_byte_near((const uint8_t *)buf + i));
      }
    }
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants