118 lines
6.5 KiB
C
118 lines
6.5 KiB
C
/*
|
|
* (c) 2011 Siegen, Germany by Nils Faerber <nils.faerber@kernelconcepts.de>
|
|
*
|
|
* license LGPL
|
|
*/
|
|
|
|
#ifndef _METAWATCH_H
|
|
#define _METAWATCH_H
|
|
|
|
#include <time.h>
|
|
#include "metawatch_protocol.h"
|
|
|
|
#define MW_PBUF_LEN 512
|
|
|
|
typedef struct _mwdevice_t {
|
|
int mw_fd; /* file decriptor for MW connection */
|
|
char pbuf[MW_PBUF_LEN]; /* protocol receive buffer */
|
|
int pbuf_len;
|
|
unsigned char devtype; /* the device type of the connected device */
|
|
unsigned char screen_mode; /* the current assumed screen mode */
|
|
/* watch message callbacks */
|
|
void (*mw_get_device_type_response_cb) (struct _mwdevice_t *mwdevice, unsigned char devtype, void *user_data);
|
|
void *mw_gdtypersp_data;
|
|
void (*mw_get_real_time_clock_response_cb) (struct _mwdevice_t *mwdevice, struct tm *mw_tm, void *user_data);
|
|
void *mw_grtcrsp_data;
|
|
void (*mw_get_battery_voltage_response_cb) (struct _mwdevice_t *mwdevice, unsigned short *voltage, unsigned short *voltage_avg, unsigned char *pgood, unsigned char *charging, void *user_data);
|
|
void *mw_gbatvrsp_data;
|
|
void (*mw_read_button_config_response_cb) (struct _mwdevice_t *mwdevice, void *user_data);
|
|
void *mw_rbtncnfrsp_data;
|
|
void (*mw_button_event_message_cb) (struct _mwdevice_t *mwdevice, unsigned char buttons, unsigned char options, void *user_data);
|
|
void *mw_btnevmsg_data;
|
|
void (*mw_read_light_sensor_response_cb) (struct _mwdevice_t *mwdevice, unsigned short *light_level, unsigned short *light_level_avg, void *user_data);
|
|
void *mw_rlsrsp_data;
|
|
void (*mw_status_change_event_cb) (struct _mwdevice_t *mwdevice, unsigned char *scrmode, unsigned char *status, void *user_data);
|
|
void *mw_stchev_data;
|
|
void (*mw_low_battery_warning_message_cb) (struct _mwdevice_t *mwdevice, void *user_data);
|
|
void *mw_lbatwarnmsg_data;
|
|
void (*mw_low_battery_bt_off_message_cb) (struct _mwdevice_t *mwdevice, void *user_data);
|
|
void *mw_lbatbtoff_data;
|
|
} mwdevice_t;
|
|
|
|
void dump_frame(unsigned char *frame, int len);
|
|
|
|
|
|
int mw_send_frame(mwdevice_t *mwdevice, unsigned char msg_type, unsigned char options, unsigned char *data, unsigned char len);
|
|
|
|
int mw_set_rtc(mwdevice_t *mwdevice, struct tm *mw_tm);
|
|
|
|
int mw_nval_operation(mwdevice_t *mwdevice, unsigned char operation, unsigned short identifier, unsigned char size, void *mdata);
|
|
|
|
int mw_set_vibrate_mode(mwdevice_t *mwdevice, unsigned char enable, unsigned short on_time, unsigned short off_time, unsigned char cycles);
|
|
|
|
int mw_configure_watch_mode(mwdevice_t *mwdevice, unsigned char mode, unsigned char save, unsigned char timeout, unsigned char invert);
|
|
|
|
int mw_update_display(mwdevice_t *mwdevice, unsigned char mode, unsigned char copy);
|
|
|
|
int mw_load_template(mwdevice_t *mwdevice, unsigned char mode, unsigned char template_select);
|
|
|
|
int mw_write_buffer(mwdevice_t *mwdevice,
|
|
unsigned char mode,
|
|
unsigned char numlines, /* number of lines, 0=two lines or 1=one line */
|
|
unsigned char row_offset, /* start at row_offset in display, e.g. lower part in idle @31 */
|
|
unsigned char *buffer, int buflen);
|
|
|
|
int mw_write_oled_buffer(mwdevice_t *mwdevice,
|
|
unsigned char mode, /* idle or scroll */
|
|
unsigned char oled, /* which OLED */
|
|
unsigned char numcols,
|
|
unsigned char col_index, /* starting index */
|
|
unsigned char *buffer, int buflen);
|
|
|
|
int mw_get_device_type_response(mwdevice_t *mwdevice, unsigned char devtype);
|
|
void mw_set_get_device_type_response_cb(mwdevice_t *mwdevice, void (*mw_get_device_type_response_cb) (mwdevice_t *mwdevice, unsigned char devtype, void *user_data), void *user_data);
|
|
|
|
int mw_get_real_time_clock_response(mwdevice_t *mwdevice, unsigned char *rtcrsp, int len);
|
|
void mw_set_get_real_time_clock_response_cb(mwdevice_t *mwdevice, void (*mw_get_real_time_clock_response_cb) (mwdevice_t *mwdevice, struct tm *mw_tm, void *user_data), void *user_data);
|
|
|
|
int mw_get_battery_voltage_response(mwdevice_t *mwdevice, unsigned char *batrsp, int len);
|
|
void mw_set_get_battery_voltage_response_cb(mwdevice_t *mwdevice, void (*mw_get_battery_voltage_response_cb) (mwdevice_t *mwdevice, unsigned short *voltage, unsigned short *voltage_avg, unsigned char *pgood, unsigned char *charging, void *user_data), void *user_data);
|
|
|
|
int mw_read_button_config_response(mwdevice_t *mwdevice, unsigned char *btnrsp, int len);
|
|
|
|
int mw_button_event_message(mwdevice_t *mwdevice, unsigned char *btnevt, int len, unsigned char opts);
|
|
void mw_set_button_event_message_cb(mwdevice_t *mwdevice, void (*mw_button_event_message_cb) (mwdevice_t *mwdevice, unsigned char buttons, unsigned char options, void *user_data), void *user_data);
|
|
|
|
int mw_read_light_sensor_response(mwdevice_t *mwdevice, unsigned char *lightrsp, int len);
|
|
void mw_set_read_light_sensor_response_cb(mwdevice_t *mwdevice, void (*mw_read_light_sensor_response_cb) (mwdevice_t *mwdevice, unsigned short *light_level, unsigned short *light_level_avg, void *user_data), void *user_data);
|
|
|
|
int mw_status_change_event(mwdevice_t *mwdevice, unsigned char option, unsigned char *statrsp, int len);
|
|
void mw_set_status_change_event_cb(mwdevice_t *mwdevice, void (*mw_status_change_event_cb) (mwdevice_t *mwdevice, unsigned char *scrmode, unsigned char *status, void *user_data), void *user_data);
|
|
|
|
int mw_low_battery_warning_message(mwdevice_t *mwdevice);
|
|
void mw_set_low_battery_warning_message_cb(mwdevice_t *mwdevice, void (*mw_low_battery_warning_message_cb) (mwdevice_t *mwdevice, void *user_data), void *user_data);
|
|
|
|
int mw_low_battery_bt_off_message(mwdevice_t *mwdevice);
|
|
void mw_set_low_battery_bt_off_message_cb(mwdevice_t *mwdevice, void (*mw_low_battery_bt_off_message_cb) (mwdevice_t *mwdevice, void *user_data), void *user_data);
|
|
|
|
int mw_enable_button(mwdevice_t *mwdevice, unsigned char mode, unsigned char button_index, unsigned char press_type, unsigned char callback_type, unsigned char callback_option);
|
|
|
|
int mw_disable_button(mwdevice_t *mwdevice, unsigned char mode, unsigned char button_index, unsigned char press_type);
|
|
|
|
int mw_advance_watch_hands(mwdevice_t *mwdevice, unsigned char hours, unsigned char minutes, unsigned char seconds);
|
|
|
|
int mw_battery_configuration(mwdevice_t *mwdevice, unsigned char warn_lvl, unsigned char bt_off_lvl);
|
|
|
|
int mw_decode_frame(mwdevice_t *mwdevice, unsigned char *buf, int len);
|
|
|
|
int mw_feed_msg_buffer(mwdevice_t *mwdevice, unsigned char *buf, int len);
|
|
|
|
int mw_init(mwdevice_t *mwdevice, int mw_fd);
|
|
|
|
/* helper function to flip bit order in a byte and optionally invert the image */
|
|
void bmap_buffer_flipinvert(unsigned char flip, unsigned char invert, unsigned char *buf, int len);
|
|
|
|
void mw_send_bitmap(mwdevice_t *mwdevice, unsigned char mode, int width, int height, int offset, unsigned char *bmapbuf, int buflen);
|
|
|
|
#endif /* _METAWATCH_H */
|
|
|