Tuner debug, spinner index working

This commit is contained in:
Charles J. Cliffe 2015-03-25 21:35:42 -04:00
parent de2b25e148
commit d7784a393d
3 changed files with 34 additions and 3 deletions

View File

@ -110,6 +110,23 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) {
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseMoved(event);
int index;
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),11,-1.0,(1.0/3.0)*2.0); // freq
if (index > 0) {
std::cout << "freq " << index << std::endl;
}
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),7,-1.0+(2.25/3.0),(1.0/4.0)*2.0); // bw
if (index > 0) {
std::cout << "bw " << index << std::endl;
}
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),11,-1.0+(2.0/3.0)*2.0,(1.0/3.0)*2.0); // center
if (index > 0) {
std::cout << "ctr " << index << std::endl;
}
}
void TuningCanvas::OnMouseDown(wxMouseEvent& event) {

View File

@ -108,6 +108,21 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float
glEnd();
}
int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth) {
mPos -= 0.5;
mPos *= 2.0;
float delta = mPos-displayPos;
if (delta < 0 || delta > displayWidth) {
return 0;
}
int index = floor((delta/displayWidth)*(count));
return count-index;
}
void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long center) {
GLint vp[4];
glGetIntegerv( GL_VIEWPORT, vp);
@ -115,9 +130,6 @@ void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long c
float viewHeight = (float) vp[3];
float viewWidth = (float) vp[2];
#define NUM_BINS 11
short num_bin[NUM_BINS] = { 0, 0, 1, 0, 5, 7, 0, 0, 0, 0, 0 };
DrawTuner(freq,11,-1.0,(1.0/3.0)*2.0);
DrawTuner(bw,7,-1.0+(2.25/3.0),(1.0/4.0)*2.0);
DrawTuner(center,11,-1.0+(2.0/3.0)*2.0,(1.0/3.0)*2.0);

View File

@ -14,6 +14,8 @@ public:
void DrawBegin();
void Draw(float r, float g, float b, float a, float p1, float p2);
void DrawTuner(long long freq, int count, float displayPos, float displayWidth);
int GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth);
void DrawDemodFreqBw(long long freq, unsigned int bw, long long center);
void DrawEnd();