00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <time.h>
00022
00023 #if defined(_WIN32)
00024 #else
00025 # include <strings.h>
00026 #endif
00027
00028 #include "scrLED.h"
00029
00030 typedef struct _tag_screen_fans
00031 {
00033 unsigned int fanCount;
00034
00036 unsigned int * rpmList;
00037
00038 } SCREEN_FANS, * LPSCREEN_FANS;
00039
00040
00041
00042
00043
00044 int fanSpeedReport(void * context,
00045 unsigned int fan_id,
00046 unsigned int fan_speed);
00047
00048
00049
00050
00051
00052
00053 int ModuleCreate(int handle, void ** context, LPMODULE_FN_ARRAY pFnArray)
00054 {
00055 int rc = 0;
00056
00057 LPSCREEN_FANS pInst = NULL;
00058
00059
00060 pInst = malloc(sizeof(SCREEN_FANS));
00061 if (pInst == NULL) {
00062 printf("malloc() failed in Fans module create");
00063 rc = -1;
00064 goto end_of_function;
00065 }
00066
00067
00068 pInst->fanCount = 1;
00069
00070
00071 pInst->rpmList = calloc(pInst->fanCount, sizeof(unsigned int));
00072
00073
00074
00075
00076 pFnArray->version = 1;
00077
00078
00079 pFnArray->pfnTextData = GetDisplayData;
00080 pFnArray->pfnReadLEDStatus = GetLEDStatus;
00081
00082
00083
00084
00085 *context = pInst;
00086
00087 end_of_function:
00088
00089 return rc;
00090 }
00091
00092
00093 int ModuleDestroy(void * context)
00094 {
00095 LPSCREEN_FANS pInst = (LPSCREEN_FANS) context;
00096
00097 free(pInst);
00098
00099 return 0;
00100 }
00101
00102
00103 int GetDisplayData(void * context, LPSCREEN pScreen, char ** buf)
00104 {
00105 LPSCREEN_FANS pInstance = (LPSCREEN_FANS) context;
00106
00107 char * lfChar = NULL;
00108
00109
00110 sprintf(*buf, "FAN %u: %u RPM", 0, pInstance->rpmList[0]);
00111
00112 return 0;
00113 }
00114
00115 int GetLEDStatus(void * context, unsigned int led_id,
00116 LPCOLOUR pColourOn, LPCOLOUR pColourOff,
00117 unsigned int * pDutyCycle, unsigned int * pFreq)
00118 {
00119 SET_COLOUR(pColourOn, 100, 0, 0);
00120 SET_COLOUR(pColourOff, 0, 100, 0);
00121
00122
00123 *pDutyCycle = 50;
00124
00125
00126 *pFreq = 50 + (25 * led_id);
00127
00128 return 0;
00129 }
00130