rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
buttonshift.cpp
Go to the documentation of this file.
1/**
2 * @file buttonshift.cpp
3 * @brief Polls pins for gear changes
4 *
5 * @date Aug 31, 2020
6 * @author David Holdeman, (c) 2020
7 */
8
9#include "pch.h"
10
11#include "buttonshift.h"
12
13#if EFI_TCU
15
17 debounceUp("gear_up"),
18 debounceDown("gear_down")
19 {
20
21}
22
30
32 bool upPinState = false;
33 bool downPinState = false;
34 // Read pins
35 upPinState = debounceUp.readPinEvent();
36 downPinState = debounceDown.readPinEvent();
37 gear_e gear = getDesiredGear();
38 // Select new gear based on current desired gear.
39 if (upPinState) {
40 switch (gear) {
41 case REVERSE:
43 break;
44 case NEUTRAL:
46 break;
47 case GEAR_1:
49 break;
50 case GEAR_2:
52 break;
53 case GEAR_3:
55 break;
56 default:
57 break;
58 }
59 } else if (downPinState) {
60 switch (gear) {
61 case NEUTRAL:
63 break;
64 case GEAR_1:
66 break;
67 case GEAR_2:
69 break;
70 case GEAR_3:
72 break;
73 case GEAR_4:
75 break;
76 default:
77 break;
78 }
79 }
80
82}
83
87#endif // EFI_TCU
ButtonShiftController buttonShiftController
ButtonShiftController * getButtonShiftController()
bool readPinEvent()
void init(efitimems_t threshold, brain_pin_e &pin, pin_input_mode_e &mode, bool inverted=false)
Definition debounce.cpp:23
ButtonDebounce debounceDown
Definition buttonshift.h:25
ButtonDebounce debounceUp
Definition buttonshift.h:24
virtual void init()
virtual void update()
virtual gear_e getDesiredGear() const
virtual gear_e setDesiredGear(gear_e)
static constexpr engine_configuration_s * engineConfiguration
gear_e
@ GEAR_2
@ REVERSE
@ GEAR_1
@ GEAR_4
@ NEUTRAL
@ GEAR_3