-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathstore.c
141 lines (121 loc) · 3.65 KB
/
store.c
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* Copyright (C)
* 2015 - John Melton, G0ORX/N6LYT
* 2016 - Steve Wilson, KA6S
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bandstack.h"
#include "band.h"
#include "filter.h"
#include "mode.h"
#include "alex.h"
#include "property.h"
#include "store.h"
#include "store_menu.h"
/*
struct MEM {
char title[16]; // Begin BAND Struct
BANDSTACK *bandstack;
unsigned char OCrx;
unsigned char OCtx;
int preamp;
int alexRxAntenna;
int alexTxAntenna;
int alexAttenuation;
double pa_calibration;
long long frequencyMin;
long long frequencyMax;
long long frequencyLO;
int disablePA;
long long frequency; // Begin BANDSTACK_ENTRY
int mode;
int filter;
int var1Low;
int var1High;
int var2Low;
int var2High;
}*/
MEM mem[NUM_OF_MEMORYS]; // This makes it a compile time option
/* */
/* Memory uses the same format as Band Stack */
/* Implement NUM_OF_MEMORYS memory locations for now... */
void memSaveState() {
char name[128];
char value[128];
int b;
for(b=0;b<NUM_OF_MEMORYS;b++) {
if(strlen(mem[b].title)>0) {
sprintf(name,"mem.%d.title",b);
setProperty(name,mem[b].title);
sprintf(value,"%lld",mem[b].frequency);
sprintf(name,"mem.%d.freqA",b);
setProperty(name,value);
sprintf(value,"%d",mem[b].mode);
sprintf(name,"mem.%d.mode",b);
setProperty(name,value);
sprintf(value,"%d",mem[b].filter);
sprintf(name,"mem.%d.filter",b);
setProperty(name,value);
}
}
//sprintf(value,"%d",band);
//setProperty("band",value);
}
void memRestoreState() {
char* value;
int b;
char name[128];
// Initialize the array with default values
// Allows this to be a compile time option..
for(b=0; b<NUM_OF_MEMORYS; b++) {
strcpy(mem[b].title,"10");
mem[b].frequency = 28010000LL;
mem[b].mode = modeCWU;
mem[b].filter = filterF0;
}
fprintf(stderr,"memRestoreState: restore memory\n");
for(b=0;b<NUM_OF_MEMORYS;b++) {
sprintf(name,"mem.%d.title",b);
value=getProperty(name);
if(value) {
strcpy(mem[b].title,value);
fprintf(stderr,"RESTORE: index=%d title=%s\n",b,value);
}
sprintf(name,"mem.%d.freqA",b);
value=getProperty(name);
if(value) {
mem[b].frequency=atoll(value);
fprintf(stderr,"RESTORE MEM:Mem %d=FreqA %11lld\n",b,mem[b].frequency);
}
sprintf(name,"mem.%d.mode",b);
value=getProperty(name);
if(value) {
mem[b].mode=atoi(value);
fprintf(stderr,"RESTORE: index=%d mode=%d\n",b,mem[b].mode);
}
sprintf(name,"mem.%d.filter",b);
value=getProperty(name);
if(value) {
mem[b].filter=atoi(value);
fprintf(stderr,"RESTORE: index=%d filter=%d\n",b,mem[b].filter);
}
}
//value=getProperty("band");
//if(value) band=atoi(value);
}