Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
njriasan committed Nov 18, 2019
2 parents be2bb27 + c213600 commit bbfc6f8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions buckler/buckler_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,21 @@ typedef struct {

static button_info_t x_button = {"X", 0b1 << 3, 3, 0};
static button_info_t b_button = {"B", 0b1, 0, 0};
static button_info_t stick_push_button = {"STICK PUSH", 0xb1111 << 8, 8, 8};
static button_info_t stick_push_button = {"STICK PUSH", 0b1111 << 8, 8, 8};

static button_info_t *buttons[NUM_BUTTONS] = {&x_button, &b_button, &stick_push_button };

void ble_evt_write(ble_evt_t const* p_ble_evt) {
// TODO: logic for each characteristic and related state changes
//printf("%x\n", stick_push_button.value);
for (unsigned int i = 0; i < NUM_BUTTONS; i++) {
buttons[i]->value = (buttons[i]->mask & controller_bytes) >> buttons[i]->shift_amount;
}
uint8_t *bytes_look = (uint8_t *) &controller_bytes;
//printf("%x\n", stick_push_button.value);
//printf("%x %x\n", bytes_look[0], bytes_look[1]);
//printf("\n\n");


if (x_button.value == 1) {
if (stick_push_button.value == 6) {
Expand All @@ -93,6 +99,8 @@ void ble_evt_write(ble_evt_t const* p_ble_evt) {
}
} else if (b_button.value == 1) {
state = DECELERATE;
} else {
state = OFF;
}
}

Expand Down Expand Up @@ -208,7 +216,7 @@ int main(void) {
state = OFF;
} else {
// perform state-specific actions here
kobukiDriveDirect(100, 100);
kobukiDriveDirect(700, 700);
}
break; // each case needs to end with break!
}
Expand All @@ -232,7 +240,7 @@ int main(void) {
state = OFF;
} else {
// perform state-specific actions here
kobukiDriveDirect(-50, 100);
kobukiDriveDirect(650, 700);
}
break; // each case needs to end with break!
}
Expand All @@ -244,7 +252,7 @@ int main(void) {
state = OFF;
} else {
// perform state-specific actions here
kobukiDriveDirect(100, -50);
kobukiDriveDirect(700, 650);
}
break; // each case needs to end with break!
}
Expand Down

0 comments on commit bbfc6f8

Please sign in to comment.