diff --git a/Makefile b/Makefile index 2af90d0..4865a71 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # Compiler options here. ifeq ($(USE_OPT),) USE_OPT = -Og -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage -# USE_OPT = -fdce -fdse -fmerge-constants -fstore-merging -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage +# USE_OPT = -O2 -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage endif # C specific options here (added to USE_OPT). diff --git a/nanovna.h b/nanovna.h index 522505c..1db0c1a 100644 --- a/nanovna.h +++ b/nanovna.h @@ -26,6 +26,10 @@ //#define __SIMULATION__ //#define __PIPELINE__ #define __SCROLL__ +#define __ICONS__ +#define __MEASURE__ +#define __SELFTEST__ + /* * main.c */ diff --git a/plot.c b/plot.c index 8b662c8..0f6e086 100644 --- a/plot.c +++ b/plot.c @@ -1429,7 +1429,9 @@ draw_cell(int m, int n) if (n == 0) cell_draw_marker_info(x0, y0); #endif +#ifdef __SELFTEST__ cell_draw_test_info(x0, y0); +#endif // PULSE; // Draw reference position (<10 system ticks for all screen calls) for (t = 0; t < TRACES_MAX; t++) { diff --git a/sa_core.c b/sa_core.c index b725708..355b754 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1045,6 +1045,7 @@ static bool sweep(bool break_on_operation) } m++; // Try next marker } +#ifdef __MEASURE__ if (setting_measurement == M_IMD && markers[0].index > 10) { markers[1].enabled = search_maximum(1, frequencies[markers[0].index]*2, 8); markers[2].enabled = search_maximum(2, frequencies[markers[0].index]*3, 12); @@ -1059,6 +1060,7 @@ static bool sweep(bool break_on_operation) } else if (setting_measurement == M_PHASE_NOISE && markers[0].index > 10) { markers[1].index = markers[0].index + (setting_mode == M_LOW ? 290/4 : -290/4); // Position phase noise marker at requested offset } +#endif peakIndex = max_index[0]; peakLevel = actual_t[peakIndex]; peakFreq = frequencies[peakIndex]; @@ -1249,6 +1251,7 @@ void draw_cal_status(void) } // -------------------- Self testing ------------------------------------------------- +#ifdef __SELFTEST__ enum { TC_SIGNAL, TC_BELOW, TC_ABOVE, TC_FLAT, TC_MEASURE, TC_SET, TC_END, @@ -1569,10 +1572,13 @@ int add_spur(int f) } return 1; } +#endif void self_test(void) { -#if 0 +#ifdef __SELFTEST__ + + #if 0 in_selftest = true; reset_settings(M_LOW); test_prepare(4); @@ -1698,6 +1704,8 @@ void self_test(void) reset_settings(M_LOW); in_selftest = false; #endif + +#endif } void reset_calibration(void) @@ -1710,6 +1718,7 @@ const int power_rbw [5] = { 100, 300, 30, 10, 3 }; void calibrate(void) { +#ifdef __CALIBRATE__ int local_test_status; float last_peak_level; in_selftest = true; @@ -1766,6 +1775,7 @@ quit: sweep_mode = SWEEP_ENABLE; set_refer_output(0); reset_settings(M_LOW); +#endif } diff --git a/ui.c b/ui.c index ba27e04..290e3cd 100644 --- a/ui.c +++ b/ui.c @@ -1567,10 +1567,12 @@ draw_menu_buttons(const menuitem_t *menu) if (menu[i].type & MT_FORM) { ili9341_fill(active_button_start+2, y+2, active_button_width-4, FONT_GET_HEIGHT*2+8, bg); ili9341_drawstring_size(text, active_button_start+6, y+6, 2); +#ifdef __ICONS__ if (menu[i].type & MT_ICON) { blit16BitWidthBitmap(240,y+6,16,16,&left_icons[((menu[i].data >>4)&0xf)*16]); blit16BitWidthBitmap(256,y+6,16,16,&right_icons[((menu[i].data >>0)&0xf)*16]); } +#endif } else { if (menu_is_multiline(menu[i].label, &l1, &l2)) { #define BIG_BUTTON_FONT 1 @@ -1841,11 +1843,15 @@ lever_move_marker(int status) if (active_marker >= 0 && markers[active_marker].enabled) { if ((status & EVT_DOWN) && markers[active_marker].index > 0) { markers[active_marker].index -= step; + if (markers[active_marker].index < 5) + markers[active_marker].index = 5 ; markers[active_marker].frequency = frequencies[markers[active_marker].index]; redraw_marker(active_marker); } if ((status & EVT_UP) && markers[active_marker].index < sweep_points-1) { markers[active_marker].index += step; + if (markers[active_marker].index > POINTS_COUNT-5) + markers[active_marker].index = POINTS_COUNT-5 ; markers[active_marker].frequency = frequencies[markers[active_marker].index]; redraw_marker(active_marker); } diff --git a/ui_sa.c b/ui_sa.c index e8aefa4..705e227 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -65,6 +65,7 @@ extern int setting_step_delay; void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *bitmap); + const uint16_t left_icons [] = { #define I_EMPTY 0*16 @@ -333,7 +334,6 @@ const uint16_t right_icons [] = 0b0000000000000000, }; - enum { KM_START=1, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFPOS, KM_SCALE, KM_ATTENUATION, KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_10MHZ @@ -454,7 +454,8 @@ 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", "\2ATTENUATE\0 0-31dB", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL" + "error", "START", "STOP", "CENTER", "SPAN", "CW FREQ", "REFPOS", "SCALE", // 0-7 + "\2ATTENUATE\0 0-31dB", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL", "OFFSET" // 8-16 }; #endif @@ -630,6 +631,7 @@ static void menu_measure_cb(int item, uint8_t data) { (void)item; menu_move_back(); +#ifdef __MEASURE__ switch(data) { case M_OFF: // Off reset_settings(GetMode()); @@ -682,6 +684,7 @@ static void menu_measure_cb(int item, uint8_t data) break; } +#endif // selection = -1; ui_mode_normal(); // draw_cal_status();