Skip to content

Commit

Permalink
flip tt mode (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinetic-flow authored Nov 12, 2020
1 parent a183093 commit 20fb0cf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
7 changes: 6 additions & 1 deletion arcin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,12 @@ int main() {
} else if (config.qe1_sens > 0) {
qe1_count *= config.qe1_sens;
}
report.axis_x = uint8_t(qe1_count);

if (analog_tt_reverse_direction) {
report.axis_x = uint8_t(255 - qe1_count);
} else {
report.axis_x = uint8_t(qe1_count);
}
}

report.axis_y = 127;
Expand Down
21 changes: 19 additions & 2 deletions arcin/modeswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ uint16_t led_mode_switch_request = 0;
config_flags original_flags = {0};
config_flags current_flags = {0};

bool analog_tt_reverse_direction = false;

config_flags initialize_mode_switch(config_flags flags) {
original_flags = flags;
current_flags = original_flags;
Expand Down Expand Up @@ -101,9 +103,11 @@ void process_tt_mode_switch() {
(ARCIN_PIN_BUTTON_START | ARCIN_PIN_BUTTON_SELECT | ARCIN_PIN_BUTTON_3);

// analog only -> digital only
if (!current_flags.DigitalTTEnable && !current_flags.AnalogTTForceEnable) {
if (!current_flags.DigitalTTEnable &&
!current_flags.AnalogTTForceEnable &&
!analog_tt_reverse_direction) {

current_flags.DigitalTTEnable = 1;
current_flags.AnalogTTForceEnable = 0;
schedule_led(
Time::time() + 2500,
(mode_lights | ARCIN_PIN_BUTTON_4),
Expand All @@ -112,9 +116,22 @@ void process_tt_mode_switch() {
return;
}

// digital only -> analog only (flipped)
if (current_flags.DigitalTTEnable && !current_flags.AnalogTTForceEnable) {
current_flags.DigitalTTEnable = 0;
analog_tt_reverse_direction = true;
schedule_led(
Time::time() + 2500,
(mode_lights | ARCIN_PIN_BUTTON_6),
mode_lights);

return;
}

// all others -> analog only
current_flags.DigitalTTEnable = 0;
current_flags.AnalogTTForceEnable = 0;
analog_tt_reverse_direction = false;
schedule_led(
Time::time() + 2500,
(mode_lights | ARCIN_PIN_BUTTON_2),
Expand Down
2 changes: 2 additions & 0 deletions arcin/modeswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ config_flags initialize_mode_switch(config_flags flags);

config_flags process_mode_switch(uint16_t raw_input);

extern bool analog_tt_reverse_direction;

#endif

0 comments on commit 20fb0cf

Please sign in to comment.