forked from edorfaus/TEMPered
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from mwerezak/weber-software-master
Added support for 413d:2107 TEMPerGold_V3.1
- Loading branch information
Showing
3 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdbool.h> | ||
#include <string.h> | ||
|
||
#include "type-info.h" | ||
#include "../tempered-internal.h" | ||
|
||
bool tempered_type_hid_get_temperature_simple( | ||
tempered_device *device, struct tempered_type_hid_sensor *sensor, | ||
struct tempered_type_hid_query_result *group_data, float *tempC | ||
) { | ||
if ( | ||
group_data->length <= sensor->temperature_high_byte_offset || | ||
group_data->length <= sensor->temperature_low_byte_offset | ||
) { | ||
tempered_set_error( | ||
device, strdup( "Not enough data was read from the sensor." ) | ||
); | ||
return false; | ||
} | ||
|
||
int low_byte_offset = sensor->temperature_low_byte_offset; | ||
int high_byte_offset = sensor->temperature_high_byte_offset; | ||
int temp = ( group_data->data[low_byte_offset] & 0xFF ) | ||
+ ( (signed char)group_data->data[high_byte_offset] << 8 ) | ||
; | ||
|
||
*tempC = temp / 100.0; | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef TEMPERED__TYPE_HID__SIMPLE_H | ||
#define TEMPERED__TYPE_HID__SIMPLE_H | ||
|
||
#include <stdbool.h> | ||
|
||
#include "type-info.h" | ||
|
||
bool tempered_type_hid_get_temperature_simple( | ||
tempered_device *device, struct tempered_type_hid_sensor *sensor, | ||
struct tempered_type_hid_query_result *group_data, float *tempC | ||
); | ||
|
||
#endif |