Replaced the Virtual out pulse function with long and short pulse

- Replace V_PULSE with V_PULSE_LONG and V_PULSE_SHORT functions.

- replace the asdf_arch_pulse_delay() with asdf_arch_pulse_delay_short() and
asdf_arch_pulse_delay_long() functions.

- modify keymaps to use long and short pulses.

- long pulse is 50 ms.  Short pulse is 10 us.

- Added localizing prefix to keymap definitions to avoid conflicts.
This commit is contained in:
David Fenyes 2020-03-17 01:42:51 -05:00
parent 58126667d9
commit dae4b8d322
7 changed files with 137 additions and 104 deletions

View File

@ -626,11 +626,11 @@ static void asdf_arch_init_row_outputs(void)
ASDF_ROW_DDR |= ASDF_ROW_MASK;
}
// PROCEDURE: asdf_arch_pulse_delay
// PROCEDURE: asdf_arch_pulse_delay_short
// INPUTS: none
// OUTPUTS: none
//
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses.
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses specified by ASDF_PULSE_DELAY_SHORT_US
//
// SIDE EFFECTS: see above.
//
@ -640,9 +640,28 @@ static void asdf_arch_init_row_outputs(void)
//
// COMPLEXITY: 1
//
void asdf_arch_pulse_delay(void)
void asdf_arch_pulse_delay_short(void)
{
_delay_us(ASDF_PULSE_DELAY_US);
_delay_us(ASDF_PULSE_DELAY_SHORT_US);
}
// PROCEDURE: asdf_arch_pulse_delay_long
// INPUTS: none
// OUTPUTS: none
//
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses specified by ASDF_PULSE_DELAY_LONG_MS
//
// SIDE EFFECTS: see above.
//
// NOTES: Set ASDF_PULSE_DELAY_US in asdf_config.h
//
// SCOPE: public
//
// COMPLEXITY: 1
//
void asdf_arch_pulse_delay_long(void)
{
_delay_us(ASDF_PULSE_DELAY_LONG_MS);
}
// PROCEDURE: asdf_arch_init

View File

@ -336,12 +336,19 @@ void asdf_arch_out3_open_lo_set(uint8_t value);
// pressed within the row, with 1=pressed, 0=released.
asdf_cols_t asdf_arch_read_row(uint8_t row);
// PROCEDURE: asdf_arch_pulse_delay
// PROCEDURE: asdf_arch_pulse_delay_short
// INPUTS: none
// OUTPUTS: none
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses.
// NOTES: Set ASDF_PULSE_DELAY_US in asdf_config.h
void asdf_arch_pulse_delay(void);
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses specified by ASDF_PULSE_DELAY_SHORT_US
void asdf_arch_pulse_delay_short(void);
// PROCEDURE: asdf_arch_pulse_delay_long
// INPUTS: none
// OUTPUTS: none
// DESCRIPTION: Delays a fixed amount of time for keyboard output pulses specified by ASDF_PULSE_DELAY_LONG_MS
void asdf_arch_pulse_delay_long(void);
// PROCEDURE: asdf_arch_tick
// INPUTS: none

View File

@ -45,25 +45,23 @@
#define ASDF_APPLE2_NUM_ROWS 16 // DIP switches are row 15.
#define ASDF_APPLE2_NUM_COLS 8
#define ACTION_BREAK ACTION_NOTHING
#define APPLE_ACTION_RESET ACTION_VOUT1
#define APPLE_VIRTUAL_RESET VOUT1
#define APPLE_RESET_OUTPUT PHYSICAL_OUT3_OPEN_HI
#define APPLE_RESET_ACTIVE_VALUE 0
#define ACTION_RESET ACTION_VOUT1
#define VIRTUAL_RESET VOUT1
#define RESET_OUTPUT PHYSICAL_OUT3_OPEN_HI
#define RESET_ACTIVE_VALUE 0
#define APPLE_ACTION_CLEAR ACTION_VOUT2
#define APPLE_VIRTUAL_CLR_SCR VOUT2
#define APPLE_CLR_SCR_OUTPUT PHYSICAL_OUT1_OPEN_LO
#define APPLE_CLR_SCR_ACTIVE_VALUE 1
#define ACTION_CLEAR ACTION_VOUT2
#define VIRTUAL_CLR_SCR VOUT2
#define CLR_SCR_OUTPUT PHYSICAL_OUT1_OPEN_LO
#define CLR_SCR_ACTIVE_VALUE 1
#define APPLE_VIRTUAL_POWER_LED VLED1
#define APPLE_POWER_LED PHYSICAL_LED1
#define APPLE_POWER_LED_INIT_VALUE 1
#define VIRTUAL_POWER_LED VLED1
#define POWER_LED PHYSICAL_LED1
#define POWER_LED_INIT_VALUE 1
#define VIRTUAL_DISABLED_LED VLED2
#define DISABLED_LED PHYSICAL_LED3
#define DISABLED_INIT_VALUE 0
#define APPLE_VIRTUAL_DISABLED_LED VLED2
#define APPLE_DISABLED_LED PHYSICAL_LED3
#define APPLE_DISABLED_INIT_VALUE 0
#define ASDF_APPLE2_KEYMAP_INITIALIZER_LENGTH 4
@ -73,39 +71,39 @@
#define ASDF_APPLE2_PLAIN_KEYMAP_INITIALIZER \
{ \
{ .virtual_device = VCAPS_LED, \
.physical_device = POWER_LED, \
.physical_device = APPLE_POWER_LED, \
.initial_value = 0 }, \
{ .virtual_device = VIRTUAL_DISABLED_LED, \
.physical_device = DISABLED_LED, \
{ .virtual_device = APPLE_VIRTUAL_DISABLED_LED, \
.physical_device = APPLE_DISABLED_LED, \
.initial_value = 0 }, \
{ .virtual_device = VIRTUAL_RESET, \
.physical_device = RESET_OUTPUT, \
.function = V_PULSE, \
.initial_value = !RESET_ACTIVE_VALUE }, \
{ .virtual_device = VIRTUAL_CLR_SCR, \
.physical_device = CLR_SCR_OUTPUT, \
.function = V_PULSE, \
.initial_value = !CLR_SCR_ACTIVE_VALUE } \
{ .virtual_device = APPLE_VIRTUAL_RESET, \
.physical_device = APPLE_RESET_OUTPUT, \
.function = V_PULSE_SHORT, \
.initial_value = !APPLE_RESET_ACTIVE_VALUE }, \
{ .virtual_device = APPLE_VIRTUAL_CLR_SCR, \
.physical_device = APPLE_CLR_SCR_OUTPUT, \
.function = V_PULSE_LONG, \
.initial_value = !APPLE_CLR_SCR_ACTIVE_VALUE } \
}
// The ALL CAPS map is the classic Apple II/II+ map. There is no CAPS LED, since
// CAPS doesn't matter in the ALL CAPS keymap.
#define ASDF_APPLE2_CAPS_KEYMAP_INITIALIZER \
{ \
{ .virtual_device = VIRTUAL_POWER_LED, \
.physical_device = POWER_LED, \
.initial_value = POWER_LED_INIT_VALUE }, \
{ .virtual_device = VIRTUAL_DISABLED_LED, \
.physical_device = DISABLED_LED, \
{ .virtual_device = APPLE_VIRTUAL_POWER_LED, \
.physical_device = APPLE_POWER_LED, \
.initial_value = APPLE_POWER_LED_INIT_VALUE }, \
{ .virtual_device = APPLE_VIRTUAL_DISABLED_LED, \
.physical_device = APPLE_DISABLED_LED, \
.initial_value = 0 }, \
{ .virtual_device = VIRTUAL_RESET, \
.physical_device = RESET_OUTPUT, \
.function = V_PULSE, \
.initial_value = !RESET_ACTIVE_VALUE }, \
{ .virtual_device = VIRTUAL_CLR_SCR, \
.physical_device = CLR_SCR_OUTPUT, \
.function = V_PULSE, \
.initial_value = !CLR_SCR_ACTIVE_VALUE } \
{ .virtual_device = APPLE_VIRTUAL_RESET, \
.physical_device = APPLE_RESET_OUTPUT, \
.function = V_PULSE_SHORT, \
.initial_value = !APPLE_RESET_ACTIVE_VALUE }, \
{ .virtual_device = APPLE_VIRTUAL_CLR_SCR, \
.physical_device = APPLE_CLR_SCR_OUTPUT, \
.function = V_PULSE_LONG, \
.initial_value = !APPLE_CLR_SCR_ACTIVE_VALUE } \
}
@ -170,7 +168,7 @@
[3] = { ACTION_NOTHING, 'K', 'J', 'H', 'G', 'F', 'D', 'S' }, \
[4] = { ACTION_NOTHING, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' }, \
[5] = { ACTION_NOTHING, ACTION_NOTHING, ACTION_NOTHING, ASCII_CR, ASCII_AT, 'O', 'L', '>' }, \
[6] = { ACTION_NOTHING, ACTION_NOTHING, ACTION_CLEAR, '=', \
[6] = { ACTION_NOTHING, ACTION_NOTHING, APPLE_ACTION_CLEAR, '=', \
'*', ASCII_ZERO, ASCII_RT_PAREN, ASCII_LT_PAREN }, \
[7] = { APPLE_LEFT_ARROW, ASCII_SINGLE_QUOTE, '&', '%', '$', '#', ASCII_DOUBLE_QUOTE, '!' }, \
ASDF_APPLE2_DIP_SWITCHES \
@ -200,7 +198,7 @@
[3] = { ACTION_NOTHING, 'K', 'J', 'H', 'G', 'F', 'D', 'S' }, \
[4] = { ACTION_NOTHING, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' }, \
[5] = { ACTION_NOTHING, ACTION_NOTHING, ACTION_NOTHING, ASCII_CR, ACTION_REPEAT, 'O', 'L', '>' }, \
[6] = { ACTION_NOTHING, ACTION_NOTHING, ACTION_CLEAR, '=', \
[6] = { ACTION_NOTHING, ACTION_NOTHING, APPLE_ACTION_CLEAR, '=', \
'*', ASCII_ZERO, ASCII_RT_PAREN, ASCII_LT_PAREN }, \
[7] = { APPLE_LEFT_ARROW, ASCII_SINGLE_QUOTE, '&', '%', '$', '#', ASCII_DOUBLE_QUOTE, '!' }, \
ASDF_APPLE2_DIP_SWITCHES \
@ -220,7 +218,7 @@
ASCII_CTRL_T, ASCII_CTRL_R, ASCII_CTRL_E, ASCII_CTRL_W }, \
[5] = { ACTION_NOTHING, ACTION_NOTHING, ACTION_NOTHING, ASCII_CR, \
ACTION_REPEAT, ASCII_CTRL_O, ASCII_CTRL_L, ACTION_NOTHING }, \
[6] = { ACTION_NOTHING, ACTION_NOTHING, ACTION_RESET, ACTION_NOTHING, \
[6] = { ACTION_NOTHING, ACTION_NOTHING, APPLE_ACTION_RESET, ACTION_NOTHING, \
ACTION_NOTHING, ACTION_FN_10, ACTION_FN_9, ACTION_FN_8 }, \
[7] = { APPLE_LEFT_ARROW, ACTION_FN_7, ACTION_FN_6, ACTION_FN_5, \
ACTION_FN_4, ACTION_FN_3, ACTION_FN_2, ACTION_FN_1 }, \

View File

@ -37,22 +37,24 @@
#define ASDF_ASCII_NUM_ROWS 16 // DIP switches are row 15.
#define ASDF_ASCII_NUM_COLS 8
#define ACTION_BREAK ACTION_NOTHING
#define ASCII_ACTION_BREAK ACTION_NOTHING
#define VIRTUAL_RESET VOUT1
#define RESET_OUTPUT PHYSICAL_OUT3_OPEN_HI
#define RESET_ACTIVE_VALUE 0
#define ASCII_VIRTUAL_RESET VOUT1
#define ASCII_ACTION_RESET ACTION_VOUT1
#define ASCII_RESET_OUTPUT PHYSICAL_OUT3_OPEN_HI
#define ASCII_RESET_ACTIVE_VALUE 0
#define VIRTUAL_CLR_SCR VOUT2
#define CLR_SCR_OUT PHYSICAL_OUT1_OPEN_LO
#define CLR_SCR_ACTIVE_VALUE 1
#define ASCII_VIRTUAL_CLR_SCR VOUT2
#define ASCII_ACTION_CLEAR ACTION_VOUT2
#define ASCII_CLR_SCR_OUT PHYSICAL_OUT1_OPEN_LO
#define ASCII_CLR_SCR_ACTIVE_VALUE 1
#define VIRTUAL_POWER_LED VLED1
#define POWER_LED PHYSICAL_LED1
#define POWER_LED_INIT_VALUE 1
#define ASCII_VIRTUAL_POWER_LED VLED1
#define ASCII_POWER_LED PHYSICAL_LED1
#define ASCII_POWER_LED_INIT_VALUE 1
#define CAPS_LED PHYSICAL_LED3
#define CAPS_LED_INIT_VALUE 0
#define ASCII_CAPS_LED PHYSICAL_LED3
#define ASCII_CAPS_LED_INIT_VALUE 0
@ -60,20 +62,20 @@
#define ASDF_ASCII_PLAIN_KEYMAP_INITIALIZER \
{ \
{ .virtual_device = VIRTUAL_POWER_LED, \
.physical_device = POWER_LED, \
.initial_value = POWER_LED_INIT_VALUE }, \
{ .virtual_device = ASCII_VIRTUAL_POWER_LED, \
.physical_device = ASCII_POWER_LED, \
.initial_value = ASCII_POWER_LED_INIT_VALUE }, \
{ .virtual_device = VCAPS_LED, \
.physical_device = CAPS_LED, \
.initial_value = CAPS_LED_INIT_VALUE }, \
{ .virtual_device = VIRTUAL_RESET, \
.physical_device = RESET_OUTPUT, \
.function = V_PULSE, \
.initial_value = !RESET_ACTIVE_VALUE }, \
{ .virtual_device = VIRTUAL_CLR_SCR, \
.physical_device = CLR_SCR_OUT, \
.function = V_PULSE, \
.initial_value = !CLR_SCR_ACTIVE_VALUE }, \
.physical_device = ASCII_CAPS_LED, \
.initial_value = ASCII_CAPS_LED_INIT_VALUE }, \
{ .virtual_device = ASCII_VIRTUAL_RESET, \
.physical_device = ASCII_RESET_OUTPUT, \
.function = V_PULSE_SHORT, \
.initial_value = !ASCII_RESET_ACTIVE_VALUE }, \
{ .virtual_device = ASCII_VIRTUAL_CLR_SCR, \
.physical_device = ASCII_CLR_SCR_OUT, \
.function = V_PULSE_LONG, \
.initial_value = !ASCII_CLR_SCR_ACTIVE_VALUE }, \
}
// For the CAPS map, no LED is mapped to the CapsLock virtual LED, since
@ -81,20 +83,20 @@
// an unused LED output, initialized to OFF, to ensure the LED is dark.
#define ASDF_ASCII_CAPS_KEYMAP_INITIALIZER \
{ \
{ .virtual_device = VIRTUAL_POWER_LED, \
.physical_device = POWER_LED, \
.initial_value = POWER_LED_INIT_VALUE }, \
{ .virtual_device = ASCII_VIRTUAL_POWER_LED, \
.physical_device = ASCII_POWER_LED, \
.initial_value = ASCII_POWER_LED_INIT_VALUE }, \
{ .virtual_device = VLED1, \
.physical_device = CAPS_LED, \
.initial_value = CAPS_LED_INIT_VALUE }, \
{ .virtual_device = VIRTUAL_RESET, \
.physical_device = RESET_OUTPUT, \
.function = V_PULSE, \
.initial_value = !RESET_ACTIVE_VALUE }, \
{ .virtual_device = VIRTUAL_CLR_SCR, \
.physical_device = CLR_SCR_OUT, \
.function = V_PULSE, \
.initial_value = !CLR_SCR_ACTIVE_VALUE }, \
.physical_device = ASCII_CAPS_LED, \
.initial_value = ASCII_CAPS_LED_INIT_VALUE }, \
{ .virtual_device = ASCII_VIRTUAL_RESET, \
.physical_device = ASCII_RESET_OUTPUT, \
.function = V_PULSE_SHORT, \
.initial_value = !ASCII_RESET_ACTIVE_VALUE }, \
{ .virtual_device = ASCII_VIRTUAL_CLR_SCR, \
.physical_device = ASCII_CLR_SCR_OUT, \
.function = V_PULSE_LONG, \
.initial_value = !ASCII_CLR_SCR_ACTIVE_VALUE }, \
}
@ -140,9 +142,9 @@
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \
ASCII_ESC, ASCII_TAB, ACTION_CTRL, ASCII_BACKSLASH }, \
[1] = { ASCII_DEL, 'p', ';', '/', ASCII_SPACE, 'z', 'a', 'q' }, \
[2] = { ACTION_BREAK, ASCII_COMMA, 'm', 'n', 'b', 'v', 'c', 'x' }, \
[2] = { ASCII_ACTION_BREAK, ASCII_COMMA, 'm', 'n', 'b', 'v', 'c', 'x' }, \
[3] = { ACTION_NOTHING, 'k', 'j', 'h', 'g', 'f', 'd', 's' }, \
[4] = { ACTION_CLEAR, 'i', 'u', 'y', 't', 'r', 'e', 'w' }, \
[4] = { ACTION_NOTHING, 'i', 'u', 'y', 't', 'r', 'e', 'w' }, \
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'o', 'l', ASCII_PERIOD }, \
[6] = { ASCII_TILDE, ASCII_RT_SQUARE_BRACE, ASCII_LT_SQUARE_BRACE, '-', ':', ASCII_ZERO, '9', '8' }, \
[7] = { ASCII_AT, '7', '6', '5', '4', '3', '2', '1' }, \
@ -154,9 +156,9 @@
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \
ASCII_ESC, ASCII_TAB, ACTION_CTRL, ASCII_BACKSLASH }, \
[1] = { ASCII_DEL, 'P', ';', '/', ASCII_SPACE, 'Z', 'A', 'Q' }, \
[2] = { ACTION_BREAK, ASCII_COMMA, 'M', 'N', 'B', 'V', 'C', 'X' }, \
[2] = { ASCII_ACTION_BREAK, ASCII_COMMA, 'M', 'N', 'B', 'V', 'C', 'X' }, \
[3] = { ACTION_NOTHING, 'K', 'J', 'H', 'G', 'F', 'D', 'S' }, \
[4] = { ACTION_CLEAR, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' }, \
[4] = { ACTION_NOTHING, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' }, \
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'O', 'L', ASCII_PERIOD }, \
[6] = { ASCII_TILDE, ASCII_RT_SQUARE_BRACE, ASCII_LT_SQUARE_BRACE, '-', ':', ASCII_ZERO, '9', '8' }, \
[7] = { ASCII_AT, '7', '6', '5', '4', '3', '2', '1' }, \
@ -168,9 +170,9 @@
[0] = { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \
ASCII_ESC, ASCII_TAB, ACTION_CTRL, ASCII_VERT_BAR }, \
[1] = { ASCII_DEL, 'P', '+', '?', ASCII_SPACE, 'Z', 'A', 'Q' }, \
[2] = { ACTION_BREAK, '<', 'M', 'N', 'B', 'V', 'C', 'X' }, \
[2] = { ASCII_ACTION_CLEAR, '<', 'M', 'N', 'B', 'V', 'C', 'X' }, \
[3] = { ACTION_NOTHING, 'K', 'J', 'H', 'G', 'F', 'D', 'S' }, \
[4] = { ACTION_CLEAR, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' }, \
[4] = { ACTION_NOTHING, 'I', 'U', 'Y', 'T', 'R', 'E', 'W' }, \
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, ASCII_LF, 'O', 'L', '>' }, \
[6] = { ASCII_TILDE, ASCII_RT_CURLY_BRACE, ASCII_LT_CURLY_BRACE, '=', \
'*', ASCII_ZERO, ASCII_RT_PAREN, ASCII_LT_PAREN }, \
@ -184,11 +186,11 @@
ASCII_ESC, ASCII_TAB, ACTION_CTRL, 0x1c }, \
[1] = { ACTION_NOTHING, ASCII_CTRL_P, ACTION_NOTHING, ACTION_NOTHING, \
ASCII_SPACE, ASCII_CTRL_Z, ASCII_CTRL_A, ASCII_CTRL_Q }, \
[2] = { ACTION_RESET, ASCII_COMMA, ASCII_CTRL_M, ASCII_CTRL_N, \
[2] = { ASCII_ACTION_RESET, ASCII_COMMA, ASCII_CTRL_M, ASCII_CTRL_N, \
ASCII_CTRL_B, ASCII_CTRL_V, ASCII_CTRL_C, ASCII_CTRL_X }, \
[3] = { ACTION_NOTHING, ASCII_CTRL_K, ASCII_CTRL_J, ASCII_CTRL_H, \
ASCII_CTRL_G, ASCII_CTRL_F, ASCII_CTRL_D, ASCII_CTRL_S }, \
[4] = { ACTION_CLEAR, ASCII_CTRL_I, ASCII_CTRL_U, ASCII_CTRL_Y, \
[4] = { ACTION_NOTHING, ASCII_CTRL_I, ASCII_CTRL_U, ASCII_CTRL_Y, \
ASCII_CTRL_T, ASCII_CTRL_R, ASCII_CTRL_E, ASCII_CTRL_W }, \
[5] = { ACTION_NOTHING, ACTION_REPEAT, ACTION_CAPS, ASCII_CR, \
ASCII_LF, ASCII_CTRL_O, ASCII_CTRL_L, ACTION_NOTHING }, \

View File

@ -64,7 +64,10 @@
#define ASDF_REPEAT_TIME_MS (1000 / 15) // l5 characters per sec.
// duration of keyboard output pulses (RESET, SCREEN CLEAR, BREAK, etc.)
#define ASDF_PULSE_DELAY_US 100
#define ASDF_PULSE_DELAY_SHORT_US 10
// duration of keyboard output pulses (RESET, SCREEN CLEAR, BREAK, etc.)
#define ASDF_PULSE_DELAY_LONG_MS 50
// DEFAULT value of keyboard outputs
#define ASDF_VIRTUAL_OUT_DEFAULT_VALUE 1 // High if not used.

View File

@ -69,12 +69,15 @@ void asdf_virtual_action(asdf_virtual_dev_t virtual_out, asdf_virtual_function_t
while (PHYSICAL_NO_OUT != device) {
switch (function) {
case V_PULSE: {
case V_PULSE_LONG: {
asdf_physical_toggle(device);
asdf_arch_pulse_delay();
// yes we could omit the next two lines and fall through, but we will
// spend a few bytes of redundant code for the sake of consistency and
// readability.
asdf_arch_pulse_delay_long();
asdf_physical_toggle(device);
break;
}
case V_PULSE_SHORT: {
asdf_physical_toggle(device);
asdf_arch_pulse_delay_short();
asdf_physical_toggle(device);
break;
}

View File

@ -48,7 +48,8 @@ typedef enum {
V_NOFUNC,
V_SET_HI,
V_SET_LO,
V_PULSE,
V_PULSE_SHORT,
V_PULSE_LONG,
V_TOGGLE,
ASDF_VIRTUAL_NUM_FUNCTIONS
} asdf_virtual_function_t;