Skip to content

Class Instantiation

Arnd edited this page Dec 15, 2016 · 3 revisions

DSFamily(OneWirePin[, ReserveMem]);

The DSFamily class requires one parameter to instantiate, this is the pin number used for the 1-Wire microLAN data line. The second parameter is optional and is used to reserve EEPROM space for program use.

Each Atmel processor has EEPROM memory that can be accessed by programs. The size of this memory depends upon which processor is used, e.g. the ATmega328p has 1Kb of EEPROM storage available. This memory is persistent but does have a limited number of write cycles available to it.

Each DS-Family device has an 8-Byte unique identifier, and device commands (read temperature, convert temperature, etc.) use this 8-Byte identifier. Using a normal array at runtime for a system which can take up to 16 devices would reserve 128 Bytes of precious storage, for this reason the EEPROM is used by the library. The EEPROM is used from the end backwards, so if user programs use the EEPROM they should do so from the beginning and specify the number of bytes to reserve during class instantiation.


Example:

const uint8_t ONE_WIRE_PIN = 8;       // 1-Wire microLAN pin
DSFamily_Class ds(ONE_WIRE_PIN,128);  // Reserve first 128 bytes of EEPROM