mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
1eec8e170e
* restructured some files concerning flashrom access * added some ifdefs to shell commands
58 lines
1.5 KiB
C
58 lines
1.5 KiB
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <sht11.h>
|
|
#include <string.h>
|
|
|
|
#ifdef MODULE_SHT11
|
|
|
|
extern float sht11_temperature_offset;
|
|
|
|
void _get_humidity_handler(char* unused) {
|
|
uint8_t success;
|
|
sht11_val_t sht11_val;
|
|
success = sht11_read_sensor(&sht11_val, HUMIDITY|TEMPERATURE);
|
|
if (!success) {
|
|
printf("Error reading SHT11\n");
|
|
}
|
|
else {
|
|
printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%%\n",
|
|
sht11_val.relhum, sht11_val.relhum_temp);
|
|
}
|
|
}
|
|
void _get_temperature_handler(char* unused) {
|
|
uint8_t success;
|
|
sht11_val_t sht11_val;
|
|
success = sht11_read_sensor(&sht11_val, TEMPERATURE);
|
|
if (!success) {
|
|
printf("Error reading SHT11\n");
|
|
}
|
|
else {
|
|
printf("Temperature: %-6.2f°C\n", sht11_val.temperature);
|
|
}
|
|
}
|
|
void _get_weather_handler(char* unused) {
|
|
uint8_t success;
|
|
sht11_val_t sht11_val;
|
|
success = sht11_read_sensor(&sht11_val, HUMIDITY|TEMPERATURE);
|
|
if (!success) {
|
|
printf("Error reading SHT11\n");
|
|
}
|
|
else {
|
|
printf("Relative humidity: %5.2f%% / Temperature compensated humidity; %5.2f%% ",
|
|
sht11_val.relhum, sht11_val.relhum_temp);
|
|
printf("Temperature: %-6.2f°C\n", sht11_val.temperature);
|
|
}
|
|
}
|
|
|
|
void _set_offset_handler(char* offset) {
|
|
if (strlen(offset) == 6) {
|
|
puts("Usage: offset <OFFSET>");
|
|
}
|
|
else {
|
|
sscanf(offset, "offset %f", &sht11_temperature_offset);
|
|
printf("Temperature offset set to %f\n", sht11_temperature_offset);
|
|
}
|
|
}
|
|
|
|
#endif
|