Skip to content

Commit

Permalink
Fixed POVs diagonals pressing error
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury Vostrenkov committed Feb 25, 2020
1 parent fe891d5 commit 0d95cad
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Inc/common_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

//#define DEBUG

#define FIRMWARE_VERSION 0x1341 // v1.3.4b1
#define FIRMWARE_VERSION 0x1342 // v1.3.4b2
#define USED_PINS_NUM 30 // constant for BluePill and BlackPill boards
#define MAX_AXIS_NUM 8 // max 8
#define MAX_BUTTONS_NUM 128 // power of 2, max 128
Expand Down
2 changes: 1 addition & 1 deletion Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

static const dev_config_t init_config =
{
.firmware_version = 0x1341, // do not change
.firmware_version = 0x1342, // do not change

/*
Name of device in devices dispatcher
Expand Down
Binary file modified MDK-ARM/FreeJoy.bin
Binary file not shown.
10 changes: 10 additions & 0 deletions MDK-ARM/FreeJoy.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@
<WinNumber>1</WinNumber>
<ItemText>buttons_data</ItemText>
</Ww>
<Ww>
<count>6</count>
<WinNumber>1</WinNumber>
<ItemText>pov_data</ItemText>
</Ww>
<Ww>
<count>7</count>
<WinNumber>1</WinNumber>
<ItemText>pov_pos</ItemText>
</Ww>
</WatchWindow1>
<Tracepoint>
<THDelay>0</THDelay>
Expand Down
32 changes: 16 additions & 16 deletions Src/buttons.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,22 @@ void LogicalButtonProcessState (buttons_state_t * p_button_state, uint8_t * pov_
// set bit in povs data
if ((p_dev_config->buttons[num].type) == POV1_UP)
{
pov_buf[0] &= !(1 << 3);
pov_buf[0] &= ~(1 << 3);
pov_buf[0] |= (p_button_state->pin_state << 3);
}
else if ((p_dev_config->buttons[num].type) == POV1_RIGHT)
{
pov_buf[0] &= !(1 << 2);
pov_buf[0] &= ~(1 << 2);
pov_buf[0] |= (p_button_state->pin_state << 2);
}
else if ((p_dev_config->buttons[num].type) == POV1_DOWN)
{
pov_buf[0] &= !(1 << 1);
pov_buf[0] &= ~(1 << 1);
pov_buf[0] |= (p_button_state->pin_state << 1);
}
else
{
pov_buf[0] &= !(1 << 0);
pov_buf[0] &= ~(1 << 0);
pov_buf[0] |= (p_button_state->pin_state << 0);
}
}
Expand Down Expand Up @@ -246,22 +246,22 @@ void LogicalButtonProcessState (buttons_state_t * p_button_state, uint8_t * pov_
// set bit in povs data
if ((p_dev_config->buttons[num].type) == POV2_UP)
{
pov_buf[1] &= !(1 << 3);
pov_buf[1] &= ~(1 << 3);
pov_buf[1] |= (p_button_state->pin_state << 3);
}
else if ((p_dev_config->buttons[num].type) == POV2_RIGHT)
{
pov_buf[1] &= !(1 << 2);
pov_buf[1] &= ~(1 << 2);
pov_buf[1] |= (p_button_state->pin_state << 2);
}
else if ((p_dev_config->buttons[num].type) == POV2_DOWN)
{
pov_buf[1] &= !(1 << 1);
pov_buf[1] &= ~(1 << 1);
pov_buf[1] |= (p_button_state->pin_state << 1);
}
else
{
pov_buf[1] &= !(1 << 0);
pov_buf[1] &= ~(1 << 0);
pov_buf[1] |= (p_button_state->pin_state << 0);
}
}
Expand Down Expand Up @@ -295,22 +295,22 @@ void LogicalButtonProcessState (buttons_state_t * p_button_state, uint8_t * pov_
// set bit in povs data
if ((p_dev_config->buttons[num].type) == POV3_UP)
{
pov_buf[2] &= !(1 << 3);
pov_buf[2] &= ~(1 << 3);
pov_buf[2] |= (p_button_state->pin_state << 3);
}
else if ((p_dev_config->buttons[num].type) == POV3_RIGHT)
{
pov_buf[2] &= !(1 << 2);
pov_buf[2] &= ~(1 << 2);
pov_buf[2] |= (p_button_state->pin_state << 2);
}
else if ((p_dev_config->buttons[num].type) == POV3_DOWN)
{
pov_buf[2] &= !(1 << 1);
pov_buf[2] &= ~(1 << 1);
pov_buf[2] |= (p_button_state->pin_state << 1);
}
else
{
pov_buf[2] &= !(1 << 0);
pov_buf[2] &= ~(1 << 0);
pov_buf[2] |= (p_button_state->pin_state << 0);
}
}
Expand Down Expand Up @@ -344,22 +344,22 @@ void LogicalButtonProcessState (buttons_state_t * p_button_state, uint8_t * pov_
// set bit in povs data
if ((p_dev_config->buttons[num].type) == POV4_UP)
{
pov_buf[3] &= !(1 << 3);
pov_buf[3] &= ~(1 << 3);
pov_buf[3] |= (p_button_state->pin_state << 3);
}
else if ((p_dev_config->buttons[num].type) == POV4_RIGHT)
{
pov_buf[3] &= !(1 << 2);
pov_buf[3] &= ~(1 << 2);
pov_buf[3] |= (p_button_state->pin_state << 2);
}
else if ((p_dev_config->buttons[num].type) == POV4_DOWN)
{
pov_buf[3] &= !(1 << 1);
pov_buf[3] &= ~(1 << 1);
pov_buf[3] |= (p_button_state->pin_state << 1);
}
else
{
pov_buf[3] &= !(1 << 0);
pov_buf[3] &= ~(1 << 0);
pov_buf[3] |= (p_button_state->pin_state << 0);
}
}
Expand Down

0 comments on commit 0d95cad

Please sign in to comment.