VBW menu added

Removed_REF_marker
erikkaashoek 5 years ago
parent 7c4b4530dc
commit 6847d5df4d

@ -563,21 +563,26 @@ void ili9341_bulk(int x, int y, int w, int h)
// Fill region by some color
void ili9341_fill(int x, int y, int w, int h)
{
#if 1
ili9341_setWindow(x, y ,w, h);
send_command(ILI9341_MEMORY_WRITE, 0, NULL);
dmaStreamSetMemory0(dmatx, &background_color);
dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD);
#endif
#ifdef __REMOTE_DESKTOP__
if (auto_capture) {
send_region("fill", x, y, w, h);
send_buffer((uint8_t *)&background_color, sizeof(pixel_t));
}
#endif
#if 1
dmaStreamFlush(w * h);
#endif
// while (SPI_IN_TX_RX(LCD_SPI));
}
static void ili9341_DMA_bulk(uint16_t x, uint16_t y, uint16_t w, uint16_t h, pixel_t *buffer){
#if 1
ili9341_setWindow(x, y ,w, h);
send_command(ILI9341_MEMORY_WRITE, 0, NULL);
@ -585,12 +590,14 @@ static void ili9341_DMA_bulk(uint16_t x, uint16_t y, uint16_t w, uint16_t h, pix
dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC);
dmaStreamSetTransactionSize(dmatx, w * h);
dmaStreamEnable(dmatx);
#endif
#ifdef __REMOTE_DESKTOP__
if (auto_capture) {
send_region("bulk", x, y, w, h);
send_buffer((uint8_t *)buffer, w *h * sizeof(pixel_t));
}
#endif
// while (SPI_IN_TX_RX(LCD_SPI));
}
// Copy spi_buffer to region

@ -18,7 +18,7 @@
*/
#include "ch.h"
//#ifdef TINYSA_F303
#ifdef TINYSA_F303
#include "adc_F303.h"
#ifdef TINYSA_F072
#error "Remove comment for #ifdef TINYSA_F303"
@ -27,7 +27,7 @@
#define TINYSA4
#endif
#define TINYSA4_PROTO
//#endif
#endif
#ifdef TINYSA_F072
#ifdef TINYSA_F303
@ -73,6 +73,7 @@
#define __LIMITS__
#ifdef TINYSA4
#define __HARMONIC__
#define __VBW__
#else
#endif
@ -327,6 +328,9 @@ int is_paused(void);
void set_actual_power(float);
void SetGenerate(int);
void set_RBW(uint32_t rbw_x10);
#ifdef __VBW__
void set_VBW(uint32_t vbw_x10);
#endif
void set_lo_drive(int d);
void set_rx_drive(int d);
void set_IF(int f);

@ -43,6 +43,7 @@ setting_t setting;
freq_t frequencies[POINTS_COUNT];
uint16_t actual_rbw_x10 = 0;
freq_t frequency_step_x10 = 0;
uint16_t vbwSteps = 1;
freq_t minFreq = 0;
freq_t maxFreq = 520000000;
@ -216,7 +217,7 @@ void reset_settings(int m)
setting.step_delay = 0;
setting.offset_delay = 0;
setting.step_delay_mode = SD_NORMAL;
setting.vbw_x10 = 0;
setting.vbw_x10 = 0; // Auto mode
setting.auto_reflevel = true; // Must be after SetReflevel
setting.decay=20;
setting.attack=1;
@ -988,6 +989,14 @@ void set_RBW(uint32_t rbw_x10)
dirty = true;
}
#ifdef __VBW__
void set_VBW(uint32_t vbw_x10)
{
setting.vbw_x10 = vbw_x10;
dirty = true;
}
#endif
#ifdef __SPUR__
void set_spur(int v)
{
@ -1994,29 +2003,27 @@ void update_rbw(void) // calculate the actual_rbw and the vbwSteps (#
return;
#endif
}
frequency_step_x10 = 3000; // default value for zero span
if (setting.frequency_step > 0 && MODE_INPUT(setting.mode)) {
setting.vbw_x10 = (setting.frequency_step)/100;
} else {
setting.vbw_x10 = 3000; // trick to get right default rbw in zero span mode
frequency_step_x10 = (setting.frequency_step)/100;
}
freq_t temp_actual_rbw_x10 = setting.rbw_x10; // requested rbw , 32 bit !!!!!!
freq_t temp_actual_rbw_x10 = setting.rbw_x10;
if (temp_actual_rbw_x10 == 0) { // if auto rbw
if (setting.step_delay_mode==SD_FAST) { // if in fast scanning
#ifdef __SI4432__
if (setting.fast_speedup > 2)
temp_actual_rbw_x10 = 6*setting.vbw_x10; // rbw is six times the frequency step to ensure no gaps in coverage as there are some weird jumps
temp_actual_rbw_x10 = 6*frequency_step_x10; // rbw is six times the frequency step to ensure no gaps in coverage as there are some weird jumps
else
temp_actual_rbw_x10 = 4*setting.vbw_x10; // rbw is four times the frequency step to ensure no gaps in coverage as there are some weird jumps
temp_actual_rbw_x10 = 4*frequency_step_x10; // rbw is four times the frequency step to ensure no gaps in coverage as there are some weird jumps
#endif
#ifdef __SI4463__
temp_actual_rbw_x10 = setting.vbw_x10;
#endif
} else
#ifdef TINYSA4
temp_actual_rbw_x10 = 2*setting.vbw_x10; // rbw is NOT twice the frequency step to ensure no gaps in coverage
#else
temp_actual_rbw_x10 = 2*setting.vbw_x10; // rbw is twice the frequency step to ensure no gaps in coverage
temp_actual_rbw_x10 = frequency_step_x10;
#endif
} else {
temp_actual_rbw_x10 = 2*frequency_step_x10; // rbw is twice the frequency step to ensure no gaps in coverage
}
}
#ifdef __SI4432__
if (temp_actual_rbw_x10 < 26)
@ -2044,18 +2051,18 @@ void update_rbw(void) // calculate the actual_rbw and the vbwSteps (#
actual_rbw_x10 = set_rbw(actual_rbw_x10); // see what rbw the SI4432 can realize
if (setting.frequency_step > 0 && MODE_INPUT(setting.mode)) { // When doing frequency scanning in input mode
#ifdef TINYSA4
if (setting.vbw_x10 > actual_rbw_x10)
vbwSteps = 1+(setting.vbw_x10 / actual_rbw_x10); //((int)(2 * (setting.vbw_x10 + (actual_rbw_x10/8)) / actual_rbw_x10)); // calculate # steps in between each frequency step due to rbw being less than frequency step
if (frequency_step_x10 > actual_rbw_x10)
vbwSteps = 1+(frequency_step_x10 / actual_rbw_x10); //((int)(2 * (frequency_step_x10 + (actual_rbw_x10/8)) / actual_rbw_x10)); // calculate # steps in between each frequency step due to rbw being less than frequency step
vbwSteps += vbwSteps;
#else
vbwSteps = ((int)(2 * (setting.vbw_x10 + (actual_rbw_x10/2)) / actual_rbw_x10)); // calculate # steps in between each frequency step due to rbw being less than frequency step
vbwSteps = ((int)(2 * (frequency_step_x10 + (actual_rbw_x10/2)) / actual_rbw_x10)); // calculate # steps in between each frequency step due to rbw being less than frequency step
#endif
if (setting.step_delay_mode==SD_PRECISE) // if in Precise scanning
vbwSteps *= 2; // use twice as many steps
if (vbwSteps < 1) // at least one step, should never happen
vbwSteps = 1;
} else { // in all other modes
setting.vbw_x10 = actual_rbw_x10;
frequency_step_x10 = actual_rbw_x10;
}
#ifdef TINYSA4
done:
@ -2837,7 +2844,7 @@ modulation_again:
int offs_div10 = (t - (local_vbw_steps >> 1)) * 100; // steps of x10 * settings.
if ((local_vbw_steps & 1) == 0) // Uneven steps, center
offs_div10+= 50; // Even, shift half step
int offs = (offs_div10 * (int32_t)setting.vbw_x10 )/ local_vbw_steps;
int offs = (offs_div10 * (int32_t)frequency_step_x10 )/ local_vbw_steps;
// if (setting.step_delay_mode == SD_PRECISE)
// offs>>=1; // steps of a quarter rbw
// if (lf > -offs) // No negative frequencies
@ -3604,14 +3611,13 @@ sweep_again: // stay in sweep loop when output mo
}
}
}
//if (MODE_INPUT(setting.mode))
{
if (
#ifdef TINYSA4
if (show_bar && (i & 0x07) == 0 && (setting.actual_sweep_time_us > ONE_SECOND_TIME || (chVTGetSystemTimeX() - start_of_sweep_timestamp) > ONE_SECOND_TIME / 100)) { // if required
show_bar && (i & 0x07) == 0 && (setting.actual_sweep_time_us > ONE_SECOND_TIME || (chVTGetSystemTimeX() - start_of_sweep_timestamp) > ONE_SECOND_TIME / 100) // if required
#else
if ( show_bar && (i & 0x07) == 0 && setting.actual_sweep_time_us > ONE_SECOND_TIME) { // if required
show_bar && (i & 0x07) == 0 && setting.actual_sweep_time_us > ONE_SECOND_TIME // if required
#endif
) {
int pos = i * (WIDTH+1) / sweep_points;
ili9341_set_background(LCD_SWEEP_LINE_COLOR);
ili9341_fill(OFFSETX, CHART_BOTTOM+1, pos, 1); // update sweep progress bar
@ -3628,6 +3634,33 @@ sweep_again: // stay in sweep loop when output mo
debug_avoid_second = false;
}
}
temp_t[i] = RSSI;
}
// -------------------------------- Scan finished, do all postprocessing --------------------
if (MODE_INPUT(setting.mode)) {
#ifdef __VBW__
// ------------------------ do VBW processing ------------------------------
int vbw_count_div2 = actual_rbw_x10 * 100 / setting.frequency_step / (setting.vbw_x10 == 0 ? 10 : setting.vbw_x10);
while(vbw_count_div2-- > 0){
pureRSSI_t prev = temp_t[0];
int j;
// first point smooth
temp_t[0] = (prev + prev + temp_t[1])/3.0f;
for (j=1;j<sweep_points-1;j++){
pureRSSI_t old = temp_t[j]; // save current data point for next point smooth
temp_t[j] = (prev + temp_t[j] + temp_t[j] + temp_t[j+1])/4;
prev = old;
}
// last point smooth
temp_t[j] = (temp_t[j] + temp_t[j] + prev)/3;
}
#endif
for (int i = 0; i < sweep_points; i++) {
#if 0
// -------------------------- smoothing -----------------------------------------
@ -3644,9 +3677,7 @@ sweep_again: // stay in sweep loop when output mo
#endif
// ------------------------ do all RSSI calculations from CALC menu -------------------
if (setting.average != AV_OFF)
temp_t[i] = RSSI;
RSSI = temp_t[i];
if (setting.subtract_stored) {
RSSI = RSSI - stored_t[i] + setting.normalize_level;
}
@ -3756,8 +3787,8 @@ sweep_again: // stay in sweep loop when output mo
downslope = true;
}
} // end of peak finding
} // end of input specific processing
} // ---------------------- end of sweep loop -----------------------------
}
} // ---------------------- end of postprocessing -----------------------------
if (MODE_OUTPUT(setting.mode) && setting.modulation != MO_NONE) { // if in output mode with modulation
if (!in_selftest)
@ -3826,25 +3857,6 @@ sweep_again: // stay in sweep loop when output mo
// ---------------------- sweep finished, do all postprocessing ---------------------
#ifdef TINYSA4
// ------------------------ do VBW processing ------------------------------
int vbw_count_div2 = actual_rbw_x10 * 50 / setting.frequency_step;
while(vbw_count_div2-- > 0){
pureRSSI_t prev = actual_t[0];
int j;
// first point smooth
actual_t[0] = (prev + prev + actual_t[1])/3.0f;
for (j=1;j<sweep_points-1;j++){
pureRSSI_t old = actual_t[j]; // save current data point for next point smooth
actual_t[j] = (prev + actual_t[j] + actual_t[j] + actual_t[j+1])/4;
prev = old;
}
// last point smooth
actual_t[j] = (actual_t[j] + actual_t[j] + prev)/3;
}
#endif
if (scandirty) {
scandirty = false;
redraw_request |= REDRAW_CAL_STATUS;

@ -1930,8 +1930,8 @@ void SI446x_Fill(int s, int start)
#endif
uint32_t t = setting.additional_step_delay_us;
systime_t measure = chVTGetSystemTimeX();
__disable_irq();
systime_t measure = chVTGetSystemTimeX();
#if 1
int i = start;
@ -1952,9 +1952,9 @@ again:
#else
shiftInBuf(sel, SI4432_REG_RSSI, &age[start], sweep_points - start, t);
#endif
__enable_irq();
setting.measure_sweep_time_us = (chVTGetSystemTimeX() - measure)*100;
__enable_irq();
buf_index = (start<=0 ? 0 : start); // Is used to skip 1st entry during level triggering
buf_read = true;
}

@ -1341,6 +1341,10 @@ static const char* rbwsel_text[]={"auto","300","1k","3k","10k","30k","100k","300
#else
static const uint16_t rbwsel_x10[]={0,30,100,300,1000,3000,6000};
#endif
#ifdef __VBW__
static const uint16_t vbwsel_x10[]={0,1,3,10,30,100};
static const char* vbwsel_text[]={"auto","0.1", "0.3"," "," 3","10"};
#endif
static UI_FUNCTION_ADV_CALLBACK(menu_rbw_acb)
{
@ -1358,6 +1362,21 @@ static UI_FUNCTION_ADV_CALLBACK(menu_rbw_acb)
menu_move_back(true);
}
#ifdef __VBW__
static UI_FUNCTION_ADV_CALLBACK(menu_vbw_acb)
{
(void)item;
if (b){
b->param_1.text = vbwsel_text[data];
b->icon = setting.vbw_x10 == vbwsel_x10[data] ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
set_VBW(vbwsel_x10[data]);
menu_move_back(true);
}
#endif
static UI_FUNCTION_ADV_CALLBACK(menu_unit_acb)
{
(void)item;
@ -1839,6 +1858,19 @@ static const menuitem_t menu_rbw[] = {
{ MT_NONE, 0, NULL, NULL } // sentinel
};
#ifdef __VBW__
static const menuitem_t menu_vbw[] = {
{ MT_ADV_CALLBACK, 0, " AUTO", menu_vbw_acb},
{ MT_ADV_CALLBACK, 1, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 2, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 3, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 4, "%s RBW", menu_vbw_acb},
{ MT_ADV_CALLBACK, 5, "%s RBW", menu_vbw_acb},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
#endif
#if 0
static const menuitem_t menu_scale_per2[] = {
{ MT_ADV_CALLBACK, 6, "0.1 /", menu_scale_per_acb},
@ -2283,6 +2315,9 @@ static const menuitem_t menu_display[] = {
// { MT_ADV_CALLBACK,0, "STORE\nTRACE", menu_storage_acb},
// { MT_ADV_CALLBACK,1, "CLEAR\nSTORED", menu_storage_acb},
// { MT_ADV_CALLBACK,2, "SUBTRACT\nSTORED",menu_storage_acb},
#ifdef __VBW__
{ MT_SUBMENU, 0, "VBW", menu_vbw},
#endif
#ifdef __LIMITS__
{ MT_SUBMENU, 0, "LIMITS", menu_limit_select},
#endif

Loading…
Cancel
Save

Powered by TurnKey Linux.