various bugfixes
This commit is contained in:
parent
f653effb77
commit
8596e263e7
@ -10,10 +10,10 @@ 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 loading the data in the file scan.csv
|
### 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
|
### 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`
|
`./LivePow -p palette.png -s 22 scan.csv`
|
||||||
|
@ -19,6 +19,12 @@ void DisplayArea::paintEvent(QPaintEvent *event)
|
|||||||
painter.drawImage(rect,image,rect);
|
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)
|
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())));
|
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];
|
QRgb currentColor=imagePixels[i];
|
||||||
if(qAlpha(currentColor)==0) continue;
|
if(qAlpha(currentColor)==0) continue;
|
||||||
unsigned long oldIndex=findPaletteIndex(currentColor,palettePixels,size);
|
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;
|
imagePixels[i]=newColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ public:
|
|||||||
void setPixel(int x,int y,unsigned int col);
|
void setPixel(int x,int y,unsigned int col);
|
||||||
bool saveImage(const QString &fileName, const char *fileFormat);
|
bool saveImage(const QString &fileName, const char *fileFormat);
|
||||||
void updateColorMap(float oldMin,float oldMax,float newMin,float newMax,QImage palette);
|
void updateColorMap(float oldMin,float oldMax,float newMin,float newMax,QImage palette);
|
||||||
|
bool pixelSet(int x,int y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
@ -58,18 +58,14 @@ void InputParser::process()
|
|||||||
decimal=false;
|
decimal=false;
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
index=0;
|
|
||||||
minFreq=qMin(minFreq,currentLine.minFreq);
|
minFreq=qMin(minFreq,currentLine.minFreq);
|
||||||
maxFreq=qMax(maxFreq,currentLine.maxFreq);
|
maxFreq=qMax(maxFreq,currentLine.maxFreq);
|
||||||
|
|
||||||
sendPixel();
|
sendPixel();
|
||||||
|
|
||||||
if(currentLine.maxFreq<=lastMaxFreq){
|
|
||||||
currentY++;
|
|
||||||
currentX=0;
|
|
||||||
}
|
|
||||||
lastMaxFreq=currentLine.maxFreq;
|
lastMaxFreq=currentLine.maxFreq;
|
||||||
|
|
||||||
|
index=0;
|
||||||
nbOfLinesParsed++;
|
nbOfLinesParsed++;
|
||||||
currentLine=line();
|
currentLine=line();
|
||||||
decimal=false;
|
decimal=false;
|
||||||
@ -159,7 +155,12 @@ void InputParser::sendPixel()
|
|||||||
QRgb color;
|
QRgb color;
|
||||||
double normCol=(currentPowerValue-minPow)/(maxPow-minPow);
|
double normCol=(currentPowerValue-minPow)/(maxPow-minPow);
|
||||||
QRgb* palettePixels=(QRgb*)palette.bits();
|
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);
|
display->setPixel(currentX,currentY,color);
|
||||||
currentX++;
|
currentX++;
|
||||||
|
@ -32,7 +32,7 @@ private:
|
|||||||
unsigned long maxFreq=0;
|
unsigned long maxFreq=0;
|
||||||
|
|
||||||
float minPow=__FLT_MAX__;
|
float minPow=__FLT_MAX__;
|
||||||
float maxPow=0;
|
float maxPow=-__FLT_MAX__;
|
||||||
|
|
||||||
unsigned long lastMaxFreq=0;
|
unsigned long lastMaxFreq=0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user