more code, less void
This commit is contained in:
parent
f63103174a
commit
cf064e6a4d
|
@ -0,0 +1,2 @@
|
||||||
|
*~
|
||||||
|
build
|
|
@ -20,7 +20,7 @@
|
||||||
# BOARD # Board name (such as uno, mega2560, ...) [REQUIRED]
|
# BOARD # Board name (such as uno, mega2560, ...) [REQUIRED]
|
||||||
# SKETCH # Arduino sketch [must have SRCS or SKETCH]
|
# SKETCH # Arduino sketch [must have SRCS or SKETCH]
|
||||||
# SRCS # Sources [must have SRCS or SKETCH]
|
# SRCS # Sources [must have SRCS or SKETCH]
|
||||||
# HDRS # Headers
|
# HDRS # Headers
|
||||||
# LIBS # Libraries to link
|
# LIBS # Libraries to link
|
||||||
# PORT # Serial port (enables upload support)
|
# PORT # Serial port (enables upload support)
|
||||||
# SERIAL # Serial command for serial target
|
# SERIAL # Serial command for serial target
|
||||||
|
@ -29,10 +29,10 @@
|
||||||
# NO_AUTOLIBS # Disables Arduino library detection
|
# NO_AUTOLIBS # Disables Arduino library detection
|
||||||
#
|
#
|
||||||
# Here is a short example for a target named test:
|
# Here is a short example for a target named test:
|
||||||
#
|
#
|
||||||
# generate_arduino_firmware(
|
# generate_arduino_firmware(
|
||||||
# NAME test
|
# NAME test
|
||||||
# SRCS test.cpp
|
# SRCS test.cpp
|
||||||
# test2.cpp
|
# test2.cpp
|
||||||
# HDRS test.h test2.h
|
# HDRS test.h test2.h
|
||||||
# BOARD uno)
|
# BOARD uno)
|
||||||
|
@ -62,15 +62,15 @@
|
||||||
# name # The name of the firmware target [REQUIRED]
|
# name # The name of the firmware target [REQUIRED]
|
||||||
# BOARD # Board name (such as uno, mega2560, ...) [REQUIRED]
|
# BOARD # Board name (such as uno, mega2560, ...) [REQUIRED]
|
||||||
# SRCS # Sources [REQUIRED]
|
# SRCS # Sources [REQUIRED]
|
||||||
# HDRS # Headers
|
# HDRS # Headers
|
||||||
# LIBS # Libraries to link
|
# LIBS # Libraries to link
|
||||||
# NO_AUTOLIBS # Disables Arduino library detection
|
# NO_AUTOLIBS # Disables Arduino library detection
|
||||||
#
|
#
|
||||||
# Here is a short example for a target named test:
|
# Here is a short example for a target named test:
|
||||||
#
|
#
|
||||||
# generate_arduino_library(
|
# generate_arduino_library(
|
||||||
# NAME test
|
# NAME test
|
||||||
# SRCS test.cpp
|
# SRCS test.cpp
|
||||||
# test2.cpp
|
# test2.cpp
|
||||||
# HDRS test.h test2.h
|
# HDRS test.h test2.h
|
||||||
# BOARD uno)
|
# BOARD uno)
|
||||||
|
@ -163,7 +163,7 @@ include(CMakeParseArguments)
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# User Functions
|
# User Functions
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
|
@ -234,7 +234,7 @@ function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
|
||||||
set(INPUT_BOARD ${ARDUINO_DEFAULT_BOARD})
|
set(INPUT_BOARD ${ARDUINO_DEFAULT_BOARD})
|
||||||
endif()
|
endif()
|
||||||
required_variables(VARS INPUT_SRCS INPUT_BOARD MSG "must define for target ${INPUT_NAME}")
|
required_variables(VARS INPUT_SRCS INPUT_BOARD MSG "must define for target ${INPUT_NAME}")
|
||||||
|
|
||||||
set(ALL_LIBS)
|
set(ALL_LIBS)
|
||||||
set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS})
|
set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS})
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
||||||
|
|
||||||
add_library(${INPUT_NAME} ${ALL_SRCS})
|
add_library(${INPUT_NAME} ${ALL_SRCS})
|
||||||
|
|
||||||
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${INPUT_BOARD})
|
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${INPUT_BOARD})
|
||||||
|
@ -294,7 +294,7 @@ function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME)
|
||||||
set(LIB_DEP_INCLUDES)
|
set(LIB_DEP_INCLUDES)
|
||||||
|
|
||||||
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
|
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
|
||||||
|
|
||||||
if(NOT "${INPUT_SKETCH}" STREQUAL "")
|
if(NOT "${INPUT_SKETCH}" STREQUAL "")
|
||||||
get_filename_component(INPUT_SKETCH "${INPUT_SKETCH}" ABSOLUTE)
|
get_filename_component(INPUT_SKETCH "${INPUT_SKETCH}" ABSOLUTE)
|
||||||
setup_arduino_sketch(${INPUT_NAME} ${INPUT_SKETCH} ALL_SRCS)
|
setup_arduino_sketch(${INPUT_NAME} ${INPUT_SKETCH} ALL_SRCS)
|
||||||
|
@ -311,15 +311,15 @@ function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME)
|
||||||
if(NOT INPUT_NO_AUTOLIBS)
|
if(NOT INPUT_NO_AUTOLIBS)
|
||||||
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${LIB_DEP_INCLUDES}" "")
|
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${LIB_DEP_INCLUDES}" "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
||||||
|
|
||||||
setup_arduino_target(${INPUT_NAME} ${INPUT_BOARD} "${ALL_SRCS}" "${ALL_LIBS}" "${LIB_DEP_INCLUDES}" "")
|
setup_arduino_target(${INPUT_NAME} ${INPUT_BOARD} "${ALL_SRCS}" "${ALL_LIBS}" "${LIB_DEP_INCLUDES}" "")
|
||||||
|
|
||||||
if(INPUT_PORT)
|
if(INPUT_PORT)
|
||||||
setup_arduino_upload(${INPUT_BOARD} ${INPUT_NAME} ${INPUT_PORT} "${INPUT_PROGRAMMER}" "${INPUT_AFLAGS}")
|
setup_arduino_upload(${INPUT_BOARD} ${INPUT_NAME} ${INPUT_PORT} "${INPUT_PROGRAMMER}" "${INPUT_AFLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(INPUT_SERIAL)
|
if(INPUT_SERIAL)
|
||||||
setup_serial_target(${INPUT_NAME} "${INPUT_SERIAL}")
|
setup_serial_target(${INPUT_NAME} "${INPUT_SERIAL}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -378,21 +378,21 @@ function(GENERATE_ARDUINO_EXAMPLE LIBRARY_NAME EXAMPLE_NAME)
|
||||||
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${LIB_DEP_INCLUDES}" "")
|
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${LIB_DEP_INCLUDES}" "")
|
||||||
|
|
||||||
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
||||||
|
|
||||||
setup_arduino_target(${TARGET_NAME} ${INPUT_BOARD} "${ALL_SRCS}" "${ALL_LIBS}" "${LIB_DEP_INCLUDES}" "")
|
setup_arduino_target(${TARGET_NAME} ${INPUT_BOARD} "${ALL_SRCS}" "${ALL_LIBS}" "${LIB_DEP_INCLUDES}" "")
|
||||||
|
|
||||||
if(INPUT_PORT)
|
if(INPUT_PORT)
|
||||||
#TODO fill in options (AFLAGS)
|
#TODO fill in options (AFLAGS)
|
||||||
setup_arduino_upload(${INPUT_BOARD} ${TARGET_NAME} ${INPUT_PORT} "${INPUT_PROGRAMMER}" "")
|
setup_arduino_upload(${INPUT_BOARD} ${TARGET_NAME} ${INPUT_PORT} "${INPUT_PROGRAMMER}" "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(INPUT_SERIAL)
|
if(INPUT_SERIAL)
|
||||||
setup_serial_target(${TARGET_NAME} "${INPUT_SERIAL}")
|
setup_serial_target(${TARGET_NAME} "${INPUT_SERIAL}")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
|
@ -505,7 +505,7 @@ function(get_arduino_flags COMPILE_FLAGS_VAR LINK_FLAGS_VAR BOARD_ID)
|
||||||
set(COMPILE_FLAGS "${COMPILE_FLAGS} -I${ARDUINO_VARIANTS_PATH}/${PIN_HEADER}")
|
set(COMPILE_FLAGS "${COMPILE_FLAGS} -I${ARDUINO_VARIANTS_PATH}/${PIN_HEADER}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
set(${COMPILE_FLAGS_VAR} "${COMPILE_FLAGS}" PARENT_SCOPE)
|
set(${COMPILE_FLAGS_VAR} "${COMPILE_FLAGS}" PARENT_SCOPE)
|
||||||
set(${LINK_FLAGS_VAR} "${LINK_FLAGS}" PARENT_SCOPE)
|
set(${LINK_FLAGS_VAR} "${LINK_FLAGS}" PARENT_SCOPE)
|
||||||
|
|
||||||
|
@ -808,11 +808,9 @@ function(setup_arduino_bootloader_upload TARGET_NAME BOARD_ID PORT AVRDUDE_FLAGS
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND AVRDUDE_ARGS "-Uflash:w:${TARGET_NAME}.hex")
|
list(APPEND AVRDUDE_ARGS "-Uflash:w:${TARGET_NAME}.hex")
|
||||||
message("\n")
|
|
||||||
message(${AVRDUDE_ARGS})
|
|
||||||
message("\n")
|
|
||||||
add_custom_target(${UPLOAD_TARGET}
|
add_custom_target(${UPLOAD_TARGET}
|
||||||
${ARDUINO_AVRDUDE_PROGRAM}
|
${ARDUINO_AVRDUDE_PROGRAM}
|
||||||
${AVRDUDE_ARGS}
|
${AVRDUDE_ARGS}
|
||||||
DEPENDS ${TARGET_NAME})
|
DEPENDS ${TARGET_NAME})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -827,7 +825,7 @@ endfunction()
|
||||||
# PROGRAMMER - programmer id
|
# PROGRAMMER - programmer id
|
||||||
# PORT - serial port
|
# PORT - serial port
|
||||||
# AVRDUDE_FLAGS - avrdude flags (override)
|
# AVRDUDE_FLAGS - avrdude flags (override)
|
||||||
#
|
#
|
||||||
# Sets up target for burning firmware via a programmer.
|
# Sets up target for burning firmware via a programmer.
|
||||||
#
|
#
|
||||||
# The target for burning the firmware is ${TARGET_NAME}-burn .
|
# The target for burning the firmware is ${TARGET_NAME}-burn .
|
||||||
|
@ -848,7 +846,7 @@ function(setup_arduino_programmer_burn TARGET_NAME BOARD_ID PROGRAMMER PORT AVRD
|
||||||
list(APPEND AVRDUDE_ARGS "-Uflash:w:${TARGET_NAME}.hex")
|
list(APPEND AVRDUDE_ARGS "-Uflash:w:${TARGET_NAME}.hex")
|
||||||
|
|
||||||
add_custom_target(${PROGRAMMER_TARGET}
|
add_custom_target(${PROGRAMMER_TARGET}
|
||||||
${ARDUINO_AVRDUDE_PROGRAM}
|
${ARDUINO_AVRDUDE_PROGRAM}
|
||||||
${AVRDUDE_ARGS}
|
${AVRDUDE_ARGS}
|
||||||
DEPENDS ${TARGET_NAME})
|
DEPENDS ${TARGET_NAME})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -857,7 +855,7 @@ endfunction()
|
||||||
# [PRIVATE/INTERNAL]
|
# [PRIVATE/INTERNAL]
|
||||||
#
|
#
|
||||||
# setup_arduino_bootloader_burn(TARGET_NAME BOARD_ID PROGRAMMER PORT AVRDUDE_FLAGS)
|
# setup_arduino_bootloader_burn(TARGET_NAME BOARD_ID PROGRAMMER PORT AVRDUDE_FLAGS)
|
||||||
#
|
#
|
||||||
# TARGET_NAME - name of target to burn
|
# TARGET_NAME - name of target to burn
|
||||||
# BOARD_ID - board id
|
# BOARD_ID - board id
|
||||||
# PROGRAMMER - programmer id
|
# PROGRAMMER - programmer id
|
||||||
|
@ -914,7 +912,7 @@ function(setup_arduino_bootloader_burn TARGET_NAME BOARD_ID PROGRAMMER PORT AVRD
|
||||||
|
|
||||||
# Create burn bootloader target
|
# Create burn bootloader target
|
||||||
add_custom_target(${BOOTLOADER_TARGET}
|
add_custom_target(${BOOTLOADER_TARGET}
|
||||||
${ARDUINO_AVRDUDE_PROGRAM}
|
${ARDUINO_AVRDUDE_PROGRAM}
|
||||||
${AVRDUDE_ARGS}
|
${AVRDUDE_ARGS}
|
||||||
WORKING_DIRECTORY ${ARDUINO_BOOTLOADERS_PATH}/${${BOARD_ID}.bootloader.path}
|
WORKING_DIRECTORY ${ARDUINO_BOOTLOADERS_PATH}/${${BOARD_ID}.bootloader.path}
|
||||||
DEPENDS ${TARGET_NAME})
|
DEPENDS ${TARGET_NAME})
|
||||||
|
@ -1010,7 +1008,7 @@ function(setup_arduino_bootloader_args BOARD_ID TARGET_NAME PORT AVRDUDE_FLAGS O
|
||||||
"-b${${BOARD_ID}.upload.speed}" # Baud rate
|
"-b${${BOARD_ID}.upload.speed}" # Baud rate
|
||||||
"-P${PORT}" # Serial port
|
"-P${PORT}" # Serial port
|
||||||
"-D" # Dont erase
|
"-D" # Dont erase
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND AVRDUDE_ARGS ${AVRDUDE_FLAGS})
|
list(APPEND AVRDUDE_ARGS ${AVRDUDE_FLAGS})
|
||||||
|
|
||||||
|
@ -1099,7 +1097,7 @@ endfunction()
|
||||||
# SETTINGS_PATH - File path of settings file to load.
|
# SETTINGS_PATH - File path of settings file to load.
|
||||||
#
|
#
|
||||||
# Load a Arduino style settings file into the cache.
|
# Load a Arduino style settings file into the cache.
|
||||||
#
|
#
|
||||||
# Examples of this type of settings file is the boards.txt and
|
# Examples of this type of settings file is the boards.txt and
|
||||||
# programmers.txt files located in ${ARDUINO_SDK}/hardware/arduino.
|
# programmers.txt files located in ${ARDUINO_SDK}/hardware/arduino.
|
||||||
#
|
#
|
||||||
|
@ -1128,7 +1126,7 @@ endfunction()
|
||||||
# set(uno.SETTINGS name upload build) # List of settings for uno
|
# set(uno.SETTINGS name upload build) # List of settings for uno
|
||||||
# set(uno.upload.SUBSETTINGS protocol maximum_size) # List of sub-settings for uno.upload
|
# set(uno.upload.SUBSETTINGS protocol maximum_size) # List of sub-settings for uno.upload
|
||||||
# set(uno.build.SUBSETTINGS mcu core) # List of sub-settings for uno.build
|
# set(uno.build.SUBSETTINGS mcu core) # List of sub-settings for uno.build
|
||||||
#
|
#
|
||||||
# The ${ENTRY_NAME}.SETTINGS variable lists all settings for the entry, while
|
# The ${ENTRY_NAME}.SETTINGS variable lists all settings for the entry, while
|
||||||
# ${ENTRY_NAME}.SUBSETTINGS variables lists all settings for a sub-setting of
|
# ${ENTRY_NAME}.SUBSETTINGS variables lists all settings for a sub-setting of
|
||||||
# a entry setting pair.
|
# a entry setting pair.
|
||||||
|
@ -1188,7 +1186,7 @@ function(LOAD_ARDUINO_STYLE_SETTINGS SETTINGS_LIST SETTINGS_PATH)
|
||||||
# Save setting value
|
# Save setting value
|
||||||
set(${FULL_SETTING_NAME} ${SETTING_VALUE}
|
set(${FULL_SETTING_NAME} ${SETTING_VALUE}
|
||||||
CACHE INTERNAL "Arduino ${ENTRY_NAME} Board setting")
|
CACHE INTERNAL "Arduino ${ENTRY_NAME} Board setting")
|
||||||
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -1320,7 +1318,7 @@ function(SETUP_ARDUINO_SKETCH TARGET_NAME SKETCH_PATH OUTPUT_VAR)
|
||||||
file(GLOB SKETCH_SOURCES ${SKETCH_PATH}/*.pde ${SKETCH_PATH}/*.ino)
|
file(GLOB SKETCH_SOURCES ${SKETCH_PATH}/*.pde ${SKETCH_PATH}/*.ino)
|
||||||
list(REMOVE_ITEM SKETCH_SOURCES ${MAIN_SKETCH})
|
list(REMOVE_ITEM SKETCH_SOURCES ${MAIN_SKETCH})
|
||||||
list(SORT SKETCH_SOURCES)
|
list(SORT SKETCH_SOURCES)
|
||||||
|
|
||||||
generate_cpp_from_sketch("${MAIN_SKETCH}" "${SKETCH_SOURCES}" "${SKETCH_CPP}")
|
generate_cpp_from_sketch("${MAIN_SKETCH}" "${SKETCH_SOURCES}" "${SKETCH_CPP}")
|
||||||
|
|
||||||
# Regenerate build system if sketch changes
|
# Regenerate build system if sketch changes
|
||||||
|
@ -1407,7 +1405,7 @@ function(GENERATE_CPP_FROM_SKETCH MAIN_SKETCH_PATH SKETCH_SOURCES SKETCH_CPP)
|
||||||
|
|
||||||
# Write function prototypes
|
# Write function prototypes
|
||||||
file(APPEND ${SKETCH_CPP} "\n//=== START Forward: ${SKETCH_SOURCE_PATH}\n")
|
file(APPEND ${SKETCH_CPP} "\n//=== START Forward: ${SKETCH_SOURCE_PATH}\n")
|
||||||
foreach(SKETCH_PROTOTYPE ${SKETCH_PROTOTYPES})
|
foreach(SKETCH_PROTOTYPE ${SKETCH_PROTOTYPES})
|
||||||
string(REPLACE "\n" " " SKETCH_PROTOTYPE "${SKETCH_PROTOTYPE}")
|
string(REPLACE "\n" " " SKETCH_PROTOTYPE "${SKETCH_PROTOTYPE}")
|
||||||
string(REPLACE "{" "" SKETCH_PROTOTYPE "${SKETCH_PROTOTYPE}")
|
string(REPLACE "{" "" SKETCH_PROTOTYPE "${SKETCH_PROTOTYPE}")
|
||||||
arduino_debug_msg("\tprototype: ${SKETCH_PROTOTYPE};")
|
arduino_debug_msg("\tprototype: ${SKETCH_PROTOTYPE};")
|
||||||
|
@ -1415,7 +1413,7 @@ function(GENERATE_CPP_FROM_SKETCH MAIN_SKETCH_PATH SKETCH_SOURCES SKETCH_CPP)
|
||||||
endforeach()
|
endforeach()
|
||||||
file(APPEND ${SKETCH_CPP} "//=== END Forward: ${SKETCH_SOURCE_PATH}\n")
|
file(APPEND ${SKETCH_CPP} "//=== END Forward: ${SKETCH_SOURCE_PATH}\n")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Write Sketch CPP source
|
# Write Sketch CPP source
|
||||||
get_num_lines("${SKETCH_HEAD}" HEAD_NUM_LINES)
|
get_num_lines("${SKETCH_HEAD}" HEAD_NUM_LINES)
|
||||||
file(APPEND ${SKETCH_CPP} "#line ${HEAD_NUM_LINES} \"${MAIN_SKETCH_PATH}\"\n")
|
file(APPEND ${SKETCH_CPP} "#line ${HEAD_NUM_LINES} \"${MAIN_SKETCH_PATH}\"\n")
|
||||||
|
@ -1589,7 +1587,7 @@ endfunction()
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# C Flags
|
# C Flags
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
set(ARDUINO_C_FLAGS "-mcall-prologues -ffunction-sections -fdata-sections")
|
set(ARDUINO_C_FLAGS "-mcall-prologues -ffunction-sections -fdata-sections")
|
||||||
set(CMAKE_C_FLAGS "-Os ${ARDUINO_C_FLAGS}" CACHE STRING "")
|
set(CMAKE_C_FLAGS "-Os ${ARDUINO_C_FLAGS}" CACHE STRING "")
|
||||||
|
@ -1599,7 +1597,7 @@ set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG -w ${ARDUINO_C_FLAGS}" CACHE STRI
|
||||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -w ${ARDUINO_C_FLAGS}" CACHE STRING "")
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -w ${ARDUINO_C_FLAGS}" CACHE STRING "")
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# C++ Flags
|
# C++ Flags
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
set(ARDUINO_CXX_FLAGS "${ARDUINO_C_FLAGS} -fno-exceptions")
|
set(ARDUINO_CXX_FLAGS "${ARDUINO_C_FLAGS} -fno-exceptions")
|
||||||
set(CMAKE_CXX_FLAGS "-Os ${ARDUINO_CXX_FLAGS}" CACHE STRING "")
|
set(CMAKE_CXX_FLAGS "-Os ${ARDUINO_CXX_FLAGS}" CACHE STRING "")
|
||||||
|
@ -1636,7 +1634,7 @@ set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${ARDUINO_LINKER_FLAGS}" CACHE STR
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# Arduino Settings
|
# Arduino Settings
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
set(ARDUINO_OBJCOPY_EEP_FLAGS -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load
|
set(ARDUINO_OBJCOPY_EEP_FLAGS -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load
|
||||||
--no-change-warnings --change-section-lma .eeprom=0 CACHE STRING "")
|
--no-change-warnings --change-section-lma .eeprom=0 CACHE STRING "")
|
||||||
|
@ -1644,7 +1642,7 @@ set(ARDUINO_OBJCOPY_HEX_FLAGS -O ihex -R .eeprom CACHE STRING "")
|
||||||
set(ARDUINO_AVRDUDE_FLAGS -V CACHE STRING "")
|
set(ARDUINO_AVRDUDE_FLAGS -V CACHE STRING "")
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# Initialization
|
# Initialization
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
if(NOT ARDUINO_FOUND AND ARDUINO_SDK_PATH)
|
if(NOT ARDUINO_FOUND AND ARDUINO_SDK_PATH)
|
||||||
find_file(ARDUINO_CORES_PATH
|
find_file(ARDUINO_CORES_PATH
|
||||||
|
@ -1654,7 +1652,7 @@ if(NOT ARDUINO_FOUND AND ARDUINO_SDK_PATH)
|
||||||
DOC "Path to directory containing the Arduino core sources.")
|
DOC "Path to directory containing the Arduino core sources.")
|
||||||
|
|
||||||
find_file(ARDUINO_VARIANTS_PATH
|
find_file(ARDUINO_VARIANTS_PATH
|
||||||
NAMES variants
|
NAMES variants
|
||||||
PATHS ${ARDUINO_SDK_PATH}
|
PATHS ${ARDUINO_SDK_PATH}
|
||||||
PATH_SUFFIXES hardware/arduino
|
PATH_SUFFIXES hardware/arduino
|
||||||
DOC "Path to directory containing the Arduino variant sources.")
|
DOC "Path to directory containing the Arduino variant sources.")
|
||||||
|
@ -1713,7 +1711,7 @@ if(NOT ARDUINO_FOUND AND ARDUINO_SDK_PATH)
|
||||||
set(ARDUINO_DEFAULT_PROGRAMMER CACHE STRING "Default Arduino Programmer ID when not specified.")
|
set(ARDUINO_DEFAULT_PROGRAMMER CACHE STRING "Default Arduino Programmer ID when not specified.")
|
||||||
|
|
||||||
# Ensure that all required paths are found
|
# Ensure that all required paths are found
|
||||||
required_variables(VARS
|
required_variables(VARS
|
||||||
ARDUINO_CORES_PATH
|
ARDUINO_CORES_PATH
|
||||||
ARDUINO_BOOTLOADERS_PATH
|
ARDUINO_BOOTLOADERS_PATH
|
||||||
ARDUINO_LIBRARIES_PATH
|
ARDUINO_LIBRARIES_PATH
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
unsigned int time = 0; // profile seconds
|
unsigned int time = 0; // profile seconds
|
||||||
unsigned int degrees = 25; // actual oven temp
|
unsigned int temperatur = 25; // actual oven temp
|
||||||
|
unsigned int last_temperatur = 25;
|
||||||
|
|
||||||
unsigned int Ts_max = 200; // °C
|
unsigned int Ts_max = 200; // °C
|
||||||
unsigned int Ts_min = 150; // °C
|
unsigned int Ts_min = 150; // °C
|
||||||
|
@ -13,7 +14,26 @@ unsigned int peak_duration = 30; // 20-40s
|
||||||
unsigned int rampdown_max = 6; // 6°C/s max
|
unsigned int rampdown_max = 6; // 6°C/s max
|
||||||
unsigned int time_max = 480; // 8*60s max
|
unsigned int time_max = 480; // 8*60s max
|
||||||
|
|
||||||
byte state; // 0 = start, 1 = preheat, 2 = tal, 3 = max, 4 = rampdown
|
#define START_STATE 0
|
||||||
|
#define PREHEAT_STATE 1
|
||||||
|
#define TAL_STATE 2
|
||||||
|
#define MAX_STATE 3
|
||||||
|
#define RAMPDOWN_STATE 4
|
||||||
|
#define END_STATE 5
|
||||||
|
#define ERROR_STATE 6
|
||||||
|
|
||||||
|
byte state = START_STATE;
|
||||||
|
|
||||||
|
unsigned int Ts_min_time = 0;
|
||||||
|
unsigned int Ts_max_time = 0;
|
||||||
|
unsigned int Tl_time = 0;
|
||||||
|
unsigned int Tp_time = 0;
|
||||||
|
unsigned int Tl_end_time = 0;
|
||||||
|
|
||||||
|
#define RAMPUP_TOO_FAST 1
|
||||||
|
#define RAMPDOWN_TOO_FAST 2
|
||||||
|
unsigned int error_condition = 0;
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(13, OUTPUT);
|
pinMode(13, OUTPUT);
|
||||||
|
@ -21,33 +41,54 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_temp() {
|
void get_temp() {
|
||||||
|
// simulating an +1K/s rampup oven
|
||||||
|
last_temperatur = ++temperatur;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean check_rampup_rate() {
|
||||||
|
if (temperatur - last_temperatur > rampup_rate) {
|
||||||
|
error_condition = RAMPUP_TOO_FAST;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
time = millis() / 1000;
|
time = millis() / 1000;
|
||||||
|
get_temp();
|
||||||
|
Serial.print(time);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(temperatur);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println(last_temperatur);
|
||||||
|
|
||||||
|
|
||||||
// wait a second so as not to send massive amounts of data
|
// wait a second so as not to send massive amounts of data
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case START_STATE:
|
||||||
if (degrees > Ts_min) {
|
// going from room temp to preheat, nothing to check here
|
||||||
|
if (!check_rampup_rate())
|
||||||
|
goto error;
|
||||||
|
if (temperatur > Ts_min) {
|
||||||
state++;
|
state++;
|
||||||
}
|
}
|
||||||
case 1:
|
case PREHEAT_STATE:
|
||||||
|
if (temperatur > Ts_max)
|
||||||
|
state++;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case TAL_STATE:
|
||||||
break;
|
break;
|
||||||
case 3:
|
case MAX_STATE:
|
||||||
break;
|
break;
|
||||||
case 4:
|
case RAMPDOWN_STATE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (degrees > 60) {
|
error:
|
||||||
Serial.print("seconds: ");
|
state = END_STATE;
|
||||||
Serial.println(time);
|
Serial.println(error_condition);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue