Skip to content

createChar from PROGMEM #34

@jweglinski

Description

@jweglinski

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: enhancementProposed improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions