Use methods to set/clear/query error flags (#71)

Easier to read, quicker to write (if using code
completion), no performance loss due to inlining.
This commit is contained in:
hogthrob
2019-11-02 08:22:00 +01:00
committed by Martin Jäger
parent b09f4ca809
commit fd474e5350
4 changed files with 31 additions and 20 deletions
+4
View File
@@ -90,6 +90,10 @@ public:
// instantaneous device-level data
uint32_t error_flags; ///< Currently detected errors
float internal_temp; ///< Internal temperature (measured in MCU)
void set_error(ErrorFlag e) { error_flags |= (1U << e); }
void clear_error(ErrorFlag e) { error_flags &= ~(1U << e); }
bool has_error(ErrorFlag e) { return (error_flags & (1U << e)) != 0; }
};
#endif /* DEVICE_STATUS_H */