diff --git a/README.md b/README.md index a0674b4..23950bb 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ 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` +`soapy_power -f 80M:110M -n 10 -e 30 -B 30k -k 30 --pow2 -F rtl_power -R | ./LivePow` ### Example loading the data in the file scan.csv -`./Livepow scan.csv` +`./LivePow scan.csv` ### Example reading from scan.csv using the palette from palette.png while skipping the first 22 lines `./LivePow -p palette.png -s 22 scan.csv` diff --git a/displayarea.cpp b/displayarea.cpp index 64b2053..9b48423 100644 --- a/displayarea.cpp +++ b/displayarea.cpp @@ -19,6 +19,12 @@ void DisplayArea::paintEvent(QPaintEvent *event) painter.drawImage(rect,image,rect); } +bool DisplayArea::pixelSet(int x, int y) +{ + if(x>image.width()||y>image.height()) return false; + return qAlpha(image.pixel(x,y))==255; +} + void DisplayArea::setPixel(int x, int y, unsigned int col) { if(x>=image.width()||y>=image.height()) resizeImage(&image,QSize(qMax(x+255,image.width()),qMax(y+255,image.height()))); @@ -55,7 +61,8 @@ void DisplayArea::updateColorMap(float oldMin, float oldMax, float newMin, float QRgb currentColor=imagePixels[i]; if(qAlpha(currentColor)==0) continue; unsigned long oldIndex=findPaletteIndex(currentColor,palettePixels,size); - QRgb newColor=palettePixels[remap(oldIndex,oldMin,oldMax,newMin,newMax)]; + unsigned long newIndex=remap(oldIndex,oldMin,oldMax,newMin,newMax); + QRgb newColor=palettePixels[newIndex]; imagePixels[i]=newColor; } } diff --git a/displayarea.h b/displayarea.h index 4ed67ae..3d51db9 100644 --- a/displayarea.h +++ b/displayarea.h @@ -11,6 +11,7 @@ public: void setPixel(int x,int y,unsigned int col); bool saveImage(const QString &fileName, const char *fileFormat); void updateColorMap(float oldMin,float oldMax,float newMin,float newMax,QImage palette); + bool pixelSet(int x,int y); protected: void paintEvent(QPaintEvent *event) override; diff --git a/inputparser.cpp b/inputparser.cpp index 1adee2a..886c7fb 100644 --- a/inputparser.cpp +++ b/inputparser.cpp @@ -58,18 +58,14 @@ void InputParser::process() decimal=false; break; case '\n': - index=0; minFreq=qMin(minFreq,currentLine.minFreq); maxFreq=qMax(maxFreq,currentLine.maxFreq); sendPixel(); - if(currentLine.maxFreq<=lastMaxFreq){ - currentY++; - currentX=0; - } lastMaxFreq=currentLine.maxFreq; + index=0; nbOfLinesParsed++; currentLine=line(); decimal=false; @@ -159,7 +155,12 @@ void InputParser::sendPixel() QRgb color; double normCol=(currentPowerValue-minPow)/(maxPow-minPow); QRgb* palettePixels=(QRgb*)palette.bits(); - color=palettePixels[qRound(palette.sizeInBytes()/sizeof(QRgb)*normCol)]; + unsigned long paletteIndex=qRound(palette.sizeInBytes()/sizeof(QRgb)*normCol); + color=palettePixels[paletteIndex]; + + currentX=(currentLine.minFreq-minFreq)/currentLine.freqStep+(index-5); + + if(display->pixelSet(currentX,currentY)) currentY++; display->setPixel(currentX,currentY,color); currentX++; diff --git a/inputparser.h b/inputparser.h index b61c525..cf42b1d 100644 --- a/inputparser.h +++ b/inputparser.h @@ -32,7 +32,7 @@ private: unsigned long maxFreq=0; float minPow=__FLT_MAX__; - float maxPow=0; + float maxPow=-__FLT_MAX__; unsigned long lastMaxFreq=0;