-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathIRAnalyzerSettings.cpp
More file actions
92 lines (71 loc) · 2.66 KB
/
IRAnalyzerSettings.cpp
File metadata and controls
92 lines (71 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "IRAnalyzerSettings.h"
#include <AnalyzerHelpers.h>
#include <cstring>
IRAnalyzerSettings::IRAnalyzerSettings()
: mInputChannel( UNDEFINED_CHANNEL ),
mFrequency( 17777 ),
mSignal (NEC_SIG)
{
mInputChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
mInputChannelInterface->SetTitleAndTooltip( "Input", "Standard InfraRed" );
mInputChannelInterface->SetChannel( mInputChannel );
mFrenquencyInterface.reset( new AnalyzerSettingInterfaceInteger() );
mFrenquencyInterface->SetTitleAndTooltip( "Frequency (Hz)", "Specify the frequency used." );
mFrenquencyInterface->SetMax( 6000000 );
mFrenquencyInterface->SetMin( 1 );
mFrenquencyInterface->SetInteger( mFrequency );
mSignalInterface.reset( new AnalyzerSettingInterfaceNumberList() );
mSignalInterface->SetTitleAndTooltip( "Signal", "Type of signal" );
mSignalInterface->AddNumber( NEC_SIG, "NEC (32 bits)", "");
mSignalInterface->SetNumber( mSignal );
AddInterface( mInputChannelInterface.get() );
AddInterface( mFrenquencyInterface.get() );
AddInterface( mSignalInterface.get() );
AddExportOption( 0, "Export as text/csv file" );
AddExportExtension( 0, "text", "txt" );
AddExportExtension( 0, "csv", "csv" );
ClearChannels();
AddChannel( mInputChannel, "Infrared", false );
}
IRAnalyzerSettings::~IRAnalyzerSettings()
{
}
bool IRAnalyzerSettings::SetSettingsFromInterfaces()
{
mInputChannel = mInputChannelInterface->GetChannel();
mFrequency = mFrenquencyInterface->GetInteger();
mSignal = (IRSignal) U32( mSignalInterface->GetNumber() );
ClearChannels();
AddChannel( mInputChannel, "Infrared", true );
return true;
}
void IRAnalyzerSettings::UpdateInterfacesFromSettings()
{
mInputChannelInterface->SetChannel( mInputChannel );
mFrenquencyInterface->SetInteger( mFrequency );
mSignalInterface->SetNumber( mSignal );
}
void IRAnalyzerSettings::LoadSettings( const char* settings )
{
SimpleArchive text_archive;
text_archive.SetString( settings );
const char* name_string;
text_archive >> &name_string;
if( strcmp( name_string, "IRAnalyzer" ) != 0 )
AnalyzerHelpers::Assert( "IRAnalyzer: Provided with a settings string that doesn't belong to us;" );
text_archive >> mInputChannel;
text_archive >> mFrequency;
text_archive >> *(U32*)&mSignal;
ClearChannels();
AddChannel( mInputChannel, "Infrared", true );
UpdateInterfacesFromSettings();
}
const char* IRAnalyzerSettings::SaveSettings()
{
SimpleArchive text_archive;
text_archive << "IRAnalyzer";
text_archive << mInputChannel;
text_archive << mFrequency;
text_archive << mSignal;
return SetReturnString( text_archive.GetString() );
}