Add DIP switch select for strobe polarity and autorepeat

- arch-* files: replace private arch_strobe_init() function with public
arch_set_neg_strobe() and arch_set_pos_strobe() functions

- asdf.c,h: add ACTION hooks to set strobe polarity and enable/disable
autorepeat

- break out DIP switch definitions into a separate header file, included by each
keymap.  This ensures consistent DIP switch behavior across keymaps.
This commit is contained in:
Dave 2020-05-15 14:42:06 -05:00
parent 8828d90d96
commit 7801a17f56
10 changed files with 194 additions and 103 deletions

View File

@ -49,10 +49,6 @@ static volatile uint8_t tick = 0;
// data polarity may be changed with a DIP switch, so we use a static instead of a constant
static uint8_t data_polarity = ASDF_DEFAULT_DATA_POLARITY;
// strobe polarity may be changed with a DIP switch, so we use a static instead of a constant
static uint8_t strobe_polarity = ASDF_DEFAULT_STROBE_POLARITY;
// PROCEDURE: ISR for Timer 0 overflow
// INPUTS: none
// OUTPUTS:none
@ -554,7 +550,26 @@ void asdf_arch_out3_open_lo_set(uint8_t value)
}
}
// PROCEDURE: asdf_arch_init_strobe
// PROCEDURE: asdf_arch_pos_strobe
// INPUTS: none
// OUTPUTS: none
//
// DESCRIPTION: Initialize strobe output to positive polarity. Initial state is
// LOW
//
// SIDE EFFECTS: See DESCRIPTION
//
// SCOPE: public
//
// COMPLEXITY: 1
//
void asdf_arch_set_pos_strobe(void)
{
clear_bit(&ASDF_STROBE_PORT, ASDF_STROBE_BIT);
set_bit(&ASDF_STROBE_DDR, ASDF_STROBE_BIT);
}
// PROCEDURE: asdf_arch_neg_strobe
// INPUTS: none
// OUTPUTS: none
//
@ -566,14 +581,9 @@ void asdf_arch_out3_open_lo_set(uint8_t value)
//
// COMPLEXITY: 1
//
static void asdf_arch_init_strobe(void)
void asdf_arch_set_neg_strobe(void)
{
if (strobe_polarity == ASDF_POSITIVE_POLARITY) {
clear_bit(&ASDF_STROBE_PORT, ASDF_STROBE_BIT);
}
else {
set_bit(&ASDF_STROBE_PORT, ASDF_STROBE_BIT);
}
set_bit(&ASDF_STROBE_DDR, ASDF_STROBE_BIT);
}
@ -636,7 +646,8 @@ static void asdf_arch_init_row_outputs(void)
// INPUTS: none
// OUTPUTS: none
//
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses specified by ASDF_PULSE_DELAY_SHORT_US
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses specified by
// ASDF_PULSE_DELAY_SHORT_US
//
// SIDE EFFECTS: see above.
//
@ -655,7 +666,8 @@ void asdf_arch_pulse_delay_short(void)
// INPUTS: none
// OUTPUTS: none
//
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses specified by ASDF_PULSE_DELAY_LONG_MS
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses specified by
// ASDF_PULSE_DELAY_LONG_MS
//
// SIDE EFFECTS: see above.
//
@ -697,11 +709,15 @@ void asdf_arch_init(void)
// set up ASCII output port
asdf_arch_init_ascii_output();
// initialize keyboard data and strobe to positive polairy
// initialize keyboard data polarity and strobe polarity
data_polarity = ASDF_DEFAULT_DATA_POLARITY;
strobe_polarity = ASDF_DEFAULT_STROBE_POLARITY;
asdf_arch_init_strobe();
if (ASDF_DEFAULT_STROBE_POLARITY == ASDF_POSITIVE_POLARITY) {
asdf_arch_set_pos_strobe();
} else {
asdf_arch_set_neg_strobe();
}
asdf_arch_init_leds();
// set up row and column ports
@ -774,7 +790,8 @@ asdf_cols_t asdf_arch_osi_read_row(uint8_t row)
if (row > 7) {
cols = asdf_arch_read_row(row);
} else {
}
else {
// enable the OSI keyboard
clear_bit(&ASDF_OSI_KBE_PORT, ASDF_OSI_KBE_BIT);

View File

@ -357,6 +357,21 @@
// DIP switch is on row 8
#define ASDF_ARCH_DIPSWITCH_ROW 8
// PROCEDURE: asdf_arch_pos_strobe
// INPUTS: none
// OUTPUTS: none
// DESCRIPTION: Initialize strobe output to positive polarity. Initial state is
// LOW
void asdf_arch_set_pos_strobe(void);
// PROCEDURE: asdf_arch_neg_strobe
// INPUTS: none
// OUTPUTS: none
// DESCRIPTION: Initialize strobe output
void asdf_arch_set_neg_strobe(void);
// PROCEDURE: asdf_arch_null_output
// INPUTS: (uint8_t) value - ignored
// OUTPUTS: none

View File

@ -45,7 +45,6 @@
static volatile uint8_t tick = 0;
static uint8_t data_polarity = ASDF_DEFAULT_DATA_POLARITY;
static uint8_t strobe_polarity = ASDF_DEFAULT_STROBE_POLARITY;
// PROCEDURE: ISR for Timer 0 overflow
@ -536,7 +535,26 @@ void asdf_arch_out3_open_lo_set(uint8_t value)
}
}
// PROCEDURE: asdf_arch_init_strobe
// PROCEDURE: asdf_arch_pos_strobe
// INPUTS: none
// OUTPUTS: none
//
// DESCRIPTION: Initialize strobe output to positive polarity. Initial state is
// LOW
//
// SIDE EFFECTS: See DESCRIPTION
//
// SCOPE: public
//
// COMPLEXITY: 1
//
void asdf_arch_set_pos_strobe(void)
{
clear_bit(&ASDF_STROBE_PORT, ASDF_STROBE_BIT);
set_bit(&ASDF_STROBE_DDR, ASDF_STROBE_BIT);
}
// PROCEDURE: asdf_arch_neg_strobe
// INPUTS: none
// OUTPUTS: none
//
@ -548,14 +566,9 @@ void asdf_arch_out3_open_lo_set(uint8_t value)
//
// COMPLEXITY: 1
//
static void asdf_arch_init_strobe(void)
void asdf_arch_set_neg_strobe(void)
{
if (strobe_polarity == ASDF_POSITIVE_POLARITY) {
clear_bit(&ASDF_STROBE_PORT, ASDF_STROBE_BIT);
}
else {
set_bit(&ASDF_STROBE_PORT, ASDF_STROBE_BIT);
}
set_bit(&ASDF_STROBE_DDR, ASDF_STROBE_BIT);
}
@ -691,11 +704,17 @@ void asdf_arch_init(void)
// set up ASCII output port
asdf_arch_init_ascii_output();
// initialize keyboard data and strobe to positive polairy
// initialize keyboard data polarity and strobe polarity
data_polarity = ASDF_DEFAULT_DATA_POLARITY;
strobe_polarity = ASDF_DEFAULT_STROBE_POLARITY;
asdf_arch_init_strobe();
if (ASDF_DEFAULT_STROBE_POLARITY == ASDF_POSITIVE_POLARITY) {
asdf_arch_set_pos_strobe();
} else {
asdf_arch_set_neg_strobe();
}
asdf_arch_init_leds();
asdf_arch_init_leds();
// set up row output port

View File

@ -262,6 +262,19 @@
// DIP switch is on row 8
#define ASDF_ARCH_DIPSWITCH_ROW 8
// PROCEDURE: asdf_arch_pos_strobe
// INPUTS: none
// OUTPUTS: none
// DESCRIPTION: Initialize strobe output to positive polarity. Initial state is
// LOW
void asdf_arch_set_pos_strobe(void);
// PROCEDURE: asdf_arch_neg_strobe
// INPUTS: none
// OUTPUTS: none
// DESCRIPTION: Initialize strobe output
void asdf_arch_set_neg_strobe(void);
// PROCEDURE: asdf_arch_null_output
// INPUTS: (uint8_t) value - ignored
// OUTPUTS: none

View File

@ -39,6 +39,9 @@
#if !defined(ASDF_KEYMAP_DEFS_APPLE2_H)
#define ASDF_KEYMAP_DEFS_APPLE2_H
// include DIP switch definitions
#include "asdf_keymap_defs_dipswitch.h"
// Edit the number of rows and columns used in this map. If the number is less
// than the maxium, the unused elements will be initialized to 0.
@ -151,8 +154,7 @@
// definitions in positions 0-3 ensures consistent map selection among all
// keymaps.
#define ASDF_APPLE2_DIP_SWITCHES \
[ASDF_ARCH_DIPSWITCH_ROW] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
#define ASDF_APPLE2_DIP_SWITCHES ASDF_KEYMAP_DIP_SWITCHES
#define APPLE_LEFT_ARROW ASCII_CTRL_H
#define APPLE_RIGHT_ARROW ASCII_CTRL_U

View File

@ -31,6 +31,9 @@
#if !defined(ASDF_KEYMAP_DEFS_ASCII_H)
#define ASDF_KEYMAP_DEFS_ASCII_H
// include DIP switch definitions
#include "asdf_keymap_defs_dipswitch.h"
// Edit the number of rows and columns used in this map. If the number is less
// than the maxium, the unused elements will be initialized to 0.
@ -57,7 +60,6 @@
#define ASCII_CAPS_LED_INIT_VALUE 0
#define ASDF_ASCII_KEYMAP_INITIALIZER_LENGTH 4
#define ASDF_ASCII_PLAIN_KEYMAP_INITIALIZER \
@ -100,14 +102,20 @@
}
#define ASDF_ASCII_KEYMAP_INITIALIZER ASDF_ASCII_PLAIN_KEYMAP_INITIALIZER, ASDF_ASCII_CAPS_KEYMAP_INITIALIZER
#define ASDF_ASCII_KEYMAP_INITIALIZER \
ASDF_ASCII_PLAIN_KEYMAP_INITIALIZER, ASDF_ASCII_CAPS_KEYMAP_INITIALIZER
// Structure to initialize hooks. No hook functions are needed for ASCII keyboard.
#define ASDF_ASCII_KEYMAP_HOOK_INITIALIZER_LENGTH 0
#define ASDF_ASCII_PLAIN_KEYMAP_HOOK_INITIALIZER {}
#define ASDF_ASCII_CAPS_KEYMAP_HOOK_INITIALIZER {}
#define ASDF_ASCII_KEYMAP_HOOK_INITIALIZER ASDF_ASCII_PLAIN_KEYMAP_HOOK_INITIALIZER, ASDF_ASCII_CAPS_KEYMAP_HOOK_INITIALIZER
#define ASDF_ASCII_PLAIN_KEYMAP_HOOK_INITIALIZER \
{ \
}
#define ASDF_ASCII_CAPS_KEYMAP_HOOK_INITIALIZER \
{ \
}
#define ASDF_ASCII_KEYMAP_HOOK_INITIALIZER \
ASDF_ASCII_PLAIN_KEYMAP_HOOK_INITIALIZER, ASDF_ASCII_CAPS_KEYMAP_HOOK_INITIALIZER
// Key Matrix for combination of ASCII controller and Classic ASCII matrix
//
@ -140,9 +148,7 @@
// definitions in positions 0-3 ensures consistent map selection among all
// keymaps.
#define ASDF_ASCII_DIP_SWITCHES \
[ASDF_ARCH_DIPSWITCH_ROW] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
#define ASDF_ASCII_DIP_SWITCHES ASDF_KEYMAP_DIP_SWITCHES
// clang-format off
#define ASDF_ASCII_PLAIN_MAP \
@ -230,18 +236,14 @@
#define ASDF_ASCII_PLAIN_MAP_DEFS \
{ \
[MOD_PLAIN_MAP] = &ascii_plain_matrix, \
[MOD_SHIFT_MAP] = &ascii_shift_matrix, \
[MOD_CAPS_MAP] = &ascii_caps_matrix, \
[MOD_CTRL_MAP] = &ascii_ctrl_matrix \
[MOD_PLAIN_MAP] = &ascii_plain_matrix, [MOD_SHIFT_MAP] = &ascii_shift_matrix, \
[MOD_CAPS_MAP] = &ascii_caps_matrix, [MOD_CTRL_MAP] = &ascii_ctrl_matrix \
}
#define ASDF_ASCII_CAPS_MAP_DEFS \
{ \
[MOD_PLAIN_MAP] = &ascii_caps_matrix, \
[MOD_SHIFT_MAP] = &ascii_shift_matrix, \
[MOD_CAPS_MAP] = &ascii_caps_matrix, \
[MOD_CTRL_MAP] = &ascii_ctrl_matrix \
[MOD_PLAIN_MAP] = &ascii_caps_matrix, [MOD_SHIFT_MAP] = &ascii_shift_matrix, \
[MOD_CAPS_MAP] = &ascii_caps_matrix, [MOD_CTRL_MAP] = &ascii_ctrl_matrix \
}
#define ASDF_ASCII_ALL_MAPS ASDF_ASCII_PLAIN_MAP_DEFS, ASDF_ASCII_CAPS_MAP_DEFS
@ -258,12 +260,14 @@
#define ASDF_NUM_COLS ASDF_ASCII_NUM_COLS
#endif
#if !defined(ASDF_KEYMAP_INITIALIZER_LENGTH) || (ASDF_KEYMAP_INITIALIZER_LENGTH < ASDF_ASCII_KEYMAP_INITIALIZER_LENGTH)
#if !defined(ASDF_KEYMAP_INITIALIZER_LENGTH) \
|| (ASDF_KEYMAP_INITIALIZER_LENGTH < ASDF_ASCII_KEYMAP_INITIALIZER_LENGTH)
#undef ASDF_KEYMAP_INITIALIZER_LENGTH
#define ASDF_KEYMAP_INITIALIZER_LENGTH ASDF_ASCII_KEYMAP_INITIALIZER_LENGTH
#endif
#if !defined(ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH) || (ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH < ASDF_ASCII_KEYMAP_HOOK_INITIALIZER_LENGTH)
#if !defined(ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH) \
|| (ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH < ASDF_ASCII_KEYMAP_HOOK_INITIALIZER_LENGTH)
#undef ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH
#define ASDF_KEYMAP_HOOK_INITIALIZER_LENGTH ASDF_ASCII_KEYMAP_HOOK_INITIALIZER_LENGTH
#endif
@ -272,4 +276,3 @@
//-------|---------|---------+---------+---------+---------+---------+---------+
// Above line is 80 columns, and should display completely in the editor.

View File

@ -31,6 +31,9 @@
#if !defined(ASDF_KEYMAP_DEFS_SOL20_H)
#define ASDF_KEYMAP_DEFS_SOL20_H
// include DIP switch definitions
#include "asdf_keymap_defs_dipswitch.h"
// Edit the number of rows and columns used in this map. If the number is less
// than the maxium, the unused elements will be initialized to 0.
@ -139,19 +142,21 @@
.initial_value = SOL_KBD_TTL_HIGH }, \
}
// function hooks for the SOL keyboard. At Setup, activate CAPSLOCK to emulate
// original keyboard.
#define ASDF_SOL_KEYMAP_HOOK_INITIALIZER_LENGTH 1
// function hooks for the SOL keyboard:
// - At Setup, activate CAPSLOCK to emulate original keyboard.
// - At Setup, configure negative strobe
#define ASDF_SOL_KEYMAP_HOOK_INITIALIZER_LENGTH 2
#define ASDF_SOL_KEYMAP_HOOK_INITIALIZER \
{ \
{ \
.hook_id = ASDF_HOOK_KEYMAP_SETUP, \
{ .hook_id = ASDF_HOOK_KEYMAP_SETUP, \
.hook_func = asdf_modifier_capslock_activate, \
}, \
{ .hook_id = ASDF_HOOK_KEYMAP_SETUP, \
.hook_func = asdf_arch_set_neg_strobe, \
}, \
}
#define ASDF_SOL_DIP_SWITCHES \
[ASDF_ARCH_DIPSWITCH_ROW] = { ACTION_MAPSEL_0, ACTION_MAPSEL_1, ACTION_MAPSEL_2, ACTION_MAPSEL_3 }
#define ASDF_SOL_DIP_SWITCHES ASDF_KEYMAP_DIP_SWITCHES
// clang-format off
#define ASDF_SOL_PLAIN_MAP \

View File

@ -191,6 +191,14 @@ static void asdf_activate_action(action_t keycode)
asdf_keymaps_map_select_3_set();
break;
}
case ACTION_STROBE_POLARITY_SELECT: {
asdf_arch_set_pos_strobe();
break;
}
case ACTION_AUTOREPEAT_SELECT: {
asdf_repeat_auto_on();
break;
}
case ACTION_VLED1: {
asdf_virtual_activate(VLED1);
break;
@ -292,6 +300,14 @@ static void asdf_deactivate_action(action_t keycode)
asdf_keymaps_map_select_3_clear();
break;
}
case ACTION_STROBE_POLARITY_SELECT: {
asdf_arch_set_neg_strobe();
break;
}
case ACTION_AUTOREPEAT_SELECT: {
asdf_repeat_auto_off();
break;
}
case ACTION_NOTHING:
default: break;
}
@ -498,8 +514,7 @@ void asdf_keyscan(void)
{
asdf_hook_get(ASDF_HOOK_EACH_SCAN)();
for (uint8_t row = 0; row < ASDF_NUM_ROWS; row++) {
asdf_cols_t (*row_reader)(uint8_t) =
(asdf_cols_t (*) (uint8_t)) asdf_hook_get(ASDF_HOOK_SCANNER);
asdf_cols_t (*row_reader)(uint8_t) = (asdf_cols_t(*)(uint8_t)) asdf_hook_get(ASDF_HOOK_SCANNER);
asdf_cols_t row_key_state = (*row_reader)(row);
asdf_cols_t changed = row_key_state ^ last_stable_key_state[row];

View File

@ -57,6 +57,8 @@ typedef enum {
ACTION_MAPSEL_1,
ACTION_MAPSEL_2,
ACTION_MAPSEL_3,
ACTION_AUTOREPEAT_SELECT,
ACTION_STROBE_POLARITY_SELECT,
ACTION_VLED1,
ACTION_VLED2,
ACTION_VLED3,