X-Git-Url: http://git.itanic.dy.fi/?p=log-plotter;a=blobdiff_plain;f=plotter_status.h;fp=plotter_status.h;h=a920c9e258a4e488acba51abe03565f7db012620;hp=0000000000000000000000000000000000000000;hb=3870f4e94d04c2f900ab07100d2f2a4b577c851a;hpb=fbe43f1acc6fc7280b0efd230c3e86009f5a1c0d diff --git a/plotter_status.h b/plotter_status.h new file mode 100644 index 0000000..a920c9e --- /dev/null +++ b/plotter_status.h @@ -0,0 +1,53 @@ +#ifndef _PLOTTER_STATE_ +#define _PLOTTER_STATE_ + +enum system_status { + SYSTEM_STATUS_NO_USB = -1, + SYSTEM_STATUS_UNKNOWN, + SYSTEM_STATUS_CHARGING, + SYSTEM_STATUS_DISCHARGING, + SYSTEM_STATUS_MONITORING, + SYSTEM_STATUS_COMPLETED = 6, +}; + +struct log_plotter_status { + int old_system_status; + int system_status; +}; + +extern struct log_plotter_status plotter_state; + +static inline void set_plotter_system_status(int new_status) +{ + plotter_state.system_status = new_status; +} + +static inline char *state_to_str(int state) +{ + switch (state) { + case SYSTEM_STATUS_NO_USB: + return "No USB"; + + case SYSTEM_STATUS_CHARGING: + return "Charging"; + + case SYSTEM_STATUS_DISCHARGING: + return "Discharging"; + + case SYSTEM_STATUS_MONITORING: + return "Monitoring"; + + case SYSTEM_STATUS_COMPLETED: + return "Completed"; + + default: + return "Unknown"; + } +} + +static inline int state_has_changed(void) +{ + return plotter_state.old_system_status != plotter_state.system_status; +} + +#endif