Skip to content

Commit

Permalink
v4.3 Push to start feature (#47)
Browse files Browse the repository at this point in the history
* Version 4.3

* Think push to start is working.
  • Loading branch information
skelstar authored Jun 11, 2021
1 parent 8f85fa2 commit 09fbbb9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
6 changes: 3 additions & 3 deletions include/AnalogThumbwheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AnalogThumbwheelClass

private:
VoidUint8Callback _throttleChangedCb = nullptr;
GetBoolean_Cb _throttleEnabled_cb = nullptr;
// GetBoolean_Cb _throttleEnabled_cb = nullptr;
FastMap _accelmapper, _brakemapper;
int _pin = THROTTLE_PIN;
uint8_t _oldMapped = 0, _throttle = 127;
Expand All @@ -45,7 +45,7 @@ class AnalogThumbwheelClass
_throttleChangedCb = throttleChangedCb;
pinMode(_pin, INPUT);
_oldMapped = 127;
assert(_throttleEnabled_cb != nullptr);
// assert(_throttleEnabled_cb != nullptr);
}

uint8_t get()
Expand Down Expand Up @@ -80,7 +80,7 @@ class AnalogThumbwheelClass

void setThrottleEnabledCb(GetBoolean_Cb cb)
{
_throttleEnabled_cb = cb;
// _throttleEnabled_cb = cb;
}

bool connect()
Expand Down
21 changes: 18 additions & 3 deletions include/tasks/core0/ThrottleTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,25 @@ class ThrottleTask : public TaskBase
private:
Queue1::Manager<PrimaryButtonState> *primaryButtonQueue = nullptr;
Queue1::Manager<ThrottleState> *throttleQueue = nullptr;
Queue1::Manager<Transaction> *transactionQueue = nullptr;

Transaction m_transaction;

ThrottleState throttle;

void initialiseQueues()
{
primaryButtonQueue = createQueueManager<PrimaryButtonState>("(throttle)primaryButtonQueue");
throttleQueue = createQueueManager<ThrottleState>("(throttle)throttleQueue");
transactionQueue = createQueueManager<Transaction>("(DisplayBase)TransactionQueue");
transactionQueue->printMissedPacket = false;
transactionQueue->read();
}

void _initialise()
{
thumbwheel.setThrottleEnabledCb([]
{ return true; });
// thumbwheel.setThrottleEnabledCb([]
// { return m_transaction.moving; });

#if REMOTE_USED == NINTENDO_REMOTE
if (mux_I2C == nullptr)
Expand All @@ -83,9 +89,13 @@ class ThrottleTask : public TaskBase
if (primaryButtonQueue->hasValue())
handlePrimaryButton(primaryButtonQueue->payload);

// transaction
if (transactionQueue->hasValue())
handleTransaction(transactionQueue->payload);

// check throttle/trigger
uint8_t og_throttle = thumbwheel.get();
uint8_t status = thumbwheel.update();
uint8_t status = thumbwheel.update(m_transaction.moving);
throttle.val = thumbwheel.get();
throttle.status = status;

Expand Down Expand Up @@ -115,6 +125,11 @@ class ThrottleTask : public TaskBase
if (buttonReleased)
thumbwheel.centre();
}

void handleTransaction(Transaction &transaction)
{
m_transaction = transaction;
}
};

ThrottleTask throttleTask;
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ monitor_speed = 115200
; test_filter = test_smoother

build_flags =
-D VERSION=4.2
-D VERSION=4.3
-D VERSION_BOARD_COMPAT=4.1
!python ./getCurrentGitBranch.py ; GIT_BRANCH_NAME
!python ./getCurrentGitCommitHash.py ; GIT_COMMIT_HASH
Expand Down

0 comments on commit 09fbbb9

Please sign in to comment.