Skip to content

Commit

Permalink
Merge pull request #7 from fredlcore/v0.11
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
fredlcore authored Dec 19, 2016
2 parents f4da62a + 6772570 commit 47cb17c
Show file tree
Hide file tree
Showing 20 changed files with 3,249 additions and 21 deletions.
137 changes: 116 additions & 21 deletions BSB_lan/BSB_lan/BSB_lan.ino

Large diffs are not rendered by default.

738 changes: 738 additions & 0 deletions BSB_lan/libraries/DallasTemperature/DallasTemperature.cpp

Large diffs are not rendered by default.

242 changes: 242 additions & 0 deletions BSB_lan/libraries/DallasTemperature/DallasTemperature.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
#ifndef DallasTemperature_h
#define DallasTemperature_h

#define DALLASTEMPLIBVERSION "3.7.2"

// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.

// set to true to include code for new and delete operators
#ifndef REQUIRESNEW
#define REQUIRESNEW false
#endif

// set to true to include code implementing alarm search functions
#ifndef REQUIRESALARMS
#define REQUIRESALARMS true
#endif

#include <inttypes.h>
#include <OneWire.h>

// Model IDs
#define DS18S20MODEL 0x10
#define DS18B20MODEL 0x28
#define DS1822MODEL 0x22

// OneWire commands
#define STARTCONVO 0x44 // Tells device to take a temperature reading and put it on the scratchpad
#define COPYSCRATCH 0x48 // Copy EEPROM
#define READSCRATCH 0xBE // Read EEPROM
#define WRITESCRATCH 0x4E // Write to EEPROM
#define RECALLSCRATCH 0xB8 // Reload from last known
#define READPOWERSUPPLY 0xB4 // Determine if device needs parasite power
#define ALARMSEARCH 0xEC // Query bus for devices with an alarm condition

// Scratchpad locations
#define TEMP_LSB 0
#define TEMP_MSB 1
#define HIGH_ALARM_TEMP 2
#define LOW_ALARM_TEMP 3
#define CONFIGURATION 4
#define INTERNAL_BYTE 5
#define COUNT_REMAIN 6
#define COUNT_PER_C 7
#define SCRATCHPAD_CRC 8

// Device resolution
#define TEMP_9_BIT 0x1F // 9 bit
#define TEMP_10_BIT 0x3F // 10 bit
#define TEMP_11_BIT 0x5F // 11 bit
#define TEMP_12_BIT 0x7F // 12 bit

// Error Codes
#define DEVICE_DISCONNECTED -127

typedef uint8_t DeviceAddress[8];

class DallasTemperature
{
public:

DallasTemperature(OneWire*);

// initalise bus
void begin(void);

// returns the number of devices found on the bus
uint8_t getDeviceCount(void);

// Is a conversion complete on the wire?
bool isConversionComplete(void);

// returns true if address is valid
bool validAddress(uint8_t*);

// finds an address at a given index on the bus
bool getAddress(uint8_t*, const uint8_t);

// attempt to determine if the device at the given address is connected to the bus
bool isConnected(uint8_t*);

// attempt to determine if the device at the given address is connected to the bus
// also allows for updating the read scratchpad
bool isConnected(uint8_t*, uint8_t*);

// read device's scratchpad
void readScratchPad(uint8_t*, uint8_t*);

// write device's scratchpad
void writeScratchPad(uint8_t*, const uint8_t*);

// read device's power requirements
bool readPowerSupply(uint8_t*);

// get global resolution
uint8_t getResolution();

// set global resolution to 9, 10, 11, or 12 bits
void setResolution(uint8_t);

// returns the device resolution, 9-12
uint8_t getResolution(uint8_t*);

// set resolution of a device to 9, 10, 11, or 12 bits
bool setResolution(uint8_t*, uint8_t);

// sets/gets the waitForConversion flag
void setWaitForConversion(bool);
bool getWaitForConversion(void);

// sets/gets the checkForConversion flag
void setCheckForConversion(bool);
bool getCheckForConversion(void);

// sends command for all devices on the bus to perform a temperature conversion
void requestTemperatures(void);

// sends command for one device to perform a temperature conversion by address
bool requestTemperaturesByAddress(uint8_t*);

// sends command for one device to perform a temperature conversion by index
bool requestTemperaturesByIndex(uint8_t);

// returns temperature in degrees C
float getTempC(uint8_t*);

// returns temperature in degrees F
float getTempF(uint8_t*);

// Get temperature for device index (slow)
float getTempCByIndex(uint8_t);

// Get temperature for device index (slow)
float getTempFByIndex(uint8_t);

// returns true if the bus requires parasite power
bool isParasitePowerMode(void);

bool isConversionAvailable(uint8_t*);

#if REQUIRESALARMS

typedef void AlarmHandler(uint8_t*);

// sets the high alarm temperature for a device
// accepts a char. valid range is -55C - 125C
void setHighAlarmTemp(uint8_t*, const char);

// sets the low alarm temperature for a device
// accepts a char. valid range is -55C - 125C
void setLowAlarmTemp(uint8_t*, const char);

// returns a signed char with the current high alarm temperature for a device
// in the range -55C - 125C
char getHighAlarmTemp(uint8_t*);

// returns a signed char with the current low alarm temperature for a device
// in the range -55C - 125C
char getLowAlarmTemp(uint8_t*);

// resets internal variables used for the alarm search
void resetAlarmSearch(void);

// search the wire for devices with active alarms
bool alarmSearch(uint8_t*);

// returns true if ia specific device has an alarm
bool hasAlarm(uint8_t*);

// returns true if any device is reporting an alarm on the bus
bool hasAlarm(void);

// runs the alarm handler for all devices returned by alarmSearch()
void processAlarms(void);

// sets the alarm handler
void setAlarmHandler(AlarmHandler *);

// The default alarm handler
static void defaultAlarmHandler(uint8_t*);

#endif

// convert from celcius to farenheit
static float toFahrenheit(const float);

// convert from farenheit to celsius
static float toCelsius(const float);

#if REQUIRESNEW

// initalize memory area
void* operator new (unsigned int);

// delete memory reference
void operator delete(void*);

#endif

private:
typedef uint8_t ScratchPad[9];

// parasite power on or off
bool parasite;

// used to determine the delay amount needed to allow for the
// temperature conversion to take place
uint8_t bitResolution;

// used to requestTemperature with or without delay
bool waitForConversion;

// used to requestTemperature to dynamically check if a conversion is complete
bool checkForConversion;

// count of devices on the bus
uint8_t devices;

// Take a pointer to one wire instance
OneWire* _wire;

// reads scratchpad and returns the temperature in degrees C
float calculateTemperature(uint8_t*, uint8_t*);

void blockTillConversionComplete(uint8_t*,uint8_t*);

#if REQUIRESALARMS

// required for alarmSearch
uint8_t alarmSearchAddress[8];
char alarmSearchJunction;
uint8_t alarmSearchExhausted;

// the alarm handler function pointer
AlarmHandler *_AlarmHandler;

#endif

};
#endif
53 changes: 53 additions & 0 deletions BSB_lan/libraries/DallasTemperature/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Arduino Library for Dallas Temperature ICs
==========================================

Usage
-----

This library supports the following devices:
DS18B20
DS18S20 - Please note there appears to be an issue with this series.
DS1822

You will need a pull-up resistor of about 5 KOhm between the 1-Wire data line
and your 5V power. If you are using the DS18B20, ground pins 1 and 3. The
centre pin is the data line '1-wire'.

We have included a "REQUIRESNEW" and "REQUIRESALARMS" definition. If you
want to slim down the code feel free to use either of these by including
#define REQUIRESNEW or #define REQUIRESALARMS a the top of DallasTemperature.h

Credits
-------

The OneWire code has been derived from
http://www.arduino.cc/playground/Learning/OneWire.
Miles Burton <[email protected]> originally developed this library.
Tim Newsome <[email protected]> added support for multiple sensors on
the same bus.
Guil Barros [[email protected]] added getTempByAddress (v3.5)
Rob Tillaart [[email protected]] added async modus (v3.7.0)


Website
-------

You can find the latest version of the library at
http://milesburton.com/index.php?title=Dallas_Temperature_Control_Library

License
-------

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
85 changes: 85 additions & 0 deletions BSB_lan/libraries/DallasTemperature/change.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

This file contains the change history of the Dallas Temperature Control Library.

VERSION 3.7.2 BETA
===================
DATE: 6 DEC 2011

- Jordan Hochenbaum [[email protected]] updated library for compatibility with Arduino 1.0.

VERSION 3.7.0 BETA
===================
DATE: 11 JAN 2011

- Rob Tillaart [[email protected]] added async modus (v3.7.0)
The library is backwards compatible with version 3.6.0

MAJOR: async modus
------------------
- Added - private bool waitForConversion.
This boolean is default set to true in the Constructor to keep the library backwards compatible. If this flag is true calls to requestTemperatures(), requestTemperaturesByAddress() et al, will be blocking with the appropiate time specified (in datasheet) for the resolution used. If the flag is set to false, requestTemperatures() et al, will return immediately after the conversion command is send over the 1-wire interface. The programmer is responsible to wait long enough before reading the temperature values. This enables the application to do other things while waiting for a new reading, like calculations, update LCD, read/write other IO lines etc. See examples.

- Added - void setWaitForConversion(bool);
To set the flag to true or false, depending on the modus needed.

- Added - bool getWaitForConversion(void);
To get the current value of the flag.

- Changed - void requestTemperatures(void);
Added a test (false == waitForConversion) to return immediately after the conversion command instead of waiting until the conversion is ready.

- Changed - bool requestTemperaturesByAddress(uint8_t*);
Added a test (false == waitForConversion) to return immediately after the conversion command instead of waiting until the conversion is ready.


MINOR version number
--------------------
- Added - #define DALLASTEMPLIBVERSION "3.7.0"
To indicate the version number in .h file


MINOR internal var bitResolution
----------------------------
- Changed - private int conversionDelay - is renamed to - private int bitResolution
As this variable holds the resolution. The delay for the conversion is derived from it.

- Changed - uint8_t getResolution(uint8_t* deviceAddress);
If the device is not connected, it returns 0, otherwise it returns the resolution of the device.

- Changed - bool setResolution(uint8_t* deviceAddress, uint8_t newResolution);
If the device is not connected, it returns FALSE (fail), otherwise it returns TRUE (succes).

- Added - uint8_t getResolution();
Returns bitResolution.

- Added - void setResolution(uint8_t newResolution)
Sets the internal variable bitResolution, and all devices to this value


MINOR check connected state
----------------------------
- Changed - bool requestTemperaturesByIndex(deviceIndex)
Changed return type from void to bool. The function returns false if the device identified with [deviceIndex] is not found on the bus and true otherwise.

- Changed - bool requestTemperaturesByAddress(deviceAddress)
Changed return type from void to bool. The function returns false if the device identified with [deviceAddress] is not found on the bus and true otherwise.
Added code to handle the DS18S20 which has a 9 bit resolution separately.
Changed code so the blocking delay matches the bitResolution set in the device with deviceAddress.

- Changed - bool requestTemperaturesByIndex(uint8_t deviceIndex)
Changed return type from void to bool. The function returns false if the device identified with [deviceIndex] is not found on the bus and true otherwise.



VERSION 3.6.0
==============
DATE: 2010-10-10

- no detailed change history known except:

- The OneWire code has been derived from
http://www.arduino.cc/playground/Learning/OneWire.
- Miles Burton <[email protected]> originally developed this library.
- Tim Newsome <[email protected]> added support for multiple sensors on
the same bus.
- Guil Barros [[email protected]] added getTempByAddress (v3.5)
Loading

0 comments on commit 47cb17c

Please sign in to comment.