ttrftech / NanoVNA

Very Tiny Palmtop Vector Network Analyzer
1.06k stars 296 forks source link

Big code redisign (increase CELL draw size, more faster screen render) #120

Closed DiSlord closed 4 years ago

DiSlord commented 4 years ago

Also save about 4-5kB flash 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

DiSlord commented 4 years ago

I hope now code more easy to undestand and easy to change (need just redefine some size values), and old CELL_INDEX definition look very bad Then i increase CELLWIDTH, code not work, and i rewrite it, its take a lot of time, but interesting

edy555 commented 4 years ago

Excellent! Thanks for the great contribution.