plugins/hddtemp/hddTemp.c

00001 /*
00002  * Copyright Ian Burnett 2005, 2006.
00003  *
00004  * This file is part of Ian's Interactive LCD controller (IILC).
00005  * 
00006  * IILC is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU General Public License as published by the Free
00008  * Software Foundation; either version 2 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * IILC is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00014  * for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with IILC; if not, write to the Free Software Foundation, Inc.,
00018  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
00019  */
00020 
00021 #include "hddTemp.h"
00022 
00023 
00024 typedef struct _tag_screen_temp
00025 {
00026     double temp;
00027 
00028 
00029 } SCREEN_TEMP, * LPSCREEN_TEMP;
00030 
00031 
00032 void temperatureReport(void * context,
00033                        unsigned int sensor_id,
00034                        double degrees_c,
00035                        const char * pszName);
00036 
00037 int ModuleCreate(int handle, void ** context, LPMODULE_FN_ARRAY pFnArray)
00038 {
00039     LPSCREEN_TEMP pInst = NULL;
00040 
00041     /* Create our own scratch space */
00042     pInst = malloc(sizeof(SCREEN_TEMP));
00043     *context = pInst;
00044 
00045     /* We can use fn array version 1 */
00046     pFnArray->version = 1;
00047 
00048     /* Setup our various functions */
00049     pFnArray->pfnTextData = GetDisplayData;
00050     pFnArray->pfnTempReport = temperatureReport;
00051 
00052     return 0;
00053 }
00054 
00055 
00056 int ModuleDestroy(void * context)
00057 {
00058     LPSCREEN_TEMP pInst = (LPSCREEN_TEMP) context;
00059 
00060     /* Release the scratch storage array */
00061     free(pInst);
00062 
00063     return 0;
00064 }
00065 
00066 
00067 int GetDisplayData(void * context, LPSCREEN pScreen, char ** buf)
00068 {
00069     LPSCREEN_TEMP pInstance = (LPSCREEN_TEMP) context;
00070 
00071     sprintf(*buf, "%.1f%cC", pInstance->temp, 0x80);
00072     
00073     return 0;
00074 }
00075 
00076 void temperatureReport(void * context, unsigned int sensor_id, double degrees_c, const char * pszName)
00077 {
00078     LPSCREEN_TEMP pInst = (LPSCREEN_TEMP) context;
00079 
00080     pInst->temp = degrees_c;
00081 }

Generated on Mon Jul 17 01:36:11 2006 for IILC by  doxygen 1.4.6