(For faster screen update on marker move, all old area update info invalidate after use draw_all_cells(TRUE) on page switch)
Force redraw all cells after end marker move
#define FREQ_MODE_START_STOP 0x0
#define FREQ_MODE_CENTER_SPAN 0x1
Now sweep mode not defined from frequency0 > frequency1 or frequency0 < frequency1
frequency0 always < frequency1
All freq must get by use get_sweep_frequency(mode)
Revert Select CH0 reflect channel before set freq, add additional delay on 0 sweep point
Little code optimization
Add commented 600kHz I2C bus timings (work, give x1.5 speed, but need change DSP ready timings not by wait_count, need use chVTGetSystemTimeX() its better)
Improve sweep speed about 60%
Stop generation on pause sweep
Remove all hack for si5351
Reduce code size
Fix integer overflow on big freq values
Additional
Change I2C
Others:
move marker_tracking variable to ui config
move some definition to correct place
reduce tlv320aic3204 code size
Speedup marker move from lever (BUTTON_REPEAT_TICKS = 625)
Need test stability
CH_CFG_USE_WAITEXIT (used only is Shell run as thread)
CH_CFG_USE_EVENTS (NanoVNA not use events)
CH_CFG_USE_EVENTS_TIMEOUT (NanoVNA not use events)
Implement stack use check in "threads" command, now free stack space show in table as "stk free" in hex
Check stack usage by sweep, and main threads (seems all ok, but add 64 bytes to sweep)
Replace some const values to defined
Write simple profiling definitions
START_PROFILE
STOP_PROFILE
Use it for detect sys tick amount and output to screen
main.c
Reduce VNA_SHELL_MAX_LENGTH to 48, and made shell_line as static (reduce stack usage)
Remove BaseSequentialStream *chp from command calls (use static shell_stream), it reduce code size and stack usage
Use VNA_SHELL_FUNCTION definition for all commands
Remove chMtxLock(&mutex);chMtxUnlock(&mutex); from commands, and define command flag for use it in calls
Apply default scale from trace_info on trace change
Led blink outside from main sweep cycle (better look, and less noise)
Some size fixes
chprintf.c
Implement small memory stream object, only put function and plot_printf(char *str, int size, const char *fmt, ...)
Use it in all code (little increase speed, and huge decrease size)
Restore USE_EXCEPTIONS_STACKSIZE = 0x180 (possible not need, but not good tested)
plot.c
Made huge screen render profile (add some comments)
Not use cell clipping on draw cell data (use constants increase speed, decrease stack usage (not need put it to stack))
Clip cell if need only on screen flush
Use new plot_printf, remove chsnprintf usage
Apply code style
============================================================================================================
Interesting fact
Usage memset(spi_buffer, DEFAULT_BG_COLOR, (h*CELLWIDTH)*sizeof(uint16_t)); dramatically decrease render speed
possibly it fill buffer by 8 bit data, so slow
Usage
uint32_t *p = (uint32_t *)spi_buffer;
while (count--) {
p[0] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[1] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[2] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[3] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p+=4;
}
gives x10 speed perfomance
Draw polar and smit grid very slow (but i don`t know how increase it except use bitmaps, but it need about 5-8k flash size and file prepare)
On long lines render slow down, but clipping use more calculation, and not give good result
Need made stack usage check
Decrease interrupt stack size
Use __ROR instruction in flash.c for checksum rotate
Fix erase background for frequencies string in plot.c
Implement getStringIndex function for parse string arguments, now Usage show correct information about used arg, and more easy use strings definitions
Example:
Need check if string "on" in avaible arguments list "load|open|short|thru|isoln|done|on|off|reset|data|in"
getStringIndex("on", "load|open|short|thru|isoln|done|on|off|reset|data|in") return 6
If not found return -1
Not need use if (strcmp() == ...) else ....
This usage save some amount of size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
I can`t upload my version chprintf.c to ChibiOS\os\hal\lib\streams upload it to root :(
now support print float and Suffix if use example %.1F on 1.234e-3 print 1.234m, %F print 1.23m
now support + flag %+d on 8 print +8, %+d on -8 print -8
now support freq output if use %q example %q on 1234567890 print 1.234 567 890 GHz, %.8q print 1.234567GHz
fix rounding errors on print float example if print use %.2f on 2.199 print 2.20 (before 2.19)
Use it in code - made more compact (save about 2k bytes) and easy display values (set output more digits after . for some values)
Made some font glyph more compact, allow 3px glyph
More correct create frequencies table on big span (not use float operations), also produce more compact code
Use double value input from keyboard (not lost Hz on input)
Set sweep_points as uint Optimize set_sweep_frequency size
Fix freq commands broken after freq set as uint32 (add str to uint32 functions for freq bigger then 2 147 483 647):
cmd_freq
cmd_offset
cmd_threshold
cmd_scan
cmd_sweep
Define _isdigit macro (replace isdigit() function, its too big)
Rewrite std universal atoi() to more compact my_atoi and write new unsigned variant my_atoui
fix 'micro' char in font
fix draw STOP distance in frequency field
fix x position calc in plot_into_index
fix frequencies delta defined as int in plot.c
fix frequencies defined as int in ui.c
Set menuitem_t size align as WORD (more compact on flash)
Add data to menuitem_t (more easy use callback functions, and save its sizing)
Rewrite some ui callback functions for use data field
More better look infinity and delta symbols
Fix grid sizing in update_grid (broken after frequency0 and frequency1 set as uint)
Rework display spi driver:
use DMA for read, write
add blitBitmap functions
Use DMA for color fill
More correct SPI bus control
Move color definitions to nanovna.h
Some code optimization for speed and size (save about 3k bytes)
Change grid Y resolution to 10
Fix convert from float to int (fix some rounding errors on plot)
Disable unused HAL serial
Change battery icon