00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00054 pInst = malloc(sizeof(SCREEN_TEMP));
00055 *context = pInst;
00056
00057
00058 pFnArray->version = 1;
00059
00060
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
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