-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Blade ID Scan Millis Timeout #697
base: master
Are you sure you want to change the base?
Changes from 6 commits
7c6f58f
b2019e7
f3477f0
0b46840
af79ab7
99020b8
31de15d
066ca81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,6 +356,9 @@ class PropBase : CommandParser, Looper, protected SaberBase, public ModeInterfac | |
BladeSet BladeOff() { | ||
#ifdef IDLE_OFF_TIME | ||
last_on_time_ = millis(); | ||
#endif | ||
#ifdef BLADE_ID_SCAN_MILLIS | ||
blade_id_scan_start_ = millis(); | ||
#endif | ||
bool on = IsOn(); | ||
BladeSet ret = SaberBase::OnBlades(); | ||
|
@@ -581,22 +584,41 @@ class PropBase : CommandParser, Looper, protected SaberBase, public ModeInterfac | |
#ifndef SHARED_POWER_PINS | ||
#warning SHARED_POWER_PINS is recommended when using BLADE_ID_SCAN_MILLIS | ||
#endif | ||
bool find_blade_again_pending_ = false; | ||
uint32_t last_scan_id_ = 0; | ||
bool ScanBladeIdNow() { | ||
uint32_t now = millis(); | ||
if (now - last_scan_id_ > BLADE_ID_SCAN_MILLIS) { | ||
last_scan_id_ = now; | ||
size_t best_config = FindBestConfig(PROFFIEOS_LOG_LEVEL >= 500); | ||
if (current_config != blades + best_config) { | ||
// We can't call FindBladeAgain right away because | ||
// we're called from the blade. Wait until next loop() call. | ||
find_blade_again_pending_ = true; | ||
} | ||
return true; | ||
|
||
bool find_blade_again_pending_ = false; | ||
uint32_t last_scan_id_ = 0; | ||
bool ScanBladeIdNow() { | ||
uint32_t now = millis(); | ||
|
||
bool scan = (now - last_scan_id_) > BLADE_ID_SCAN_MILLIS; | ||
|
||
#ifdef BLADE_ID_STOP_SCAN_WHILE_IGNITED | ||
if (IsOn()) { | ||
scan = false; | ||
} | ||
#endif | ||
|
||
#ifdef BLADE_ID_SCAN_TIMEOUT | ||
#define BLADE_ID_SCAN_TIMEOUT 60 * 10 * 1000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub highlighted 4 different lines. Which one are you saying should be removed? Also I am not sure why any of the 4 lines highlighted would be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line: It will produce a warning message that BLADE_ID_SCAN_TIMEOUT is already defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been completed. Now with the re-write / refactoring of the feature the user should be able to define a timeout if they want blade id to timeout but it won't effect users who don't specify a timeout. |
||
|
||
if ((now - blade_id_scan_start_) < BLADE_ID_SCAN_TIMEOUT) { | ||
profezzorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
scan = false; | ||
} | ||
#endif | ||
|
||
if (scan) { | ||
last_scan_id_ = now; | ||
size_t best_config = FindBestConfig(PROFFIEOS_LOG_LEVEL >= 500); | ||
if (current_config != blades + best_config) { | ||
// We can't call FindBladeAgain right away because | ||
// we're called from the blade. Wait until next loop() call. | ||
find_blade_again_pending_ = true; | ||
} | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
// Must be called from loop() | ||
void PollScanId() { | ||
|
@@ -1120,6 +1142,13 @@ class PropBase : CommandParser, Looper, protected SaberBase, public ModeInterfac | |
|
||
current_mode->mode_Loop(); | ||
|
||
#ifdef BLADE_ID_SCAN_MILLIS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here (#ifdef BLADE_ID_SCAN_TIMEOUT) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if (SaberBase::IsOn() || | ||
(current_style() && current_style()->Charging())) { | ||
blade_id_scan_start_ = millis(); | ||
profezzorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
#endif | ||
|
||
#ifdef IDLE_OFF_TIME | ||
if (SaberBase::IsOn() || | ||
(current_style() && current_style()->Charging())) { | ||
|
@@ -1140,6 +1169,10 @@ class PropBase : CommandParser, Looper, protected SaberBase, public ModeInterfac | |
#ifdef IDLE_OFF_TIME | ||
uint32_t last_on_time_; | ||
#endif | ||
|
||
#ifdef BLADE_ID_SCAN_MILLIS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here (#ifdef BLADE_ID_SCAN_TIMEOUT) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
uint32_t blade_id_scan_start_; | ||
#endif | ||
|
||
#ifdef SOUND_LIBRARY_REQUIRED | ||
RefPtr<BufferedWavPlayer> wav_player_; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be #ifdef BLADE_ID_SCAN_TIMEOUT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done