Skip to content

Commit

Permalink
v1.35 04.01.2013
Browse files Browse the repository at this point in the history
- Test version - Lots of stuff fixed in panadapter. Does not work perfectly,
  but is more or less usable.
- Fixes for tuning sync and A/B frequeny switching and storing
  • Loading branch information
satrian committed Jan 5, 2013
1 parent c5e243d commit e257337
Show file tree
Hide file tree
Showing 8 changed files with 482 additions and 209 deletions.
59 changes: 39 additions & 20 deletions ExtIODialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ extern const struct usb_version* libver;

CPanadapterDialog* m_pmodelessPanadapter = NULL;

extern CWnd* MainWindow;

// CExtIODialog dialog

IMPLEMENT_DYNAMIC(CExtIODialog, CDialog)
Expand Down Expand Up @@ -309,6 +311,14 @@ void CExtIODialog::PostNcDestroy()
// We have to handle close event, as we do not have parent object what would perform destruction for us
void CExtIODialog::OnClose()
{
if (m_pmodelessPanadapter)
{
m_pmodelessPanadapter->CloseWindow();

while(m_pmodelessPanadapter)
{}
}

if (m_pmodeless)
{
m_pmodeless->DestroyWindow();
Expand Down Expand Up @@ -603,8 +613,26 @@ unsigned long tunefreq;

AfxGetApp()->WriteProfileInt(_T("Config"), _T("ChannelMode"), m_nChannelMode);

if ((m_nChannelMode > 1)&&(m_nChannelMode < 5)) // fix tuning for diversity modes
switch(ChannelMode)
{
case CHMODE_A:
case CHMODE_B:

SyncTuning=AfxGetApp()->GetProfileInt(_T("Config"), _T("SyncTuning"), 0);
m_SyncTuneCheck.SetCheck(SyncTuning);
m_SyncTuneCheck.EnableWindow(true);
m_SyncGainCheck.SetCheck(SyncGain);
m_SyncGainCheck.EnableWindow(true);
if (HWType == 3)
IQSampleRate=IQSAMPLERATE_FULL;

m_Button1.EnableWindow(false);
break;

case CHMODE_APB:
case CHMODE_AMB:
case CHMODE_BMA: // fix tuning for diversity modes

m_SyncTuneCheck.SetCheck(1);
m_SyncTuneCheck.EnableWindow(false);
m_SyncGainCheck.SetCheck(SyncGain);
Expand All @@ -615,21 +643,11 @@ unsigned long tunefreq;
IQSampleRate=IQSAMPLERATE_DIVERSITY;

m_Button1.EnableWindow(false);
}
else if (m_nChannelMode <= 1)
{
SyncTuning=AfxGetApp()->GetProfileInt(_T("Config"), _T("SyncTuning"), 0);
m_SyncTuneCheck.SetCheck(SyncTuning);
m_SyncTuneCheck.EnableWindow(true);
m_SyncGainCheck.SetCheck(SyncGain);
m_SyncGainCheck.EnableWindow(true);
if (HWType == 3)
IQSampleRate=IQSAMPLERATE_FULL;
break;

case CHMODE_ABPAN:
case CHMODE_BAPAN:

m_Button1.EnableWindow(false);
}
else if ((m_nChannelMode >= 5)&&(m_nChannelMode <= 6))
{
m_SyncTuneCheck.SetCheck(0);
m_SyncTuneCheck.EnableWindow(false);
m_SyncGainCheck.SetCheck(0);
Expand All @@ -642,6 +660,10 @@ unsigned long tunefreq;
IQSampleRate=IQSAMPLERATE_PANADAPTER;

m_Button1.EnableWindow(true);
break;

default: // should not get here
break;
}

if (SyncTuning) // override frequencies with channel A if synchronous tuning is selected!
Expand Down Expand Up @@ -714,7 +736,7 @@ void CExtIODialog::OnBnClickedRadioCmode4() //A-B

void CExtIODialog::OnBnClickedRadioCmode5() //B-A
{
ChangeMode(lastlo_freqA, lasttune_freqA);
ChangeMode(lastlo_freqB, lasttune_freqB);
}

void CExtIODialog::OnBnClickedRadioCmode6() //A+Panadapter
Expand All @@ -729,9 +751,6 @@ void CExtIODialog::OnBnClickedRadioCmode7() //B+Panadapter

void CExtIODialog::OnBnClickedButton1()
{
// not sure if this can ever happen, but in case the ShowGUI() is called twice without closing the window inbetween,
// just re-activate the window rather than creating a new one.

if(m_pmodelessPanadapter)
{
m_pmodelessPanadapter->ShowWindow(SW_RESTORE);
Expand All @@ -743,7 +762,7 @@ void CExtIODialog::OnBnClickedButton1()

if (m_pmodelessPanadapter)
{
m_pmodelessPanadapter->Create(/*CGenericMFCDlg*/CPanadapterDialog::IDD, CWnd::GetActiveWindow() /*GetDesktopWindow()*/);
m_pmodelessPanadapter->Create(/*CGenericMFCDlg*/CPanadapterDialog::IDD, CWnd::GetActiveWindow() /*MainWindow*/ /*GetDesktopWindow()*/);
m_pmodelessPanadapter->ShowWindow(SW_SHOW);
}
else
Expand Down
22 changes: 11 additions & 11 deletions ExtIODll.rc
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ BEGIN
CONTROL "A+ B",IDC_RADIO_CMODE3,"Button",BS_AUTORADIOBUTTON,67,85,32,10
CONTROL "A - B",IDC_RADIO_CMODE4,"Button",BS_AUTORADIOBUTTON,67,96,31,10
CONTROL "B - A",IDC_RADIO_CMODE5,"Button",BS_AUTORADIOBUTTON,67,107,31,10
CONTROL "A+ Holidays!",IDC_RADIO_CMODE6,"Button",BS_AUTORADIOBUTTON,67,118,57,10
CONTROL "B+ Holidays!",IDC_RADIO_CMODE7,"Button",BS_AUTORADIOBUTTON,67,129,57,10
PUSHBUTTON "Holidays!",IDC_BUTTON1,219,135,60,13,WS_DISABLED
CONTROL "A+ Panadapter",IDC_RADIO_CMODE6,"Button",BS_AUTORADIOBUTTON,67,118,65,10
CONTROL "B+ Panadapter",IDC_RADIO_CMODE7,"Button",BS_AUTORADIOBUTTON,67,129,65,10
PUSHBUTTON "Panadapter",IDC_BUTTON1,219,135,60,13,WS_DISABLED
CONTROL "",IDC_SLIDER1,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,175,60,100,15
CONTROL "",IDC_SLIDER2,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,175,79,100,15
CONTROL "Sync Gain",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,149,101,47,10
Expand Down Expand Up @@ -160,12 +160,12 @@ EXSTYLE WS_EX_STATICEDGE
CAPTION "Panadapter"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Range:",IDC_STATIC,37,218,24,8
EDITTEXT IDC_EDIT1,65,217,154,12,ES_AUTOHSCROLL | WS_DISABLED
LTEXT "Active:",IDC_STATIC,236,218,24,8
EDITTEXT IDC_EDIT2,264,217,79,12,ES_AUTOHSCROLL | WS_DISABLED
LTEXT "Speed:",IDC_STATIC,384,219,24,8
CONTROL "",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,410,214,159,15
LTEXT "Range:",IDC_STATIC,18,218,24,8
EDITTEXT IDC_EDIT1,46,217,260,12,ES_AUTOHSCROLL | WS_DISABLED
LTEXT "Active:",IDC_STATIC,311,218,24,8
EDITTEXT IDC_EDIT2,339,217,98,12,ES_AUTOHSCROLL | WS_DISABLED
LTEXT "Speed:",IDC_STATIC,442,219,24,8
CONTROL "",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,468,214,130,15
CONTROL "Custom3",IDC_CUSTOM1,"MFCRangeSlider",WS_TABSTOP,7,186,880,11
CONTROL "Custom4",IDC_CUSTOM2,"MFCRangeSlider",WS_TABSTOP,895,14,11,160
LTEXT "0 MHz",IDC_STATIC,7,197,25,8
Expand All @@ -178,8 +178,8 @@ BEGIN
LTEXT "20 MHz",IDC_STATIC,551,197,25,8
LTEXT "28 MHz",IDC_STATIC,762,197,25,8
GROUPBOX "",IDC_WATERFALL,16,7,863,168,BS_BITMAP,WS_EX_CLIENTEDGE
LTEXT "Fourier Class by Don Cross / Fred Ackers (waveIn) (The Code Project Open Lincense)",IDC_STATIC,606,212,290,9
LTEXT "CRangeSlider Class by Jens Scheidtmann (Creative Commons BY-SA 3.0 License)",IDC_STATIC,606,220,290,9
LTEXT "FFT Code by Don Cross, Adapted by Fred Ackers (waveIn) (Code Project Open Lincense)",IDC_STATIC,606,212,300,9
LTEXT "RangeSlider Class by Jens Scheidtmann (Creative Commons BY-SA 3.0 License)",IDC_STATIC,606,220,290,9
END


Expand Down
25 changes: 15 additions & 10 deletions ExtIODll.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
IntermediateDirectory=".\Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="2"
UseOfMFC="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
Expand All @@ -51,10 +51,11 @@
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PreprocessorDefinitions="SERIAL_NO_OVERLAPPED; WIN32;_WINDOWS;_USRDLL;WINVER=0x0500;"
StringPooling="false"
MinimalRebuild="false"
RuntimeLibrary="0"
EnableFunctionLevelLinking="false"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Release/MyDll.pch"
Expand All @@ -77,15 +78,18 @@
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Release/MyDll.dll"
AdditionalDependencies="libusb.lib"
OutputFile=""
LinkIncremental="1"
SuppressStartupBanner="true"
ModuleDefinitionFile=".\MyDll.def"
ProgramDatabaseFile=".\Release/MyDll.pdb"
AdditionalLibraryDirectories="libusb"
GenerateManifest="false"
ModuleDefinitionFile=".\ExtIODll.def"
ProgramDatabaseFile=""
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Release/MyDll.lib"
ImportLibrary="Release\ExtIODll.lib"
TargetMachine="1"
/>
<Tool
Expand Down Expand Up @@ -178,6 +182,7 @@
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="libusb"
GenerateManifest="true"
ModuleDefinitionFile=".\ExtIODll.def"
GenerateDebugInformation="true"
ProgramDatabaseFile=""
Expand Down
38 changes: 20 additions & 18 deletions ExtIOFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
v1.30 28.12.2012 - LO frequency drag-along stripped, since it created more problems than it solved
- Preliminary panadapter support (faulty, zooming does not work etc. but works to some extent)
v1.35 04.01.2013 - Test version - Lots of stuff fixed in panadapter. Does not work perfectly, but is more or less usable.
- Fixes for tuning sync and A/B frequeny switching and storing
To Do:
Expand Down Expand Up @@ -183,6 +186,8 @@ usb_dev_handle *dev = NULL; // device handle to be used by libusb
const struct usb_version* libver = NULL; // libusb version information
//char tmp[128];

CWnd* MainWindow;

/*
This entry is the first called by Winrad at startup time, and it is used both to tell to the DLL that it is
time to initialize the hardware, and to get back a descriptive name and model (or Serial Number) of the HW,
Expand Down Expand Up @@ -248,7 +253,7 @@ int i;
update_registry=false; // should be in critical section really, but works without as well
break;
}
WaitForSingleObject(sleepevent, 1000); // do it only after every 10 seconds
WaitForSingleObject(sleepevent, 1000); // do it only after every second
}

if (lastlo_freqA != lastloa)
Expand All @@ -257,7 +262,7 @@ int i;
lastloa=lastlo_freqA;
}

if (lastlo_freqA != lastloa)
if (lastlo_freqB != lastlob)
{
AfxGetApp()->WriteProfileInt(_T("Config"), _T("LastLO_B"), lastlo_freqB);
lastlob=lastlo_freqB;
Expand Down Expand Up @@ -402,16 +407,19 @@ unsigned long long libvernum;
lasttune_freqA=AfxGetApp()->GetProfileInt(_T("Config"), _T("LastTune_A"), 0);
lasttune_freqB=AfxGetApp()->GetProfileInt(_T("Config"), _T("LastTune_B"), 0);


if (ChannelMode == CHMODE_B)
switch(ChannelMode)
{
case CHMODE_B:
case CHMODE_BMA:
case CHMODE_BAPAN:
lo_freq=lastlo_freqB;
tune_freq=lasttune_freqB;
}
else
{
break;

default:
lo_freq=lastlo_freqA;
tune_freq=lasttune_freqA;
break;
}

_beginthread(ExtIORegistryUpdateTask, 0, NULL);
Expand Down Expand Up @@ -877,13 +885,9 @@ char freqstring[32];
// store channel-specific
switch(ChannelMode)
{
case CHMODE_A:
case CHMODE_ABPAN:
lastlo_freqA=LOfreq;
break;

case CHMODE_B:
case CHMODE_BAPAN:
case CHMODE_BMA:
lastlo_freqB=LOfreq;
break;

Expand Down Expand Up @@ -1045,7 +1049,9 @@ extern "C" void __stdcall ShowGUI(void)

if (m_pmodeless)
{
m_pmodeless->Create(/*CGenericMFCDlg*/CExtIODialog::IDD, CWnd::GetActiveWindow() /*GetDesktopWindow()*/);
MainWindow=CWnd::GetActiveWindow();

m_pmodeless->Create(/*CGenericMFCDlg*/CExtIODialog::IDD, MainWindow /*GetDesktopWindow()*/);
m_pmodeless->ShowWindow(SW_SHOW);
}
else
Expand Down Expand Up @@ -1126,12 +1132,8 @@ unsigned long increment;
// store channel-specific
switch(ChannelMode)
{
case CHMODE_A:
case CHMODE_ABPAN:
lasttune_freqA=freq;
break;

case CHMODE_B:
case CHMODE_BMA:
case CHMODE_BAPAN:
lasttune_freqB=freq;
break;
Expand Down
4 changes: 3 additions & 1 deletion ExtIOFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern void (* ExtIOCallback)(int, int, float, void *);
#define MIN_FW_MINOR 70

#define MIN_FW_MAJOR_PAN 1
#define MIN_FW_MINOR_PAN 93 // minimum version needed to run panadapter
#define MIN_FW_MINOR_PAN 95 // minimum version needed to run panadapter

#define LIB_MIN_MAJOR 1
#define LIB_MIN_MINOR 2
Expand Down Expand Up @@ -145,6 +145,8 @@ typedef struct
DWORD steps; // how many steps to increment before going to next table entry
WORD magic_I; // magic token - if three consecutive I and Q pairs are equal to these values, it indicates the beginning of the panoramic packet of particular kind
WORD magic_Q;
WORD skip; // how many IQ pairs to skip after frequency change
WORD dummy; // make structure multiples of 32byte
} PANENTRY;

#endif // !defined(AFX_EXTIOCLASS_H__247C1094_0293_40d5_846A_6CC900C82E80__INCLUDED_)
Loading

0 comments on commit e257337

Please sign in to comment.