various bugfixes

This commit is contained in:
leo 2021-06-06 19:48:42 +02:00
parent f653effb77
commit 8596e263e7
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB
5 changed files with 19 additions and 10 deletions

View File

@ -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`

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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++;

View File

@ -32,7 +32,7 @@ private:
unsigned long maxFreq=0;
float minPow=__FLT_MAX__;
float maxPow=0;
float maxPow=-__FLT_MAX__;
unsigned long lastMaxFreq=0;