-
Notifications
You must be signed in to change notification settings - Fork 63
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
Use 'nodeRssiPeak' in delta5Node.ino #73
Open
ethomas997
wants to merge
1
commit into
scottgchin:master
Choose a base branch
from
ethomas997:etAddNodeRssiPeak
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+15
−8
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,8 @@ struct { | |
uint16_t volatile rssiPeak = 0; | ||
// The time of the peak raw rssi for the current pass | ||
uint32_t volatile rssiPeakRawTimeStamp = 0; | ||
// The peak smoothed rssi seen since the node was powered on or frequency set | ||
uint16_t volatile nodeRssiPeak = 0; | ||
|
||
// variables to track the loop time | ||
uint32_t volatile loopTime = 0; | ||
|
@@ -255,6 +257,14 @@ void loop() { | |
state.rssiSmoothed = (settings.filterRatioFloat * (float)state.rssiRaw) + ((1.0f-settings.filterRatioFloat) * state.rssiSmoothed); | ||
state.rssi = (int)state.rssiSmoothed; | ||
|
||
// Keep track of peak (smoothed) rssi; set trigger as offset of peak | ||
if (state.rssi > state.nodeRssiPeak) { | ||
state.nodeRssiPeak = state.rssi; | ||
state.rssiTrigger = state.nodeRssiPeak - settings.calibrationOffset; | ||
Serial.print("New nodeRssiPeak = "); | ||
Serial.println(state.nodeRssiPeak); | ||
} | ||
|
||
if (state.rssiTrigger > 0) { | ||
if (!state.crossing && state.rssi > state.rssiTrigger) { | ||
state.crossing = true; // Quad is going through the gate | ||
|
@@ -269,14 +279,10 @@ void loop() { | |
} | ||
|
||
if (state.crossing) { | ||
int triggerThreshold = settings.triggerThreshold; | ||
|
||
// If in calibration mode, keep raising the trigger value | ||
if (state.calibrationMode) { | ||
state.rssiTrigger = max(state.rssiTrigger, state.rssi - settings.calibrationOffset); | ||
// when calibrating, use a larger threshold | ||
triggerThreshold = settings.calibrationThreshold; | ||
} | ||
// when in calibration mode, use a larger threshold | ||
int triggerThreshold = state.calibrationMode ? | ||
settings.calibrationThreshold : settings.triggerThreshold; | ||
|
||
state.rssiPeak = max(state.rssiPeak, state.rssi); | ||
|
||
|
@@ -416,6 +422,7 @@ byte i2cHandleRx(byte command) { // The first byte sent by the I2C master is the | |
if (readAndValidateIoBuffer(0x51, 2)) { | ||
settings.vtxFreq = ioBufferRead16(); | ||
setRxModule(settings.vtxFreq); // Shouldn't do this in Interrupt Service Routine | ||
state.nodeRssiPeak = 0; // restart rssi peak tracking for node | ||
success = true; | ||
} | ||
break; | ||
|
@@ -428,7 +435,7 @@ byte i2cHandleRx(byte command) { // The first byte sent by the I2C master is the | |
case WRITE_CALIBRATION_MODE: | ||
if (readAndValidateIoBuffer(WRITE_CALIBRATION_MODE, 1)) { | ||
state.calibrationMode = ioBufferRead8(); | ||
state.rssiTrigger = state.rssi - settings.calibrationOffset; | ||
state.rssiTrigger = state.nodeRssiPeak - settings.calibrationOffset; | ||
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 looks like it assumes that you always want to set the trigger value based on peak RSSI, not the peak of the current quad in the heat. |
||
lastPass.rssiPeakRaw = 0; | ||
lastPass.rssiPeak = 0; | ||
state.rssiPeakRaw = 0; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The intent of auto calibration is to calculate a new trigger value for each new run. Each run may have a different pilot with different vtx output strength.