gfroerli / firmware

Firmware for the water temperature sensor project
GNU General Public License v3.0
6 stars 1 forks source link

Implement HardwareVersionDetector #60

Closed dbrgn closed 4 years ago

dbrgn commented 4 years ago

A simple hardware version detector on PA12 / PB4 / PB5.

2020-05-13-000222_735x627_scrot

Current output via serial:

2020-05-13-000330_433x52_scrot

Should we keep the hardware version as an integer, or should I map it to an enum (where 0 would correspond to V2_0 and others would correspond to Unknown(u8))?

rnestler commented 4 years ago

Should we keep the hardware version as an integer, or should I map it to an enum (where 0 would correspond to V2_0 and others would correspond to Unknown(u8))?

The enum would probably make the handling more readable:

match hw_version {
    HardwareVersion::V2_0 => {},
    HardwareVersion::Unsupported(version) => { panic!("Unsupported hardware version {}",  version); }
}
dbrgn commented 4 years ago

Updated, I confirmed that it works!