added option to ignore the first <n> lines
This commit is contained in:
parent
b5445c8a11
commit
65271413cf
@ -11,3 +11,6 @@ make -j4
|
|||||||
## Usage
|
## Usage
|
||||||
### Example scanning the FM radio band
|
### Example scanning the FM radio band
|
||||||
`soapy_power -f 80M:110M -n 10 -e 30 -B 30k -k 30 --pow2 -F rtl_power -R | ./Livepow`
|
`soapy_power -f 80M:110M -n 10 -e 30 -B 30k -k 30 --pow2 -F rtl_power -R | ./Livepow`
|
||||||
|
|
||||||
|
### Example loadind the data in the file scan.csv
|
||||||
|
./Livepow scan.csv
|
||||||
|
@ -17,6 +17,10 @@ InputParser::InputParser(FILE* input,DisplayArea* display)
|
|||||||
timer->start(0);*/
|
timer->start(0);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputParser::sendParameters(unsigned long ignoreFirstNLines)
|
||||||
|
{
|
||||||
|
this->ignoreFirstNLines=ignoreFirstNLines;
|
||||||
|
}
|
||||||
|
|
||||||
void InputParser::process()
|
void InputParser::process()
|
||||||
{
|
{
|
||||||
@ -24,6 +28,11 @@ void InputParser::process()
|
|||||||
int c=fgetc(input);
|
int c=fgetc(input);
|
||||||
if(c==EOF) continue;
|
if(c==EOF) continue;
|
||||||
|
|
||||||
|
if(nbOfLinesParsed<ignoreFirstNLines){
|
||||||
|
if(c=='\n') nbOfLinesParsed++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch(c){
|
switch(c){
|
||||||
case ',':
|
case ',':
|
||||||
switch(index){
|
switch(index){
|
||||||
@ -52,6 +61,7 @@ void InputParser::process()
|
|||||||
}
|
}
|
||||||
lastMaxFreq=currentLine.maxFreq;
|
lastMaxFreq=currentLine.maxFreq;
|
||||||
|
|
||||||
|
nbOfLinesParsed++;
|
||||||
currentLine=line();
|
currentLine=line();
|
||||||
decimal=false;
|
decimal=false;
|
||||||
break;
|
break;
|
||||||
@ -137,7 +147,7 @@ void InputParser::sendPixel()
|
|||||||
maxPow=newMax;
|
maxPow=newMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
int col=qRound(currentPowerValue-minPow*255/(maxPow-minPow));
|
int col=qRound((currentPowerValue-minPow)*255/(maxPow-minPow));
|
||||||
display->setPixel(currentX,currentY,qRgba(col,col,col,255));
|
display->setPixel(currentX,currentY,qRgba(col,col,col,255));
|
||||||
currentX++;
|
currentX++;
|
||||||
currentPowerValue=0;
|
currentPowerValue=0;
|
||||||
|
@ -24,6 +24,8 @@ class InputParser : public QObject
|
|||||||
public:
|
public:
|
||||||
InputParser(FILE* input,DisplayArea* display);
|
InputParser(FILE* input,DisplayArea* display);
|
||||||
|
|
||||||
|
void sendParameters(unsigned long ignoreFirstNLines);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned long minFreq=-1;
|
unsigned long minFreq=-1;
|
||||||
unsigned long maxFreq=0;
|
unsigned long maxFreq=0;
|
||||||
@ -35,6 +37,9 @@ private:
|
|||||||
|
|
||||||
unsigned long index=0;
|
unsigned long index=0;
|
||||||
|
|
||||||
|
unsigned long nbOfLinesParsed=0;
|
||||||
|
unsigned long ignoreFirstNLines=0;
|
||||||
|
|
||||||
line currentLine;
|
line currentLine;
|
||||||
|
|
||||||
FILE* input;
|
FILE* input;
|
||||||
|
5
main.cpp
5
main.cpp
@ -12,6 +12,11 @@ int main(int argc, char *argv[])
|
|||||||
argsParser.addHelpOption();
|
argsParser.addHelpOption();
|
||||||
argsParser.addPositionalArgument("source","csv file to read data from, default stdin");
|
argsParser.addPositionalArgument("source","csv file to read data from, default stdin");
|
||||||
|
|
||||||
|
QCommandLineOption skipFirstLines(QStringList() << "s" << "ignoreFirstLines",
|
||||||
|
"Skip the first <n> lines",
|
||||||
|
"number of lines");
|
||||||
|
argsParser.addOption(skipFirstLines);
|
||||||
|
|
||||||
argsParser.process(a);
|
argsParser.process(a);
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
@ -41,6 +41,10 @@ void MainWindow::sendArgs(QCommandLineParser *argsParser)
|
|||||||
|
|
||||||
parser=new InputParser(input,displayArea);
|
parser=new InputParser(input,displayArea);
|
||||||
|
|
||||||
|
if(argsParser->isSet("s")){
|
||||||
|
parser->sendParameters(argsParser->value("s").toLong());
|
||||||
|
}
|
||||||
|
|
||||||
QThread* workerThread=new QThread();
|
QThread* workerThread=new QThread();
|
||||||
|
|
||||||
parser->moveToThread(workerThread);
|
parser->moveToThread(workerThread);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user