CFLAGS = -Wall -g -DDEBUG -O2 $(CCFLAGS) `pkg-config --cflags glib-2.0` `pkg-config --cflags dbus-glib-1` `pkg-config --cflags dbus-1` `pkg-config --cflags libsoup-2.4`
#CFLAGS = -Wall -O2 $(CCFLAGS)
-LDFLAGS = `pkg-config --libs glib-2.0` `pkg-config --libs dbus-glib-1` `pkg-config --libs dbus-1` `pkg-config --libs libxml-2.0` `pkg-config --libs libsoup-2.4`
+LDFLAGS = -lm `pkg-config --libs glib-2.0` `pkg-config --libs dbus-glib-1` `pkg-config --libs dbus-1` `pkg-config --libs libxml-2.0` `pkg-config --libs libsoup-2.4`
PRGNAME = metawatch
x2 = tmp;
tmp = 48 + (48. * sin(((2. * M_PI) / 12.) * (double)i));
y2 = tmp;
- mw_buf_draw_line_bresenham(mwbuf, x, y, x2, y2, MW_WHITE);
+ mw_buf_draw_line_bresenham_w(mwbuf, x, y, x2, y2, 2, MW_WHITE);
};
// Hour
g_print("hour = %d -> %f (%f)\n", hour, (double)hour + mf, mf);
x = tmp;
tmp = 48 + (30. * sin(((2. * M_PI) / 12.) * ((double)hour + mf)));
y = tmp;
- mw_buf_draw_line_bresenham(mwbuf, 48, 48, x, y, MW_WHITE);
+ mw_buf_draw_line_bresenham_w(mwbuf, 48, 48, x, y, 2, MW_WHITE);
// Minute
tmp = 48. + (40. * cos(((2. * M_PI) / 60.) * (double)minute));
x = tmp;
tmp = 48 + (40. * sin(((2. * M_PI) / 60.) * (double)minute));
y = tmp;
- mw_buf_draw_line_bresenham(mwbuf, 48, 48, x, y, MW_WHITE);
+ mw_buf_draw_line_bresenham_w(mwbuf, 48, 48, x, y, 2, MW_WHITE);
snprintf(daystr, 5, "%d", day);
mw_buf_print(mwbuf, 74, 45, daystr, 0, MW_WHITE, MW_BLACK);
}
if (strncmp(cmd, "dana", 4) == 0) {
if (pcnt < 3)
- g_print("two few params, hour minute\n");
+ g_print("two few params, hour minute, day of month\ndana h m d\n");
else {
draw_app_ana_clock(&mwdata->mwdevice, atoi(params[0]), atoi(params[1]), atoi(params[2]));
}
}
}
+void mw_buf_draw_line_bresenham_w(mw_buffer *mwbuf, unsigned int xstart, unsigned int ystart, unsigned int xend, unsigned int yend, unsigned char thickness, mw_color clr)
+{
+ int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
+
+ dx = xend - xstart;
+ dy = yend - ystart;
+
+ incx = (dx >= 0) ? 1 : -1;
+ incy = (dy >= 0) ? 1 : -1;
+
+ if (dx<0)
+ dx = -dx;
+ if (dy<0)
+ dy = -dy;
+
+ if (dx>dy) {
+ pdx = incx; pdy = 0;
+ ddx=incx; ddy=incy;
+ es =dy; el =dx;
+ } else {
+ pdx=0; pdy=incy;
+ ddx=incx; ddy=incy;
+ es =dx; el =dy;
+ }
+
+ x = xstart;
+ y = ystart;
+ err = el/2;
+ mw_buf_draw_pixel(mwbuf, x, y, clr);
+ for (i=1; i<thickness; i++) {
+ mw_buf_draw_pixel(mwbuf, x-i, y, clr);
+ mw_buf_draw_pixel(mwbuf, x+i, y, clr);
+ mw_buf_draw_pixel(mwbuf, x, y-i, clr);
+ mw_buf_draw_pixel(mwbuf, x, y+i, clr);
+ }
+
+ for (t = 0; t < el; ++t) {
+ err -= es;
+ if (err < 0) {
+ err += el;
+ x += ddx;
+ y += ddy;
+ } else {
+ x += pdx;
+ y += pdy;
+ }
+ mw_buf_draw_pixel(mwbuf, x, y, clr);
+ for (i=1; i<thickness; i++) {
+ mw_buf_draw_pixel(mwbuf, x-i, y, clr);
+ mw_buf_draw_pixel(mwbuf, x+i, y, clr);
+ mw_buf_draw_pixel(mwbuf, x, y-i, clr);
+ mw_buf_draw_pixel(mwbuf, x, y+i, clr);
+ }
+ }
+}
/* ----------------------------------------------------------------------
* Complex combined functions, for user convenience
void mw_buf_print(mw_buffer *mwbuf, unsigned int x, unsigned int y, char *text, unsigned char fsize, mw_color fgclr, mw_color bgclr);
void mw_buf_draw_line_bresenham(mw_buffer *mwbuf, unsigned int xstart, unsigned int ystart, unsigned int xend, unsigned int yend, mw_color clr);
+void mw_buf_draw_line_bresenham_w(mw_buffer *mwbuf, unsigned int xstart, unsigned int ystart, unsigned int xend, unsigned int yend, unsigned char thickness, mw_color clr);
void mw_do_notification(mwdevice_t *mwdevice, char *title, char *text, unsigned char vibrate);