Merge pull request #55 from anklimov/develop

1-wire fixes
This commit is contained in:
2020-05-09 04:16:55 +03:00
committed by GitHub
17 changed files with 19711 additions and 19675 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -44,59 +44,59 @@
:1002B0000000BF000000803F0000000000084178FF
:1002C000D3BB4387D1133D190E3CC3BD4282AD2B36
:1002D0003E68EC8276BED98FE1A93E4C80EFFFBE2E
:1002E00001C4FF7F3F00000000000C94B7200C9475
:1002F000954C0C940E7A0C94985D0C944F580C9479
:1003000081680C94972D0C9422760C94AB100C946D
:100310002C640C94EF270C9464170C940F4B0C94E2
:10032000B10E0C94DA690C94FD690C941F280C949E
:10033000134B0C94CB430C94360F0C949D5D0C9492
:1003400078260C9496310C946D680C9403750C947B
:1003500028640C94F6640C945A530C94580F0C9423
:10036000710F0C946E7D0C9489680C9447650C9405
:100370003F170C947B0F0C943D260C94C0520C94A8
:100380003D650C9493260C9476680C94DD640C9473
:10039000CD0E0C94DD520C94764A0C9411280C94DA
:1003A0003A640C9401100C9462290C94DE0F0C94A6
:1003B0004A580C940F730C94EC640C94FB630C94EB
:1003C000F67C0C941A650C94C4430C945D2B0C942D
:1003D000C55D0C944C540C942F730C943F680C9492
:1003E0004D580C94DE720C9424580C94A0680C9414
:1003F00008690C94484A0C94154A0C9441490C9491
:10040000481E0C947E1E0C940B4B0C942D5D0C948A
:100410004E170C94817D0C9488310C942E580C94BA
:100420002E650C9459680C944C260C942B2E0C942D
:1004300001730C940C640C9474680C9430640C94E8
:10044000D7280C94FF630C94174B0C944A280C94F7
:1004500065650C94A04A0C941E640C9424650C945D
:1004600082260C947E730C94B0690C9440360C94E4
:1004700026200C94C02D0C94F37C0C9420580C94E2
:10048000D2270C94DA0E0C94CA100C94F8490C94F0
:10049000BB570C94B1570C94DA490C94BE5D0C9484
:1004A00045360C9490310C945D170C94C5280C942F
:1004B000257D0C9421210C9420260C942C2E0C9438
:1004C000F8350C9451650C9400470C94FA170C9471
:1004D0000E7E0C94E2640C945C260C94C7430C943E
:1004E00027580C946F650C9410650C9439580C9433
:1004F0002F1E0C9470490C94A17D0C940E540C94F6
:100500005D680C9482200C943C1E0C940B180C9487
:1005100014640C9447140C9416690C94F40F0C9406
:10052000680F0C9426180C94C9680C941A640C94E7
:1005300085260C945C280C942C5D0C94541E0C9411
:1005400085310C94F2520C94272E0C94D50F0C94F8
:100550006D260C94242A0C94224B0C9400650C9468
:100560008B280C9415290C94E8280C94CC6B0C94D3
:1005700010640C94C9430C9421580C943E640C9460
:10058000D8640C9444690C942F2E0C945B650C94E5
:1005900094100C948E490C9484280C94F4690C9457
:1005A00022640C948B0A0C9417760C940E7D0C9498
:1005B000782D0C9408650C9455680C94402A0C9482
:1005C00043360C940C100C94FC460C9419760C9445
:1005D000EB790C9431730C948A680C94981F0C94EA
:1005E000DC790C94646A0C94D6690C94E6170C942C
:1005F00075260C9490260C9436760C9405290C9450
:1006000009640C94ED720C9436640C94B4720C94DE
:10061000D75F0C9443640C9405640C9468690C9443
:10062000AB496364696E6F70737578585B004452B0
:1002E00001C4FF7F3F00000000000C94A04A0C9462
:1002F0005B650C94D75F0C9408690C9417760C948A
:10030000D7280C94782D0C94F6640C94F37C0C9400
:1003100089680C943F680C94154A0C94F2520C9422
:1003200081680C94242A0C9482200C941F280C942D
:10033000710F0C9408650C940B4B0C94257D0C9458
:10034000E8280C9430640C941A640C9421580C9492
:1003500016690C943E640C941A650C944E170C9418
:1003600068690C94C4430C94DD520C94DD640C94C5
:100370005C280C94D2270C9420260C9426180C94FC
:1003800041490C94E2640C9478260C946D680C94AA
:100390004A280C9484280C947E730C9464170C9453
:1003A00000470C94360F0C947B0F0C948B280C9404
:1003B0005A530C9436640C943F170C9455680C9463
:1003C00093260C948A680C94972D0C940E7E0C94B2
:1003D00001730C942F730C9401100C94541E0C9404
:1003E000FB630C94981F0C94C7430C9422640C94E8
:1003F000C0520C9451650C94FA170C9439580C9413
:1004000090310C946E7D0C940E540C9409640C94F1
:1004100085260C9427580C94CA100C94A17D0C943A
:10042000C55D0C94680F0C94AB100C9405640C948F
:10043000CC6B0C9400650C942B2E0C94B4720C9421
:100440003A640C94B0690C94DE0F0C9494100C94E4
:100450003D260C94B1570C942F2E0C944F580C94AD
:1004600059680C94272E0C944C540C94954C0C9475
:1004700040360C9445360C942C640C9424650C94F2
:100480008B0A0C947E1E0C942C2E0C94F8350C9434
:1004900010650C940F730C94224B0C94EC640C9428
:1004A00043640C9422760C9414640C94F8490C94D4
:1004B000CB430C94E6170C9490260C94F40F0C94F8
:1004C000484A0C9420580C940E7D0C9403750C949F
:1004D000646A0C943D650C9496310C942F1E0C9418
:1004E000C9680C9424580C944A580C946D260C94AA
:1004F00021210C94D50F0C94F4690C948E490C9422
:100500000C640C94ED720C94BB570C9470490C94D1
:10051000174B0C94DA690C9462290C945D2B0C94A3
:10052000402A0C94EF270C942D5D0C94FC460C94FF
:1005300085310C945D680C9415290C9465650C94B8
:10054000985D0C940F4B0C940E7A0C94CD0E0C9479
:1005500031730C942E650C9474680C94B10E0C9449
:1005600082260C9410640C941E640C945D170C94F9
:1005700076680C94B7200C94134B0C9475260C944D
:1005800005290C94D6690C94DE720C94C02D0C9441
:10059000FD690C9444690C94481E0C9419760C94D3
:1005A0006F650C9488310C94C9430C9426200C94EC
:1005B0002E580C9411280C9428640C94DA490C944D
:1005C00047140C9443360C94D8640C94817D0C949D
:1005D000580F0C9447650C943C1E0C9436760C9482
:1005E000FF630C94DA0E0C945C260C940B180C949C
:1005F000F67C0C944C260C94DC790C944D580C949D
:10060000A0680C949D5D0C94C5280C942C5D0C94F2
:10061000AB490C94764A0C940C100C94EB790C9426
:10062000BE5D6364696E6F70737578585B00445289
:10063000590046414E5F4F4E4C5900584F4E0048AE
:10064000414C54003D0050696E3A003D0050696EC7
:100650003A002048616C7465640A003D005265737D
@@ -132,8 +132,8 @@
:10083000524553542C584F4E2C584F46462C544F2B
:1008400047474C4500656E756D00666C6F617400BE
:10085000322E312E300024686F6D6965007570741A
:10086000696D652C66726565686561700039643113
:10087000356637615F323032302D30352D303700FC
:10086000696D652C66726565686561700036323742
:10087000376134345F323032302D30352D3039002D
:100880004C696768744875622000246E616D65006C
:100890007265616479002074727920616761696EA4
:1008A00020696E2035207365636F6E647300666126
@@ -212,8 +212,8 @@
:100D3000436F6E666967207365727665723A000A62
:100D4000282B295741544348444F47003230313112
:100D500030334C0020432B2B2076657273696F6E05
:100D60003A00396431356637615F323032302D30C8
:100D7000352D3037000A4C617A79686F6D652E72B7
:100D60003A00363237376134345F323032302D302A
:100D7000352D3039000A4C617A79686F6D652E72B5
:100D800075204C6967687448756220636F6E747271
:100D90006F6C6C6572200000002000230026002983
:100DA000002C002F003200000100000301060109A1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

17
lighthub/lighthub.ino.cpp Normal file
View 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();
}

View File

@@ -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);

View File

@@ -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++;
@@ -99,15 +101,13 @@ int owSetup(owChangedType owCh) {
oneWire = new OneWire (USE_1W_PIN);
#endif
// Pass our oneWire reference to Dallas Temperature.
sensors = new DallasTemperature(oneWire);
// sensors = new DallasTemperature(oneWire);
term = new DeviceAddress[t_max];
//regs = new int [t_max];
wstat = new uint16_t[t_max];
owChanged = owCh;
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
Wire.begin();
@@ -123,40 +123,40 @@ int owSetup(owChangedType owCh) {
debugSerial.println(F("\tChecking for 1-Wire devices..."));
if (oneWire->wireReset())
debugSerial.println(F("\tReset done"));
if (oneWire->getError() == DS2482_ERROR_SHORT)
{
debugSerial<<F("1-wire shorted.")<<endl;
return false;
}
sensors->begin();
owChanged = owCh;
//owUpdate();
//debugSerial.println(F("\t1-w Updated"));
sensors->setWaitForConversion(false);
return true;
}
#endif
debugSerial.println(F("\tDS2482 error"));
return false;
// IC Default 9 bit. If you have troubles consider upping it 12. Ups the delay giving the IC more time to process the temperature measurement
#else
// software driver
oneWire->reset();
delay(500);
return true;
#endif //DS2482-100
#endif
#endif //1w is not disabled
return false;
}
int sensors_loop(void) {
if (!sensors) return 100000;
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
if (oneWire->getError() == DS2482_ERROR_SHORT)
{
debugSerial<<F("1-wire disabled (shorted)")<<endl;
return 100000;
debugSerial<<F("1-wire shorted")<<endl;
oneWire->wireReset();
return 10000;
}
#endif
if (!sensors)
{
// Setup sensors library and resolution
sensors = new DallasTemperature(oneWire);
sensors->begin();
// IC Default 9 bit. If you have troubles consider upping it 12. Ups the delay giving the IC more time to process the temperature measurement
for (short i = 0; i < t_count; i++) sensors->setResolution(term[i],TEMPERATURE_PRECISION);
sensors->setWaitForConversion(false);
}
if (si >= t_count) {
@@ -201,17 +201,22 @@ void owAdd(DeviceAddress addr) {
if (t_count>=t_max) return;
wstat[t_count] = SW_FIND; //Newly detected
memcpy(term[t_count], addr, 8);
//term[t_count]=addr;
debugSerial<<F("dev#")<<t_count<<F(" Addr:");
PrintBytes(term[t_count], 8,0);
debugSerial.println();
if (term[t_count][0] == 0x28) {
sensors->setResolution(term[t_count], TEMPERATURE_PRECISION);
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
if (term[t_count][0] == 0x28)
oneWire->setStrongPullup();
// sensors.requestTemperaturesByAddress(term[t_count]);
}
#endif
t_count++;
#endif
}
#endif
void setupOwIdle (void (*ptr)())
{
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
if (oneWire) oneWire->idle(ptr);
#endif
}

View File

@@ -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);

View File

@@ -60,6 +60,7 @@ board = nrf52840_dk
framework = arduino
build_flags = !python get_build_flags.py nrf52840-5500
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
ESP_EEPROM
DmxSimple
DMXSerial
@@ -116,6 +117,7 @@ framework = arduino
upload_speed = 921600
build_flags = !python get_build_flags.py m5stack
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DmxSimple
DMXSerial
DmxDue
@@ -165,6 +167,7 @@ board = esp32-evb
upload_speed = 115200
build_flags = !python get_build_flags.py esp32-wifi
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DmxSimple
DMXSerial
DmxDue
@@ -212,6 +215,7 @@ framework = arduino
board = due
build_flags = !python get_build_flags.py due-5100
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx
ESP_EEPROM
DMXSerial
@@ -258,6 +262,7 @@ board = megaatmega2560
framework = arduino
build_flags = !python get_build_flags.py mega2560slim-5100
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx
DmxDue
DueFlashStorage
@@ -298,6 +303,7 @@ board = megaatmega2560
framework = arduino
build_flags = !python get_build_flags.py mega2560-5500
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx
DmxDue
DueFlashStorage
@@ -347,6 +353,7 @@ upload_protocol = esptool
; --port=65280
build_flags = !python get_build_flags.py esp8266-wifi
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DmxSimple
DMXSerial
DmxDue
@@ -397,6 +404,7 @@ framework = arduino
upload_port = net:192.168.88.2:23000
build_flags = !python get_build_flags.py mega2560-5100
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx
DmxDue
DueFlashStorage
@@ -439,6 +447,7 @@ board = due
;build_flags = !bash check_custom_build_flags_due-5500.sh
build_flags = !python get_build_flags.py due-5500
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx
ESPDMX
ESP-Dmx
@@ -486,6 +495,7 @@ framework = arduino
board = due
build_flags = !python get_build_flags.py lighthub21
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx
ESPDMX
ESP-Dmx
@@ -534,6 +544,7 @@ board = megaatmega2560
framework = arduino
build_flags = !python get_build_flags.py controllino
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx
DmxDue
DueFlashStorage
@@ -578,6 +589,7 @@ upload_protocol = stlink
debug_tool = stlink
build_flags = !python get_build_flags.py stm32-enc2860
lib_ignore =
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
DHT sensor library for ESPx
DmxDue
DueFlashStorage