in lcd2s.c [217:261]
static int lcd2s_redefine_char(struct charlcd *lcd, char *esc)
{
/* Generator : LGcxxxxx...xx; must have <c> between '0'
* and '7', representing the numerical ASCII code of the
* redefined character, and <xx...xx> a sequence of 16
* hex digits representing 8 bytes for each character.
* Most LCDs will only use 5 lower bits of the 7 first
* bytes.
*/
struct lcd2s_data *lcd2s = lcd->drvdata;
u8 buf[LCD2S_CHARACTER_SIZE + 2] = { LCD2S_CMD_DEF_CUSTOM_CHAR };
u8 value;
int shift, i;
if (!strchr(esc, ';'))
return 0;
esc++;
buf[1] = *(esc++) - '0';
if (buf[1] > 7)
return 1;
i = 0;
shift = 0;
value = 0;
while (*esc && i < LCD2S_CHARACTER_SIZE + 2) {
int half;
shift ^= 4;
half = hex_to_bin(*esc++);
if (half < 0)
continue;
value |= half << shift;
if (shift == 0) {
buf[i++] = value;
value = 0;
}
}
lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf));
return 1;
}