28 lines
623 B
C
28 lines
623 B
C
/* see LICENSE file for details on license */
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include "module.h"
|
|
#include "file.c"
|
|
#include "thermal.h"
|
|
|
|
int convert_milli_to_reg(int millidegree) {
|
|
return millidegree / 1000;
|
|
}
|
|
|
|
int thermal_update(struct module *module) {
|
|
char *filepath = THERMAL_PRE THERMAL_DIR THERMAL_TMP;
|
|
int i;
|
|
|
|
i = read_file_into_buffer(filepath, (char *)&module->buffer, MODULE_BUFFER_LEN);
|
|
if(i == -1) return i; /* indicate an error */
|
|
|
|
i = atoi((char *)&module->buffer);
|
|
if(!i) return -1;
|
|
|
|
i = convert_milli_to_reg(i);
|
|
snprintf((char *)&module->buffer, MODULE_BUFFER_LEN, "%i", i);
|
|
|
|
return 0;
|
|
}
|