Commit ba4f550806460eb5d2124aae9022b5a0b54270c6

Authored by Imanol-Mikel Barba Sabariego
1 parent bbea0c5b

--no commit message

Project/applications/smartcities/include/sensors.h
... ... @@ -10,7 +10,7 @@
10 10  
11 11 #define LIGHT_ADDR 0x39
12 12 #define DISTANCE_ADDR 0x01
13   -#define PRESSURE_ADDR 0x77
  13 +#define PRESSURE_ADDR 0x77 //Cambiar a MPL115A
14 14 #define HUMIDITY_TEMP_ADDR 0x27
15 15 //REMEMBER TO UPDATE I2C_scan ROUTINE WITH EACH NEW SENSOR!!!!
16 16 #define TOTAL_SENSORS 4
... ... @@ -36,12 +36,15 @@ extern sensor pressure_sensor;
36 36 uint32_t get_light_data(void);
37 37 uint16_t get_light_ch0(void);
38 38 uint16_t get_light_ch1(void);
  39 +char* light_value(uint32_t light);
39 40  
40 41 //ULTRASONIC SENSOR
41 42 uint16_t get_distance_data(void);
42 43 void init_ultrasound(void);
43 44 uint8_t get_distance_low(void);
44 45 uint8_t get_distance_high(void);
  46 +char* distance_value(uint16_t distance);
  47 +
45 48  
46 49 //PRESSURE SENSOR
47 50 typedef struct {
... ... @@ -61,6 +64,7 @@ typedef struct {
61 64 uint16_t get_pressure_data(void);
62 65 bmp085_callibration get_pressure_callibration_data(void);
63 66 char* callibration_pressure_data_csv(bmp085_callibration parameters);
  67 +char* pressure_value(uint16_t pressure);
64 68 void init_pressure(void);
65 69  
66 70 //HUMIDITY AND TEMPERATURE SENSOR
... ... @@ -68,5 +72,6 @@ void init_pressure(void);
68 72 void init_humidity_temp(void);
69 73 uint16_t get_humidity_data(void);
70 74 uint16_t get_temperature_data(void);
  75 +char* temp_humidity_value(uint16_t temp, uint16_t humidity);
71 76  
72 77 #endif
... ...
Project/applications/smartcities/sensors.c
... ... @@ -3,7 +3,7 @@
3 3 sensor light_sensor = {LIGHT_ADDR, "Light sensor", "illumination", "lux",NULL};
4 4 sensor ultrasound_sensor = {DISTANCE_ADDR, "Ultrasound sensor", "distance", "cm",NULL};
5 5 sensor pressure_sensor = {PRESSURE_ADDR, "Pressure sensor", "pressure", "kPa",NULL};
6   -sensor humidity_temp_sensor = {HUMIDITY_TEMP_ADDR, "Humidity and Temperature","ºC,RH",NULL};
  6 +sensor humidity_temp_sensor = {HUMIDITY_TEMP_ADDR, "Humidity and Temperature","ºC,RH",NULL};
7 7  
8 8 uint32_t get_light_data(void)
9 9 {
... ... @@ -260,3 +260,31 @@ uint16_t get_temperature_data(void)
260 260 I2C_stop(I2C1);
261 261 return data;
262 262 }
  263 +
  264 +char* light_value(uint32_t light)
  265 +{
  266 + char *value = chHeapAlloc(NULL,10 + 1);
  267 + sprintf(value,"%d",light);
  268 + return value;
  269 +}
  270 +char* distance_value(uint16_t distance)
  271 +{
  272 + char *value = chHeapAlloc(NULL,5 + 1);
  273 + sprintf(value,"%d",distance);
  274 + return value;
  275 +}
  276 +char* pressure_value(uint16_t pressure)
  277 +{
  278 + char *value = chHeapAlloc(NULL,5 + 1);
  279 + sprintf(value,"%d",pressure);
  280 + return value;
  281 +}
  282 +char* temp_humidity_value(uint16_t temp, uint16_t humidity)
  283 +{
  284 + char *value = chHeapAlloc(NULL,21 + 1);
  285 + sprintf(value,"%d,%d",temp,humidity);
  286 + return value;
  287 +}
  288 +
  289 +//light_value(get_light_data());
  290 +//temp_humidity_value(get_temperature_data(),get_humidity_data());
263 291 \ No newline at end of file
... ...