Skip to content

Commit

Permalink
FF.CFG: Rename oled-text= to display-order=. It now controls both LCD…
Browse files Browse the repository at this point in the history
… and OLED.

Remove the 's' single-height specifier, this is teh default height anyway.
Double-height is now an optional 'd' suffix to each row's content line nr.
  • Loading branch information
keirf committed Jun 25, 2019
1 parent c0413c1 commit 71a0b70
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 30 deletions.
14 changes: 7 additions & 7 deletions examples/FF.CFG
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,18 @@ oled-font = 6x13
# Values: 0 <= N <= 255
oled-contrast = 143

# Text height and arrangement on OLED
# 'default', or a comma-separated list (one entry per OLED row, top down).
# Each list item is a character pair: <content-row><height>
# Text height and arrangement on LCD/OLED
# 'default', or a comma-separated list (one entry per LCD/OLED row, top down).
# Each list item is a digit plus optional height specifier: <content-row>[d]
# content-row: '0-3' = specified content row, '7' = blank
# 0: Current image name
# 1: Status
# 2: Image/Volume info
# 3: Current subfolder name
# height: 's' = single height (16px), 'd' = double height (32px)
# 'default' depends on display size: 128x32='0s,1s' ; 128x64='0d,1s,2s'
# Values: [0-7][sd] | default
oled-text = default
# height specifier: 'd' = double height (32px, OLED only; ignored for LCD)
# 'default' depends on display, eg.: oled-128x32='0,1' ; oled-128x64='3,0d,1'
# Values: [0-7][d] | default
display-order = default

# Turn an LCD or OLED display off after N seconds of inactivity
# N=0: always off; N=255: always on
Expand Down
10 changes: 5 additions & 5 deletions inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ struct __packed ff_cfg {
#define CHGRST_step 0xff
#define CHGRST_pa14 0x0e
uint8_t chgrst;
#define OTXT_default 0xffff
#define OTXT_shift 4
#define OTXT_row 7
#define OTXT_double 8
uint16_t oled_text;
#define DORD_default 0xffff
#define DORD_shift 4
#define DORD_row 7
#define DORD_double 8
uint16_t display_order;
};

extern struct ff_cfg ff_cfg;
Expand Down
6 changes: 3 additions & 3 deletions scripts/mk_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def main(argv):
else:
opts += ['DISPLAY_' + x]
val = '|'.join(opts)
elif opt == "oled-text":
elif opt == "display-order":
if val == "default":
val = "OTXT_" + val
val = "DORD_" + val
else:
v = 0
sh = 0
for x in val.split(","):
o = re.match("([0-9])([sd])", x)
o = re.match("([0-9])(d?)", x)
v |= int(o.group(1)) << sh
if o.group(2) == "d":
v |= 8 << sh
Expand Down
23 changes: 15 additions & 8 deletions src/display/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,20 @@ static void emit8(uint8_t **p, uint8_t val, uint8_t signals)
static unsigned int lcd_prep_buffer(void)
{
const static uint8_t row_offs[] = { 0x00, 0x40, 0x14, 0x54 };
char *p = text[i2c_row];
uint16_t order;
char *p;
uint8_t *q = buffer;
unsigned int i;
unsigned int i, row;

order = (ff_cfg.display_order != DORD_default) ? ff_cfg.display_order
: (lcd_rows == 2) ? 0x7710 : 0x2103;

row = (order >> (i2c_row * DORD_shift)) & DORD_row;
p = (row < ARRAY_SIZE(text)) ? text[row] : NULL;

emit8(&q, CMD_SETDDRADDR | row_offs[i2c_row], 0);
for (i = 0; i < lcd_columns; i++)
emit8(&q, *p++, _RS);
emit8(&q, p ? *p++ : ' ', _RS);

if (++i2c_row >= lcd_rows) {
i2c_row = 0;
Expand Down Expand Up @@ -637,23 +644,23 @@ static unsigned int oled_start_i2c(uint8_t *buf)

static int oled_to_lcd_row(int in_row)
{
uint16_t oled_text;
uint16_t order;
int i = 0, row;
bool_t large = FALSE;

oled_text = (ff_cfg.oled_text != OTXT_default) ? ff_cfg.oled_text
order = (ff_cfg.display_order != DORD_default) ? ff_cfg.display_order
: (oled_height == 32) ? 0x7710 : menu_mode ? 0x7903 : 0x7183;

for (;;) {
large = !!(oled_text & OTXT_double);
large = !!(order & DORD_double);
i += large ? 2 : 1;
if (i > in_row)
break;
oled_text >>= OTXT_shift;
order >>= DORD_shift;
}

/* Remap the row */
row = oled_text & OTXT_row;
row = order & DORD_row;
if (row < lcd_rows) {
oled_convert_text_row(text[row]);
} else {
Expand Down
14 changes: 7 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,24 +1050,24 @@ static void read_ff_cfg(void)
ff_cfg.oled_contrast = strtol(opts.arg, NULL, 10);
break;

case FFCFG_oled_text: {
case FFCFG_display_order: {
char *p = opts.arg;
int sh = 0;
ff_cfg.oled_text = OTXT_default;
ff_cfg.display_order = DORD_default;
if (!strcmp(p, "default"))
break;
ff_cfg.oled_text = 0;
ff_cfg.display_order = 0;
while (p != NULL) {
ff_cfg.oled_text |= ((p[0]-'0')&7) << sh;
ff_cfg.display_order |= ((p[0]-'0')&7) << sh;
if (p[1] == 'd')
ff_cfg.oled_text |= OTXT_double << sh;
sh += OTXT_shift;
ff_cfg.display_order |= DORD_double << sh;
sh += DORD_shift;
if ((p = strchr(p, ',')) == NULL)
break;
p++;
}
if (sh < 16)
ff_cfg.oled_text |= 0x7777 << sh;
ff_cfg.display_order |= 0x7777 << sh;
break;
}

Expand Down

0 comments on commit 71a0b70

Please sign in to comment.