summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--device-functions.c69
-rw-r--r--device-functions.h2
-rw-r--r--flash.c11
3 files changed, 50 insertions, 32 deletions
diff --git a/device-functions.c b/device-functions.c
index 3b1bf22..879ae73 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -89,7 +89,7 @@ void Main_Rst (void)
globals.ChannelState[i].pw=0.0;
}
- globals.ChannelState[i].amplitude = rst_fixed_ampl_point(i);
+ globals.ChannelState[i].amplitude = rst_ampl_value(i);
globals.ChannelState[i].offset=0.0;
globals.ChannelState[i].zout=globals.Flash.zout_min[i];
@@ -4480,41 +4480,54 @@ int number_of_fixed_ampl_points(int channel)
}
-float rst_fixed_ampl_point (int channel)
+float rst_ampl_value (int channel)
{
// smallest positive value, or zero
- int i, max, pos_count, neg_count;
- pos_count = 0;
- neg_count = 0;
-
- float smallest_pos, smallest_neg;
- smallest_pos = 1e9;
- smallest_neg = -1e9;
-
+ int max;
max = number_of_fixed_ampl_points(channel);
- // any zeroes?
- for (i=0; i<max; i++) {
- if (globals.Flash.fixed_ampl_points[channel][i] >= 0.0 ) {
- ++pos_count;
- if (globals.Flash.fixed_ampl_points[channel][i] < smallest_pos) {
- smallest_pos = globals.Flash.fixed_ampl_points[channel][i];
- }
- } else if (globals.Flash.fixed_ampl_points[channel][i] < 0.0 ) {
- ++neg_count;
- if (globals.Flash.fixed_ampl_points[channel][i] > smallest_neg) {
- smallest_neg = globals.Flash.fixed_ampl_points[channel][i];
+ if (max == 0) {
+ // not a unit that uses a list of fixed amplitudes
+
+ if ((globals.Flash.min_ampl[channel] > 0.0) && (globals.Flash.max_ampl[channel] > 0.0)) {
+ // both min and max ampls are positive, range does not include zero. AVR-D4-B.
+ return globals.Flash.min_ampl[channel];
+ } else {
+ // normal unit
+ return 0.0;
+ }
+ } else {
+ int i, pos_count, neg_count;
+ pos_count = 0;
+ neg_count = 0;
+
+ float smallest_pos, smallest_neg;
+ smallest_pos = 1e9;
+ smallest_neg = -1e9;
+
+ // any zeroes?
+ for (i=0; i<max; i++) {
+ if (globals.Flash.fixed_ampl_points[channel][i] >= 0.0 ) {
+ ++pos_count;
+ if (globals.Flash.fixed_ampl_points[channel][i] < smallest_pos) {
+ smallest_pos = globals.Flash.fixed_ampl_points[channel][i];
+ }
+ } else if (globals.Flash.fixed_ampl_points[channel][i] < 0.0 ) {
+ ++neg_count;
+ if (globals.Flash.fixed_ampl_points[channel][i] > smallest_neg) {
+ smallest_neg = globals.Flash.fixed_ampl_points[channel][i];
+ }
}
}
- }
- if (pos_count > 0) {
- return smallest_pos;
- } else if (neg_count > 0) {
- return smallest_neg;
- } else {
- return 0.0;
+ if (pos_count > 0) {
+ return smallest_pos;
+ } else if (neg_count > 0) {
+ return smallest_neg;
+ } else {
+ return 0.0;
+ }
}
}
diff --git a/device-functions.h b/device-functions.h
index 9e47de2..6e5287c 100644
--- a/device-functions.h
+++ b/device-functions.h
@@ -74,7 +74,7 @@ int IO_Setup_RS232(int baud, char handshake, gboolean update_flash);
int change_password (gchar *old_password, gchar *new_password);
int number_of_fixed_ampl_points(int channel);
-float rst_fixed_ampl_point (int channel);
+float rst_ampl_value (int channel);
gboolean fixed_ampl_ok (int channel, float use_ampl);
void get_min_max_fixed_ampls (int channel, float *min_ampl, float *max_ampl);
diff --git a/flash.c b/flash.c
index f71f19a..23a7823 100644
--- a/flash.c
+++ b/flash.c
@@ -948,9 +948,7 @@ void fixFlash(FlashStruct *mem)
gboolean uses_fixed_ampl;
uses_fixed_ampl = (number_of_fixed_ampl_points(i) > 0);
- if (uses_fixed_ampl) {
- safe_val = rst_fixed_ampl_point (i);
- }
+ safe_val = rst_ampl_value (i);
for (j=0; j<max_stored_settings; j++) {
if (mem->rcl_burst_time[i][j] < globals.Constraints.composite_min_burst_time[i]) {
@@ -971,6 +969,13 @@ void fixFlash(FlashStruct *mem)
}
if (uses_fixed_ampl && !fixed_ampl_ok(i,mem->rcl_amplitude[i][j])) {
+ // AVRQ-4-B
+ mem->rcl_amplitude[i][j] = safe_val;
+ ++fix_initial_constants;
+ }
+
+ if ((safe_val != 0.0) && (mem->rcl_amplitude[i][j] == 0.0)) {
+ // AVR-D4-B
mem->rcl_amplitude[i][j] = safe_val;
++fix_initial_constants;
}