plugins/temp/scrTemp.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 "trace.h"
00022 
00023 #include "scrTemp.h"
00024 
00025 
00026 #define IILC_MODULE MODULE_TYPE_DISPLAY
00027 
00028 
00029 typedef struct _tag_screen_temp
00030 {
00031     double temp;
00032 
00033     const char * pszName;
00034 
00035 } SCREEN_TEMP, * LPSCREEN_TEMP;
00036 
00037 
00038 void temperatureReport(void * context,
00039                        unsigned int sensor_id,
00040                        double degrees_c,
00041                        const char * pszName);
00042 
00043 void fanSpeedReport(void * context, 
00044                     unsigned int fan_id, 
00045                     unsigned int fan_speed, 
00046                     const char * pszName);
00047 
00048 
00049 int ModuleCreate(int handle, void ** context, LPMODULE_FN_ARRAY pFnArray)
00050 {
00051     LPSCREEN_TEMP pInst = NULL;
00052 
00053     /* Create our own scratch space */
00054     pInst = malloc(sizeof(SCREEN_TEMP));
00055     *context = pInst;
00056 
00057     /* We can use fn array version 1 */
00058     pFnArray->version = 1;
00059 
00060     /* Setup our various functions */
00061     pFnArray->pfnTextData = GetDisplayData;
00062     pFnArray->pfnTempReport = temperatureReport;
00063     pFnArray->pfnFanSpeedReport = fanSpeedReport;
00064 
00065     return 0;
00066 }
00067 
00068 
00069 int ModuleDestroy(void * context)
00070 {
00071     LPSCREEN_TEMP pInst = (LPSCREEN_TEMP) context;
00072 
00073     /* Release the scratch storage array */
00074     free(pInst);
00075 
00076     return 0;
00077 }
00078 
00079 
00080 int GetDisplayData(void * context, int nRow, int nWidth, char * buf)
00081 {
00082     LPSCREEN_TEMP pInstance = (LPSCREEN_TEMP) context;
00083 
00084     sprintf(buf, "%.1f%cC", pInstance->temp, 0x80);
00085     
00086     return 0;
00087 }
00088 
00089 void temperatureReport(void * context, unsigned int sensor_id, double degrees_c, const char * pszName)
00090 {
00091     LPSCREEN_TEMP pInst = (LPSCREEN_TEMP) context;
00092 
00093     IILC_TRACE_ENTRY(IILC_MODULE, T_temperatureReport);
00094     traceDebug(IILC_TRACE_CONTEXT, 
00095         "pInst %p, sensor_id %u, degrees_c %f", pInst, sensor_id, degrees_c);
00096 
00097     pInst->temp = degrees_c;
00098     pInst->pszName = pszName;
00099 
00100     traceInfo(IILC_TRACE_CONTEXT, "(TEMP) Temperature report for sensor [%10s] at %.0fC", pszName, degrees_c);
00101 
00102     IILC_TRACE_EXIT;
00103 }
00104 
00105 
00106 void fanSpeedReport(void * context, unsigned int fan_id, unsigned int fan_speed, const char * pszName)
00107 {
00108     IILC_TRACE_ENTRY(IILC_MODULE, T_fanSpeedReport);
00109 
00110     fan_speed = (((fan_speed * 2) + 5) / 10) * 5;
00111 
00112     traceInfo(IILC_TRACE_CONTEXT, "(TEMP) Fan speed report of sensor    [%10s] at %u RPM", pszName, fan_speed);
00113     
00114     IILC_TRACE_EXIT;
00115 }
00116 

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