* changed API for rtc
* added drivers directory to doxygen file * added missing include to sht11 header * added rtc and sht11 support to default project * added rtc to auto_init * added rtc and sht11 support to shelldev/timer
parent
ba03f610c4
commit
3b218ec24a
@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <lpc2387-rtc.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
void _gettime_handler(char *unused) {
|
||||
struct tm now;
|
||||
rtc_get_localtime(&now);
|
||||
|
||||
printf("%s", asctime(&now));
|
||||
}
|
||||
|
||||
void _settime_handler(char* c) {
|
||||
struct tm now;
|
||||
int res;
|
||||
uint16_t month, epoch_year;
|
||||
|
||||
res = sscanf(c, "settime %hu-%hu-%i %i:%i:%i",
|
||||
&epoch_year,
|
||||
&month,
|
||||
&(now.tm_mday),
|
||||
&(now.tm_hour),
|
||||
&(now.tm_min),
|
||||
&(now.tm_sec));
|
||||
|
||||
if (res < 6) {
|
||||
printf("Usage: settime YYYY-MM-DD hh:mm:ss\n");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
printf("OK %s", asctime(&now));
|
||||
}
|
||||
|
||||
now.tm_year = epoch_year - 1900;
|
||||
now.tm_mon = month - 1;
|
||||
time_t t = mktime(&now);
|
||||
rtc_set(t);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <sht11.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue