Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
orgua committed Oct 15, 2016
1 parent c68ecd7 commit 914502c
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 476 deletions.
14 changes: 7 additions & 7 deletions examples/BAE910_device/BAE910_device.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "OneWireHub.h"
#include "BAE910.h" // 3rd party OneWire slave device, family code 0xFC

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
const uint8_t Analog_PIN = 0;
constexpr uint8_t pin_led { 13 };
constexpr uint8_t pin_onewire { 8 };
constexpr uint8_t pin_analog { 0 };

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto bae910 = BAE910(BAE910::family_code, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);


Expand All @@ -26,7 +26,7 @@ bool blinking()
static uint8_t ledState = LOW; // ledState used to set the LED
if (ledState == LOW) ledState = HIGH;
else ledState = LOW;
digitalWrite(led_PIN, ledState);
digitalWrite(pin_led, ledState);
return 1;
}
return 0;
Expand All @@ -38,7 +38,7 @@ void setup()
Serial.begin(115200);
Serial.println("OneWire-Hub BAE910 emulation ADC example");

pinMode(led_PIN, OUTPUT);
pinMode(pin_led, OUTPUT);

// Setup OneWire
hub.attach(bae910);
Expand All @@ -60,6 +60,6 @@ void loop()
if (blinking())
{
// read ADC and write into BAE register
bae910.memory.field.adc10 = analogRead(Analog_PIN);
bae910.memory.field.adc10 = analogRead(pin_analog);
}
}
16 changes: 9 additions & 7 deletions examples/DS18B20_thermometer/DS18B20_thermometer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
#include "OneWireHub.h"
#include "DS18B20.h" // Digital Thermometer, 12bit

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_led { 13 };
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(pin_onewire);

auto hub = OneWireHub(OneWire_PIN);
auto ds18b20 = DS18B20(DS18B20::family_code, 0x00, 0x02, 0x0B, 0x08, 0x01, 0x0D); // Digital Thermometer
auto ds18s20 = DS18B20(0x10, 0x00, 0x02, 0x0F, 0x08, 0x01, 0x0D); // Digital Thermometer
auto ds1822 = DS18B20(0x22, 0x00, 0x02, 0x0F, 0x08, 0x01, 0x0D); // Digital Thermometer


bool blinking()
{
const uint32_t interval = 500; // interval at which to blink (milliseconds)
constexpr uint32_t interval = 1000; // interval at which to blink (milliseconds)
static uint32_t nextMillis = millis(); // will store next time LED will updated

if (millis() > nextMillis)
Expand All @@ -29,7 +30,7 @@ bool blinking()
static uint8_t ledState = LOW; // ledState used to set the LED
if (ledState == LOW) ledState = HIGH;
else ledState = LOW;
digitalWrite(led_PIN, ledState);
digitalWrite(pin_led, ledState);
return 1;
}
return 0;
Expand All @@ -40,8 +41,9 @@ void setup()
{
Serial.begin(115200);
Serial.println("OneWire-Hub DS18B20 Temperature-Sensor");
Serial.flush();

pinMode(led_PIN, OUTPUT);
pinMode(pin_led, OUTPUT);

// Setup OneWire
hub.attach(ds18b20);
Expand All @@ -55,7 +57,7 @@ void setup()
ds1822.setTemp(temperature);

Serial.println("config done");
}
};

void loop()
{
Expand Down
10 changes: 5 additions & 5 deletions examples/DS2401_serial/DS2401_serial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include "OneWireHub.h"
#include "DS2401.h" // Serial Number

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_led { 13 };
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto ds2401A = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0A ); // Work - Serial Number
auto ds2401B = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0B ); // Work - Serial Number
auto ds2401C = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0C );
Expand All @@ -28,7 +28,7 @@ bool blinking()
static uint8_t ledState = LOW; // ledState used to set the LED
if (ledState == LOW) ledState = HIGH;
else ledState = LOW;
digitalWrite(led_PIN, ledState);
digitalWrite(pin_led, ledState);
return 1;
}
return 0;
Expand All @@ -40,7 +40,7 @@ void setup()
Serial.begin(115200);
Serial.println("OneWire-Hub DS2401 Serial Number used as iButton");

pinMode(led_PIN, OUTPUT);
pinMode(pin_led, OUTPUT);

// Setup OneWire
hub.attach(ds2401C); // always online
Expand Down
11 changes: 5 additions & 6 deletions examples/DS2405_switch/DS2405_switch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
#include "OneWireHub.h"
#include "DS2405.h" // Dual channel addressable switch

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_led { 13 };
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto ds2405 = DS2405( DS2405::family_code, 0x00, 0x0D, 0x02, 0x04, 0x00, 0x05 ); // Work - Dual channel addressable switch

void setup()
{
Serial.begin(115200);
Serial.println("OneWire-Hub DS2405 - One channel addressable switch");

pinMode(led_PIN, OUTPUT);
pinMode(pin_led, OUTPUT);

// Setup OneWire
hub.attach(ds2405);
Expand All @@ -44,8 +44,7 @@ void loop()
Serial.print(" PinState: ");
Serial.println(switch_state);

if (switch_state) digitalWrite(led_PIN, HIGH);
else digitalWrite(led_PIN, LOW);
digitalWrite(pin_led, switch_state);
}


Expand Down
11 changes: 5 additions & 6 deletions examples/DS2408_switch/DS2408_switch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
#include "OneWireHub.h"
#include "DS2408.h"

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_led { 13 };
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto ds2408 = DS2408( 0x29, 0x0D, 0x02, 0x04, 0x00, 0x08, 0x0A );


bool blinking()
{
const uint32_t interval = 500; // interval at which to blink (milliseconds)
Expand All @@ -26,7 +25,7 @@ bool blinking()
static uint8_t ledState = LOW; // ledState used to set the LED
if (ledState == LOW) ledState = HIGH;
else ledState = LOW;
digitalWrite(led_PIN, ledState);
digitalWrite(pin_led, ledState);
return 1;
}
return 0;
Expand All @@ -38,7 +37,7 @@ void setup()
Serial.begin(115200);
Serial.println("OneWire-Hub DS2408 - 8CH GPIO Port Extender");

pinMode(led_PIN, OUTPUT);
pinMode(pin_led, OUTPUT);

// Setup OneWire
hub.attach(ds2408); // always online
Expand Down
10 changes: 5 additions & 5 deletions examples/DS2413_switch/DS2413_switch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include "OneWireHub.h"
#include "DS2413.h" // Dual channel addressable switch

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_led { 13 };
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto ds2413 = DS2413( DS2413::family_code, 0x00, 0x0D, 0x02, 0x04, 0x01, 0x03 ); // Work - Dual channel addressable switch

bool blinking()
Expand All @@ -25,7 +25,7 @@ bool blinking()
static uint8_t ledState = LOW; // ledState used to set the LED
if (ledState == LOW) ledState = HIGH;
else ledState = LOW;
digitalWrite(led_PIN, ledState);
digitalWrite(pin_led, ledState);
return 1;
}
return 0;
Expand All @@ -36,7 +36,7 @@ void setup()
Serial.begin(115200);
Serial.println("OneWire-Hub DS2413 Dual channel addressable switch");

pinMode(led_PIN, OUTPUT);
pinMode(pin_led, OUTPUT);

// Setup OneWire
hub.attach(ds2413);
Expand Down
8 changes: 3 additions & 5 deletions examples/DS2431_EEPROM/DS2431_EEPROM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@
#include "OneWireHub.h"
#include "DS2431.h"

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto ds2431 = DS2431(DS2431::family_code, 0xE8, 0x9F, 0x90, 0x0E, 0x00, 0x00);

void setup()
{
Serial.begin(115200);
Serial.println("OneWire-Hub DS2431");

pinMode(led_PIN, OUTPUT);

// Setup OneWire
hub.attach(ds2431);

Expand Down
7 changes: 2 additions & 5 deletions examples/DS2433_EEPROM/DS2433_EEPROM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@
#include "OneWireHub.h"
#include "DS2433.h"

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto ds2433 = DS2433(DS2433::family_code, 0x01, 0x01, 0x33, 0x24, 0xD0, 0x00);

void setup()
{
Serial.begin(115200);
Serial.println("OneWire-Hub DS2433");

pinMode(led_PIN, OUTPUT);

// Setup OneWire
hub.attach(ds2433);

Expand Down
14 changes: 7 additions & 7 deletions examples/DS2438_battMon/DS2438_battMon.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include "OneWireHub.h"
#include "DS2438.h" // Smart Battery Monitor

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_led { 13 };
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(OneWire_PIN);
auto ds2438 = DS2438( DS2438::family_code, 0x0D, 0x02, 0x04, 0x03, 0x08, 0x0A ); // - Smart Battery Monitor
auto hub = OneWireHub(pin_onewire);
auto ds2438 = DS2438( DS2438::family_code, 0x00, 0x00, 0x38, 0x24, 0xDA, 0x00 ); // - Smart Battery Monitor

bool blinking()
{
Expand All @@ -26,7 +26,7 @@ bool blinking()
static uint8_t ledState = LOW; // ledState used to set the LED
if (ledState == LOW) ledState = HIGH;
else ledState = LOW;
digitalWrite(led_PIN, ledState);
digitalWrite(pin_led, ledState);
return 1;
}
return 0;
Expand All @@ -37,7 +37,7 @@ void setup()
Serial.begin(115200);
Serial.println("OneWire-Hub DS2438 Smart Battery Monitor");

pinMode(led_PIN, OUTPUT);
pinMode(pin_led, OUTPUT);

// Setup OneWire
hub.attach(ds2438);
Expand Down Expand Up @@ -65,7 +65,7 @@ void loop()
ds2438.setVolt(volt_10mV);
ds2438.setCurr(current);

//Serial.println(temp);
Serial.println(temp);
};
};

Expand Down
9 changes: 3 additions & 6 deletions examples/DS2502_EEPROM/DS2502_EEPROM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#include "OneWireHub.h"
#include "DS2502.h"

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_onewire { 8 };

const uint8_t chargerData[4] = {0xFB, 0x31, 0x33, 0x30};//130W
//const uint8_t chargerData[4] = {0xFB, 0x30, 0x39, 0x30};//90W
//const uint8_t chargerData[4] = {0xFB, 0x30, 0x36, 0x36};//65W

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto ds2502 = DS2502( DS2502::family_code, 0x02, 0x00, 0x05, 0x02, 0x0D, 0x00 );
auto ds2501a = DS2502( 0x91, 0x01, 0x00, 0x05, 0x02, 0x0D, 0x00 );
auto ds2501b = DS2502( 0x11, 0x01, 0x00, 0x05, 0x02, 0x0D, 0x00 );
Expand All @@ -25,11 +24,9 @@ auto dellCHb = DS2502( 0x28, 0x0E, 0x01, 0x01, 0x0E, 0x0D, 0x00 ); // should

void setup()
{
Serial.begin(115200);
//Serial.begin(115200);
Serial.println("OneWire-Hub DS2502");

pinMode(led_PIN, OUTPUT);

// Setup OneWire
dellCHa.writeMemory(chargerData, sizeof(chargerData), 0x20); // write to bank 1
dellCHa.redirectPage(0,1); // set memorybanks to all read from bank 1
Expand Down
10 changes: 5 additions & 5 deletions examples/DS2890_poti/DS2890_poti.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include "OneWireHub.h"
#include "DS2890.h" // Single channel digital potentiometer

const uint8_t led_PIN = 13; // the number of the LED pin
const uint8_t OneWire_PIN = 8;
constexpr uint8_t pin_led { 13 };
constexpr uint8_t pin_onewire { 8 };

auto hub = OneWireHub(OneWire_PIN);
auto hub = OneWireHub(pin_onewire);
auto ds2890 = DS2890( 0x2C, 0x00, 0x0D, 0x02, 0x08, 0x09, 0x00 ); // Work - Single channel digital potentiometer

bool blinking()
Expand All @@ -25,7 +25,7 @@ bool blinking()
static uint8_t ledState = LOW; // ledState used to set the LED
if (ledState == LOW) ledState = HIGH;
else ledState = LOW;
digitalWrite(led_PIN, ledState);
digitalWrite(pin_led, ledState);
return 1;
}
return 0;
Expand All @@ -36,7 +36,7 @@ void setup()
Serial.begin(115200);
Serial.println("OneWire-Hub DS2890 Single channel digital potentiometer");

pinMode(led_PIN, OUTPUT);
pinMode(pin_led, OUTPUT);

// Setup OneWire
hub.attach(ds2890);
Expand Down
Loading

0 comments on commit 914502c

Please sign in to comment.