Cache attenuation data, not rewrite if some

Not redraw status on trigger
pull/4/head
DiSlord 6 years ago
parent 7213afd3e2
commit 26e33535d7

@ -270,7 +270,7 @@ VNA_SHELL_FUNCTION(cmd_v)
shell_printf("%d\r\n", SI4432_Sel); shell_printf("%d\r\n", SI4432_Sel);
return; return;
} }
VFO = my_atoi(argv[0]); VFO = my_atoi(argv[0]) > 0 ? 1 : 0;
shell_printf("VFO %d\r\n", VFO); shell_printf("VFO %d\r\n", VFO);
} }

@ -854,8 +854,8 @@ uint32_t peakFreq;
int peakIndex; int peakIndex;
float temppeakLevel; float temppeakLevel;
int temppeakIndex; int temppeakIndex;
static unsigned long old_freq[4] = { 0, 0, 0, 0 }; static unsigned long old_freq[MAX_SI4432] = { 0, 0, 0,;
static unsigned long real_old_freq[4] = { 0, 0, 0, 0 }; static unsigned long real_old_freq[MAX_SI4432] = { 0, 0, 0};
// volatile int t; // volatile int t;
//static uint32_t extra_vbw_step_time = 0; //static uint32_t extra_vbw_step_time = 0;
@ -1782,7 +1782,7 @@ sweep_again: // stay in sweep loop when output mo
if (setting.trigger == T_SINGLE) if (setting.trigger == T_SINGLE)
pause_sweep(); // Stop scanning after completing this sweep if above trigger pause_sweep(); // Stop scanning after completing this sweep if above trigger
} }
scandirty = true; // To show trigger happened // scandirty = true; // To show trigger happened
} }
// ---------------------- process measured actual sweep time ----------------- // ---------------------- process measured actual sweep time -----------------
@ -1844,8 +1844,7 @@ sweep_again: // stay in sweep loop when output mo
if (!in_selftest && setting.mode == M_LOW && setting.auto_attenuation && max_index[0] > 0) { // calculate and apply auto attenuate if (!in_selftest && setting.mode == M_LOW && setting.auto_attenuation && max_index[0] > 0) { // calculate and apply auto attenuate
setting.atten_step = false; // No step attenuate in low mode auto attenuate setting.atten_step = false; // No step attenuate in low mode auto attenuate
float old_attenuate = get_attenuation(); float actual_max_level = actual_t[max_index[0]] - get_attenuation();
float actual_max_level = actual_t[max_index[0]] - old_attenuate;
if (actual_max_level < - 31 && setting.attenuate >= 10) { if (actual_max_level < - 31 && setting.attenuate >= 10) {
setting.attenuate -= 10.0; setting.attenuate -= 10.0;
} else if (actual_max_level < - 26 && setting.attenuate >= 5) { } else if (actual_max_level < - 26 && setting.attenuate >= 5) {
@ -1853,9 +1852,9 @@ sweep_again: // stay in sweep loop when output mo
} else if (actual_max_level > - 19 && setting.attenuate <= 20) { } else if (actual_max_level > - 19 && setting.attenuate <= 20) {
setting.attenuate += 10.0; setting.attenuate += 10.0;
} }
if (old_attenuate != get_attenuation()) { // Try update settings
if (PE4302_Write_Byte((int) get_attenuation() * 2)) {
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
PE4302_Write_Byte((int)(setting.attenuate * 2));
SI4432_Sel = 0; SI4432_Sel = 0;
if (setting.atten_step) { if (setting.atten_step) {
set_switch_transmit(); // This should never happen set_switch_transmit(); // This should never happen

@ -124,7 +124,8 @@ static void shiftOutBuf(uint8_t *buf, uint16_t size) {
}while(--size); }while(--size);
} }
#endif #endif
const int SI_nSEL[3] = { GPIO_RX_SEL, GPIO_LO_SEL, 0}; // #3 is dummy!!!!!!
const uint16_t SI_nSEL[MAX_SI4432] = { GPIO_RX_SEL, GPIO_LO_SEL, 0}; // #3 is dummy!!!!!!
volatile int SI4432_Sel = 0; // currently selected SI4432 volatile int SI4432_Sel = 0; // currently selected SI4432
// volatile int SI4432_guard = 0; // volatile int SI4432_guard = 0;
@ -398,7 +399,7 @@ int SI4432_is_fast_mode(void)
void SI4432_Fill(int s, int start) void SI4432_Fill(int s, int start)
{ {
SI4432_Sel = s; SI4432_Sel = s;
int sel = SI_nSEL[SI4432_Sel]; uint16_t sel = SI_nSEL[SI4432_Sel];
#if 0 #if 0
uint32_t t = calc_min_sweep_time_us(); // Time to delay in uS for all sweep uint32_t t = calc_min_sweep_time_us(); // Time to delay in uS for all sweep
if (t < setting.sweep_time_us){ if (t < setting.sweep_time_us){
@ -657,8 +658,12 @@ void PE4302_shiftOut(uint8_t val)
} }
} }
#endif #endif
void PE4302_Write_Byte(unsigned char DATA )
static unsigned char old_attenuation[MAX_SI4432] = {0, 0, 0};
bool PE4302_Write_Byte(unsigned char DATA )
{ {
if (old_attenuation[SI4432_Sel] == DATA)
return false;
// chThdSleepMicroseconds(PE4302_DELAY); // chThdSleepMicroseconds(PE4302_DELAY);
SPI2_CLK_LOW; SPI2_CLK_LOW;
// chThdSleepMicroseconds(PE4302_DELAY); // chThdSleepMicroseconds(PE4302_DELAY);
@ -670,7 +675,7 @@ void PE4302_Write_Byte(unsigned char DATA )
// chThdSleepMicroseconds(PE4302_DELAY); // chThdSleepMicroseconds(PE4302_DELAY);
CS_PE_LOW; CS_PE_LOW;
// chThdSleepMicroseconds(PE4302_DELAY); // chThdSleepMicroseconds(PE4302_DELAY);
return true;
} }
#endif #endif

@ -21,6 +21,12 @@
#ifndef __SI4432_H__ #ifndef __SI4432_H__
#define __SI4432_H__ #define __SI4432_H__
//
#define MAX_SI4432 3
#define SI4432_RX 0
#define SI4432_LO_OUT 1
#define SI4432_DUMMY 2
#define SI4432_DEV_TYPE 0x00 #define SI4432_DEV_TYPE 0x00
#define SI4432_DEV_VERSION 0x01 #define SI4432_DEV_VERSION 0x01
@ -112,7 +118,7 @@ void SI4432_Set_Frequency ( uint32_t Freq );
void SI4432_Transmit(int d); void SI4432_Transmit(int d);
void SI4432_Receive(void); void SI4432_Receive(void);
uint16_t SI4432_SET_RBW(uint16_t WISH); uint16_t SI4432_SET_RBW(uint16_t WISH);
void PE4302_Write_Byte(unsigned char DATA ); bool PE4302_Write_Byte(unsigned char DATA );
void PE4302_init(void); void PE4302_init(void);
#ifdef __ULTRA_SA__ #ifdef __ULTRA_SA__

Loading…
Cancel
Save

Powered by TurnKey Linux.