Fix for both issue #5 and a bug in keyboard driver leading to undetected keypresses in some cases

replace/a968504941a4ce6be3a5309873e5de9a951464ea
Silvano Seva 2020-11-15 20:38:28 +01:00
rodzic 3feaa992b8
commit 72988cd5cf
4 zmienionych plików z 25 dodań i 0 usunięć

Wyświetl plik

@ -66,10 +66,17 @@ uint32_t kbd_getKeys()
/* /*
* Scan keyboard by coloumns. * Scan keyboard by coloumns.
* For key configuration, see: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard * For key configuration, see: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard
*
* Keys coloumns (LCD_D...) have 1k series resistor and a 10pF capacitor
* connected to ground, making a low-pass filter with a settling time of
* ~50ns. CPU runs at 168MHz and 50ns are approximately eigth instructions,
* this means that we have to put a small delay before reading the GPIOs to
* allow voltage to settle.
*/ */
uint32_t keys = 0; uint32_t keys = 0;
gpio_setPin(KB_ROW1); gpio_setPin(KB_ROW1);
delayUs(1);
if(gpio_readPin(LCD_D7)) keys |= KEY_STAR; if(gpio_readPin(LCD_D7)) keys |= KEY_STAR;
if(gpio_readPin(LCD_D2)) keys |= KEY_3; if(gpio_readPin(LCD_D2)) keys |= KEY_3;
if(gpio_readPin(LCD_D1)) keys |= KEY_2; if(gpio_readPin(LCD_D1)) keys |= KEY_2;
@ -82,6 +89,7 @@ uint32_t kbd_getKeys()
gpio_clearPin(KB_ROW1); gpio_clearPin(KB_ROW1);
gpio_setPin(KB_ROW2); gpio_setPin(KB_ROW2);
delayUs(1);
if(gpio_readPin(LCD_D7)) keys |= KEY_ESC; if(gpio_readPin(LCD_D7)) keys |= KEY_ESC;
if(gpio_readPin(LCD_D2)) keys |= KEY_DOWN; if(gpio_readPin(LCD_D2)) keys |= KEY_DOWN;
if(gpio_readPin(LCD_D1)) keys |= KEY_UP; if(gpio_readPin(LCD_D1)) keys |= KEY_UP;
@ -94,6 +102,7 @@ uint32_t kbd_getKeys()
gpio_clearPin(KB_ROW2); gpio_clearPin(KB_ROW2);
gpio_setPin(KB_ROW3); gpio_setPin(KB_ROW3);
delayUs(1);
if(gpio_readPin(LCD_D6)) keys |= KEY_F1; if(gpio_readPin(LCD_D6)) keys |= KEY_F1;
if(gpio_readPin(LCD_D7)) keys |= KEY_MONI; if(gpio_readPin(LCD_D7)) keys |= KEY_MONI;

Wyświetl plik

@ -69,10 +69,15 @@
/* /*
* Keyboard. Here we define only rows, since coloumn lines are the same as * Keyboard. Here we define only rows, since coloumn lines are the same as
* LCD_Dx. See also: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard * LCD_Dx. See also: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard
*
* "Monitor" and "Function" buttons, on the other hand, are connected to
* keyboard row 3 and on LCD_D7 and LCD_D6. See also the schematic.
*/ */
#define KB_ROW1 GPIOA,6 /* K1 */ #define KB_ROW1 GPIOA,6 /* K1 */
#define KB_ROW2 GPIOD,2 /* K2 */ #define KB_ROW2 GPIOD,2 /* K2 */
#define KB_ROW3 GPIOD,3 /* K3 */ #define KB_ROW3 GPIOD,3 /* K3 */
#define MONI_SW LCD_D7
#define FUNC_SW LCD_D6
/* Tone generator */ /* Tone generator */
#define CTCSS_OUT GPIOC,7 /* System "beep" */ #define CTCSS_OUT GPIOC,7 /* System "beep" */

Wyświetl plik

@ -66,10 +66,15 @@
/* /*
* Keyboard. Here we define only rows, since coloumn lines are the same as * Keyboard. Here we define only rows, since coloumn lines are the same as
* LCD_Dx. See also: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard * LCD_Dx. See also: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard
*
* "Monitor" and "Function" buttons, on the other hand, are connected to
* keyboard row 3 and on LCD_D7 and LCD_D6. See also the schematic.
*/ */
#define KB_ROW1 GPIOA,6 /* K1 */ #define KB_ROW1 GPIOA,6 /* K1 */
#define KB_ROW2 GPIOD,2 /* K2 */ #define KB_ROW2 GPIOD,2 /* K2 */
#define KB_ROW3 GPIOD,3 /* K3 */ #define KB_ROW3 GPIOD,3 /* K3 */
#define MONI_SW LCD_D7
#define FUNC_SW LCD_D6
/* Tone generator */ /* Tone generator */
#define CTCSS_OUT GPIOC,7 /* System "beep" */ #define CTCSS_OUT GPIOC,7 /* System "beep" */

Wyświetl plik

@ -61,10 +61,16 @@
/* /*
* Keyboard. Here we define only rows, since coloumn lines are the same as * Keyboard. Here we define only rows, since coloumn lines are the same as
* LCD_Dx. See also: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard * LCD_Dx. See also: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard
*
* "Monitor" and "Function" buttons, on the other hand, are connected to
* keyboard row 3 and on LCD_D6 and LCD_D7. They are SWAPPED with respect to
* connections made on MD-380.
*/ */
#define KB_ROW1 GPIOA,6 /* K1 */ #define KB_ROW1 GPIOA,6 /* K1 */
#define KB_ROW2 GPIOD,2 /* K2 */ #define KB_ROW2 GPIOD,2 /* K2 */
#define KB_ROW3 GPIOD,3 /* K3 */ #define KB_ROW3 GPIOD,3 /* K3 */
#define MONI_SW LCD_D6
#define FUNC_SW LCD_D7
/* /*
* To enable pwm for display backlight dimming uncomment this directive. * To enable pwm for display backlight dimming uncomment this directive.