Restructure directory organization
This commit is contained in:
@@ -13,6 +13,6 @@ WORKDIR /usr/src/
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN make
|
||||
RUN make all
|
||||
|
||||
CMD ["./main"]
|
||||
@@ -2,9 +2,7 @@ PROJECT = plant-manager
|
||||
|
||||
MCU = atmega328p
|
||||
F_CPU = 16000000UL
|
||||
PROGRAMMER = arduino
|
||||
PORT ?= /dev/ttyACM0
|
||||
BAUD = 115200
|
||||
PROGRAMMER = usbasp
|
||||
|
||||
ARDUINO_INSTALL_PATH = /usr/share/arduino
|
||||
ARDUINO_CORE_PATH = $(ARDUINO_INSTALL_PATH)/hardware/arduino/avr/cores/arduino
|
||||
@@ -12,7 +10,7 @@ ARDUINO_VARIANT_PATH = $(ARDUINO_INSTALL_PATH)/hardware/arduino/avr/variants/sta
|
||||
|
||||
CC = avr-gcc
|
||||
CXX = avr-g++
|
||||
LD = $(CXX) # Use C++ linker
|
||||
LD = $(CXX)
|
||||
OC = avr-objcopy
|
||||
AD = avrdude
|
||||
AR = avr-ar
|
||||
@@ -22,9 +20,8 @@ BUILD_DIR = build
|
||||
OBJ_DIR = $(BUILD_DIR)/obj
|
||||
CORE_DIR = $(BUILD_DIR)/core
|
||||
|
||||
|
||||
CFLAGS = -Wall -Os -DF_CPU=$(F_CPU) -mmcu=$(MCU) -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VARIANT_PATH) -I.
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fpermissive
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fpermissive -std=gnu++11
|
||||
|
||||
LDFLAGS = -Wall -Os -mmcu=$(MCU) -Wl,--gc-sections
|
||||
LIBS = -lm
|
||||
@@ -34,15 +31,19 @@ HDRS = moisture.h config.h
|
||||
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS_CPP:.cpp=.o))
|
||||
|
||||
CORE_C_SRCS = \
|
||||
wiring.c \
|
||||
wiring_analog.c \
|
||||
wiring_digital.c
|
||||
wiring_digital.c \
|
||||
hooks.c
|
||||
|
||||
CORE_CPP_SRCS = \
|
||||
abi.cpp \
|
||||
new.cpp \
|
||||
Print.cpp \
|
||||
Stream.cpp \
|
||||
HardwareSerial.cpp
|
||||
HardwareSerial.cpp \
|
||||
HardwareSerial0.cpp \
|
||||
main.cpp
|
||||
|
||||
CORE_SRCS = $(addprefix $(ARDUINO_CORE_PATH)/, $(CORE_C_SRCS) $(CORE_CPP_SRCS))
|
||||
CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%.c,$(CORE_DIR)/%.o,$(filter %.c,$(CORE_SRCS))) \
|
||||
@@ -78,7 +79,7 @@ $(TARGET): $(ELF_TARGET)
|
||||
$(OC) -O ihex -R .eeprom $< $@
|
||||
|
||||
flash: $(TARGET)
|
||||
$(AD) -v -p $(MCU) -c $(PROGRAMMER) -P $(PORT) -b $(BAUD) -D -U flash:w:$<:i
|
||||
$(AD) -v -p $(MCU) -c $(PROGRAMMER) -D -U flash:w:$<:i
|
||||
|
||||
clean:
|
||||
$(RM) $(TARGET) $(ELF_TARGET) $(OBJS) $(CORE_OBJS) $(CORE_LIB)
|
||||
@@ -1,7 +1,9 @@
|
||||
#include <Arduino.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "config.h"
|
||||
#include <avr/interrupt.h>
|
||||
#include "moisture.h"
|
||||
|
||||
ISR(WDT_vect) {
|
||||
@@ -1,5 +1,8 @@
|
||||
#include <Arduino.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "moisture.h"
|
||||
#include "config.h"
|
||||
|
||||
@@ -23,6 +26,7 @@ int16_t readMoisture(void) {
|
||||
moistureReadingSum += analogRead(MOISTURE_SENSOR_A0);
|
||||
moistureReadingCount++;
|
||||
|
||||
//TODO: implement variance check (if over a certain variance discard measurements for this cicle)
|
||||
if (moistureReadingCount >= SENSOR_READINGS) {
|
||||
int16_t avg = moistureReadingSum / SENSOR_READINGS;
|
||||
//Serial.println(avg);
|
||||
Reference in New Issue
Block a user