Compare commits
38 Commits
Author | SHA1 | Date |
---|---|---|
Siwat Sirichai | 5c55023829 | |
Siwat Sirichai | 0a93b41845 | |
Siwat Sirichai | c1f4f5c1cd | |
Siwat Sirichai | 3736f53112 | |
Siwat Sirichai | 24871d2316 | |
Siwat Sirichai | bc85bcf601 | |
Siwat Sirichai | 1988bc953e | |
Siwat Sirichai | 5f5176969f | |
Siwat Sirichai | 816d31ad5f | |
Siwat Sirichai | 2b728b55c5 | |
Siwat Sirichai | 8ca7c5407d | |
Siwat Sirichai | ed85d07148 | |
Siwat Sirichai | c8ff21f522 | |
Siwat Sirichai | fc04b190a4 | |
Siwat Sirichai | 921a5f1cc4 | |
Siwat Sirichai | 010c92fc17 | |
Siwat Sirichai | 93468a074d | |
Siwat Sirichai | d489126f14 | |
Siwat Sirichai | dae545a63e | |
Siwat Sirichai | 9e2efddfc9 | |
Siwat Sirichai | 192b1468f8 | |
Siwat Sirichai | e3c07411cb | |
Siwat Sirichai | a9181c90e6 | |
Siwat Sirichai | 3b146b3bdf | |
Siwat Sirichai | 47f5e325aa | |
Siwat Sirichai | 1e08039a1e | |
Siwat Sirichai | 38a656ee55 | |
Siwat Sirichai | ef43526d2c | |
Siwat Sirichai | 62f774964d | |
Siwat Sirichai | 549500822c | |
Siwat Sirichai | 557df3333e | |
Siwat Sirichai | bb0838ad30 | |
Siwat Sirichai | 1010dae0e6 | |
Siwat Sirichai | d2610b983f | |
Siwat Sirichai | 509f18b7cc | |
Siwat Sirichai | 47402e1c71 | |
Siwat Sirichai | 02eb63a54c | |
Siwat Sirichai | e124c73f67 |
|
@ -4,3 +4,7 @@
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
.vscode/ipch
|
.vscode/ipch
|
||||||
.vs/
|
.vs/
|
||||||
|
.vscode/
|
||||||
|
.vscode/settings.json
|
||||||
|
firmware/
|
||||||
|
release/
|
|
@ -1,20 +1,78 @@
|
||||||
{
|
{
|
||||||
"C_Cpp.errorSquiggles": "enabled",
|
"C_Cpp.errorSquiggles": "enabled",
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.cps": "javascript",
|
"*.cps": "javascript",
|
||||||
"string": "cpp",
|
"string": "cpp",
|
||||||
"optional": "cpp",
|
"optional": "cpp",
|
||||||
"istream": "cpp",
|
"istream": "cpp",
|
||||||
"ostream": "cpp",
|
"ostream": "cpp",
|
||||||
"system_error": "cpp",
|
"system_error": "cpp",
|
||||||
"array": "cpp",
|
"array": "cpp",
|
||||||
"functional": "cpp",
|
"functional": "cpp",
|
||||||
"tuple": "cpp",
|
"tuple": "cpp",
|
||||||
"type_traits": "cpp",
|
"type_traits": "cpp",
|
||||||
"utility": "cpp",
|
"utility": "cpp",
|
||||||
"*.d": "cpp",
|
"*.d": "cpp",
|
||||||
"*.html": "cpp",
|
"*.html": "cpp",
|
||||||
"*.tcc": "cpp",
|
"*.tcc": "cpp",
|
||||||
"regex": "cpp"
|
"regex": "cpp"
|
||||||
}
|
},
|
||||||
|
"C_Cpp_Runner.msvcBatchPath": "",
|
||||||
|
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||||
|
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||||
|
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||||
|
"C_Cpp_Runner.cStandard": "",
|
||||||
|
"C_Cpp_Runner.cppStandard": "",
|
||||||
|
"C_Cpp_Runner.useMsvc": false,
|
||||||
|
"C_Cpp_Runner.warnings": [
|
||||||
|
"-Wall",
|
||||||
|
"-Wextra",
|
||||||
|
"-Wpedantic",
|
||||||
|
"-Wshadow",
|
||||||
|
"-Wformat=2",
|
||||||
|
"-Wcast-align",
|
||||||
|
"-Wconversion",
|
||||||
|
"-Wsign-conversion",
|
||||||
|
"-Wnull-dereference"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.msvcWarnings": [
|
||||||
|
"/W4",
|
||||||
|
"/permissive-",
|
||||||
|
"/w14242",
|
||||||
|
"/w14287",
|
||||||
|
"/w14296",
|
||||||
|
"/w14311",
|
||||||
|
"/w14826",
|
||||||
|
"/w44062",
|
||||||
|
"/w44242",
|
||||||
|
"/w14905",
|
||||||
|
"/w14906",
|
||||||
|
"/w14263",
|
||||||
|
"/w44265",
|
||||||
|
"/w14928"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.enableWarnings": true,
|
||||||
|
"C_Cpp_Runner.warningsAsError": false,
|
||||||
|
"C_Cpp_Runner.compilerArgs": [],
|
||||||
|
"C_Cpp_Runner.linkerArgs": [],
|
||||||
|
"C_Cpp_Runner.includePaths": [],
|
||||||
|
"C_Cpp_Runner.includeSearch": [
|
||||||
|
"*",
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.excludeSearch": [
|
||||||
|
"**/build",
|
||||||
|
"**/build/**",
|
||||||
|
"**/.*",
|
||||||
|
"**/.*/**",
|
||||||
|
"**/.vscode",
|
||||||
|
"**/.vscode/**"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||||
|
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||||
|
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||||
|
"C_Cpp_Runner.showCompilationTime": false,
|
||||||
|
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||||
|
"C_Cpp_Runner.msvcSecureNoWarnings": false,
|
||||||
|
"cmake.sourceDirectory": "D:/Git/iot-firmware/.pio/libdeps/full/Adafruit BusIO"
|
||||||
}
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git'
|
||||||
|
sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio'
|
||||||
|
sh '/usr/bin/python3 gen_release.py'
|
||||||
|
stash includes: 'release/**/*', name: 'release_binaries'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Publish') {
|
||||||
|
steps {
|
||||||
|
unstash 'release_binaries'
|
||||||
|
archiveArtifacts artifacts: 'release/**/*', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
|
import configparser
|
||||||
|
from time import sleep as delay
|
||||||
|
|
||||||
|
|
||||||
|
# Get the current directory
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
# Define the path to the firmware folder
|
||||||
|
firmware_folder = os.path.join(current_dir, 'firmware')
|
||||||
|
|
||||||
|
# Create the firmware folder if it does not exist
|
||||||
|
if not os.path.exists(firmware_folder):
|
||||||
|
os.makedirs(firmware_folder)
|
||||||
|
|
||||||
|
# Define the path to the release folder
|
||||||
|
release_folder = os.path.join(current_dir, 'release')
|
||||||
|
|
||||||
|
# Get the platformio path from environment variable
|
||||||
|
platformio_path = os.environ.get('PLATFORMIO_PATH')
|
||||||
|
# If the environment variable is not set, use the default path
|
||||||
|
if platformio_path is None:
|
||||||
|
if platform.system() == 'Darwin':
|
||||||
|
platformio_path = os.path.expanduser('~/.platformio/penv/bin/platformio')
|
||||||
|
elif platform.system() == 'Windows':
|
||||||
|
platformio_path = os.path.expanduser('~/.platformio/penv/Scripts/platformio.exe')
|
||||||
|
elif platform.system() == 'Linux':
|
||||||
|
platformio_path = os.path.expanduser('~/.platformio/penv/bin/platformio')
|
||||||
|
|
||||||
|
if os.path.exists(release_folder):
|
||||||
|
# If the release folder exists, delete it
|
||||||
|
shutil.rmtree(release_folder)
|
||||||
|
os.makedirs(release_folder)
|
||||||
|
|
||||||
|
# Get the current Git branch name
|
||||||
|
git_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip()
|
||||||
|
commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode().strip()[:10]
|
||||||
|
|
||||||
|
# If arguments are supplied, build the environments that match the arguments
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
environments = sys.argv[1:]
|
||||||
|
|
||||||
|
# If no argument are supplied, build all environments listed in platformio.ini
|
||||||
|
else:
|
||||||
|
environments = []
|
||||||
|
with open(os.path.join(current_dir, 'platformio.ini')) as f:
|
||||||
|
|
||||||
|
# Iterate over the lines in platformio.ini
|
||||||
|
for line in f.readlines():
|
||||||
|
|
||||||
|
# Check if the line contains the string "env:"
|
||||||
|
if '[env:' in line:
|
||||||
|
|
||||||
|
# Extract the environment using regular expressions
|
||||||
|
environment = re.search(r'\[env:(.*?)\]', line).group(1)
|
||||||
|
|
||||||
|
# Add the environment to the list of environments
|
||||||
|
environments.append(environment)
|
||||||
|
|
||||||
|
# Remove old platformio.ini file from firmware folder if it exists
|
||||||
|
if os.path.isfile(os.path.join(firmware_folder, 'platformio.ini')):
|
||||||
|
os.remove(os.path.join(firmware_folder, 'platformio.ini'))
|
||||||
|
|
||||||
|
# Copy the platformio.ini file to the firmware folder
|
||||||
|
shutil.copyfile(os.path.join(current_dir, 'platformio.ini'), os.path.join(firmware_folder, 'platformio.ini'))
|
||||||
|
|
||||||
|
# Check that the file is copied correctly
|
||||||
|
if not os.path.isfile(os.path.join(firmware_folder, 'platformio.ini')):
|
||||||
|
raise Exception('platformio.ini file not copied correctly')
|
||||||
|
|
||||||
|
# Read the platformio.ini file
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(os.path.join(firmware_folder, 'platformio.ini'))
|
||||||
|
|
||||||
|
# Add firmware version to build_flags in platformio.ini
|
||||||
|
for environment in environments:
|
||||||
|
if 'build_flags' not in config[f'env:{environment}']:
|
||||||
|
config[f'env:{environment}']['build_flags'] = f'-DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"'
|
||||||
|
else:
|
||||||
|
config[f'env:{environment}']['build_flags'] = config[f'env:{environment}']['build_flags'] + f' -DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"'
|
||||||
|
|
||||||
|
# Write the platformio.ini file
|
||||||
|
with open(os.path.join(firmware_folder, 'platformio.ini'), 'w') as configfile:
|
||||||
|
config.write(configfile)
|
||||||
|
|
||||||
|
# if argument is not supplied, build all environments listed in platformio.ini
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
subprocess.run([f'{platformio_path}', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir)
|
||||||
|
|
||||||
|
for environment in environments:
|
||||||
|
if(len(sys.argv) > 1):
|
||||||
|
subprocess.run([f'{platformio_path}', 'run', '-e', environment,'-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir)
|
||||||
|
|
||||||
|
# Iterate over the subfolders in the firmware folder
|
||||||
|
for subfolder in os.listdir(firmware_folder):
|
||||||
|
subfolder_path = os.path.join(firmware_folder, subfolder)
|
||||||
|
|
||||||
|
# Check if the subfolder matches the environment argument
|
||||||
|
if subfolder == environment:
|
||||||
|
# Check if the subfolder contains a firmware.bin file
|
||||||
|
firmware_file = os.path.join(subfolder_path, 'firmware.bin')
|
||||||
|
if os.path.isfile(firmware_file):
|
||||||
|
# Move the firmware.bin file to the release folder with the Git branch name and commit hash appended
|
||||||
|
new_file_name = os.path.join(release_folder, f"{git_branch}_{subfolder}_{commit_hash}.bin")
|
||||||
|
shutil.move(firmware_file, new_file_name)
|
149
platformio.ini
149
platformio.ini
|
@ -8,7 +8,153 @@
|
||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[env:wt32-eth01]
|
[platformio]
|
||||||
|
build_dir = firmware
|
||||||
|
|
||||||
|
[env:full]
|
||||||
|
platform = espressif32
|
||||||
|
board = wt32-eth01
|
||||||
|
framework = arduino
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
build_flags = -DENABLE_INTERNAL_LCD -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_ANALOG_MODULE -DENABLE_WEBUI
|
||||||
|
lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
|
knolleary/PubSubClient@^2.8
|
||||||
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
dersimn/PubSubClientTools@^0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
|
robtillaart/DHTNEW@^0.4.18
|
||||||
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:lcd_climate]
|
||||||
|
platform = espressif32
|
||||||
|
board = wt32-eth01
|
||||||
|
framework = arduino
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
build_flags = -DENABLE_INTERNAL_LCD -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE
|
||||||
|
lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
|
knolleary/PubSubClient@^2.8
|
||||||
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
dersimn/PubSubClientTools@^0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
|
robtillaart/DHTNEW@^0.4.18
|
||||||
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:webui]
|
||||||
|
platform = espressif32
|
||||||
|
board = wt32-eth01
|
||||||
|
framework = arduino
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
build_flags = -DENABLE_WEBUI
|
||||||
|
lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
|
knolleary/PubSubClient@^2.8
|
||||||
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
dersimn/PubSubClientTools@^0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
|
robtillaart/DHTNEW@^0.4.18
|
||||||
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
|
|
||||||
|
[env:climate_webui]
|
||||||
|
platform = espressif32
|
||||||
|
board = wt32-eth01
|
||||||
|
framework = arduino
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
build_flags = -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_WEBUI
|
||||||
|
lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
|
knolleary/PubSubClient@^2.8
|
||||||
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
dersimn/PubSubClientTools@^0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
|
robtillaart/DHTNEW@^0.4.18
|
||||||
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:lcd_webui]
|
||||||
|
platform = espressif32
|
||||||
|
board = wt32-eth01
|
||||||
|
framework = arduino
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
build_flags = -DENABLE_INTERNAL_LCD -DENABLE_WEBUI
|
||||||
|
lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
|
knolleary/PubSubClient@^2.8
|
||||||
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
dersimn/PubSubClientTools@^0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
|
robtillaart/DHTNEW@^0.4.18
|
||||||
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:ir_climate_analog_webui]
|
||||||
|
platform = espressif32
|
||||||
|
board = wt32-eth01
|
||||||
|
framework = arduino
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
build_flags = -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_ANALOG_MODULE -DENABLE_WEBUI
|
||||||
|
lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
|
knolleary/PubSubClient@^2.8
|
||||||
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
dersimn/PubSubClientTools@^0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
|
robtillaart/DHTNEW@^0.4.18
|
||||||
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:lcd_analog]
|
||||||
|
platform = espressif32
|
||||||
|
board = wt32-eth01
|
||||||
|
framework = arduino
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
build_flags = -DENABLE_INTERNAL_LCD -DENABLE_ANALOG_MODULE
|
||||||
|
lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
|
knolleary/PubSubClient@^2.8
|
||||||
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
dersimn/PubSubClientTools@^0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
|
robtillaart/DHTNEW@^0.4.18
|
||||||
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:lcd]
|
||||||
|
platform = espressif32
|
||||||
|
board = wt32-eth01
|
||||||
|
framework = arduino
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
build_flags = -DENABLE_INTERNAL_LCD
|
||||||
|
lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
|
knolleary/PubSubClient@^2.8
|
||||||
|
ivanseidel/ArduinoThread@^2.1.1
|
||||||
|
arduino-libraries/Arduino_BuiltIn@^1.0.0
|
||||||
|
dersimn/PubSubClientTools@^0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
|
robtillaart/DHTNEW@^0.4.18
|
||||||
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:minimal]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = wt32-eth01
|
board = wt32-eth01
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
@ -23,4 +169,3 @@ lib_deps = siwats/ESPMegaPROR3@^1.3.0
|
||||||
seithan/Easy Nextion Library@^1.0.6
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
robtillaart/FRAM_I2C@^0.6.1
|
robtillaart/FRAM_I2C@^0.6.1
|
||||||
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||||
monitor_speed = 115200
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
# IoT Core OS V3
|
||||||
|
This is an OS for the ESPMega PRO R3 Programable Logic Controller
|
||||||
|
|
||||||
|
## **Compatibility**
|
||||||
|
1. **CPU**
|
||||||
|
- ESPMega PRO R3.0a/b
|
||||||
|
- ESPMega PRO R3.1a
|
||||||
|
- ESPMega PRO R3.2a/b/c
|
||||||
|
2. **CPU Add-ons**
|
||||||
|
- ESPMega PRO Internal Display Module
|
||||||
|
- ESPMega PRO External Touch Display Module
|
||||||
|
3. **Add-on Cards**
|
||||||
|
- ESPMega I/O Analog Expansion Card
|
||||||
|
- ESPMega I/O IR Expansion Kit
|
||||||
|
- ESPMega I/O Card Hub
|
||||||
|
- ESPMega I/O UART Multiplexer [WIP]
|
||||||
|
- ESPMega I/O Digital Expansion Card [WIP]
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Internal Touch Display support for diagnostics and configuration
|
||||||
|
- WebUI for Configuration and OTA Update
|
||||||
|
- Allowing for reading and writing to registers from MQTT
|
||||||
|
- Provides abstraction layer to the MQTT protocol and internal components
|
||||||
|
|
||||||
|
## User Code and 3rd Party Extension
|
||||||
|
This OS allows the user to write custom program for the device to run in the OS<br/>
|
||||||
|
### *usercode.hpp* and *user_code.cpp*
|
||||||
|
### I/O Abstraction Layer
|
||||||
|
### MQTT Abstraction Layer
|
||||||
|
### RTC and Clock Abstraction Layer
|
||||||
|
### Persistent Storage Abstraction Layer
|
||||||
|
### Climate Abstraction Layer
|
||||||
|
### Energy Monitoring Abstraction Layer
|
||||||
|
### Timer Abstraction Layer
|
||||||
|
### LCD Abstraction Layer
|
File diff suppressed because it is too large
Load Diff
|
@ -43,15 +43,16 @@
|
||||||
#endif
|
#endif
|
||||||
#include "espmega_iot_timer.hpp"
|
#include "espmega_iot_timer.hpp"
|
||||||
|
|
||||||
void mqtt_callback(char* topic, byte* payload, unsigned int length);
|
IRAM_ATTR void mqtt_callback(char* topic, byte* payload, unsigned int length);
|
||||||
void virtual_interrupt_loop();
|
void virtual_interrupt_loop();
|
||||||
void virtual_interrupt_callback(int pin, int state);
|
void virtual_interrupt_callback(int pin, int state);
|
||||||
|
void virtual_interrupt_preload();
|
||||||
void network_begin();
|
void network_begin();
|
||||||
void mqtt_connect();
|
void mqtt_connect();
|
||||||
void mqtt_subscribe();
|
void mqtt_subscribe();
|
||||||
void thread_initialization();
|
void thread_initialization();
|
||||||
void pwm_state_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
IRAM_ATTR void pwm_state_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
||||||
void pwm_value_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
IRAM_ATTR void pwm_value_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
||||||
void state_request_callback();
|
void state_request_callback();
|
||||||
void io_begin();
|
void io_begin();
|
||||||
void ir_loop();
|
void ir_loop();
|
||||||
|
@ -60,8 +61,9 @@ void ota_begin();
|
||||||
|
|
||||||
void publish_pwm_states();
|
void publish_pwm_states();
|
||||||
void publish_pwm_state(int id);
|
void publish_pwm_state(int id);
|
||||||
void pwm_set_state(int id, int state);
|
void publish_pwm_value(int id);
|
||||||
void pwm_set_value(int id, int value);
|
IRAM_ATTR void pwm_set_state(int id, int state);
|
||||||
|
IRAM_ATTR void pwm_set_value(int id, int value);
|
||||||
void pwm_toggle(int id);
|
void pwm_toggle(int id);
|
||||||
void pwm_toggle(int id1, int id2);
|
void pwm_toggle(int id1, int id2);
|
||||||
void pwm_cycle_value(int id);
|
void pwm_cycle_value(int id);
|
||||||
|
@ -104,8 +106,8 @@ void trigger13();
|
||||||
void trigger14();
|
void trigger14();
|
||||||
void trigger15();
|
void trigger15();
|
||||||
|
|
||||||
void eeprom_retrieve_init();
|
void fram_retrieve_init();
|
||||||
void eeprom_pwm_update();
|
void fram_pwm_update();
|
||||||
|
|
||||||
void lcd_ac_refresh_fan();
|
void lcd_ac_refresh_fan();
|
||||||
void lcd_ac_refresh_mode();
|
void lcd_ac_refresh_mode();
|
||||||
|
@ -115,20 +117,47 @@ void set_netmask(String address);
|
||||||
void set_dns(String address);
|
void set_dns(String address);
|
||||||
void set_gw(String address);
|
void set_gw(String address);
|
||||||
void set_mqtt_server(String address);
|
void set_mqtt_server(String address);
|
||||||
void eeprom_ip_update(uint16_t rom_address, uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4);
|
void fram_ip_update(uint16_t rom_address, uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4);
|
||||||
IPAddress eeprom_ip_retrieve(uint16_t rom_address);
|
IPAddress fram_ip_retrieve(uint16_t rom_address);
|
||||||
void set_hostname(String hostname);
|
void set_hostname(String hostname);
|
||||||
void eeprom_hostname_retrieve();
|
void fram_hostname_retrieve();
|
||||||
void set_basetopic(String topic);
|
void set_basetopic(String topic);
|
||||||
void eeprom_basetopic_retrieve();
|
void fram_basetopic_retrieve();
|
||||||
void mqtt_port_set(uint16_t port);
|
void mqtt_port_set(uint16_t port);
|
||||||
void eeprom_mqtt_port_retrieve();
|
void fram_mqtt_port_retrieve();
|
||||||
void eeprom_mqtt_username_retrieve();
|
void fram_mqtt_username_retrieve();
|
||||||
void eeprom_mqtt_password_retrieve();
|
void fram_mqtt_password_retrieve();
|
||||||
void set_mqtt_username(String username);
|
void set_mqtt_username(String username);
|
||||||
void set_mqtt_password(String password);
|
void set_mqtt_password(String password);
|
||||||
void eeprom_mqtt_useauth_retrieve();
|
void fram_mqtt_useauth_retrieve();
|
||||||
void set_mqtt_useauth(bool use_auth);
|
void set_mqtt_useauth(bool use_auth);
|
||||||
|
|
||||||
void factory_reset();
|
void factory_reset();
|
||||||
void check_boot_reset();
|
void check_boot_reset();
|
||||||
|
|
||||||
|
void enable_adc(int id);
|
||||||
|
void disable_adc(int id);
|
||||||
|
void adc_update(int id);
|
||||||
|
void adc_update_force(int id);
|
||||||
|
void adc_update_all();
|
||||||
|
void adc_loop();
|
||||||
|
void publish_adc_value(int id);
|
||||||
|
void publish_adc_values();
|
||||||
|
uint16_t get_adc_value(int id);
|
||||||
|
void adc_set_state_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length);
|
||||||
|
void dac_set_value(int id, int value);
|
||||||
|
void dac_set_state(int id, bool state);
|
||||||
|
void dac_set_value_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length);
|
||||||
|
void dac_set_state_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length);
|
||||||
|
void publish_dac_value(int id);
|
||||||
|
void publish_dac_state(int id);
|
||||||
|
void publish_dac_values();
|
||||||
|
void publish_dac_states();
|
||||||
|
void publish_adc_state(int id);
|
||||||
|
void publish_adc_states();
|
||||||
|
uint16_t adc_get_value(int id);
|
||||||
|
bool adc_get_state(int id);
|
||||||
|
uint16_t dac_get_value(int id);
|
||||||
|
bool dac_get_state(int id);
|
||||||
|
|
||||||
|
void pwm_set_publish_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length);
|
|
@ -6,19 +6,31 @@
|
||||||
#include "espmega_iot_timer.hpp"
|
#include "espmega_iot_timer.hpp"
|
||||||
#include "espmega_iot_external_lcd.hpp"
|
#include "espmega_iot_external_lcd.hpp"
|
||||||
|
|
||||||
// Enable Software Module(s)
|
// Bus Overclocking Configuration
|
||||||
#define ENABLE_INTERNAL_LCD
|
// Do not enable if you are using external I/O cards as it will cause signal integrity issues.
|
||||||
#define ENABLE_IR_MODULE
|
// Choose only one mode
|
||||||
#define ENABLE_CLIMATE_MODULE // Require IR Module
|
//#define OVERCLOCK_FM
|
||||||
#define ENABLE_WEBUI
|
//#define OVERCLOCK_FM2
|
||||||
|
|
||||||
// Infrared Transciever
|
// I/O Configuration
|
||||||
|
#define VIRTUAL_INTERRUPT_PRELOAD // Preload Virtual Interrupts buffer
|
||||||
|
|
||||||
|
// Enable Software Module(s)
|
||||||
|
// Deprecated. Use Build Flags instead.
|
||||||
|
// #define ENABLE_INTERNAL_LCD
|
||||||
|
// #define ENABLE_IR_MODULE
|
||||||
|
// #define ENABLE_CLIMATE_MODULE // Require IR Module
|
||||||
|
// #define ENABLE_ANALOG_MODULE
|
||||||
|
// #define ENABLE_WEBUI
|
||||||
|
|
||||||
|
// IR Kit Configuration
|
||||||
#define IR_RECIEVE_PIN 35
|
#define IR_RECIEVE_PIN 35
|
||||||
#define IR_SEND_PIN 17
|
#define IR_SEND_PIN 5
|
||||||
#define MARK_EXCESS_MICROS 20
|
#define MARK_EXCESS_MICROS 20
|
||||||
#define RAW_BUFFER_LENGTH 750
|
#define IR_RAW_BUFFER_LENGTH 750
|
||||||
#define AC_MAX_TEMPERATURE 30
|
#define AC_MAX_TEMPERATURE 30
|
||||||
#define AC_MIN_TEMPERATURE 15
|
#define AC_MIN_TEMPERATURE 15
|
||||||
|
#define DHT22_PIN 32
|
||||||
|
|
||||||
// External LCD Configuration
|
// External LCD Configuration
|
||||||
#define ENABLE_EXTERNAL_LCD
|
#define ENABLE_EXTERNAL_LCD
|
||||||
|
@ -29,19 +41,24 @@
|
||||||
#define ESPMega_EXTLCD Serial2
|
#define ESPMega_EXTLCD Serial2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Analog Module Configuration
|
||||||
|
#define ANALOG_REPORTING_INTERVAL 500
|
||||||
|
|
||||||
// User Defined Functions
|
// User Defined Functions
|
||||||
|
void timer1_callback();
|
||||||
|
void bt0PopCallback(void *ptr);
|
||||||
|
|
||||||
|
// User Defined IoT Core Callback Functions (Required)
|
||||||
|
void user_mqtt_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
||||||
|
void user_state_request_callback();
|
||||||
|
void mqtt_connected_user_callback();
|
||||||
void user_pre_init();
|
void user_pre_init();
|
||||||
void user_init();
|
void user_init();
|
||||||
void user_loop();
|
void user_loop();
|
||||||
void virtual_interrupt_user_callback(int pin, int state);
|
|
||||||
void pwm_changed_user_callback(int pin);
|
void pwm_changed_user_callback(int pin);
|
||||||
void ac_changed_user_callback(int mode, int temperature, int fan_speed);
|
void ac_changed_user_callback(int mode, int temperature, int fan_speed);
|
||||||
void timer_tick_callback();
|
void timer_tick_callback();
|
||||||
void timer1_callback();
|
void virtual_interrupt_user_callback(int pin, int state);
|
||||||
void mqtt_connected_user_callback();
|
|
||||||
void bt0PopCallback(void *ptr);
|
|
||||||
void user_state_request_callback();
|
|
||||||
void user_mqtt_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
|
||||||
|
|
||||||
// ESPMega IoT Core Build-in Functions
|
// ESPMega IoT Core Build-in Functions
|
||||||
extern void pwm_set_state(int id, int state);
|
extern void pwm_set_state(int id, int state);
|
||||||
|
@ -53,9 +70,26 @@ extern bool pwm_get_state(int id);
|
||||||
extern uint16_t pwm_get_value(int id);
|
extern uint16_t pwm_get_value(int id);
|
||||||
extern boolean pwm_group_state(int id1, int id2);
|
extern boolean pwm_group_state(int id1, int id2);
|
||||||
extern bool input_get_state(int id);
|
extern bool input_get_state(int id);
|
||||||
|
extern bool standalone;
|
||||||
|
extern PubSubClient mqtt;
|
||||||
|
|
||||||
|
// IR Kit Build-in Functions
|
||||||
|
#ifdef ENABLE_IR_MODULE
|
||||||
extern void ac_set_state(int mode, int temperature, int fan_speed);
|
extern void ac_set_state(int mode, int temperature, int fan_speed);
|
||||||
extern uint8_t ac_get_temperature();
|
extern uint8_t ac_get_temperature();
|
||||||
extern uint8_t ac_get_mode();
|
extern uint8_t ac_get_mode();
|
||||||
extern uint8_t ac_get_fan_speed();
|
extern uint8_t ac_get_fan_speed();
|
||||||
extern bool standalone;
|
#endif
|
||||||
extern PubSubClient mqtt;
|
|
||||||
|
//Analog Expansion Card Build-in Functions
|
||||||
|
#ifdef ENABLE_ANALOG_MODULE
|
||||||
|
extern void dac_set_value(int id, int value);
|
||||||
|
extern void dac_set_state(int id, bool state);
|
||||||
|
extern void enable_adc(int id);
|
||||||
|
extern void disable_adc(int id);
|
||||||
|
extern void enable_dac(int id);
|
||||||
|
extern uint16_t adc_get_value(int id);
|
||||||
|
extern bool adc_get_state(int id);
|
||||||
|
extern uint16_t dac_get_value(int id);
|
||||||
|
extern bool dac_get_state(int id);
|
||||||
|
#endif
|
Loading…
Reference in New Issue