added option to ignore the first <n> lines
This commit is contained in:
parent
b5445c8a11
commit
65271413cf
@ -11,3 +11,6 @@ make -j4
|
||||
## Usage
|
||||
### 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`
|
||||
|
||||
### 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);*/
|
||||
}
|
||||
|
||||
void InputParser::sendParameters(unsigned long ignoreFirstNLines)
|
||||
{
|
||||
this->ignoreFirstNLines=ignoreFirstNLines;
|
||||
}
|
||||
|
||||
void InputParser::process()
|
||||
{
|
||||
@ -24,6 +28,11 @@ void InputParser::process()
|
||||
int c=fgetc(input);
|
||||
if(c==EOF) continue;
|
||||
|
||||
if(nbOfLinesParsed<ignoreFirstNLines){
|
||||
if(c=='\n') nbOfLinesParsed++;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(c){
|
||||
case ',':
|
||||
switch(index){
|
||||
@ -52,6 +61,7 @@ void InputParser::process()
|
||||
}
|
||||
lastMaxFreq=currentLine.maxFreq;
|
||||
|
||||
nbOfLinesParsed++;
|
||||
currentLine=line();
|
||||
decimal=false;
|
||||
break;
|
||||
@ -137,7 +147,7 @@ void InputParser::sendPixel()
|
||||
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));
|
||||
currentX++;
|
||||
currentPowerValue=0;
|
||||
|
@ -24,6 +24,8 @@ class InputParser : public QObject
|
||||
public:
|
||||
InputParser(FILE* input,DisplayArea* display);
|
||||
|
||||
void sendParameters(unsigned long ignoreFirstNLines);
|
||||
|
||||
private:
|
||||
unsigned long minFreq=-1;
|
||||
unsigned long maxFreq=0;
|
||||
@ -35,6 +37,9 @@ private:
|
||||
|
||||
unsigned long index=0;
|
||||
|
||||
unsigned long nbOfLinesParsed=0;
|
||||
unsigned long ignoreFirstNLines=0;
|
||||
|
||||
line currentLine;
|
||||
|
||||
FILE* input;
|
||||
|
5
main.cpp
5
main.cpp
@ -12,6 +12,11 @@ int main(int argc, char *argv[])
|
||||
argsParser.addHelpOption();
|
||||
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);
|
||||
|
||||
MainWindow w;
|
||||
|
@ -41,6 +41,10 @@ void MainWindow::sendArgs(QCommandLineParser *argsParser)
|
||||
|
||||
parser=new InputParser(input,displayArea);
|
||||
|
||||
if(argsParser->isSet("s")){
|
||||
parser->sendParameters(argsParser->value("s").toLong());
|
||||
}
|
||||
|
||||
QThread* workerThread=new QThread();
|
||||
|
||||
parser->moveToThread(workerThread);
|
||||
|
Loading…
x
Reference in New Issue
Block a user