diff --git a/lighthub/lighthub.ino.cpp b/lighthub/lighthub.ino.cpp new file mode 100644 index 0000000..9f8c3a2 --- /dev/null +++ b/lighthub/lighthub.ino.cpp @@ -0,0 +1,17 @@ +# 1 "/var/folders/kt/8psth65x03v6tw_phdhbj12r0000gn/T/tmpzcgFX2" +#include +# 1 "/Users/andrey/Documents/Arduino/lighthub/lighthub/lighthub.ino" +#include "main.h" +void setup(); +void loop(); +#line 2 "/Users/andrey/Documents/Arduino/lighthub/lighthub/lighthub.ino" +void setup(){ + + setup_main(); + + +} +void loop(){ + + loop_main(); +} \ No newline at end of file diff --git a/lighthub/main.cpp b/lighthub/main.cpp index 503cfa2..671edf1 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -1489,9 +1489,9 @@ void setup_main() { delay(20); //owReady = 0; -#ifdef _owire - if (oneWire) oneWire->idle(&owIdle); -#endif + #ifdef _owire + setupOwIdle(&owIdle); + #endif mqttClient.setCallback(mqttCallback); diff --git a/lighthub/owTerm.cpp b/lighthub/owTerm.cpp index 4bf29e6..1499993 100644 --- a/lighthub/owTerm.cpp +++ b/lighthub/owTerm.cpp @@ -72,7 +72,9 @@ int owUpdate() { debugSerial.println(); if (term[t_count][0] == 0x28) { sensors->setResolution(term[t_count], TEMPERATURE_PRECISION); + #ifdef DS2482_100_I2C_TO_1W_BRIDGE oneWire->setStrongPullup(); + #endif // sensors.requestTemperaturesByAddress(term[t_count]); } t_count++; @@ -127,7 +129,7 @@ int owSetup(owChangedType owCh) { return false; #else // software driver - oneWire->deviceReset(); + oneWire->reset(); delay(500); return true; #endif //DS2482-100 @@ -138,13 +140,14 @@ return false; int sensors_loop(void) { - +#ifdef DS2482_100_I2C_TO_1W_BRIDGE if (oneWire->getError() == DS2482_ERROR_SHORT) { debugSerial<wireReset(); return 10000; } +#endif if (!sensors) { @@ -202,9 +205,18 @@ void owAdd(DeviceAddress addr) { debugSerial<setStrongPullup(); + #endif t_count++; #endif } #endif + +void setupOwIdle (void (*ptr)()) +{ + #ifdef DS2482_100_I2C_TO_1W_BRIDGE + if (oneWire) oneWire->idle(ptr); + #endif +} diff --git a/lighthub/owTerm.h b/lighthub/owTerm.h index ea1028e..548bfa6 100644 --- a/lighthub/owTerm.h +++ b/lighthub/owTerm.h @@ -1,4 +1,4 @@ -/* Copyright © 2017-2018 Andrey Klimov. All rights reserved. +/* Copyright © 2017-2020 Andrey Klimov. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ e-mail anklimov@gmail.com */ //define APU_OFF +#pragma once #define SW_AUX0 0x40 #define SW_AUX1 0x80 @@ -52,23 +53,25 @@ e-mail anklimov@gmail.com #ifndef OWIRE_DISABLE -#ifndef ARDUINO_ARCH_STM32F1 -#include -#endif - #include #include "aJSON.h" extern aJsonObject *owArr; typedef void (*owChangedType) (int , DeviceAddress, float) ; + #ifndef USE_1W_PIN #define DS2482_100_I2C_TO_1W_BRIDGE // HW driver +#include + #ifndef ARDUINO_ARCH_STM32F1 + #include + #endif +#else +#include //Software driver +#define wireReset reset +#define wireSearch search #endif -#ifdef DS2482_100_I2C_TO_1W_BRIDGE -#include -#endif extern OneWire *oneWire; @@ -86,7 +89,7 @@ extern owChangedType owChanged; int owUpdate(); int owSetup(owChangedType owCh); void owLoop(); -void owIdle(void) ; +void setupOwIdle(void (*)()) ; int owFind(DeviceAddress addr); void owAdd (DeviceAddress addr);