1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

Hide sat. icons initially.

Hide sattelites not in the last GPS update (based on the magic number
'16' from the constellation widget).
Fix a range check.


git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1504 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
cranphin 2010-09-01 23:11:54 +00:00 committed by cranphin
parent a6ec576f97
commit 25076d09a7
2 changed files with 14 additions and 6 deletions

View File

@ -69,7 +69,7 @@ GpsConstellationWidget::GpsConstellationWidget(QWidget *parent) : QGraphicsView(
satIcons[i]->setSharedRenderer(renderer);
satIcons[i]->setElementId("sat-notSeen");
satIcons[i]->setParentItem(world);
satIcons[i]->hide();
}
}
@ -96,8 +96,10 @@ void GpsConstellationWidget::showEvent(QShowEvent *event)
void GpsConstellationWidget::updateSat(int index, int prn, int elevation, int azimuth, int snr)
{
if (index > 16)
if (index >= 16) {
return; // A bit of error checking never hurts.
}
// TODO: add range checking
satellites[index][0] = prn;
satellites[index][1] = elevation;

View File

@ -289,6 +289,8 @@ void NMEAParser::nmeaProcessGPGSV(char *packet)
QStringList tokenslist = nmeaString->split(",");
// Officially there should be a max of three sentences (12 sats), some gps receivers do more..
const int sentence_total = tokenslist.at(1).toInt(); // Number of sentences for full data
const int sentence_index = tokenslist.at(2).toInt(); // sentence x of y
const int sat_count = tokenslist.at(3).toInt(); // Number of satellites in view
@ -300,14 +302,18 @@ void NMEAParser::nmeaProcessGPGSV(char *packet)
const int elv = tokenslist.at(base+1).toInt(); // Elevation, degrees
const int azimuth = tokenslist.at(base+2).toInt(); // Azimuth, degrees
const int sig = tokenslist.at(base+3).toInt(); // SNR - higher is better
// TODO: probably need a better way to create an index, and also I think we need something else then index,
// cause what happens if less satelites are found, or the gps juggles the order?
const int index = sentence_index * 4 + sat;
emit satellite(index, id, elv, azimuth, sig);
}
if(sentence_index == sentence_total) {
// Last sentence
int total_sats = sentence_index * 4 + sats;
for(int emptySatIndex = total_sats; emptySatIndex < 16; emptySatIndex++) {
// Wipe the rest.
emit satellite(emptySatIndex, 0, 0, 0, 0);
}
}
}
/**