<commit_before>/**
 * @file CosaWirelessDS18B20.ino
 * @version 1.0
 *
 * @section License
 * Copyright (C) 2013-2014, <NAME>
 *
 * 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.
 * 
 * @section Description
 * Demonstration sending temperature readings from two 1-Wire DS18B20
 * devices over the Wireless Interface and devices. 
 *
 * @section Circuit
 *                         RF433/TX
 *                       +------------+
 * (D8/D0)-------------1-|DATA        |
 * (VCC)---------------2-|VCC         |                    V
 * (GND)---------------3-|GND         |                    |
 *                       |ANT       0-|--------------------+
 *                       +------------+       17.3 cm
 *
 *                           DS18B20
 *                       +------------+
 * (GND)---------------1-|GND         |\
 * (D3)------+---------2-|DQ          | |
 *           |       +-3-|VDD         |/
 *          4K7      |   +------------+
 *           |       | 
 * (D4)------+       +---(VCC/GND)
 *
 * Connect RF433/315 Transmitter Data to ATtiny85 D0, connect VCC 
 * GND. Connect 1-Wire digital thermometer to D3 with pullup resistor.
 * The pullup resistor (4K7) may be connected to D4 to allow active power
 * control. This sketch supports parasite powered DS18B20 devices.
 * Connect the DS18B20 VCC to GND. 
 * 
 * @section Measurements
 * Arduino Mini Pro 16 Mhz (Power LED removed).
 * Power	Idle	Sampling	Transmitting	
 * LiPo 3.9 V	40 uA	1.3 mA 		6 mA (RF433).
 * FTDI 5,1 V	190 uA	1.5 mA		10 mA (RF433).
 *
 * @section Note
 * This sketch is designed to also run on an ATtiny85 running on the
 * internal 8 MHz clock. 
 *
 * This file is part of the Arduino Che Cosa project.
 */

#include "Cosa/OutputPin.hh"
#include "Cosa/AnalogPin.hh"
#include "Cosa/OWI.hh"
#include "Cosa/OWI/Driver/DS18B20.hh"
#include "Cosa/Power.hh"
#include "Cosa/Watchdog.hh"
#include "Cosa/RTC.hh"

// Configuration; network and device addresses
#define NETWORK 0xC05A
#if defined(BOARD_ATTINY)
#define DEVICE 0x30
#else
#define DEVICE 0x31
#endif

// Select Wireless device driver
// #define USE_CC1101
// #define USE_NRF24L01P
#define USE_VWI

#if defined(USE_CC1101)
#include "Cosa/Wireless/Driver/CC1101.hh"
CC1101 rf(NETWORK, DEVICE);

#elif defined(USE_NRF24L01P)
#include "Cosa/Wireless/Driver/NRF24L01P.hh"
NRF24L01P rf(NETWORK, DEVICE);

#elif defined(USE_VWI)
#include "Cosa/Wireless/Driver/VWI.hh"
#include "Cosa/Wireless/Driver/VWI/Codec/VirtualWireCodec.hh"
VirtualWireCodec codec;
#define SPEED 4000
#if defined(BOARD_ATTINY)
VWI rf(NETWORK, DEVICE, SPEED, Board::D1, Board::D0, &codec);
#else
VWI rf(NETWORK, DEVICE, SPEED, Board::D7, Board::D8, &codec);
#endif
#endif

// Connect to one-wire device; Assuming there are two sensors
OWI owi(Board::D3);
DS18B20 indoors(&owi);
DS18B20 outdoors(&owi);

// Active pullup (pullup resistor connected to this pin)
OutputPin pw(Board::D4);

// Power-down sleep
#define DEEP_SLEEP(s)					\
  do {							\
    uint8_t mode = Power::set(SLEEP_MODE_PWR_DOWN);	\
    SLEEP(s);						\
    Power::set(mode);					\
  } while (0)



void setup()
{
  // Start watchdog, real-time clock and wireless device
  Watchdog::begin(128);
  RTC::begin();
  rf.begin();
  
  // Connect to the temperature sensors; use active pullup
  pw.on();<commit_msg>Correct wireless power-down in example sketch; CosaWirelessDS18B20.<commit_after>/**
 * @file CosaWirelessDS18B20.ino
 * @version 1.0
 *
 * @section License
 * Copyright (C) 2013-2014, <NAME>
 *
 * 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.
 * 
 * @section Description
 * Demonstration sending temperature readings from two 1-Wire DS18B20
 * devices over the Wireless Interface and devices. 
 *
 * @section Circuit
 *                         RF433/TX
 *                       +------------+
 * (D8/D0)-------------1-|DATA        |
 * (VCC)---------------2-|VCC         |                    V
 * (GND)---------------3-|GND         |                    |
 *                       |ANT       0-|--------------------+
 *                       +------------+       17.3 cm
 *
 *                           DS18B20
 *                       +------------+
 * (GND)---------------1-|GND         |\
 * (D3)------+---------2-|DQ          | |
 *           |       +-3-|VDD         |/
 *          4K7      |   +------------+
 *           |       | 
 * (D4)------+       +---(VCC/GND)
 *
 * Connect RF433/315 Transmitter Data to ATtiny85 D0, connect VCC 
 * GND. Connect 1-Wire digital thermometer to D3 with pullup resistor.
 * The pullup resistor (4K7) may be connected to D4 to allow active power
 * control. This sketch supports parasite powered DS18B20 devices.
 * Connect the DS18B20 VCC to GND. 
 * 
 * @section Measurements
 * Arduino Mini Pro 16 Mhz (Power LED removed).
 * Power	Idle	Sampling	Transmitting	
 * LiPo 3.9 V	40 uA	1.3 mA 		6 mA (RF433).
 * FTDI 5,1 V	190 uA	1.5 mA		10 mA (RF433).
 *
 * @section Note
 * This sketch is designed to also run on an ATtiny85 running on the
 * internal 8 MHz clock. 
 *
 * This file is part of the Arduino Che Cosa project.
 */

#include "Cosa/OutputPin.hh"
#include "Cosa/AnalogPin.hh"
#include "Cosa/OWI.hh"
#include "Cosa/OWI/Driver/DS18B20.hh"
#include "Cosa/Power.hh"
#include "Cosa/Watchdog.hh"
#include "Cosa/RTC.hh"

// Configuration; network and device addresses
#define NETWORK 0xC05A
#if defined(BOARD_ATTINY)
#define DEVICE 0x30
#else
#define DEVICE 0x31
#endif

// Select Wireless device driver
// #define USE_CC1101
// #define USE_NRF24L01P
#define USE_VWI

#if defined(USE_CC1101)
#include "Cosa/Wireless/Driver/CC1101.hh"
CC1101 rf(NETWORK, DEVICE);

#elif defined(USE_NRF24L01P)
#include "Cosa/Wireless/Driver/NRF24L01P.hh"
NRF24L01P rf(NETWORK, DEVICE);

#elif defined(USE_VWI)
#include "Cosa/Wireless/Driver/VWI.hh"
#include "Cosa/Wireless/Driver/VWI/Codec/VirtualWireCodec.hh"
VirtualWireCodec codec;
#define SPEED 4000
#if defined(BOARD_ATTINY)
VWI rf(NETWORK, DEVICE, SPEED, Board::D1, Board::D0, &codec);
#else
VWI rf(NETWORK, DEVICE, SPEED, Board::D7, Board::D8, &codec);
#endif
#endif

// Connect to one-wire device; Assuming there are two sensors
OWI owi(Board::D3);
DS18B20 indoors(&owi);
DS18B20 outdoors(&owi);

// Active pullup (pullup resistor connected to this pin)
OutputPin pw(Board::D4);

// Power-down sleep
#define DEEP_SLEEP(s)					\
  do {							\
    uint8_t mode = Power::set(SLEEP_MODE_PWR_DOWN);	\
    SLEEP(s);						\
    Power::set(mode);					\
  } while (0)



void setup()
{
  // Start watchdog and real-time clock
  Watchdog::begin(128);
  RTC::begin();

  // Start the wireless device
  rf.begin();
  rf.powerdown();

  // Connect to the temperature sensors; use active pullup
  pw.on();
{'fraction_non_alphanumeric': 0.14539240173524384, 'fraction_numerical': 0.04285526488760352, 'mean_word_length': 2.300650759219089, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5010650', 'n_tokens_mistral': 2811, 'n_tokens_neox': 2515, 'n_words': 768}