0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-18 22:29:50 +03:00

Fic typing in keys bug

This commit is contained in:
OneOfEleven
2023-10-05 17:38:25 +01:00
parent 40d09591b3
commit 5c346c8466
10 changed files with 54 additions and 37 deletions

View File

@ -58,10 +58,10 @@ enum GPIOC_PINS {
GPIOC_PIN_PTT = 5
};
void GPIO_ClearBit(volatile uint32_t *pReg, uint8_t Bit);
void GPIO_ClearBit(volatile uint32_t *pReg, uint8_t Bit);
uint8_t GPIO_CheckBit(volatile uint32_t *pReg, uint8_t Bit);
void GPIO_FlipBit(volatile uint32_t *pReg, uint8_t Bit);
void GPIO_SetBit(volatile uint32_t *pReg, uint8_t Bit);
void GPIO_FlipBit( volatile uint32_t *pReg, uint8_t Bit);
void GPIO_SetBit( volatile uint32_t *pReg, uint8_t Bit);
#endif

View File

@ -22,10 +22,10 @@
#include "driver/i2c.h"
#include "misc.h"
KEY_Code_t gKeyReading0 = KEY_INVALID;
KEY_Code_t gKeyReading1 = KEY_INVALID;
uint16_t gDebounceCounter;
bool gWasFKeyPressed;
KEY_Code_t gKeyReading0 = KEY_INVALID;
KEY_Code_t gKeyReading1 = KEY_INVALID;
uint16_t gDebounceCounter = 0;
bool gWasFKeyPressed = false;
static const struct {
@ -42,9 +42,8 @@ static const struct {
} keyboard[] = {
// Zero row
{
// Set to zero to handle special case of nothing pulled down.
{ // Zero row
// Set to zero to handle special case of nothing pulled down
.set_to_zero_mask = 0xffff,
.pins = {
{ .key = KEY_SIDE1, .pin = GPIOA_PIN_KEYBOARD_0},
@ -120,6 +119,7 @@ KEY_Code_t KEYBOARD_Poll(void)
// Read all 4 GPIO pins at once
reg = GPIOA->DATA;
for (unsigned int i = 0; i < ARRAY_SIZE(keyboard[j].pins); i++)
{
const uint16_t mask = 1u << keyboard[j].pins[i].pin;
@ -134,13 +134,13 @@ KEY_Code_t KEYBOARD_Poll(void)
break;
}
// Create I2C stop condition. Since we might have toggled I2C pins.
// Create I2C stop condition since we might have toggled I2C pins
// This leaves GPIOA_PIN_KEYBOARD_4 and GPIOA_PIN_KEYBOARD_5 high
I2C_Stop();
// Reset VOICE pins
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_6);
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
GPIO_SetBit( &GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
return Key;
}

View File

@ -123,6 +123,7 @@ void ST7565_FillScreen(uint8_t Value)
ST7565_Init(false);
SPI_ToggleMasterMode(&SPI0->CR, false);
for (i = 0; i < 8; i++)
{
unsigned int j;
@ -135,6 +136,7 @@ void ST7565_FillScreen(uint8_t Value)
}
SPI_WaitForUndocumentedTxFifoStatusBit();
}
SPI_ToggleMasterMode(&SPI0->CR, true);
}
@ -152,6 +154,8 @@ void ST7565_Init(const bool full)
SYSTEM_DelayMs(120);
}
else
SPI_ToggleMasterMode(&SPI0->CR, false);
ST7565_WriteByte(0xA2); // bias 9
ST7565_WriteByte(0xC0); // com normal
@ -164,9 +168,10 @@ void ST7565_Init(const bool full)
ST7565_WriteByte(0x24); //
ST7565_WriteByte(0x81); // volume first ?
ST7565_WriteByte(0x1f); // contrast ?
if (full)
{
ST7565_WriteByte(0x1f); // contrast ?
ST7565_WriteByte(0x2B); // power control ?
SYSTEM_DelayMs(1);
@ -181,11 +186,11 @@ void ST7565_Init(const bool full)
ST7565_WriteByte(0x2F); //
SYSTEM_DelayMs(40);
ST7565_WriteByte(0x40); // start line ?
ST7565_WriteByte(0xAF); // display on ?
}
ST7565_WriteByte(0x40); // start line ?
ST7565_WriteByte(0xAF); // display on ?
SPI_WaitForUndocumentedTxFifoStatusBit();
SPI_ToggleMasterMode(&SPI0->CR, true);