Merge branch 'tinySA' into tinySA-v0.2

tinySA-v0.2
erikkaashoek 6 years ago
commit fddb3310e7

@ -608,8 +608,8 @@ void ili9341_drawstring_7x13(const char *str, int x, int y)
{
while (*str) {
uint8_t ch = *str++;
const uint16_t *char_buf = &x7x13b_bits[(ch * 13)];
blit16BitWidthBitmap(x, y, 7, 11, char_buf);
const uint16_t *char_buf = &x7x13b_bits[(ch * 13)]; // All chars start at row 2
blit16BitWidthBitmap(x, y, 7, 12, char_buf); // Only 'Q' has 12 rows
x += 7;
}
}

@ -2662,6 +2662,7 @@ int main(void)
ui_init();
//Initialize graph plotting
plot_init();
redraw_frame();
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);

@ -132,7 +132,7 @@ enum {
};
enum {
MO_NONE, MO_AM, MO_NFM, MO_WFM,
MO_NONE, MO_AM, MO_NFM, MO_WFM, MO_EXTERNAL,
};
#define MODE_OUTPUT(x) ((x) == M_GENLOW || (x) == M_GENHIGH )

@ -1144,7 +1144,7 @@ marker_position(int m, int t, int *x, int *y)
static int greater(int x, int y) { return x > y; }
static int lesser(int x, int y) { return x < y; }
static int (*compare)(int x, int y) = lesser;
static int (*compare)(int x, int y) = greater;
int
marker_search(void)
@ -1157,9 +1157,9 @@ marker_search(void)
int value = CELL_Y(trace_index[TRACE_ACTUAL][0]);
for (i = 0; i < sweep_points; i++) {
index_t index = trace_index[TRACE_ACTUAL][i];
if ((*compare)(value, CELL_Y(index))) {
value = CELL_Y(index);
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, new_value)) {
value = new_value;
found = i;
}
}
@ -1173,30 +1173,36 @@ set_marker_search(int mode)
compare = (mode == 0) ? greater : lesser;
}
int
search_is_greater(void)
{
return(compare == greater);
}
int
marker_search_left(int from)
{
int i;
int found = -1;
#define MINMAX_DELTA -10
#define MINMAX_DELTA -5
if (uistat.current_trace == -1)
return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
for (i = from - 1; i >= 0; i--) {
index_t index = trace_index[TRACE_ACTUAL][i];
if ((*compare)(value - MINMAX_DELTA, CELL_Y(index)))
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value + MINMAX_DELTA, new_value))
break;
value = CELL_Y(index);
value = new_value;
}
for (; i >= 0; i--) {
index_t index = trace_index[TRACE_ACTUAL][i];
if ((*compare)(CELL_Y(index), value + MINMAX_DELTA)) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(new_value, value - MINMAX_DELTA)) {
break;
}
found = i;
value = CELL_Y(index);
value = new_value;
}
return found;
}
@ -1211,19 +1217,19 @@ marker_search_right(int from)
return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
for (i = from + 1; i < sweep_points; i++) {
index_t index = trace_index[TRACE_ACTUAL][i];
if ((*compare)(value, CELL_Y(index)))
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value+MINMAX_DELTA, new_value))
break;
value = CELL_Y(index);
value = new_value;
}
for (; i < sweep_points; i++) {
index_t index = trace_index[TRACE_ACTUAL][i];
if ((*compare)(CELL_Y(index), value)) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(new_value, value-MINMAX_DELTA)) {
break;
}
found = i;
value = CELL_Y(index);
value = new_value;
}
return found;
}
@ -1506,9 +1512,9 @@ draw_all_cells(bool flush_markmap)
b = (k-128)*4;
}
#else
volatile int k = (actual_t[i]+120)* 2;
if (k > 255) k = 255;
volatile unsigned int r=0,g=0,b=0;
int k = (actual_t[i]+120)* 2 * 8;
k &= 255;
unsigned int r=0,g=0,b=0;
if (k < 64) {
b = 255;
g = k*2 + 128;
@ -2083,6 +2089,7 @@ toggle_waterfall(void)
{
if (!waterfall) {
_height = HEIGHT_SCROLL;
ili9341_fill(5*5, HEIGHT, 320 - 5*5, 236-HEIGHT, 0);
waterfall = true;
fullscreen = false;
} else {

@ -27,6 +27,7 @@ int setting_decay;
int setting_noise;
float actual_rbw = 0;
float setting_vbw = 0;
int setting_tracking_output;
int setting_measurement;
@ -63,6 +64,7 @@ void reset_settings(int m)
setting_auto_reflevel = true; // Must be after SetReflevel
setting_decay=20;
setting_noise=5;
setting_tracking_output = false;
trace[TRACE_STORED].enabled = false;
trace[TRACE_TEMP].enabled = false;
@ -138,6 +140,18 @@ void SetDrive(int d)
dirty = true;
}
void set_tracking_output(int t)
{
setting_tracking_output = t;
dirty = true;
}
void toggle_tracking_output(void)
{
setting_tracking_output = !setting_tracking_output;
dirty = true;
}
void SetModulation(int m)
{
setting_modulation = m;
@ -420,6 +434,7 @@ void apply_settings(void)
} else
actualStepDelay = setting_step_delay;
PE4302_Write_Byte(setting_attenuate * 2);
#if 0
if (setting_modulation == MO_NFM ) {
SI4432_Sel = 1;
SI4432_Write_Byte(0x7A, 1); // Use frequency hopping channel width for FM modulation
@ -430,6 +445,7 @@ void apply_settings(void)
SI4432_Sel = 1;
SI4432_Write_Byte(0x79, 0); // IF no FM back to channel 0
}
#endif
SetRX(setting_mode);
SI4432_SetReference(setting_refer);
update_rbw();
@ -494,6 +510,9 @@ case M_LOW: // Mixed into 0
SetAGCLNA();
SI4432_Sel = 1;
if (setting_tracking_output)
SetSwitchTransmit();
else
SetSwitchReceive();
// SI4432_Receive(); For noise testing only
SI4432_Transmit(setting_drive);
@ -521,9 +540,13 @@ case M_GENLOW: // Mixed output from 0
SI4432_Transmit(setting_drive);
SI4432_Sel = 1;
if (setting_modulation == MO_EXTERNAL) {
SetSwitchTransmit(); // High input for external LO scuh as tracking output of other tinySA
SI4432_Receive();
} else {
SetSwitchReceive();
SI4432_Transmit(12); // Fix LO drive a 10dBm
}
break;
case M_GENHIGH: // Direct output from 1
SI4432_Sel = 0;
@ -576,9 +599,9 @@ int binary_search_frequency(int f)
int fplus = f + ((int)actual_rbw ) * 1000;
while (L <= R) {
int m = (L + R) / 2;
if (frequencies[m] < fmin)
if ((int)frequencies[m] < fmin)
L = m + 1;
else if (frequencies[m] > fplus)
else if ((int)frequencies[m] > fplus)
R = m - 1;
else
return m; // index is m

@ -45,6 +45,7 @@ void set_decay(int);
void set_noise(int);
extern int32_t frequencyExtra;
extern int setting_tracking;
extern int setting_tracking_output;
extern int setting_drive;
extern int setting_lna;
extern int setting_agc;
@ -150,13 +151,13 @@ const uint16_t left_icons [] =
0x0000,
0x0000,
0x0000,
0x0000,
0x0060,
0x0039,
0x0fff,
0x0039,
0x0060,
0x0000,
0x0000,
#define I_LOW_OUTPUT 3*16
@ -170,9 +171,9 @@ const uint16_t left_icons [] =
0b0000000000000000,
0b0000000000000000,
0b0000000110000000,
0b0000011110000001,
0b0000011100000001,
0b0000111111111111,
0b0000011110000001,
0b0000011100000001,
0b0000000110000000,
0b0000000000000000,
0b0000000000000000,
@ -182,9 +183,9 @@ const uint16_t left_icons [] =
0b0000000000000000,
0b0000000000000000,
0b0000000110000000,
0b0000011110000001,
0b0000011100000001,
0b0000111111111111,
0b0000011110000001,
0b0000011100000001,
0b0000000110000000,
0b0000000000000000,
0b0000000000000000,
@ -300,16 +301,16 @@ const uint16_t right_icons [] =
0b0000000000000000,
0b0111111111111111,
0b0100000000000001,
0b1100000011000001,
0b1100001110001001,
0b1100011100011101,
0b0100001110111001,
0b1100000010000001,
0b1100001111000001,
0b1100011110001001,
0b0100011100011101,
0b0100011110111001,
0b0100001111111001,
0b0100011111110001,
0b0100111110000001,
0b1100111110000001,
0b1101111100000001,
0b1101111000000001,
0b1100100000000001,
0b1100111000000001,
0b0100000000000001,
0b0111111111111111,
0b0000000000000000,
@ -454,7 +455,7 @@ static const char * const keypad_mode_label[] = {
#endif
#ifdef __SA__
static const char * const keypad_mode_label[] = {
"error", "START", "STOP", "CENTER", "SPAN", "CW FREQ", "REFPOS", "SCALE", // 0-7
"error", "START", "STOP", "CENTER", "SPAN", "FREQ", "REFPOS", "SCALE", // 0-7
"\2ATTENUATE\0 0-31dB", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL", "OFFSET" // 8-16
};
#endif
@ -573,8 +574,8 @@ static void menu_dfu_cb(int item, uint8_t data)
}
const int menu_modulation_value[]={MO_NONE,MO_AM, MO_NFM, MO_WFM};
const char *menu_modulation_text[]={"NONE","AM","NARROW FM","WIDE FM"};
const int menu_modulation_value[]={MO_NONE,MO_AM, MO_NFM, MO_WFM, MO_EXTERNAL};
const char *menu_modulation_text[]={"NONE","AM","NARROW FM","WIDE FM", "EXTERNAL"};
static void menu_modulation_cb(int item, uint8_t data)
{
@ -752,6 +753,7 @@ static void menu_marker_type_cb(int item, uint8_t data)
markers[i].mtype &= ~M_REFERENCE;
}
markers[active_marker].mtype |= M_REFERENCE;
markers[active_marker].mtype &= ~M_DELTA;
} else {
if (data == M_DELTA && (markers[active_marker].mtype & M_REFERENCE))
markers[active_marker].mtype &= ~M_REFERENCE;
@ -828,6 +830,9 @@ static void menu_settings2_cb(int item, uint8_t data)
case 2:
toggle_tracking();
break;
case 3:
toggle_tracking_output();
break;
}
draw_menu();
// draw_cal_status();
@ -899,6 +904,7 @@ const menuitem_t menu_modulation[] = {
{ MT_FORM | MT_CALLBACK, 1, "AM", menu_modulation_cb},
{ MT_FORM | MT_CALLBACK, 2, "NARROW FM", menu_modulation_cb},
{ MT_FORM | MT_CALLBACK, 3, "WIDE FM", menu_modulation_cb},
{ MT_FORM | MT_CALLBACK, 4, "EXTERNAL", menu_modulation_cb},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
};
@ -1057,7 +1063,7 @@ const menuitem_t menu_marker_ops[] = {
static const menuitem_t menu_marker[] = {
{ MT_SUBMENU, 0, "\2SELECT\0MARKERS", menu_marker_sel},
{ MT_SUBMENU, 0, "\2MARKER\0TYPE", menu_marker_type},
{ MT_SUBMENU, 0, "\2CHANGE\0MARKER", menu_marker_type},
{ MT_SUBMENU, 0, "\2MARKER\0OPS", menu_marker_ops},
{ MT_SUBMENU, 0, "\2SEARCH\0MARKER", menu_marker_search},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
@ -1084,6 +1090,7 @@ static const menuitem_t menu_settings2[] =
static const menuitem_t menu_settings[] =
{
{ MT_CALLBACK, 3, "\2TRACKING\0OUTPUT",menu_settings2_cb},
{ MT_KEYPAD, KM_ACTUALPOWER, "\2ACTUAL\0POWER", NULL},
{ MT_KEYPAD, KM_IF, "\2IF\0FREQ", NULL},
{ MT_KEYPAD, KM_SAMPLETIME, "\2SAMPLE\0TIME", NULL},
@ -1147,7 +1154,7 @@ static const menuitem_t menu_acquire[] = {
{ MT_CALLBACK, 0, "RESET", menu_autosettings_cb},
{ MT_SUBMENU, 0, "ATTEN", menu_atten},
{ MT_SUBMENU,0, "RBW", menu_rbw},
{ MT_SUBMENU,0, "AVER", menu_average},
{ MT_SUBMENU,0, "CALC", menu_average},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
};
@ -1155,7 +1162,7 @@ static const menuitem_t menu_acquire[] = {
static const menuitem_t menu_acquirehigh[] = {
{ MT_CALLBACK, 0, "RESET", menu_autosettings_cb},
{ MT_SUBMENU,0, "RBW", menu_rbw},
{ MT_SUBMENU,0, "AVER", menu_average},
{ MT_SUBMENU,0, "CALC", menu_average},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
@ -1194,7 +1201,7 @@ static const menuitem_t menu_stimulus[] = {
{ MT_KEYPAD, KM_STOP, "STOP", NULL},
{ MT_KEYPAD, KM_CENTER, "CENTER", NULL},
{ MT_KEYPAD, KM_SPAN, "SPAN", NULL},
{ MT_KEYPAD, KM_CW, "CW FREQ", NULL},
{ MT_KEYPAD, KM_CW, "\2ZERO\0SPAN", NULL},
{ MT_SUBMENU,0, "RBW", menu_rbw},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
@ -1318,7 +1325,11 @@ static void menu_item_modify_attribute(
mark = true;
}
} else if (menu == menu_dBper) {
if (data == get_trace_scale(1)){
if (data == setting_scale){
mark = true;
}
} else if (menu == menu_measure && MT_MASK(menu[item].type) == MT_CALLBACK) {
if (data == setting_measurement){
mark = true;
}
} else if (menu == menu_rbw) {
@ -1330,7 +1341,10 @@ static void menu_item_modify_attribute(
if (data == setting_drive){
mark = true;
}
} else if (menu == menu_modulation && MT_MASK(menu[item].type) == MT_CALLBACK) {
if (data == setting_modulation){
mark = true;
}
} else if (menu == menu_display) {
if (item ==0 && is_paused()){
mark = true;
@ -1344,6 +1358,10 @@ static void menu_item_modify_attribute(
if (item == 4 && get_waterfall()){
mark = true;
}
} else if (menu == menu_settings) {
if (item ==0 && setting_tracking_output){
mark = true;
}
} else if (menu == menu_settings2 || menu == menu_settingshigh2) {
if (item ==0 && setting_agc){
mark = true;
@ -1357,9 +1375,13 @@ static void menu_item_modify_attribute(
} else if (menu == menu_marker_type && active_marker >= 0 && markers[active_marker].enabled == M_ENABLED) {
if (data & markers[active_marker].mtype)
mark = true;
else if (data==markers[active_marker].mtype) // This catches the M_NORMAL case
else if (item < 5 && data==markers[active_marker].mtype) // This catches the M_NORMAL case
mark = true;
} else if (menu == menu_marker_search) {
if (item == 0 && search_is_greater())
mark = true;
if (item == 1 && !search_is_greater())
mark = true;
if (item == 4 && markers[active_marker].mtype & M_TRACKING)
mark = true;
} else if (menu == menu_marker_sel) {

Loading…
Cancel
Save

Powered by TurnKey Linux.