summaryrefslogtreecommitdiff
path: root/device-functions.c
blob: 081d63cb2819ddbcb9a0307f23f675a90b9420c7 (plain)
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
141
142
143
144
145
146
147
#include "device-functions.h"
#include "globals.h"
#include "version.h"


/*** BeginHeader idn_string */
void idn_string(gchar** response);
/*** EndHeader */
/*----------------------------------------------------------------------------------------------------------*/
void idn_string(gchar** response)
{
	*response = g_strdup_printf ("AVTECH ELECTROSYSTEMS,%s,%s,%s",
	                             globals.Flash.model_num,
	                             globals.Flash.serial_num,
	                             FW_VERSION);
}


/*----------------------------------------------------------------------------------------------------------*/
int Set_frequency(int check_possible_only,int word_override,int range_override,int channel,float set_freq)
{
	// keep, but ignore, the first 3 parameters for now

	// all this does right now is check the frequency range,
	// and store the set value.

	/* abandon if high channel selected by user but not enabled by firmware */
	if (channel && !globals.Flash.ChanKey_frequency) {
		return InvalidChannel;
	}

	if (set_freq < globals.Flash.min_freq[channel]) {
		return freq_lower_limit;
	}
	if (set_freq > globals.Flash.max_freq[channel]) {
		return freq_upper_limit;
	}

	globals.ChannelState[channel].frequency=set_freq;

	return OK;
}


void Main_Rst (void)
{
	int i;

	globals.extended_ampl_min_max=NO;

	// go backwards, so channel 0 overrides everything
	for (i=globals.Flash.channels-1; i>=0; --i) {

		globals.ChannelState[i].route_primary=1;
		globals.ChannelState[i].route_secondary=1;
		globals.ChannelState[i].frequency=globals.Flash.min_freq[i];
		globals.ChannelState[i].delay=globals.Flash.min_delay[i];

		if (globals.Flash.min_pw[i] > 0.0) {
			globals.ChannelState[i].pw=globals.Flash.min_pw[i];
		} else {
			globals.ChannelState[i].pw=0.0;
		}

		if (globals.Flash.ampl_min_max_only[i] || (globals.Flash.min_ampl[i] > 0.0)) {
			globals.ChannelState[i].amplitude = globals.Flash.min_ampl[i];
		} else {
			globals.ChannelState[i].amplitude=0.0;
		}
		globals.ChannelState[i].offset=0.0;

		globals.ChannelState[i].zout=globals.Flash.zout_min[i];
		globals.ChannelState[i].hold_setting = hold_width;
		globals.ChannelState[i].double_pulse = double_off;
		globals.ChannelState[i].ab_mode = pw_normal;
		globals.ChannelState[i].func_mode = pulse_mode_on;
		globals.ChannelState[i].polarity = globals.Flash.invert_by_default[i];
		globals.ChannelState[i].output_state = output_off;
		globals.ChannelState[i].gate_type = gate_sync;
		globals.ChannelState[i].trigger_source = source_internal;
		globals.ChannelState[i].amp_mode = amp_mode_normal;
		globals.ChannelState[i].os_mode = os_mode_normal;
		globals.ChannelState[i].gate_level = gate_low;
		globals.ChannelState[i].load_type= globals.Flash.low_load_type[i];
		globals.ChannelState[i].test_delay_mode = NO;
		globals.ChannelState[i].logic_level = logic_ttl;
		globals.ChannelState[i].burst_count = 1 && !globals.Flash.burst_func[i];
		globals.ChannelState[i].burst_time = globals.Constraints.composite_min_burst_time[i];
		globals.ChannelState[i].rise_time = globals.Flash.min_rise_time[i];
		globals.ChannelState[i].soft_current_limit = globals.Flash.max_soft_current_limit[i];
		globals.ChannelState[i].vcc1 = 0.0;
		globals.ChannelState[i].vcc2 = globals.Flash.vcc2_min[i];
		globals.ChannelState[i].vlogic = 0.0;
		globals.ChannelState[i].slew = globals.Flash.min_slew[i];

		globals.do_check_settings=NO;   /* don't check for conflicting settings */
		/* FIXME - implement Set_* functions!
				Set_Pw(0,0,0,i,globals.ChannelState[i].pw,0);

				Set_Route(i,ROUTE_PRIMARY,globals.ChannelState[i].route_primary);
				Set_Route(i,ROUTE_SECONDARY,globals.ChannelState[i].route_secondary);

				Set_frequency(0,0,0,i,globals.ChannelState[i].frequency);
				Set_Delay(0,0,0,i,globals.ChannelState[i].delay);
				Set_Double(i,globals.ChannelState[i].double_pulse);
				Set_Pwmode(i,globals.ChannelState[i].ab_mode);
				Set_Func(i,globals.ChannelState[i].func_mode);
				Set_Pol(i,globals.ChannelState[i].polarity);
				Set_Gate_Sync(i,globals.ChannelState[i].gate_type);
				Set_Gate_Level(i,globals.ChannelState[i].gate_level);
				Set_EA(i,globals.ChannelState[i].amp_mode);
				Set_EO(i,globals.ChannelState[i].os_mode);
				if (globals.Flash.switchable_zout[i]) {
					Set_zout(i,globals.ChannelState[i].zout,1);
				}

				Set_Load(i,globals.ChannelState[i].load_type);
				Set_Logic_Level(i,globals.ChannelState[i].logic_level);
				Set_rise_time(0,0,0,i,globals.ChannelState[i].rise_time);
				Set_slew(0,0,0,i,globals.ChannelState[i].slew);
				Set_current_limit(0,i,globals.ChannelState[i].soft_current_limit);

				if (globals.Flash.max_burst_count[i]>1) {
					Set_Burst_Count(i,globals.ChannelState[i].burst_count,globals.ChannelState[i].burst_time);
				}

				Set_Trig_Source(i,globals.ChannelState[i].trigger_source);

				Set_Amplitude(0,0,0,0,0,0,i,globals.ChannelState[i].amplitude,0);
				Set_Offset(0,0,0,0,i,globals.ChannelState[i].offset);
				Set_Output_State(i,globals.ChannelState[i].output_state);

				Set_current_limit(0,i,globals.ChannelState[i].soft_current_limit);

				Set_avrq_ampl(0,0,0,2,globals.ChannelState[i].vcc1);
				Set_avrq_ampl(0,0,0,3,globals.ChannelState[i].vcc2);
				Set_avrq_ampl(0,0,0,4,globals.ChannelState[i].vlogic);
		*/
		globals.do_check_settings=YES;  /* check for conflicting settings */
	}


//	Error_check(globals.ChannelState);      /* establishes min/max values for queries, but reports no errors */
//	update_whole_main_menu=YES;
//	Ctrl_PRF_Limiter(1);
//	Menu_Clear_Buttons();
}