comparison autocal/txlevels.c @ 102:80281b67511f

fc-rfcal-txband: fixed bug in the corner case when the target power level is above the highest basis point
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 12 Aug 2017 08:47:09 +0000
parents b0618796d28d
children 7ad0495991ed
comparison
equal deleted inserted replaced
101:b0618796d28d 102:80281b67511f
20 unsigned 20 unsigned
21 find_apc_for_target(target_dbm, pslope) 21 find_apc_for_target(target_dbm, pslope)
22 double target_dbm; 22 double target_dbm;
23 vout_t *pslope; 23 vout_t *pslope;
24 { 24 {
25 vout_t target_vout; 25 vout_t target_vout, slope;
26 unsigned n; 26 unsigned n;
27 int apc_delta; 27 int apc_delta;
28 28
29 target_vout = dbm_to_vout(target_dbm); 29 target_vout = dbm_to_vout(target_dbm);
30 for (n = 0; n < num_basis_points - 1; n++) 30 for (n = 0; n < num_basis_points - 1; n++)
31 if (target_vout < tx_basis[n+1].vout) 31 if (target_vout < tx_basis[n+1].vout)
32 break; 32 break;
33 if (n == num_basis_points - 1)
34 slope = tx_basis[n-1].slope;
35 else
36 slope = tx_basis[n].slope;
33 if (pslope) 37 if (pslope)
34 *pslope = tx_basis[n].slope; 38 *pslope = slope;
35 apc_delta = (target_vout - tx_basis[n].vout) / tx_basis[n].slope; 39 apc_delta = (target_vout - tx_basis[n].vout) / slope;
36 return tx_basis[n].apc + apc_delta; 40 return tx_basis[n].apc + apc_delta;
37 } 41 }
38 42
39 calibrate_tx_levels() 43 calibrate_tx_levels()
40 { 44 {