From c31d619c83ba2a6c7c803082e804d18da657a389 Mon Sep 17 00:00:00 2001 From: John Klug Date: Wed, 23 May 2018 10:14:11 -0500 Subject: Merge in global logic mts-io hotspot code. --- io-module/buttons.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 io-module/buttons.h (limited to 'io-module/buttons.h') diff --git a/io-module/buttons.h b/io-module/buttons.h new file mode 100644 index 0000000..d324929 --- /dev/null +++ b/io-module/buttons.h @@ -0,0 +1,84 @@ +/* + * buttons.h + * + * Created on: Apr 27, 2018 + * Author: leonid + */ + +#ifndef IO_MODULE_BUTTONS_H_ +#define IO_MODULE_BUTTONS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mts_io.h" + +#define NEW_BUTTON_INTERFACE + +#define BUTTON_CHECK_PER_SEC 8 +#define BUTTON_INTERVAL (HZ / BUTTON_CHECK_PER_SEC) +#define BUTTON_HOLD_COUNT (BUTTON_CHECK_PER_SEC * 3) +#define BUTTON_LONG_HOLD_COUNT (BUTTON_CHECK_PER_SEC * 30) + +typedef struct button_info { + char name[32]; + char label_pin[32]; + char label_monitor[32]; + char label_monitor_intervals[32]; + + /* PID to notify */ + pid_t pid; + + /* Unix signals */ + int short_signal; + int long_signal; + int extra_long_signal; + + /* Monitor intervals */ + int short_interval; + int long_interval; + + /* Internal fields */ + int pressed_count; + bool sent_extra_long; +} button_info_t, *button_info_pt; + +extern void init_buttons(void); +extern void cleanup_buttons(void); +extern int set_buttons (button_info_pt* platform_buttons); + +extern ssize_t mts_attr_show_button_monitor_intervals(struct device *dev, struct device_attribute *attr, char *buf); +extern ssize_t mts_attr_store_button_monitor_intervals(struct device *dev, struct device_attribute *attr, char *buf, size_t count); +extern ssize_t mts_attr_show_button_monitor(struct device *dev, + struct device_attribute *attr, + char *buf); +extern ssize_t mts_attr_store_button_monitor(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count); + +// Reset button is common for all devices. It is defined in buttons.c + +extern button_info_t reset_button; +extern struct device_attribute dev_attr_reset_monitor_intervals; +extern struct device_attribute dev_attr_reset_monitor; +extern struct device_attribute dev_attr_reset; +extern button_info_pt default_buttons[]; + +#endif /* IO_MODULE_BUTTONS_H_ */ -- cgit v1.2.3