The OneWire library works. It's a bit hacked together, as neither the software timer or hardware timer APIs would have worked well, because they are implemented terribly by Espressif. The easiest way to get around this was to just use system_get_time() and work off of that for timing in one-wire comms. Split the publish function into two separate functions: one to publish floating point numbers, and one to publish integers. In a language like Lua or C++ you could have these as one function, but in C it's easier to just split them. The main.c has a new function called dataLog that deals with getting the DS18B20 data and then handing that off to pubfloat(). I updated the timer names to be more descriptive. I grabbed some code to convert integers and floats to strings, as I can't be bothered to write that code myself for the millionth time. If something goes wrong and we are disconnected from our TCP connection, all timers are halted so we don't blindly keep trying to send packets over a non-existent link. Unfortunately the onewire library is hardcoded to use pin 5. That will be the next update. Signed-off-by: A.M. Rowsell <amrowsell@frozenelectronics.ca>
29 lines
869 B
Makefile
29 lines
869 B
Makefile
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
P=main
|
|
CC=xtensa-lx106-elf-gcc
|
|
AR=xtensa-lx106-elf-ar
|
|
LDLIBS=-nostdlib -ggdb -Wl,-Map=output.map -Wl,--start-group -lm -lc -lhal -lpp -llwip -lphy -lnet80211 -lwpa -lat -lwpa2 -lmain -Wl,--end-group -lgcc
|
|
CFLAGS= -I. -mlongcalls -std=gnu11 -Wall
|
|
LDFLAGS=-Teagle.app.v6.ld
|
|
OBJ=main.o mqtt.o onewire.o
|
|
DEPS=main.h mqtt.h onewire.h
|
|
|
|
$(P)-0x00000.bin: $(P)
|
|
esptool.py elf2image $^
|
|
|
|
$(P): $(OBJ)
|
|
|
|
%.o: %.c $(DEPS)
|
|
|
|
flash: $(P)-0x00000.bin
|
|
esptool.py --port /dev/feather0 write_flash 0 $(P)-0x00000.bin 0x10000 $(P)-0x10000.bin
|
|
|
|
clean:
|
|
rm -f $(P) $(OBJ) $(P)-0x00000.bin $(P)-0x10000.bin *~
|
|
|
|
library:
|
|
$(CC) -c -fPIC $(CFLAGS) $(P).c -o $(P).o
|
|
$(AR) rcs lib$(P).a $(P).o
|