mirror of
https://github.com/anklimov/lighthub
synced 2025-12-07 20:29:50 +03:00
fix for software 1-wire driver
This commit is contained in:
17
lighthub/lighthub.ino.cpp
Normal file
17
lighthub/lighthub.ino.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
# 1 "/var/folders/kt/8psth65x03v6tw_phdhbj12r0000gn/T/tmpzcgFX2"
|
||||
#include <Arduino.h>
|
||||
# 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();
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<<F("1-wire shorted")<<endl;
|
||||
oneWire->wireReset();
|
||||
return 10000;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!sensors)
|
||||
{
|
||||
@@ -202,9 +205,18 @@ void owAdd(DeviceAddress addr) {
|
||||
debugSerial<<F("dev#")<<t_count<<F(" Addr:");
|
||||
PrintBytes(term[t_count], 8,0);
|
||||
debugSerial.println();
|
||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||
if (term[t_count][0] == 0x28)
|
||||
oneWire->setStrongPullup();
|
||||
#endif
|
||||
t_count++;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void setupOwIdle (void (*ptr)())
|
||||
{
|
||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||
if (oneWire) oneWire->idle(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -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 <DS2482_OneWire.h>
|
||||
#endif
|
||||
|
||||
#include <DallasTemperature.h>
|
||||
#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 <Wire.h>
|
||||
#ifndef ARDUINO_ARCH_STM32F1
|
||||
#include <DS2482_OneWire.h>
|
||||
#endif
|
||||
#else
|
||||
#include <OneWire.h> //Software driver
|
||||
#define wireReset reset
|
||||
#define wireSearch search
|
||||
#endif
|
||||
|
||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||
#include <Wire.h>
|
||||
#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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user