Skip to content

Commit

Permalink
Allow multi-row hotkey text. Include example for Piotr AmiGotek.
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed Oct 10, 2019
1 parent f90e399 commit 8acfc7b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern struct __packed config {
/* Mask of user pins driven HIGH by this hotkey.
* Pins in @pin_mod but not in @pin_high are driven LOW. */
uint8_t pin_high;
char str[22];
char str[30];
} hotkey[10];

uint16_t crc16_ccitt;
Expand Down
15 changes: 15 additions & 0 deletions src/default_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ const static struct config dfl_config = {
}
#endif

#if 0
/* An example configuration for DF0/DF1 switching, for Piotr.
* Also an example of multi-row hotkey description text. */
.user_pin_opendrain = 0,
.user_pin_pushpull = U(0),
.user_pin_high = U(0), /* Default = DF0: AmiGotek */
.hotkey = {
[F(9)] = { .str = "DF0: AmiGotek\0DF1: Floppy",
.pin_mod = U(0),
.pin_high = U(0), },
[F(10)] = { .str = "DF0: Floppy\0DF1: AmiGotek",
.pin_mod = U(0), },
}
#endif

#undef F
#undef U

Expand Down
15 changes: 11 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ static void update_amiga_keys(void)
static uint16_t hk_latch;
bool_t hk_pressed;
uint32_t s, r;
char *p;
/* Unused hotkey? */
if (hk->pin_mod == 0)
continue;
Expand All @@ -484,10 +485,16 @@ static void update_amiga_keys(void)
s = (uint16_t)hk->pin_high << pin_u0;
r = (uint16_t)(hk->pin_mod & ~hk->pin_high) << pin_u0;
gpio_user->bsrr = ((uint32_t)r << 16) | s;
if (hk->str[0]) {
strcpy((char *)notify.text[0], hk->str);
notify.cols = strlen(hk->str);
notify.rows = 1;
if (*(p = hk->str)) {
notify.cols = notify.rows = 0;
memset(notify.text, 0, sizeof(notify.text));
while (*p) {
int len = strlen(p);
strcpy((char *)notify.text[notify.rows], p);
notify.cols = max(notify.cols, len);
notify.rows++;
p += len + 1;
}
notify.on = TRUE;
notify_time = time_now();
}
Expand Down

0 comments on commit 8acfc7b

Please sign in to comment.