jancumps / pico_scpi_usbtmc_labtool

LabVIEW compatible instrument on a Raspberry Pico
https://github.com/jancumps/pico_scpi_usbtmc_labtool/wiki
MIT License
13 stars 17 forks source link

all register scpi use same reader writer func #55

Closed jancumps closed 1 year ago

jancumps commented 1 year ago

all register setters and getters share the same logic. Initially, I created a handler for each register's SCPI commands.
They have the same code, except for the register name.
This pull request refactors this into 1 setter and 1 getter. It reduces each SCPI command handler to a 1 line function body. And the common code is placed in 2 helper functions.

It saves lines of code, but the main goal is to not have almost identical code in a number of functions.
Can also be used for any addition register support we add.

closes #53