Looking good. Things to consider:
-
Some (most?) ADC’s have an external reference voltage – sometimes VCC, often a separate reference pin. Maybe replace the FS param/attribute with an input port/reference voltage.
-
It would be possible for the input voltage being measured to be greater than the reference voltage or less than 0V. Maybe clip the min/max digitized value to 0-255.
Just thoughts.
–robert