From d0ed5f03a2dfc00288373179e9b2dc390d5762c4 Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Mon, 22 Feb 2016 21:18:50 -0800 Subject: [PATCH] A couple of fixups prior to merging into main project Changed the ds_sensor_t struct to just return a float instead of major/minor Renamed ds18b20.h functions to have consistent `ds18b20_*` naming. Removed some unnecessary LICENSE files. Clarified onewire origin/license. --- examples/ds18b20_broadcaster/LICENSE | 22 ------------------- .../ds18b20_broadcaster/ds18b20_broadcaster.c | 6 +++-- examples/ds18b20_onewire/LICENSE | 22 ------------------- examples/ds18b20_onewire/ds18b20_onewire.c | 6 +++-- extras/ds18b20/LICENSE | 22 ------------------- extras/ds18b20/ds18b20.c | 14 +++++------- extras/ds18b20/ds18b20.h | 11 ++++------ extras/onewire/LICENSE | 9 ++++++++ extras/onewire/README.md | 13 ++++++++--- 9 files changed, 37 insertions(+), 88 deletions(-) delete mode 100644 examples/ds18b20_broadcaster/LICENSE delete mode 100644 examples/ds18b20_onewire/LICENSE delete mode 100644 extras/ds18b20/LICENSE diff --git a/examples/ds18b20_broadcaster/LICENSE b/examples/ds18b20_broadcaster/LICENSE deleted file mode 100644 index 0b7ce5f..0000000 --- a/examples/ds18b20_broadcaster/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Grzegorz Hetman : ghetman@gmail.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/examples/ds18b20_broadcaster/ds18b20_broadcaster.c b/examples/ds18b20_broadcaster/ds18b20_broadcaster.c index 926dbad..92d340b 100644 --- a/examples/ds18b20_broadcaster/ds18b20_broadcaster.c +++ b/examples/ds18b20_broadcaster/ds18b20_broadcaster.c @@ -58,7 +58,7 @@ void broadcast_temperature(void *pvParameters) for(;;) { // Search all DS18B20, return its amount and feed 't' structure with result data. - amount = readDS18B20(GPIO_FOR_ONE_WIRE, t); + amount = ds18b20_read_all(GPIO_FOR_ONE_WIRE, t); if (amount < sensors){ printf("Something is wrong, I expect to see %d sensors \nbut just %d was detected!\n", sensors, amount); @@ -66,8 +66,10 @@ void broadcast_temperature(void *pvParameters) for (int i = 0; i < amount; ++i) { + int intpart = (int)t[i].value; + int fraction = (int)((t[i].value - intpart) * 100); // Multiple "" here is just to satisfy compiler and don`t raise 'hex escape sequence out of range' warning. - sprintf(msg, "Sensor %d report: %d.%d ""\xC2""\xB0""C\n",t[i].id, t[i].major, t[i].minor); + sprintf(msg, "Sensor %d report: %d.%02d ""\xC2""\xB0""C\n",t[i].id, intpart, fraction); printf("%s", msg); struct netbuf* buf = netbuf_new(); diff --git a/examples/ds18b20_onewire/LICENSE b/examples/ds18b20_onewire/LICENSE deleted file mode 100644 index 0b7ce5f..0000000 --- a/examples/ds18b20_onewire/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Grzegorz Hetman : ghetman@gmail.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/examples/ds18b20_onewire/ds18b20_onewire.c b/examples/ds18b20_onewire/ds18b20_onewire.c index 39db124..78d13bf 100644 --- a/examples/ds18b20_onewire/ds18b20_onewire.c +++ b/examples/ds18b20_onewire/ds18b20_onewire.c @@ -30,7 +30,7 @@ void print_temperature(void *pvParameters) while(1) { // Search all DS18B20, return its amount and feed 't' structure with result data. - amount = readDS18B20(GPIO_FOR_ONE_WIRE, t); + amount = ds18b20_read_all(GPIO_FOR_ONE_WIRE, t); if (amount < sensors){ printf("Something is wrong, I expect to see %d sensors \nbut just %d was detected!\n", sensors, amount); @@ -38,8 +38,10 @@ void print_temperature(void *pvParameters) for (int i = 0; i < amount; ++i) { + int intpart = (int)t[i].value; + int fraction = (int)((t[i].value - intpart) * 100); // Multiple "" here is just to satisfy compiler and don`t raise 'hex escape sequence out of range' warning. - printf("Sensor %d report: %d.%d ""\xC2""\xB0""C\n",t[i].id, t[i].major, t[i].minor); + printf("Sensor %d report: %d.%02d ""\xC2""\xB0""C\n",t[i].id, intpart, fraction); } printf("\n"); vTaskDelay(delay / portTICK_RATE_MS); diff --git a/extras/ds18b20/LICENSE b/extras/ds18b20/LICENSE deleted file mode 100644 index 0b7ce5f..0000000 --- a/extras/ds18b20/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Grzegorz Hetman : ghetman@gmail.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/extras/ds18b20/ds18b20.c b/extras/ds18b20/ds18b20.c index 1dc657b..cb4a1d1 100644 --- a/extras/ds18b20/ds18b20.c +++ b/extras/ds18b20/ds18b20.c @@ -13,7 +13,7 @@ #define DS1820_ALARMSEARCH 0xEC #define DS1820_CONVERT_T 0x44 -uint8_t readDS18B20(uint8_t pin, ds_sensor_t *result){ +uint8_t ds18b20_read_all(uint8_t pin, ds_sensor_t *result) { uint8_t addr[8]; uint8_t sensor_id = 0; @@ -55,18 +55,16 @@ uint8_t readDS18B20(uint8_t pin, ds_sensor_t *result){ float temperature; temperature = (temp * 625.0)/10000; - //printf("Got a DS18B20 Reading: %d.%d\n", (int)temperature, (int)(temperature - (int)temperature) * 100); + //printf("Got a DS18B20 Reading: %d.%02d\n", (int)temperature, (int)(temperature - (int)temperature) * 100); result[sensor_id].id = sensor_id; - result[sensor_id].major = (int)temperature; - result[sensor_id].minor = (int)(temperature) - (int)temperature * 100; + result[sensor_id].value = temperature; sensor_id++; } return sensor_id; } -float read_single_DS18B20(uint8_t pin){ +float ds18b20_read_single(uint8_t pin) { - onewire_init(pin); onewire_reset(pin); onewire_write(pin, DS1820_SKIP_ROM, ONEWIRE_DEFAULT_POWER); @@ -101,5 +99,5 @@ float read_single_DS18B20(uint8_t pin){ temperature = (temp * 625.0)/10000; return temperature; - //printf("Got a DS18B20 Reading: %d.%d\n", (int)temperature, (int)(temperature - (int)temperature) * 100); -} \ No newline at end of file + //printf("Got a DS18B20 Reading: %d.%02d\n", (int)temperature, (int)(temperature - (int)temperature) * 100); +} diff --git a/extras/ds18b20/ds18b20.h b/extras/ds18b20/ds18b20.h index 415b803..594227b 100644 --- a/extras/ds18b20/ds18b20.h +++ b/extras/ds18b20/ds18b20.h @@ -2,19 +2,16 @@ #define DRIVER_DS18B20_H_ typedef struct { - uint8_t id; - uint8_t major; - uint8_t minor; + uint8_t id; + float value; } ds_sensor_t; // Scan all ds18b20 sensors on bus and return its amount. // Result are saved in array of ds_sensor_t structure. -// Cause printf in esp sdk don`t support float, -// I split result as two number (major, minor). -uint8_t readDS18B20(uint8_t pin, ds_sensor_t *result); +uint8_t ds18b20_read_all(uint8_t pin, ds_sensor_t *result); // This method is just to demonstrate how to read // temperature from single dallas chip. -float read_single_DS18B20(uint8_t pin); +float ds18b20_read_single(uint8_t pin); #endif diff --git a/extras/onewire/LICENSE b/extras/onewire/LICENSE index 18a75d3..c5a152a 100644 --- a/extras/onewire/LICENSE +++ b/extras/onewire/LICENSE @@ -20,3 +20,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------- + +Portions copyright (C) 2000 Dallas Semiconductor Corporation, under the +following additional terms: + +Except as contained in this notice, the name of Dallas Semiconductor +shall not be used except as stated in the Dallas Semiconductor +Branding Policy. + diff --git a/extras/onewire/README.md b/extras/onewire/README.md index f849550..e490b9a 100644 --- a/extras/onewire/README.md +++ b/extras/onewire/README.md @@ -1,7 +1,14 @@ # Yet another one wire driver for the ESP8266 -This is a port of bit banging one wire driver based on nodemcu implementaion. +This is a port of a bit-banging one wire driver based on the implementation +from NodeMCU. -Seams that they port it from https://www.pjrc.com/teensy/td_libs_OneWire.html +This, in turn, appears to have been based on the PJRC Teensy driver +(https://www.pjrc.com/teensy/td_libs_OneWire.html), by Jim Studt, Paul +Stoffregen, and a host of others. -For all aspect regarding license, please check LICENSE file and coresponding projects. \ No newline at end of file +The original code is licensed under the MIT license. The CRC code was taken +(at least partially) from Dallas Semiconductor sample code, which was licensed +under an MIT license with an additional clause (prohibiting inappropriate use +of the Dallas Semiconductor name). See the accompanying LICENSE file for +details.