Automatic Frequency Control enhancement. Provides default AFC and ability to disable in the Decoder tab of each channel. Spectral display includes visual indicators of frequency center (grey) and current AFC offset (yellow).

This commit is contained in:
dennis.sheirer
2014-09-11 22:46:05 +00:00
parent 4e0fd9b7b0
commit 0f43c7ed22
23 changed files with 546 additions and 119 deletions

View File

@@ -302,6 +302,32 @@ public class OverlayPanel extends JPanel
xaxis, (float)(getSize().getHeight()) - mSpectrumInset ) );
}
/**
* Draws a vertical line at the xaxis
*/
private void drawAFC( Graphics2D graphics, float xaxis, boolean isError )
{
float height = (float)(getSize().getHeight()) - mSpectrumInset;
if( isError )
{
graphics.setColor( Color.YELLOW );
graphics.draw( new Line2D.Float( xaxis, height * 0.75f,
xaxis, height - 1.0f ) );
}
else
{
graphics.setColor( Color.LIGHT_GRAY );
graphics.draw( new Line2D.Float( xaxis, height * 0.65f,
xaxis, height - 1.0f ) );
}
}
/**
* Returns the x-axis value corresponding to the frequency
*/
@@ -436,8 +462,22 @@ public class OverlayPanel extends JPanel
yAxis,
width );
}
/* Draw Automatic Frequency Control line */
if( channel.hasAFC() )
{
int frequency = (int)tunerChannel.getFrequency();
int error = frequency + channel.getAFC().getErrorCorrection();
drawAFC( graphics, getAxisFromFrequency( frequency ), false );
drawAFC( graphics, getAxisFromFrequency( error ), true );
}
}
}
/**
* Draws a textual label at the x/y position, clipping the end of the text
* to fit within the maxwidth value.