All packaged in C++ form. Well, not the keywords.txt file. I'm not sure what that is, though I guess it has something to do with the color coding of the build in editor.
This library is general 1-wire. It might be nice to derive a DS18S20 class from this that knows about temperature to handle the conversions, or that might start making too much object code. Maybe I'm being too sensitive to code bloat, but it seems that higher level libraries will end up containing a lot of unused functions for any given application. e.g. I won't use the alarm threshold registers in my application but I'd end up with functions for them linked into my code. I had enough worry about that in just the generic functions that I ended up with a couple nasty preprocessor symbols to omit some of the larger functions that people might not need.
So, the easiest jobis done too, although I am not sure if I got it right. I thought I read something about the keywords.txt file, but I can't find it anymore.
You can check out the keywords.txt of the existing libraries (in lib/targets/libraries). It looks good, except that OneWire should be in the datatypes section and a KEYWORD1. Now we just need to zip it all and upload it somewhere (the playground?).
You can check out the keywords.txt of the existing libraries (in lib/targets/libraries). It looks good, except that OneWire should be in the datatypes section and a KEYWORD1. Now we just need to zip it all and upload it somewhere (the playground?).
I made this after looking at an example. Only the OneWire wasn't clear to me. I have changed the file, so you can just copy/paste it.
Has anybody gotten this working with the 008 environment? I can make it compile by changing digital_pin_to_port to digital_pin_to_port_PGM and such, but I'm not getting valid readings from the DS18S20P I'm testing it with.
Has anybody gotten this working with the 008 environment?
Jim Studt was kind enough to email me with details of how to get the OneWire library working with arduino-0008. I've posted an updated version of the library to Index of /onewire
Don't know if you need more code sample for One Wire, but the project OWW is open source and addresses a lot of One Wire devices : http://oww.sourceforge.net
When attempting to compile my program with the onewire library I am getting this error. I have created the library directories and added the keyword file.
o: In function __static_initialization_and_destruction_0(int, int)': undefined reference to OneWire::OneWire(unsigned char)
Anyone know how to fix it?
#include <OneWire.h>
OneWire ds(10); <------------ Commenting out this line makes the program compile
Has anyone tried the library with the arduino-0010 version yet? When I try to use the 008 version of the OneWire library with it, I get a bunch of errors.
[...] it really eats up SRAM. The CRC tables use about 256 bytes of RAM (from the 1 kbytes the atmega168 has).
On my system I have temporarily commented out that section, but I think a good solution would be to use PROGMEM for the CRC tables.
A better solution, I think, would be to do the CRC calculation in code, without using the lookup table at all. I spent a couple of hours on that yesterday and worked it out. Just replace the current code for the OneWire::crc8() function with the following,
uint8_t OneWire::crc8 ( uint8_t *addr, uint8_t len )
{
uint8_t i, j;
uint8_t crc = 0;
for (i = 0; i < len; i++) {
uint8_t inbyte = addr[i];
for (j = 0; j < 8; j++) {
uint8_t mix = (crc ^ inbyte) & 0x01;
crc >>= 1;
if (mix) crc ^= 0x8C;
inbyte >>= 1;
}
}
return crc;
}