/* $Id$ * $URL$ * * timer widget handling * * Copyright (C) 2006 Michael Reinelt * Copyright (C) 2006 The LCD4Linux Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * exported functions: * * WIDGET_CLASS Widget_Timer * the timer widget * */ #include "config.h" #include #include #include #include #include "debug.h" #include "cfg.h" #include "qprintf.h" #include "property.h" #include "timer.h" #include "widget.h" #include "widget_timer.h" #ifdef WITH_DMALLOC #include #endif void widget_timer_update(void *Self) { WIDGET *W = (WIDGET *) Self; WIDGET_TIMER *Timer = W->data; int update, active; /* evaluate expressions */ property_eval(&Timer->update); property_eval(&Timer->active); /* get new update interval */ update = P2N(&Timer->update); if (update < 10) update = 10; /* finally, fire it! */ active = P2N(&Timer->active); if (active > 0) { property_eval(&Timer->expression); } /* add a new one-shot timer */ timer_add(widget_timer_update, Self, update, 1); } int widget_timer_init(WIDGET * Self) { char *section; WIDGET_TIMER *Timer; /* prepare config section */ /* strlen("Widget:")=7 */ section = malloc(strlen(Self->name) + 8); strcpy(section, "Widget:"); strcat(section, Self->name); Timer = malloc(sizeof(WIDGET_TIMER)); memset(Timer, 0, sizeof(WIDGET_TIMER)); /* load properties */ property_load(section, "expression", NULL, &Timer->expression); property_load(section, "update", "100", &Timer->update); property_load(section, "active", "1", &Timer->active); free(section); Self->data = Timer; /* just do it! */ widget_timer_update(Self); return 0; } int widget_timer_quit(WIDGET * Self) { if (Self) { /* do not deallocate child widget! */ if (Self->parent == NULL) { if (Self->data) { WIDGET_TIMER *Timer = Self->data; property_free(&Timer->expression); property_free(&Timer->update); property_free(&Timer->active); free(Self->data); Self->data = NULL; } } } return 0; } int widget_timer_register(void) { WIDGET_CLASS wc; wc = Widget_Timer; widget_register(&wc); return 0; } WIDGET_CLASS Widget_Timer = { name:"timer", type:WIDGET_TYPE_TIMER, init:widget_timer_init, draw:NULL, quit:widget_timer_quit, }; 011-07-27picoLCDGraphics needs keypad linkedmichael2-0/+2 2011-07-27various compiler warnings fixedmichael13-60/+39 2011-07-27Autoconf 2.68michael3-1455/+2751 2011-07-27run smoketest on all of my 8 coresmichael1-2/+2 2011-07-27indentationmichael4-330/+320 2011-07-27patch to replace outdate library libmpd with recent library libmpdclient from...michael2-240/+427 2011-07-27lcd4linux-wireless.patch from Hans de Goedemichael1-1/+1 2011-07-27st2205-width-height-swap.patch from Hans de Goedemichael1-2/+2 2011-07-27hwmon patch from Hans de Goedemichael1-0/+14 2011-07-27patch to support SureElectronicsDE-LD023 from Matt Joicemichael1-3/+16 2011-05-06Fixed keypad widget in GLCD2USBharbaum1-0/+7 2011-02-12timer.c: fixed detection of positive clock skew (and some typos)mzuther4-10/+10 2011-01-23timer.c: fixed clock skew detectionmzuther1-26/+46 2011-01-23timer.c: skip intermediate timer intervalsmzuther2-16/+46 2011-01-05fix for a bug introduced in the DE-LD021 drivermichael1-3/+3 2011-01-04indentationmichael2-3/+3 2011-01-04support for Sure Electronics DE-LD021 by Natanael Olaizmichael1-10/+8 2011-01-02driver for EFN LED modules by Tilman Glötznermichael9-21/+469 2010-11-28commented, corrected and beautified both timer and timer group codemzuther11-197/+511 2010-11-27finished commenting the timer codemzuther2-46/+138 2010-11-20started commenting the timer codemzuther5-52/+170 2010-11-19Added brightness support for GLCD2USBharbaum5-28/+8014