24
24
static GIOChannel *hrm_io_channel = NULL;
26
static guint hrm_sid1, hrm_sid3;
26
static guint hrm_sid1, hrm_sid3;
29
29
void * get_hrm_data_thread(void *ptr);
38
38
global_reconnect_hrm = TRUE;
39
39
g_source_remove(watchdog);
41
g_source_remove(hrm_sid1);
42
g_source_remove(hrm_sid3);
41
g_source_remove(hrm_sid1);
42
g_source_remove(hrm_sid3);
45
45
#endif /* HAVE_BLUEZ */
54
54
PangoContext *context = NULL;
55
55
PangoLayout *layout = NULL;
56
56
PangoFontDescription *desc = NULL;
62
62
static int x = 10, y = 310;
63
63
static int width = 0, height = 0;
72
if(mouse_dx == 0 && mouse_dy == 0)
72
if(mouse_dx == 0 && mouse_dy == 0)
75
75
buffer = g_strdup_printf("%u", hrmdata->freq);
77
77
buffer = g_strdup_printf("--");
80
80
context = gtk_widget_get_pango_context (map_drawable);
81
81
layout = pango_layout_new (context);
82
82
desc = pango_font_description_new();
84
84
pango_font_description_set_absolute_size (desc, 50 * PANGO_SCALE);
85
85
pango_layout_set_font_description (layout, desc);
86
86
pango_layout_set_text (layout, buffer, strlen(buffer));
89
89
gc = gdk_gc_new (map_drawable->window);
92
92
color.red = (hrmdata->freq > MAX_HEART_FREQ) ? 0xffff : 0;
98
98
gdk_gc_set_rgb_fg_color (gc, &color);
101
101
hrm = hrmdata->freq;
105
105
if(hrm_tmp != hrm || force_redraw)
108
108
gdk_draw_drawable (
109
109
map_drawable->window,
110
110
map_drawable->style->fg_gc[GTK_WIDGET_STATE (map_drawable)],
114
114
width+10,height+10);
118
118
gdk_draw_layout(map_drawable->window,
124
124
pango_layout_get_pixel_size(layout, &width, &height);
130
130
pango_font_description_free (desc);
131
131
g_object_unref (layout);
140
140
#ifdef HAVE_BLUEZ
141
141
static GtkWidget *widget1=NULL, *widget2=NULL;
142
142
static gchar buffer[128];
145
145
widget1 = lookup_widget(window1, "label206");
146
146
widget2 = lookup_widget(window1, "label207");
149
149
g_snprintf (buffer, 128, _("<b><big>%d</big></b> <small>bpm</small>"),
151
151
gtk_label_set_label(GTK_LABEL(widget1), buffer);
187
187
(char *) buf, sizeof(buf),
188
188
&bytes_read, &error);
190
190
if(status == G_IO_STATUS_NORMAL)
194
194
if(hrm_status == 0)
196
196
if((bytes_read == 60) && (buf[0] == 2))
197
197
hrmdata->freq = buf[12];
199
199
if((bytes_read == 1) && (buf[0] == 2))
203
203
if(bytes_read == 59)
204
204
hrmdata->freq = buf[11];
210
210
g_source_remove(watchdog);
211
211
watchdog = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT_IDLE,60,reset_hrm_io,NULL,NULL);
216
216
printf("gio: %s \n", error->message);
221
221
if(hrmdata->freq < hrmdata->min && hrmdata->freq > 50)
222
222
hrmdata->min = hrmdata->freq;
223
223
if(hrmdata->freq > hrmdata->max && hrmdata->freq < 220)
266
266
printf("error opening hrm socket\n");
270
270
str2ba(global_hrm_bt_addr, &addr.rc_bdaddr);
272
272
addr.rc_family = AF_BLUETOOTH;
273
273
addr.rc_channel = 1;
275
275
conn = connect(hrm_sock, (struct sockaddr *)&addr, sizeof(addr));
277
277
printf("error connecting %s\n", global_hrm_bt_addr);
280
280
shutdown(hrm_sock, SHUT_RDWR);
283
283
global_reconnect_hrm = FALSE;
286
286
hrmdata = g_new0(hrm_data_t,1);
287
287
hrmdata->min = 999;
290
290
len = read(hrm_sock, buf, 500);
292
292
fprintf(stderr, "HRM Rcvd %i bytes", len);
295
295
watchdog = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT_IDLE,60,reset_hrm_io,NULL,NULL);
297
297
hrm_io_channel = g_io_channel_unix_new(hrm_sock);
298
298
g_io_channel_set_encoding(hrm_io_channel, NULL, &error);
299
299
g_io_channel_set_flags(hrm_io_channel, G_IO_FLAG_NONBLOCK, NULL);
301
301
hrm_sid1 = g_io_add_watch_full(hrm_io_channel, G_PRIORITY_HIGH_IDLE+200, G_IO_ERR | G_IO_HUP, cb_hrm_io_error, NULL, NULL);
302
302
hrm_sid3 = g_io_add_watch_full(hrm_io_channel, G_PRIORITY_HIGH_IDLE+200, G_IO_IN | G_IO_PRI, cb_hrm_data, NULL, NULL);