Skip to content

Commit

Permalink
fixed array copy bug when copying input button map
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisVeigl committed May 9, 2021
1 parent aafa5bc commit 1360c0e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 9 additions & 5 deletions FabiWare/buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
#include "keys.h"
#include "buttons.h"

int8_t input_map[NUMBER_OF_PHYSICAL_BUTTONS] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
int8_t input_map_PCB[NUMBER_OF_PHYSICAL_BUTTONS] = {10, 16, 19, 5, 6, 7, 8, 9};
int8_t input_map[NUMBER_OF_PHYSICAL_BUTTONS_NOPCB] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
int8_t input_map_PCB[NUMBER_OF_PHYSICAL_BUTTONS_PCB] = {10, 16, 19, 5, 6, 7, 8, 9};

struct buttonType buttons [NUMBER_OF_BUTTONS]; // array for all buttons - type definition see fabi.h
struct buttonDebouncerType buttonDebouncers [NUMBER_OF_BUTTONS]; // array for all buttonsDebouncers - type definition see fabi.h
char keystringBuffer[KEYSTRING_BUFFER_LEN]; // buffer for all string parameters for the buttons of a slot

uint8_t NUMBER_OF_PHYSICAL_BUTTONS;
uint16_t buttonStates = 0;
uint16_t pressure = 0;
uint8_t reportRawValues = 0;
Expand All @@ -37,10 +38,13 @@ uint8_t valueReportCount = 0;
initialise button pins and default modes
*/
void initButtons() {

// update pin mapping for PCB version
if (PCBversion)
memcpy(input_map, input_map_PCB, NUMBER_OF_PHYSICAL_BUTTONS - 1);
if (PCBversion) {
NUMBER_OF_PHYSICAL_BUTTONS = NUMBER_OF_PHYSICAL_BUTTONS_PCB;
memcpy(input_map, input_map_PCB, NUMBER_OF_PHYSICAL_BUTTONS);
}
else NUMBER_OF_PHYSICAL_BUTTONS = NUMBER_OF_PHYSICAL_BUTTONS_NOPCB;

for (int i = 0; i < NUMBER_OF_PHYSICAL_BUTTONS; i++) // initialize physical buttons and bouncers
pinMode (input_map[i], INPUT_PULLUP); // configure the pins for input mode with pullup resistors
Expand Down
4 changes: 4 additions & 0 deletions FabiWare/buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#ifndef _BUTTONS_H_
#define _BUTTONS_H_

#define NUMBER_OF_PHYSICAL_BUTTONS_NOPCB 9 // number of connectable switches for no-PCB version
#define NUMBER_OF_PHYSICAL_BUTTONS_PCB 8 // number of connectable switches for PCB version
#define NUMBER_OF_LEDS 3 // number of connectable leds (no-PCB verion)

#define SIP_BUTTON 9
#define PUFF_BUTTON 10
#define PRESSURE_SENSOR_PIN A0
Expand Down
4 changes: 1 addition & 3 deletions FabiWare/fabi.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
#include <Mouse.h>
#include <Keyboard.h>

#define NUMBER_OF_BUTTONS 11 // number of connected or virtual switches, note: if more than 16, change buttonState type to uint32_t!
#define NUMBER_OF_PHYSICAL_BUTTONS 9 // number of connected switches
#define NUMBER_OF_LEDS 3 // number of connected leds
#define NUMBER_OF_BUTTONS 11 // number of pyhsical plus virtual switches, note: if more than 16, change buttonState type to uint32_t!

#define MAX_SLOTNAME_LEN 10 // maximum lenght for a slotname
#define KEYSTRING_BUFFER_LEN 400 // maximum lenght for all string parameters of a slot
Expand Down

0 comments on commit 1360c0e

Please sign in to comment.