mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-12 20:59:00 +08:00
Add Script to parse all c/cpp/h/ino files and format them using clang-format with Google style
Update style to some files with clang-format using Google style Add Script to parse all embedded js/css files and format them using prettier based on .prettierrc config file Update style to embedded js/css files with prettier
This commit is contained in:
parent
9a597ca940
commit
ea1eb83a28
28
embedded/.prettierrc
Normal file
28
embedded/.prettierrc
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 4,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"jsxSingleQuote": false,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": false,
|
||||
"arrowParens": "always",
|
||||
"requirePragma": false,
|
||||
"insertPragma": false,
|
||||
"proseWrap": "preserve",
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.js",
|
||||
"options": {
|
||||
"parser": "babel"
|
||||
}
|
||||
},
|
||||
{"files": "*.scss",
|
||||
"options": {
|
||||
"parser": "css"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,85 +1,83 @@
|
||||
let path = require("path");
|
||||
const fs = require("fs");
|
||||
const { createReadStream, createWriteStream } = require("fs");
|
||||
const { createGzip } = require("zlib");
|
||||
const chalk = require("chalk");
|
||||
let path = require('path');
|
||||
const fs = require('fs');
|
||||
const { createReadStream, createWriteStream } = require('fs');
|
||||
const { createGzip } = require('zlib');
|
||||
const chalk = require('chalk');
|
||||
|
||||
let distPath = path.normalize(__dirname + "/../dist/");
|
||||
let srcPath = path.normalize(__dirname + "/../assets/");
|
||||
let distPath = path.normalize(__dirname + '/../dist/');
|
||||
let srcPath = path.normalize(__dirname + '/../assets/');
|
||||
let headerPath = path.normalize(
|
||||
__dirname + "/../../esp3d/src/modules/http/favicon.h"
|
||||
__dirname + '/../../esp3d/src/modules/http/favicon.h'
|
||||
);
|
||||
|
||||
|
||||
|
||||
const convertToC = (filepath) => {
|
||||
console.log(chalk.yellow("Converting bin to text file"));
|
||||
console.log(chalk.yellow('Converting bin to text file'));
|
||||
//Cleaning files
|
||||
if (fs.existsSync(distPath + "out.tmp")) fs.rmSync(distPath + "out.tmp");
|
||||
if (fs.existsSync(distPath + "favicon.h")) fs.rmSync(distPath + "favicon.h");
|
||||
if (fs.existsSync(distPath + 'out.tmp')) fs.rmSync(distPath + 'out.tmp');
|
||||
if (fs.existsSync(distPath + 'favicon.h'))
|
||||
fs.rmSync(distPath + 'favicon.h');
|
||||
|
||||
const data = new Uint8Array(
|
||||
fs.readFileSync(filepath, { flag: "r" })
|
||||
);
|
||||
console.log("data size is ", data.length);
|
||||
let out = "#define favicon_size " + data.length + "\n";
|
||||
out += "const unsigned char favicon[" + data.length + "] PROGMEM = {\n ";
|
||||
const data = new Uint8Array(fs.readFileSync(filepath, { flag: 'r' }));
|
||||
console.log('data size is ', data.length);
|
||||
let out = '#define favicon_size ' + data.length + '\n';
|
||||
out += 'const unsigned char favicon[' + data.length + '] PROGMEM = {\n ';
|
||||
let nb = 0;
|
||||
data.forEach((byte, index) => {
|
||||
out += " 0x" + (byte.toString(16).length == 1 ? "0" : "") + byte.toString(16);
|
||||
if (index < data.length - 1) out += ",";
|
||||
out +=
|
||||
' 0x' +
|
||||
(byte.toString(16).length == 1 ? '0' : '') +
|
||||
byte.toString(16);
|
||||
if (index < data.length - 1) out += ',';
|
||||
if (nb == 15) {
|
||||
out += "\n ";
|
||||
out += '\n ';
|
||||
nb = 0;
|
||||
} else {
|
||||
nb++;
|
||||
}
|
||||
});
|
||||
|
||||
out += "\n};\n";
|
||||
fs.writeFileSync(distPath + "out.tmp", out);
|
||||
out += '\n};\n';
|
||||
fs.writeFileSync(distPath + 'out.tmp', out);
|
||||
|
||||
//Check conversion
|
||||
if (fs.existsSync(distPath + "out.tmp")) {
|
||||
console.log(chalk.green("[ok]"));
|
||||
if (fs.existsSync(distPath + 'out.tmp')) {
|
||||
console.log(chalk.green('[ok]'));
|
||||
} else {
|
||||
console.log(chalk.red("[error]Conversion failed"));
|
||||
console.log(chalk.red('[error]Conversion failed'));
|
||||
return;
|
||||
}
|
||||
|
||||
//Format header file
|
||||
console.log(chalk.yellow("Building header"));
|
||||
console.log(chalk.yellow('Building header'));
|
||||
fs.writeFileSync(
|
||||
distPath + "favicon.h",
|
||||
fs.readFileSync(srcPath + "header.txt")
|
||||
distPath + 'favicon.h',
|
||||
fs.readFileSync(srcPath + 'header.txt')
|
||||
);
|
||||
let bin2cfile = fs.readFileSync(distPath + "out.tmp").toString();
|
||||
fs.appendFileSync(distPath + "favicon.h", bin2cfile);
|
||||
let bin2cfile = fs.readFileSync(distPath + 'out.tmp').toString();
|
||||
fs.appendFileSync(distPath + 'favicon.h', bin2cfile);
|
||||
fs.appendFileSync(
|
||||
distPath + "favicon.h",
|
||||
fs.readFileSync(srcPath + "footer.txt")
|
||||
distPath + 'favicon.h',
|
||||
fs.readFileSync(srcPath + 'footer.txt')
|
||||
);
|
||||
|
||||
//Check format result
|
||||
if (fs.existsSync(distPath + "favicon.h")) {
|
||||
console.log(chalk.green("[ok]"));
|
||||
if (fs.existsSync(distPath + 'favicon.h')) {
|
||||
console.log(chalk.green('[ok]'));
|
||||
} else {
|
||||
console.log(chalk.red("[error]Conversion failed"));
|
||||
console.log(chalk.red('[error]Conversion failed'));
|
||||
return;
|
||||
}
|
||||
|
||||
//Move file to src
|
||||
console.log(chalk.yellow("Overwriting header in sources"));
|
||||
fs.writeFileSync(headerPath, fs.readFileSync(distPath + "favicon.h"));
|
||||
console.log(chalk.yellow('Overwriting header in sources'));
|
||||
fs.writeFileSync(headerPath, fs.readFileSync(distPath + 'favicon.h'));
|
||||
if (fs.existsSync(headerPath)) {
|
||||
console.log(chalk.green("[ok]"));
|
||||
console.log(chalk.green('[ok]'));
|
||||
} else {
|
||||
console.log(chalk.red("[error]Overwriting failed"));
|
||||
console.log(chalk.red('[error]Overwriting failed'));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Create a gzip function for reusable purpose
|
||||
const compressFile = (filePath, targetPath) => {
|
||||
@ -87,9 +85,10 @@ const compressFile = (filePath, targetPath) => {
|
||||
stream
|
||||
.pipe(createGzip(targetPath))
|
||||
.pipe(createWriteStream(targetPath))
|
||||
.on("finish", () =>{console.log(`Successfully compressed at ${targetPath}`);
|
||||
convertToC (targetPath)}
|
||||
);
|
||||
.on('finish', () => {
|
||||
console.log(`Successfully compressed at ${targetPath}`);
|
||||
convertToC(targetPath);
|
||||
});
|
||||
};
|
||||
|
||||
compressFile(srcPath + "favicon.ico", distPath + "favicon.ico.gz");
|
||||
compressFile(srcPath + 'favicon.ico', distPath + 'favicon.ico.gz');
|
||||
|
@ -1,75 +1,76 @@
|
||||
let path = require("path");
|
||||
const fs = require("fs");
|
||||
const child_process = require("child_process");
|
||||
const chalk = require("chalk");
|
||||
let path = require('path');
|
||||
const fs = require('fs');
|
||||
const child_process = require('child_process');
|
||||
const chalk = require('chalk');
|
||||
|
||||
let distPath = path.normalize(__dirname + "/../dist/");
|
||||
let srcPath = path.normalize(__dirname + "/../src/");
|
||||
let distPath = path.normalize(__dirname + '/../dist/');
|
||||
let srcPath = path.normalize(__dirname + '/../src/');
|
||||
let headerPath = path.normalize(
|
||||
__dirname + "/../../esp3d/src/modules/http/embedded.h"
|
||||
__dirname + '/../../esp3d/src/modules/http/embedded.h'
|
||||
);
|
||||
|
||||
console.log(chalk.yellow("Converting bin to text file"));
|
||||
console.log(chalk.yellow('Converting bin to text file'));
|
||||
//Cleaning files
|
||||
if (fs.existsSync(distPath + "out.tmp")) fs.rmSync(distPath + "out.tmp");
|
||||
if (fs.existsSync(distPath + "embedded.h")) fs.rmSync(distPath + "embedded.h");
|
||||
if (fs.existsSync(distPath + 'out.tmp')) fs.rmSync(distPath + 'out.tmp');
|
||||
if (fs.existsSync(distPath + 'embedded.h')) fs.rmSync(distPath + 'embedded.h');
|
||||
|
||||
const data = new Uint8Array(
|
||||
fs.readFileSync(distPath + "index.html.gz", { flag: "r" })
|
||||
fs.readFileSync(distPath + 'index.html.gz', { flag: 'r' })
|
||||
);
|
||||
console.log("data size is ", data.length);
|
||||
let out = "#define tool_html_gz_size " + data.length + "\n";
|
||||
out += "const unsigned char tool_html_gz[" + data.length + "] PROGMEM = {\n ";
|
||||
console.log('data size is ', data.length);
|
||||
let out = '#define tool_html_gz_size ' + data.length + '\n';
|
||||
out += 'const unsigned char tool_html_gz[' + data.length + '] PROGMEM = {\n ';
|
||||
let nb = 0;
|
||||
data.forEach((byte, index) => {
|
||||
out += " 0x" + (byte.toString(16).length == 1 ? "0" : "") + byte.toString(16);
|
||||
if (index < data.length - 1) out += ",";
|
||||
out +=
|
||||
' 0x' + (byte.toString(16).length == 1 ? '0' : '') + byte.toString(16);
|
||||
if (index < data.length - 1) out += ',';
|
||||
if (nb == 15) {
|
||||
out += "\n ";
|
||||
out += '\n ';
|
||||
nb = 0;
|
||||
} else {
|
||||
nb++;
|
||||
}
|
||||
});
|
||||
|
||||
out += "\n};\n";
|
||||
fs.writeFileSync(distPath + "out.tmp", out);
|
||||
out += '\n};\n';
|
||||
fs.writeFileSync(distPath + 'out.tmp', out);
|
||||
|
||||
//Check conversion
|
||||
if (fs.existsSync(distPath + "out.tmp")) {
|
||||
console.log(chalk.green("[ok]"));
|
||||
if (fs.existsSync(distPath + 'out.tmp')) {
|
||||
console.log(chalk.green('[ok]'));
|
||||
} else {
|
||||
console.log(chalk.red("[error]Conversion failed"));
|
||||
console.log(chalk.red('[error]Conversion failed'));
|
||||
return;
|
||||
}
|
||||
|
||||
//Format header file
|
||||
console.log(chalk.yellow("Building header"));
|
||||
console.log(chalk.yellow('Building header'));
|
||||
fs.writeFileSync(
|
||||
distPath + "embedded.h",
|
||||
fs.readFileSync(srcPath + "header.txt")
|
||||
distPath + 'embedded.h',
|
||||
fs.readFileSync(srcPath + 'header.txt')
|
||||
);
|
||||
let bin2cfile = fs.readFileSync(distPath + "out.tmp").toString();
|
||||
fs.appendFileSync(distPath + "embedded.h", bin2cfile);
|
||||
let bin2cfile = fs.readFileSync(distPath + 'out.tmp').toString();
|
||||
fs.appendFileSync(distPath + 'embedded.h', bin2cfile);
|
||||
fs.appendFileSync(
|
||||
distPath + "embedded.h",
|
||||
fs.readFileSync(srcPath + "footer.txt")
|
||||
distPath + 'embedded.h',
|
||||
fs.readFileSync(srcPath + 'footer.txt')
|
||||
);
|
||||
|
||||
//Check format result
|
||||
if (fs.existsSync(distPath + "embedded.h")) {
|
||||
console.log(chalk.green("[ok]"));
|
||||
if (fs.existsSync(distPath + 'embedded.h')) {
|
||||
console.log(chalk.green('[ok]'));
|
||||
} else {
|
||||
console.log(chalk.red("[error]Conversion failed"));
|
||||
console.log(chalk.red('[error]Conversion failed'));
|
||||
return;
|
||||
}
|
||||
|
||||
//Move file to src
|
||||
console.log(chalk.yellow("Overwriting header in sources"));
|
||||
fs.writeFileSync(headerPath, fs.readFileSync(distPath + "embedded.h"));
|
||||
console.log(chalk.yellow('Overwriting header in sources'));
|
||||
fs.writeFileSync(headerPath, fs.readFileSync(distPath + 'embedded.h'));
|
||||
if (fs.existsSync(headerPath)) {
|
||||
console.log(chalk.green("[ok]"));
|
||||
console.log(chalk.green('[ok]'));
|
||||
} else {
|
||||
console.log(chalk.red("[error]Overwriting failed"));
|
||||
console.log(chalk.red('[error]Overwriting failed'));
|
||||
return;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
const path = require("path");
|
||||
const { createReadStream, createWriteStream } = require("fs");
|
||||
const { createGzip } = require("zlib");
|
||||
const faviconPath = path.normalize(__dirname + "/../assets/favicon.ico");
|
||||
const path = require('path');
|
||||
const { createReadStream, createWriteStream } = require('fs');
|
||||
const { createGzip } = require('zlib');
|
||||
const faviconPath = path.normalize(__dirname + '/../assets/favicon.ico');
|
||||
|
||||
// Create a gzip function for reusable purpose
|
||||
const compressFile = (filePath) => {
|
||||
@ -9,7 +9,8 @@ const compressFile = (filePath) => {
|
||||
stream
|
||||
.pipe(createGzip())
|
||||
.pipe(createWriteStream(`${filePath}.gz`))
|
||||
.on("finish", () =>console.log(`Successfully compressed the file at ${filePath}`)
|
||||
.on('finish', () =>
|
||||
console.log(`Successfully compressed the file at ${filePath}`)
|
||||
);
|
||||
};
|
||||
compressFile(faviconPath);
|
File diff suppressed because it is too large
Load Diff
@ -1,31 +1,31 @@
|
||||
const path = require("path");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const path = require('path');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
mode: "development", // this will trigger some webpack default stuffs for dev
|
||||
entry: path.resolve(__dirname, "../src/index.js"), // if not set, default path to './src/index.js'. Accepts an object with multiple key-value pairs, with key as your custom bundle filename(substituting the [name]), and value as the corresponding file path
|
||||
mode: 'development', // this will trigger some webpack default stuffs for dev
|
||||
entry: path.resolve(__dirname, '../src/index.js'), // if not set, default path to './src/index.js'. Accepts an object with multiple key-value pairs, with key as your custom bundle filename(substituting the [name]), and value as the corresponding file path
|
||||
output: {
|
||||
filename: "[name].bundle.js", // [name] will take whatever the input filename is. defaults to 'main' if only a single entry value
|
||||
path: path.resolve(__dirname, "../dist"), // the folder containing you final dist/build files. Default to './dist'
|
||||
filename: '[name].bundle.js', // [name] will take whatever the input filename is. defaults to 'main' if only a single entry value
|
||||
path: path.resolve(__dirname, '../dist'), // the folder containing you final dist/build files. Default to './dist'
|
||||
},
|
||||
devServer: {
|
||||
historyApiFallback: true, // to make our SPA works after a full reload, so that it serves 'index.html' when 404 response
|
||||
open: true,
|
||||
static: {
|
||||
directory: path.resolve(__dirname, "./dist"),
|
||||
directory: path.resolve(__dirname, './dist'),
|
||||
},
|
||||
port: 8088,
|
||||
proxy: {
|
||||
context: () => true,
|
||||
target: "http://localhost:8080",
|
||||
target: 'http://localhost:8080',
|
||||
},
|
||||
},
|
||||
stats: "minimal", // default behaviour spit out way too much info. adjust to your need.
|
||||
devtool: "source-map", // a sourcemap type. map to original source with line number
|
||||
stats: 'minimal', // default behaviour spit out way too much info. adjust to your need.
|
||||
devtool: 'source-map', // a sourcemap type. map to original source with line number
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.join(__dirname, "../src/index.html"),
|
||||
inlineSource: ".(js|css)$",
|
||||
template: path.join(__dirname, '../src/index.html'),
|
||||
inlineSource: '.(js|css)$',
|
||||
inject: true,
|
||||
}),
|
||||
], // automatically creates a 'index.html' for us with our <link>, <style>, <script> tags inserted! Visit https://github.com/jantimon/html-webpack-plugin for more options
|
||||
@ -35,9 +35,9 @@ module.exports = {
|
||||
test: /\.js$/,
|
||||
exclude: /(node_modules)/,
|
||||
use: {
|
||||
loader: "babel-loader",
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: ["@babel/preset-env"],
|
||||
presets: ['@babel/preset-env'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -46,7 +46,7 @@ module.exports = {
|
||||
// this are the loaders. they interpret files, in this case css. they run from right to left sequence.
|
||||
// css-loader: "interprets @import and url() like import/require() and will resolve them."
|
||||
// style-loader: "Adds CSS to the DOM by injecting a <style> tag". this is fine for development.
|
||||
use: ["style-loader", "css-loader"],
|
||||
use: ['style-loader', 'css-loader'],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -1,41 +1,41 @@
|
||||
const path = require("path");
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
|
||||
const HtmlInlineScriptPlugin = require("html-inline-script-webpack-plugin");
|
||||
const HTMLInlineCSSWebpackPlugin = require("html-inline-css-webpack-plugin")
|
||||
.default;
|
||||
const Compression = require("compression-webpack-plugin");
|
||||
const path = require('path');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin');
|
||||
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');
|
||||
const HTMLInlineCSSWebpackPlugin =
|
||||
require('html-inline-css-webpack-plugin').default;
|
||||
const Compression = require('compression-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
mode: "production", // this trigger webpack out-of-box prod optimizations
|
||||
entry: path.resolve(__dirname, "../src/index.js"),
|
||||
mode: 'production', // this trigger webpack out-of-box prod optimizations
|
||||
entry: path.resolve(__dirname, '../src/index.js'),
|
||||
output: {
|
||||
filename: `[name].[hash].js`, // [hash] is useful for cache busting!
|
||||
path: path.resolve(__dirname, "../dist"),
|
||||
path: path.resolve(__dirname, '../dist'),
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
||||
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
loader: "babel-loader",
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
'@babel/preset-env',
|
||||
{
|
||||
useBuiltIns: "usage",
|
||||
useBuiltIns: 'usage',
|
||||
debug: false,
|
||||
corejs: 3,
|
||||
targets: {"chrome": "88"},
|
||||
targets: { chrome: '88' },
|
||||
},
|
||||
],
|
||||
],
|
||||
@ -49,13 +49,13 @@ module.exports = {
|
||||
// always deletes the dist folder first in each build run.
|
||||
new CleanWebpackPlugin(),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "[name].css",
|
||||
chunkFilename: "[id].css",
|
||||
filename: '[name].css',
|
||||
chunkFilename: '[id].css',
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.join(__dirname, "../src/index.html"),
|
||||
inlineSource: ".(js|css)$",
|
||||
inject: "body",
|
||||
template: path.join(__dirname, '../src/index.html'),
|
||||
inlineSource: '.(js|css)$',
|
||||
inject: 'body',
|
||||
}),
|
||||
|
||||
new HtmlInlineScriptPlugin({
|
||||
@ -65,10 +65,10 @@ module.exports = {
|
||||
new HTMLInlineCSSWebpackPlugin(),
|
||||
new Compression({
|
||||
test: /\.(html)$/,
|
||||
filename: "[path][base].gz",
|
||||
algorithm: "gzip",
|
||||
filename: '[path][base].gz',
|
||||
algorithm: 'gzip',
|
||||
exclude: /.map$/,
|
||||
deleteOriginalAssets: "keep-source-map",
|
||||
deleteOriginalAssets: 'keep-source-map',
|
||||
}),
|
||||
],
|
||||
optimization: {
|
||||
@ -81,7 +81,7 @@ module.exports = {
|
||||
minifyJS: true,
|
||||
},
|
||||
minify: (data, minimizerOptions) => {
|
||||
const htmlMinifier = require("html-minifier-terser");
|
||||
const htmlMinifier = require('html-minifier-terser');
|
||||
const [[filename, input]] = Object.entries(data);
|
||||
|
||||
return htmlMinifier.minify(input, minimizerOptions);
|
||||
@ -89,5 +89,5 @@ module.exports = {
|
||||
}),
|
||||
],
|
||||
},
|
||||
devtool: "source-map", // supposedly the ideal type without bloating bundle size
|
||||
devtool: 'source-map', // supposedly the ideal type without bloating bundle size
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,17 @@
|
||||
function initMenus() {
|
||||
document.getElementById("FWLink").addEventListener("click", function () {
|
||||
window.open("https://github.com/luc-github/ESP3D/tree/3.0", "_blank");
|
||||
document.getElementById('FWLink').addEventListener('click', function () {
|
||||
window.open('https://github.com/luc-github/ESP3D/tree/3.0', '_blank');
|
||||
});
|
||||
|
||||
document.getElementById("UiLink").addEventListener("click", function () {
|
||||
window.open("https://github.com/luc-github/ESP3D-WEBUI/tree/3.0", "_blank");
|
||||
document.getElementById('UiLink').addEventListener('click', function () {
|
||||
window.open(
|
||||
'https://github.com/luc-github/ESP3D-WEBUI/tree/3.0',
|
||||
'_blank'
|
||||
);
|
||||
});
|
||||
|
||||
document.getElementById("hlpLink").addEventListener("click", function () {
|
||||
window.open("https://github.com/luc-github/ESP3D/wiki", "_blank");
|
||||
document.getElementById('hlpLink').addEventListener('click', function () {
|
||||
window.open('https://github.com/luc-github/ESP3D/wiki', '_blank');
|
||||
});
|
||||
}
|
||||
|
||||
|
63
embedded/tools/format_sources.py
Normal file
63
embedded/tools/format_sources.py
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from shutil import which
|
||||
|
||||
def format_sources():
|
||||
"""
|
||||
Format JavaScript and CSS files using Prettier.
|
||||
|
||||
This script locates all JavaScript and CSS files in the 'src' and 'config' directories
|
||||
(including subdirectories) and formats them using the Prettier tool. It requires Node.js
|
||||
and the Prettier package to be installed.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
# Base directory of the script
|
||||
script_path = os.path.abspath(__file__)
|
||||
|
||||
# Extract dir path
|
||||
script_dir = os.path.dirname(script_path)
|
||||
|
||||
# Build paths of sources dirs: ../src and ../config
|
||||
src_dir = os.path.abspath(os.path.normpath(os.path.join(script_dir, '..', 'src')))
|
||||
config_dir = os.path.abspath(os.path.normpath(os.path.join(script_dir, '..', 'config')))
|
||||
|
||||
# Parse all c, h , cpp, js, css files in all directories and sub directories
|
||||
file_paths = []
|
||||
for base_dir in [src_dir, config_dir]:
|
||||
for root, dirs, files in os.walk(base_dir):
|
||||
for file in files:
|
||||
if file.endswith(('.js', '.css')):
|
||||
file_path = os.path.join(root, file)
|
||||
file_paths.append(os.path.abspath(os.path.normpath(file_path)))
|
||||
print(os.path.abspath(os.path.normpath(file_path)))
|
||||
|
||||
# Locate the Prettier binary
|
||||
node_path = which('node')
|
||||
print(node_path)
|
||||
if not node_path:
|
||||
print("node not found in PATH. Please install it globally or locally.")
|
||||
exit(1)
|
||||
node_dir = os.path.dirname(node_path)
|
||||
client_path = os.path.join('node_modules', 'npm', 'bin', 'npx-cli.js')
|
||||
print(client_path)
|
||||
|
||||
# Now format all files one by one with prettier
|
||||
prettierrc_path = os.path.abspath(os.path.normpath(os.path.join(script_dir, '..', '.prettierrc')))
|
||||
print("Using:" + prettierrc_path)
|
||||
for file_path in file_paths:
|
||||
tmpPath = file_path
|
||||
print("Formating " + tmpPath)
|
||||
try:
|
||||
command = ['node', client_path, 'prettier', '--write', tmpPath]
|
||||
print(command)
|
||||
subprocess.run(command, check=False, cwd=node_dir)
|
||||
print("=> Ok")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f'=>Error : {e}')
|
||||
|
||||
# Call the format_sources function
|
||||
format_sources()
|
@ -621,7 +621,6 @@
|
||||
|
||||
// #define ESP3D_DEBUG_LEVEL LOG_LEVEL_DEBUG
|
||||
|
||||
|
||||
#ifdef ESP_LOG_FEATURE
|
||||
#define LOG_ESP3D_BAUDRATE 115200
|
||||
#define LOG_ESP3D_OUTPUT_PORT 8000
|
||||
@ -639,7 +638,8 @@
|
||||
* Do not modify
|
||||
************************************/
|
||||
|
||||
#if defined(ESP_GOT_DATE_TIME_HOOK) ||defined(SD_TIMESTAMP_FEATURE) || defined(FILESYSTEM_TIMESTAMP_FEATURE)
|
||||
#if defined(ESP_GOT_DATE_TIME_HOOK) || defined(SD_TIMESTAMP_FEATURE) || \
|
||||
defined(FILESYSTEM_TIMESTAMP_FEATURE)
|
||||
#define TIMESTAMP_FEATURE
|
||||
#endif // SD_TIMESTAMP_FEATURE || FILESYSTEM_TIMESTAMP_FEATURE
|
||||
|
||||
|
@ -23,13 +23,7 @@
|
||||
Esp3D myesp3d;
|
||||
|
||||
// Setup
|
||||
void setup()
|
||||
{
|
||||
myesp3d.begin();
|
||||
}
|
||||
void setup() { myesp3d.begin(); }
|
||||
|
||||
// main loop
|
||||
void loop()
|
||||
{
|
||||
myesp3d.handle();
|
||||
}
|
||||
void loop() { myesp3d.handle(); }
|
||||
|
@ -138,7 +138,8 @@ const char* help[] = {
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
#if defined(NOTIFICATION_FEATURE)
|
||||
"[ESP600](message) - send notification",
|
||||
"[ESP610]type=(NONE/PUSHOVER/EMAIL/LINE/TELEGRAM/IFTTT/HOMEASSISTANT) (T1=xxx) (T2=xxx) "
|
||||
"[ESP610]type=(NONE/PUSHOVER/EMAIL/LINE/TELEGRAM/IFTTT/HOMEASSISTANT) "
|
||||
"(T1=xxx) (T2=xxx) "
|
||||
"(TS=xxx) - display/set Notification settings",
|
||||
"[ESP620]URL=http://XXXXXX - send GET notification",
|
||||
#endif // NOTIFICATION_FEATURE
|
||||
|
@ -125,8 +125,9 @@ void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
|
||||
}
|
||||
|
||||
// contrast
|
||||
if (!dispatchIdValue(json, "contrast", String(s->status.contrast).c_str(),
|
||||
target, requestId)) {
|
||||
if (!dispatchIdValue(json, "contrast",
|
||||
String(s->status.contrast).c_str(), target,
|
||||
requestId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -151,14 +152,15 @@ void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
|
||||
}
|
||||
|
||||
// wb_mode
|
||||
if (!dispatchIdValue(json, "wb_mode", String(s->status.wb_mode).c_str(),
|
||||
target, requestId)) {
|
||||
if (!dispatchIdValue(json, "wb_mode",
|
||||
String(s->status.wb_mode).c_str(), target,
|
||||
requestId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// awb
|
||||
if (!dispatchIdValue(json, "awb", String(s->status.awb).c_str(), target,
|
||||
requestId)) {
|
||||
if (!dispatchIdValue(json, "awb", String(s->status.awb).c_str(),
|
||||
target, requestId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -170,8 +172,8 @@ void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
|
||||
}
|
||||
|
||||
// aec
|
||||
if (!dispatchIdValue(json, "aec", String(s->status.aec).c_str(), target,
|
||||
requestId)) {
|
||||
if (!dispatchIdValue(json, "aec", String(s->status.aec).c_str(),
|
||||
target, requestId)) {
|
||||
return;
|
||||
}
|
||||
// aec2
|
||||
@ -192,8 +194,8 @@ void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
|
||||
return;
|
||||
}
|
||||
// agc
|
||||
if (!dispatchIdValue(json, "agc", String(s->status.agc).c_str(), target,
|
||||
requestId)) {
|
||||
if (!dispatchIdValue(json, "agc", String(s->status.agc).c_str(),
|
||||
target, requestId)) {
|
||||
return;
|
||||
}
|
||||
// agc_gain
|
||||
@ -209,18 +211,19 @@ void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
|
||||
return;
|
||||
}
|
||||
// bpc
|
||||
if (!dispatchIdValue(json, "bpc", String(s->status.bpc).c_str(), target,
|
||||
requestId)) {
|
||||
if (!dispatchIdValue(json, "bpc", String(s->status.bpc).c_str(),
|
||||
target, requestId)) {
|
||||
return;
|
||||
}
|
||||
// wpc
|
||||
if (!dispatchIdValue(json, "wpc", String(s->status.wpc).c_str(), target,
|
||||
requestId)) {
|
||||
if (!dispatchIdValue(json, "wpc", String(s->status.wpc).c_str(),
|
||||
target, requestId)) {
|
||||
return;
|
||||
}
|
||||
// raw_gma
|
||||
if (!dispatchIdValue(json, "raw_gma", String(s->status.raw_gma).c_str(),
|
||||
target, requestId)) {
|
||||
if (!dispatchIdValue(json, "raw_gma",
|
||||
String(s->status.raw_gma).c_str(), target,
|
||||
requestId)) {
|
||||
return;
|
||||
}
|
||||
// lenc
|
||||
@ -234,13 +237,14 @@ void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
|
||||
return;
|
||||
}
|
||||
// hmirror
|
||||
if (!dispatchIdValue(json, "hmirror", String(s->status.hmirror).c_str(),
|
||||
target, requestId)) {
|
||||
if (!dispatchIdValue(json, "hmirror",
|
||||
String(s->status.hmirror).c_str(), target,
|
||||
requestId)) {
|
||||
return;
|
||||
}
|
||||
// dcw
|
||||
if (!dispatchIdValue(json, "dcw", String(s->status.dcw).c_str(), target,
|
||||
requestId)) {
|
||||
if (!dispatchIdValue(json, "dcw", String(s->status.dcw).c_str(),
|
||||
target, requestId)) {
|
||||
return;
|
||||
}
|
||||
// colorbar
|
||||
|
@ -48,9 +48,9 @@ void ESP3DCommands::ESP212(int cmd_params_pos, ESP3DMessage* msg) {
|
||||
#endif // AUTHENTICATION_FEATURE
|
||||
tmpstr = get_clean_param(msg, cmd_params_pos);
|
||||
tmpstr = esp3d_string::expandString(tmpstr.c_str());
|
||||
hasError = !esp3d_commands.dispatch(tmpstr.c_str(), ESP3DClientType::remote_screen,
|
||||
no_id, ESP3DMessageType::unique,
|
||||
ESP3DClientType::system,
|
||||
hasError = !esp3d_commands.dispatch(
|
||||
tmpstr.c_str(), ESP3DClientType::remote_screen, no_id,
|
||||
ESP3DMessageType::unique, ESP3DClientType::system,
|
||||
ESP3DAuthenticationLevel::admin);
|
||||
if (!dispatchAnswer(msg, COMMAND_ID, json, hasError,
|
||||
hasError ? error_msg.c_str() : ok_msg.c_str())) {
|
||||
|
@ -96,8 +96,8 @@ const char* FirmwareLabels[] = {"Unknown", "Grbl", "Marlin", "Smoothieware",
|
||||
|
||||
const char* FirmwareValues[] = {"0", "10", "20", "40", "50"};
|
||||
#ifdef NOTIFICATION_FEATURE
|
||||
const char* NotificationsLabels[] = {"none", "pushover", "email",
|
||||
"line", "telegram", "ifttt", "home-assistant"};
|
||||
const char* NotificationsLabels[] = {
|
||||
"none", "pushover", "email", "line", "telegram", "ifttt", "home-assistant"};
|
||||
|
||||
const char* NotificationsValues[] = {"0", "1", "2", "3", "4", "5", "6"};
|
||||
#endif // NOTIFICATION_FEATURE
|
||||
@ -109,8 +109,8 @@ const char* SupportedApChannelsStr[] = {"1", "2", "3", "4", "5", "6", "7",
|
||||
"8", "9", "10", "11", "12", "13", "14"};
|
||||
|
||||
const char* SupportedBaudListSizeStr[] = {
|
||||
"9600", "19200", "38400", "57600", "74880", "115200",
|
||||
"230400", "250000", "500000", "921600", "1000000", "1958400","2000000"};
|
||||
"9600", "19200", "38400", "57600", "74880", "115200", "230400",
|
||||
"250000", "500000", "921600", "1000000", "1958400", "2000000"};
|
||||
|
||||
#ifdef SENSOR_DEVICE
|
||||
|
||||
|
@ -43,7 +43,8 @@ void ESP3DCommands::ESP610(int cmd_params_pos, ESP3DMessage* msg) {
|
||||
const char* cmdList[] = {"type=", "T1=", "T2=", "TS="};
|
||||
uint8_t cmdListSize = sizeof(cmdList) / sizeof(char*);
|
||||
const char* notificationStr[] = {"NONE", "PUSHOVER", "EMAIL",
|
||||
"LINE", "TELEGRAM", "IFTTT", "HOMEASSISTANT"};
|
||||
"LINE", "TELEGRAM", "IFTTT",
|
||||
"HOMEASSISTANT"};
|
||||
uint8_t notificationStrSize = sizeof(notificationStr) / sizeof(char*);
|
||||
const ESP3DSettingIndex settingIndex[] = {
|
||||
ESP_NOTIFICATION_TYPE, ESP_NOTIFICATION_TOKEN1, ESP_NOTIFICATION_TOKEN2,
|
||||
|
@ -20,10 +20,9 @@
|
||||
|
||||
#include "../include/esp3d_config.h"
|
||||
#if defined(ESP_BENCHMARK_FEATURE)
|
||||
#include "esp3d_benchmark.h"
|
||||
#include "../modules/websocket/websocket_server.h"
|
||||
void report_esp3d(const char * format, ...)
|
||||
{
|
||||
#include "esp3d_benchmark.h"
|
||||
void report_esp3d(const char* format, ...) {
|
||||
char buffer[64];
|
||||
char* temp = buffer;
|
||||
va_list arg;
|
||||
@ -47,14 +46,15 @@ void report_esp3d(const char * format, ...)
|
||||
}
|
||||
}
|
||||
|
||||
void benchMark(const char* title, uint64_t bench_start,uint64_t bench_end, size_t bench_transfered)
|
||||
{
|
||||
void benchMark(const char* title, uint64_t bench_start, uint64_t bench_end,
|
||||
size_t bench_transfered) {
|
||||
float rate = 1.F * bench_transfered / (bench_end - bench_start) * 1000;
|
||||
if (rate < 1024) {
|
||||
report_esp3d("REPORT: %s %llu bytes in %llu ms, %.2f bytes/s", title, bench_transfered, bench_end - bench_start, rate);
|
||||
report_esp3d("REPORT: %s %llu bytes in %llu ms, %.2f bytes/s", title,
|
||||
bench_transfered, bench_end - bench_start, rate);
|
||||
} else {
|
||||
report_esp3d("REPORT: %s %llu bytes in %llu ms, %.2f Kbytes/s", title, bench_transfered, bench_end - bench_start, rate/1024);
|
||||
report_esp3d("REPORT: %s %llu bytes in %llu ms, %.2f Kbytes/s", title,
|
||||
bench_transfered, bench_end - bench_start, rate / 1024);
|
||||
}
|
||||
|
||||
}
|
||||
#endif // ESP_BENCHMARK_FEATURE
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#ifndef _BENCHMARK_ESP3D_H
|
||||
#define _BENCHMARK_ESP3D_H
|
||||
extern void benchMark(const char* title, uint64_t bench_start,uint64_t bench_end, size_t bench_transfered);
|
||||
extern void benchMark(const char* title, uint64_t bench_start,
|
||||
uint64_t bench_end, size_t bench_transfered);
|
||||
extern void report_esp3d(const char* format, ...);
|
||||
#endif //_BENCHMARK_ESP3D_H
|
||||
|
@ -865,7 +865,8 @@ bool ESP3DSettings::isValidIntegerSetting(uint32_t value,
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif //#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||
#endif // #if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
|
||||
// MKS_SERIAL
|
||||
case ESP_WEBDAV_PORT:
|
||||
case ESP_HTTP_PORT:
|
||||
case ESP_TELNET_PORT:
|
||||
|
@ -30,54 +30,26 @@
|
||||
#if defined(SDSUPPORT) && defined(ESP3DLIB_ENV)
|
||||
|
||||
typedef struct {
|
||||
bool saving:1,
|
||||
logging:1,
|
||||
sdprinting:1,
|
||||
sdprintdone:1,
|
||||
mounted:1,
|
||||
filenameIsDir:1,
|
||||
workDirIsRoot:1,
|
||||
abort_sd_printing:1;
|
||||
bool saving : 1, logging : 1, sdprinting : 1, sdprintdone : 1, mounted : 1,
|
||||
filenameIsDir : 1, workDirIsRoot : 1, abort_sd_printing : 1;
|
||||
} card_flags_t;
|
||||
|
||||
|
||||
|
||||
class CardReader
|
||||
{
|
||||
class CardReader {
|
||||
public:
|
||||
static card_flags_t flag; // Flags (above)
|
||||
static void mount();
|
||||
static void release();
|
||||
static bool isMounted()
|
||||
{
|
||||
return flag.mounted;
|
||||
}
|
||||
static bool isMounted() { return flag.mounted; }
|
||||
|
||||
static void abortFilePrintSoon() { flag.abort_sd_printing = isFileOpen(); }
|
||||
static void pauseSDPrint() { flag.sdprinting = false; }
|
||||
static bool isPrinting() { return flag.sdprinting; }
|
||||
static bool isPaused() { return isFileOpen() && !isPrinting(); }
|
||||
static bool isFileOpen() { return isMounted() && isPrinting(); }
|
||||
|
||||
static void abortFilePrintSoon()
|
||||
{
|
||||
flag.abort_sd_printing = isFileOpen();
|
||||
}
|
||||
static void pauseSDPrint()
|
||||
{
|
||||
flag.sdprinting = false;
|
||||
}
|
||||
static bool isPrinting()
|
||||
{
|
||||
return flag.sdprinting;
|
||||
}
|
||||
static bool isPaused()
|
||||
{
|
||||
return isFileOpen() && !isPrinting();
|
||||
}
|
||||
static bool isFileOpen()
|
||||
{
|
||||
return isMounted() && isPrinting();
|
||||
}
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#define IS_SD_PRINTING() (card.flag.sdprinting && !card.flag.abort_sd_printing)
|
||||
#define IS_SD_FETCHING() (!card.flag.sdprintdone && IS_SD_PRINTING())
|
||||
#define IS_SD_PAUSED() card.isPaused()
|
||||
|
@ -41,8 +41,12 @@ typedef uint ESP3DSettingIndex;
|
||||
// position in EEPROM / preferences will use `P_` + <position> to make a string
|
||||
// : P_0 for 0
|
||||
#define ESP_RADIO_MODE 0 // 1 byte = flag
|
||||
#define ESP_STA_SSID 1 // 33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_STA_PASSWORD 34 // 65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
|
||||
#define ESP_STA_SSID \
|
||||
1 // 33 bytes 32+1 = string ; warning does not support multibyte char like
|
||||
// chinese
|
||||
#define ESP_STA_PASSWORD \
|
||||
34 // 65 bytes 64 +1 = string ;warning does not support multibyte char like
|
||||
// chinese
|
||||
#define ESP_STA_IP_MODE 99 // 1 byte = flag
|
||||
#define ESP_STA_IP_VALUE 100 // 4 bytes xxx.xxx.xxx.xxx
|
||||
#define ESP_STA_MASK_VALUE 104 // 4 bytes xxx.xxx.xxx.xxx
|
||||
@ -56,13 +60,23 @@ typedef uint ESP3DSettingIndex;
|
||||
#define ESP_HTTP_PORT 121 // 4 bytes = int
|
||||
#define ESP_TELNET_PORT 125 // 4 bytes = int
|
||||
// #define FREE 129 // 1 bytes = flag
|
||||
#define ESP_HOSTNAME 130 // 33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_HOSTNAME \
|
||||
130 // 33 bytes 32+1 = string ; warning does not support multibyte char like
|
||||
// chinese
|
||||
#define ESP_SENSOR_INTERVAL 164 // 4 bytes = int
|
||||
#define ESP_SETTINGS_VERSION 168 // 8 bytes = 7+1 = string ESP3D + 2 digits
|
||||
#define ESP_ADMIN_PWD 176 // 21 bytes 20+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_USER_PWD 197 // 21 bytes 20+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_AP_SSID 218 // 33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_AP_PASSWORD 251 // 65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
|
||||
#define ESP_ADMIN_PWD \
|
||||
176 // 21 bytes 20+1 = string ; warning does not support multibyte char
|
||||
// like chinese
|
||||
#define ESP_USER_PWD \
|
||||
197 // 21 bytes 20+1 = string ; warning does not support multibyte char
|
||||
// like chinese
|
||||
#define ESP_AP_SSID \
|
||||
218 // 33 bytes 32+1 = string ; warning does not support multibyte char like
|
||||
// chinese
|
||||
#define ESP_AP_PASSWORD \
|
||||
251 // 65 bytes 64 +1 = string ;warning does not support multibyte char like
|
||||
// chinese
|
||||
#define ESP_AP_IP_VALUE 316 // 4 bytes xxx.xxx.xxx.xxx
|
||||
#define ESP_BOOT_DELAY 320 // 4 bytes = int
|
||||
#define ESP_WEBSOCKET_PORT 324 // 4 bytes= int
|
||||
@ -70,21 +84,33 @@ typedef uint ESP3DSettingIndex;
|
||||
#define ESP_TELNET_ON 329 // 1 byte = flag
|
||||
#define ESP_WEBSOCKET_ON 330 // 1 byte = flag
|
||||
#define ESP_SD_SPEED_DIV 331 // 1 byte = flag
|
||||
#define ESP_NOTIFICATION_TOKEN1 332 // 251 bytes 250+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_NOTIFICATION_TOKEN2 583 // 64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_NOTIFICATION_TOKEN1 \
|
||||
332 // 251 bytes 250+1 = string ; warning does not support multibyte char
|
||||
// like chinese
|
||||
#define ESP_NOTIFICATION_TOKEN2 \
|
||||
583 // 64 bytes 63+1 = string ; warning does not support multibyte char like
|
||||
// chinese
|
||||
#define ESP_SENSOR_TYPE 647 // 1 bytes = flag
|
||||
#define ESP_TARGET_FW 648 // 1 bytes = flag
|
||||
#define ESP_FREE 649 // 1 bytes = flag
|
||||
// #define FREE 650 // 1 bytes = flag
|
||||
#define ESP_TIME_SERVER1 651 // 129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_TIME_SERVER2 780 // 129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_TIME_SERVER3 909 // 129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_TIME_SERVER1 \
|
||||
651 // 129 bytes 128+1 = string ; warning does not support multibyte char
|
||||
// like chinese
|
||||
#define ESP_TIME_SERVER2 \
|
||||
780 // 129 bytes 128+1 = string ; warning does not support multibyte char
|
||||
// like chinese
|
||||
#define ESP_TIME_SERVER3 \
|
||||
909 // 129 bytes 128+1 = string ; warning does not support multibyte char
|
||||
// like chinese
|
||||
// #define FREE 1038 // 1 bytes = flag
|
||||
#define ESP_SD_MOUNT 1039 // 1 bytes = flag
|
||||
#define ESP_SESSION_TIMEOUT 1040 // 1 bytes = flag
|
||||
// #define FREE 1041 // 1 bytes = flag
|
||||
#define ESP_SD_CHECK_UPDATE_AT_BOOT 1042 // 1 bytes = flag
|
||||
#define ESP_NOTIFICATION_SETTINGS 1043 // 129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||
#define ESP_NOTIFICATION_SETTINGS \
|
||||
1043 // 129 bytes 128+1 = string ; warning does not support multibyte char
|
||||
// like chinese
|
||||
#define ESP_CALIBRATION_1 1172 // 4 bytes = int
|
||||
#define ESP_CALIBRATION_2 1176 // 4 bytes = int
|
||||
#define ESP_CALIBRATION_3 1180 // 4 bytes = int
|
||||
|
@ -92,11 +92,14 @@
|
||||
/**************************
|
||||
* Hooks
|
||||
* ***********************/
|
||||
#if defined(ESP_AUTOSTART_SCRIPT) || defined(ESP_AUTOSTART_SCRIPT_FILE) || defined(ESP_GOT_IP_HOOK) || defined(ESP_GOT_DATE_TIME_HOOK)
|
||||
#if defined(ESP_AUTOSTART_SCRIPT) || defined(ESP_AUTOSTART_SCRIPT_FILE) || \
|
||||
defined(ESP_GOT_IP_HOOK) || defined(ESP_GOT_DATE_TIME_HOOK)
|
||||
#ifndef GCODE_HOST_FEATURE
|
||||
#error GCODE_HOST_FEATURE is necessary for ESP_AUTOSTART_SCRIPT/ESP_AUTOSTART_SCRIPT_FILE/ESP_GOT_IP_HOOK/ESP_GOT_DATE_TIME_HOOK
|
||||
#endif // ifndef GCODE_HOST_FEATURE
|
||||
#endif //#if defined(ESP_AUTOSTART_SCRIPT) || defined(ESP_AUTOSTART_SCRIPT_FILE) || defined(ESP_GOT_IP_HOOK) || defined(ESP_GOT_DATE_TIME_HOOK)
|
||||
#endif // #if defined(ESP_AUTOSTART_SCRIPT) ||
|
||||
// defined(ESP_AUTOSTART_SCRIPT_FILE) || defined(ESP_GOT_IP_HOOK) ||
|
||||
// defined(ESP_GOT_DATE_TIME_HOOK)
|
||||
|
||||
#if defined(ESP_GOT_IP_HOOK) || defined(ESP_GOT_DATE_TIME_HOOK)
|
||||
#if !defined(WIFI_FEATURE) && !defined(ETH_FEATURE)
|
||||
@ -195,4 +198,3 @@
|
||||
#endif
|
||||
|
||||
#endif // SANITY_CHECK
|
||||
|
||||
|
@ -70,7 +70,8 @@ class AuthenticationService {
|
||||
static bool ClearCurrentHttpSession();
|
||||
static bool ClearAllSessions();
|
||||
static bool CreateSession(ESP3DAuthenticationLevel auth_level,
|
||||
ESP3DClientType client_type, const char *session_ID);
|
||||
ESP3DClientType client_type,
|
||||
const char *session_ID);
|
||||
#endif // HTTP_FEATURE
|
||||
private:
|
||||
static String _adminpwd;
|
||||
|
@ -28,16 +28,12 @@ struct tone_data {
|
||||
tone_data* _next;
|
||||
};
|
||||
|
||||
class BuzzerDevice
|
||||
{
|
||||
class BuzzerDevice {
|
||||
public:
|
||||
BuzzerDevice();
|
||||
~BuzzerDevice();
|
||||
void playsound(int frequency, int duration);
|
||||
bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
bool started() { return _started; }
|
||||
bool begin();
|
||||
void end();
|
||||
void handle();
|
||||
@ -45,6 +41,7 @@ public:
|
||||
bool isPlaying();
|
||||
void waitWhilePlaying();
|
||||
void beep(int count = 1, int delay = 0, int frequency = BEEP_FREQUENCY);
|
||||
|
||||
private:
|
||||
tone_data* _head;
|
||||
tone_data* _tail;
|
||||
@ -52,7 +49,6 @@ private:
|
||||
void purgeData();
|
||||
bool addToneToList(int frequency, int duration);
|
||||
void no_tone();
|
||||
|
||||
};
|
||||
extern BuzzerDevice esp3d_buzzer;
|
||||
#endif //_BUZZER_H
|
||||
|
@ -18,14 +18,11 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _CAMERA_H
|
||||
#define _CAMERA_H
|
||||
#include <WebServer.h>
|
||||
|
||||
class Camera
|
||||
{
|
||||
class Camera {
|
||||
public:
|
||||
Camera();
|
||||
~Camera();
|
||||
@ -33,19 +30,15 @@ public:
|
||||
void end();
|
||||
bool initHardware();
|
||||
bool stopHardware();
|
||||
bool handle_snap(WebServer * webserver, const char *path=NULL, const char* filename=NULL);
|
||||
bool handle_snap(WebServer *webserver, const char *path = NULL,
|
||||
const char *filename = NULL);
|
||||
void handle();
|
||||
int command(const char *param, const char *value);
|
||||
uint8_t GetModel();
|
||||
const char *GetModelString();
|
||||
bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
bool isinitialised()
|
||||
{
|
||||
return _initialised;
|
||||
}
|
||||
bool started() { return _started; }
|
||||
bool isinitialised() { return _initialised; }
|
||||
|
||||
private:
|
||||
bool _initialised;
|
||||
bool _started;
|
||||
@ -54,4 +47,3 @@ private:
|
||||
extern Camera esp3d_camera;
|
||||
|
||||
#endif //_CAMERA_H
|
||||
|
||||
|
@ -18,21 +18,17 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _DEVICES_SERVICES_H
|
||||
#define _DEVICES_SERVICES_H
|
||||
|
||||
|
||||
class DevicesServices
|
||||
{
|
||||
class DevicesServices {
|
||||
public:
|
||||
static bool begin();
|
||||
static void end();
|
||||
static void handle();
|
||||
|
||||
private:
|
||||
static bool _started;
|
||||
};
|
||||
|
||||
#endif //_DEVICES_SERVICES_H
|
||||
|
||||
|
@ -18,8 +18,6 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _ETH_CONFIG_H
|
||||
#define _ETH_CONFIG_H
|
||||
#include <Arduino.h>
|
||||
@ -48,8 +46,7 @@
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#endif // ARDUINO_ARCH_ESP8266
|
||||
|
||||
class EthConfig
|
||||
{
|
||||
class EthConfig {
|
||||
public:
|
||||
static bool begin(int8_t& espMode);
|
||||
static bool StartSTA();
|
||||
@ -57,12 +54,10 @@ public:
|
||||
static void end();
|
||||
static void handle();
|
||||
static bool started();
|
||||
static void setConnected(bool connected)
|
||||
{
|
||||
_connected = connected;
|
||||
}
|
||||
static void setConnected(bool connected) { _connected = connected; }
|
||||
|
||||
static bool linkUp();
|
||||
|
||||
private:
|
||||
static bool _started;
|
||||
static bool _connected;
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "../../include/esp3d_config.h"
|
||||
|
||||
|
||||
#define ESP_FLASH_FS_HEADER "/FS"
|
||||
|
||||
#define ESP_MAX_OPENHANDLE 4
|
||||
|
@ -27,7 +27,6 @@ littlefs_esp8266_filesystem.cpp - ESP3D littlefs filesystem configuration class
|
||||
|
||||
#include "../esp_filesystem.h"
|
||||
|
||||
|
||||
Dir tDir_handle[ESP_MAX_OPENHANDLE];
|
||||
extern File tFile_handle[ESP_MAX_OPENHANDLE];
|
||||
|
||||
|
@ -101,7 +101,8 @@ uint8_t ESP_SD::getState(bool refresh) {
|
||||
|
||||
bool ESP_SD::begin() {
|
||||
#if SDIO_BIT_MODE == SD_ONE_BIT_MODE
|
||||
#if (ESP_SDIO_CLK_PIN != -1) || (ESP_SDIO_CMD_PIN != -1) || (ESP_SDIO_D0_PIN != -1)
|
||||
#if (ESP_SDIO_CLK_PIN != -1) || (ESP_SDIO_CMD_PIN != -1) || \
|
||||
(ESP_SDIO_D0_PIN != -1)
|
||||
SD_MMC.setPins(ESP_SDIO_CLK_PIN, ESP_SDIO_CMD_PIN, ESP_SDIO_D0_PIN);
|
||||
#endif //(ESP_SDIO_CLK_PIN != -1)
|
||||
#else
|
||||
|
@ -33,8 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
// Generic template
|
||||
template <class T>
|
||||
inline Print &operator <<(Print &stream, T arg)
|
||||
{
|
||||
inline Print &operator<<(Print &stream, T arg) {
|
||||
stream.print(arg);
|
||||
return stream;
|
||||
}
|
||||
@ -42,21 +41,18 @@ inline Print &operator <<(Print &stream, T arg)
|
||||
struct _BASED {
|
||||
long val;
|
||||
int base;
|
||||
_BASED(long v, int b): val(v), base(b)
|
||||
{}
|
||||
_BASED(long v, int b) : val(v), base(b) {}
|
||||
};
|
||||
|
||||
#if ARDUINO >= 100
|
||||
|
||||
struct _BYTE_CODE {
|
||||
byte val;
|
||||
_BYTE_CODE(byte v) : val(v)
|
||||
{}
|
||||
_BYTE_CODE(byte v) : val(v) {}
|
||||
};
|
||||
#define _BYTE(a) _BYTE_CODE(a)
|
||||
|
||||
inline Print &operator <<(Print &obj, const _BYTE_CODE &arg)
|
||||
{
|
||||
inline Print &operator<<(Print &obj, const _BYTE_CODE &arg) {
|
||||
obj.write(arg.val);
|
||||
return obj;
|
||||
}
|
||||
@ -77,8 +73,7 @@ inline Print &operator <<(Print &obj, const _BYTE_CODE &arg)
|
||||
// clever technique to allow for expressions like
|
||||
// Serial << _HEX(a);
|
||||
|
||||
inline Print &operator <<(Print &obj, const _BASED &arg)
|
||||
{
|
||||
inline Print &operator<<(Print &obj, const _BASED &arg) {
|
||||
obj.print(arg.val, arg.base);
|
||||
return obj;
|
||||
}
|
||||
@ -93,12 +88,10 @@ inline Print &operator <<(Print &obj, const _BASED &arg)
|
||||
struct _FLOAT {
|
||||
float val;
|
||||
int digits;
|
||||
_FLOAT(double v, int d): val(v), digits(d)
|
||||
{}
|
||||
_FLOAT(double v, int d) : val(v), digits(d) {}
|
||||
};
|
||||
|
||||
inline Print &operator <<(Print &obj, const _FLOAT &arg)
|
||||
{
|
||||
inline Print &operator<<(Print &obj, const _FLOAT &arg) {
|
||||
obj.print(arg.val, arg.digits);
|
||||
return obj;
|
||||
}
|
||||
@ -118,8 +111,7 @@ inline Print &operator <<(Print &obj, _EndLineCode arg)
|
||||
|
||||
enum _EndLineCode { eol };
|
||||
|
||||
inline Print &operator <<(Print &obj, _EndLineCode arg)
|
||||
{
|
||||
inline Print &operator<<(Print &obj, _EndLineCode arg) {
|
||||
(void)arg;
|
||||
obj.print("\r\n");
|
||||
return obj;
|
||||
|
@ -49,7 +49,8 @@ class WiFiClient;
|
||||
#define ParameterIs(a) (parameter != NULL && !strcmp_P(parameter, PSTR(a)))
|
||||
#include <time.h>
|
||||
|
||||
enum ftpCmd { FTP_Stop = 0, // In this stage, stop any connection
|
||||
enum ftpCmd {
|
||||
FTP_Stop = 0, // In this stage, stop any connection
|
||||
FTP_Init, // initialize some variables
|
||||
FTP_Client, // wait for client connection
|
||||
FTP_User, // wait for user name
|
||||
@ -57,7 +58,8 @@ enum ftpCmd { FTP_Stop = 0, // In this stage, stop any connection
|
||||
FTP_Cmd
|
||||
}; // answers to commands
|
||||
|
||||
enum ftpTransfer { FTP_Close = 0, // In this stage, close data channel
|
||||
enum ftpTransfer {
|
||||
FTP_Close = 0, // In this stage, close data channel
|
||||
FTP_Retrieve, // retrieve file
|
||||
FTP_Store, // store file
|
||||
FTP_List, // list of files
|
||||
@ -65,13 +67,13 @@ enum ftpTransfer { FTP_Close = 0, // In this stage, close data channel
|
||||
FTP_Mlsd
|
||||
}; // listing for machine processing
|
||||
|
||||
enum ftpDataConn { FTP_NoConn = 0,// No data connexion
|
||||
enum ftpDataConn {
|
||||
FTP_NoConn = 0, // No data connexion
|
||||
FTP_Pasive, // Pasive type
|
||||
FTP_Active
|
||||
}; // Active type
|
||||
|
||||
class FtpServer
|
||||
{
|
||||
class FtpServer {
|
||||
public:
|
||||
FtpServer();
|
||||
~FtpServer();
|
||||
@ -79,18 +81,9 @@ public:
|
||||
void handle();
|
||||
void end();
|
||||
bool started();
|
||||
uint16_t ctrlport()
|
||||
{
|
||||
return ctrlPort;
|
||||
}
|
||||
uint16_t datapassiveport()
|
||||
{
|
||||
return passivePort;
|
||||
}
|
||||
uint16_t dataactiveport()
|
||||
{
|
||||
return activePort;
|
||||
}
|
||||
uint16_t ctrlport() { return ctrlPort; }
|
||||
uint16_t datapassiveport() { return passivePort; }
|
||||
uint16_t dataactiveport() { return activePort; }
|
||||
void closeClient();
|
||||
bool isConnected();
|
||||
const char* clientIPAddress();
|
||||
@ -98,6 +91,7 @@ public:
|
||||
bool isPassword(const char* password);
|
||||
bool accessFS(const char* path);
|
||||
void releaseFS();
|
||||
|
||||
private:
|
||||
void iniVariables();
|
||||
void clientConnected();
|
||||
@ -120,7 +114,8 @@ private:
|
||||
uint8_t* phour, uint8_t* pminute, uint8_t* second);
|
||||
|
||||
bool getFileModTime(const char* path, time_t& time);
|
||||
bool timeStamp( const char * path, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second );
|
||||
bool timeStamp(const char* path, uint16_t year, uint8_t month, uint8_t day,
|
||||
uint8_t hour, uint8_t minute, uint8_t second);
|
||||
int8_t readChar();
|
||||
uint8_t _fsType;
|
||||
FTP_SERVER* ftpServer;
|
||||
@ -138,7 +133,8 @@ private:
|
||||
ftpTransfer transferStage; // stage of data connexion
|
||||
ftpDataConn dataConn; // type of data connexion
|
||||
|
||||
// uint8_t __attribute__((packed, aligned(4))) // need to be aligned to 32bit for Esp8266 SPIClass::transferBytes()
|
||||
// uint8_t __attribute__((packed, aligned(4))) // need to be aligned to 32bit
|
||||
// for Esp8266 SPIClass::transferBytes()
|
||||
uint8_t buf[FTP_BUF_SIZE]; // data buffer for transfers
|
||||
char cmdLine[FTP_CMD_SIZE]; // where to store incoming char from client
|
||||
char cwdName[FTP_CWD_SIZE]; // name of current directory
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,27 +22,33 @@
|
||||
#define __favicon_h
|
||||
#define favicon_size 344
|
||||
const unsigned char favicon[344] PROGMEM = {
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50,
|
||||
0x14, 0x85, 0x4f, 0x63, 0xc1, 0x5a, 0x0b, 0x06, 0x91, 0x4e, 0x52, 0x3a, 0x44, 0x10, 0x27, 0x31,
|
||||
0x45, 0xdc, 0xec, 0xd4, 0xdf, 0x21, 0x99, 0x44, 0x1c, 0x44, 0x74, 0x17, 0x9c, 0x8a, 0x73, 0x7f,
|
||||
0x80, 0xbf, 0xa0, 0x63, 0x56, 0x1d, 0x1d, 0x9c, 0xa4, 0x74, 0x15, 0x1c, 0xc4, 0x4d, 0x90, 0x0e,
|
||||
0x52, 0xa5, 0x9e, 0x4b, 0x4f, 0xf0, 0x52, 0x13, 0xa8, 0x82, 0x2f, 0x7c, 0xcd, 0xcb, 0xb9, 0xe7,
|
||||
0xde, 0x77, 0xf3, 0x5e, 0x5b, 0xa0, 0xc4, 0x2b, 0x0c, 0xc1, 0xcf, 0x26, 0x0e, 0xcb, 0x40, 0x1d,
|
||||
0xc0, 0x26, 0xa1, 0x44, 0x65, 0xaa, 0xff, 0xd7, 0x78, 0x3b, 0x5f, 0x9e, 0x18, 0x79, 0xf3, 0x79,
|
||||
0x7d, 0x36, 0xbc, 0x2f, 0xbb, 0xc7, 0x71, 0xdc, 0x36, 0xf2, 0x62, 0xbe, 0x4e, 0x51, 0x5d, 0xd5,
|
||||
0x18, 0x93, 0xd5, 0xbc, 0xde, 0xbc, 0x36, 0xdb, 0xb3, 0x72, 0xaf, 0xa5, 0x05, 0xbf, 0x59, 0x9f,
|
||||
0x79, 0x4f, 0x4e, 0x0f, 0xf8, 0x9c, 0x14, 0xf5, 0x39, 0x3b, 0xe8, 0xdd, 0x25, 0xef, 0xc4, 0xea,
|
||||
0xbc, 0x88, 0x89, 0xb4, 0xbd, 0xa2, 0x73, 0x60, 0x2c, 0x22, 0x3d, 0xd2, 0x20, 0x2d, 0x92, 0x92,
|
||||
0x91, 0x48, 0xa5, 0x35, 0xe4, 0x89, 0x72, 0xf2, 0x13, 0xb7, 0xe6, 0x01, 0xa5, 0x8a, 0x0b, 0x57,
|
||||
0x4c, 0x73, 0xbd, 0x24, 0x2e, 0xaf, 0x4a, 0x3a, 0x9c, 0x96, 0x79, 0xef, 0x92, 0x4f, 0x79, 0x6c,
|
||||
0xdd, 0x7b, 0x31, 0x92, 0x66, 0xb1, 0xae, 0xbc, 0x1d, 0xe5, 0x9e, 0x29, 0xd6, 0x27, 0x21, 0xd9,
|
||||
0xb1, 0x7d, 0x77, 0x6b, 0x65, 0x3d, 0x99, 0xb6, 0x2d, 0x4f, 0x5f, 0xba, 0xe5, 0xae, 0x93, 0x81,
|
||||
0x9e, 0x9f, 0xc9, 0x09, 0x59, 0x53, 0x6f, 0x35, 0x43, 0xf3, 0x3a, 0x39, 0x75, 0x75, 0x1f, 0x2c,
|
||||
0xd7, 0xf9, 0x7a, 0xfa, 0xae, 0x64, 0x7d, 0x0e, 0xb4, 0x6f, 0xa9, 0xe6, 0xd9, 0x7b, 0x8d, 0xe5,
|
||||
0xad, 0x15, 0x9c, 0xc1, 0x15, 0x19, 0x3a, 0x7f, 0x56, 0x6f, 0xa8, 0xd8, 0x8f, 0xbd, 0x2f, 0x38,
|
||||
0x4f, 0xdb, 0x9b, 0xa6, 0xa8, 0xce, 0x93, 0xf3, 0x97, 0x61, 0xbf, 0xbc, 0x8d, 0x3b, 0xa0, 0x75,
|
||||
0x04, 0x44, 0x5c, 0xe5, 0x78, 0x8b, 0xff, 0x19, 0x4b, 0xc0, 0xeb, 0x0a, 0x70, 0xb3, 0x00, 0xdc,
|
||||
0x5e, 0x7e, 0x7b, 0x83, 0x36, 0x70, 0x51, 0x02, 0x1e, 0x17, 0x81, 0x8f, 0xfd, 0x69, 0xee, 0x17,
|
||||
0xbf, 0xe1, 0x18, 0x97, 0x7e, 0x04, 0x00, 0x00
|
||||
};
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x94,
|
||||
0x31, 0x4b, 0xc3, 0x50, 0x14, 0x85, 0x4f, 0x63, 0xc1, 0x5a, 0x0b, 0x06,
|
||||
0x91, 0x4e, 0x52, 0x3a, 0x44, 0x10, 0x27, 0x31, 0x45, 0xdc, 0xec, 0xd4,
|
||||
0xdf, 0x21, 0x99, 0x44, 0x1c, 0x44, 0x74, 0x17, 0x9c, 0x8a, 0x73, 0x7f,
|
||||
0x80, 0xbf, 0xa0, 0x63, 0x56, 0x1d, 0x1d, 0x9c, 0xa4, 0x74, 0x15, 0x1c,
|
||||
0xc4, 0x4d, 0x90, 0x0e, 0x52, 0xa5, 0x9e, 0x4b, 0x4f, 0xf0, 0x52, 0x13,
|
||||
0xa8, 0x82, 0x2f, 0x7c, 0xcd, 0xcb, 0xb9, 0xe7, 0xde, 0x77, 0xf3, 0x5e,
|
||||
0x5b, 0xa0, 0xc4, 0x2b, 0x0c, 0xc1, 0xcf, 0x26, 0x0e, 0xcb, 0x40, 0x1d,
|
||||
0xc0, 0x26, 0xa1, 0x44, 0x65, 0xaa, 0xff, 0xd7, 0x78, 0x3b, 0x5f, 0x9e,
|
||||
0x18, 0x79, 0xf3, 0x79, 0x7d, 0x36, 0xbc, 0x2f, 0xbb, 0xc7, 0x71, 0xdc,
|
||||
0x36, 0xf2, 0x62, 0xbe, 0x4e, 0x51, 0x5d, 0xd5, 0x18, 0x93, 0xd5, 0xbc,
|
||||
0xde, 0xbc, 0x36, 0xdb, 0xb3, 0x72, 0xaf, 0xa5, 0x05, 0xbf, 0x59, 0x9f,
|
||||
0x79, 0x4f, 0x4e, 0x0f, 0xf8, 0x9c, 0x14, 0xf5, 0x39, 0x3b, 0xe8, 0xdd,
|
||||
0x25, 0xef, 0xc4, 0xea, 0xbc, 0x88, 0x89, 0xb4, 0xbd, 0xa2, 0x73, 0x60,
|
||||
0x2c, 0x22, 0x3d, 0xd2, 0x20, 0x2d, 0x92, 0x92, 0x91, 0x48, 0xa5, 0x35,
|
||||
0xe4, 0x89, 0x72, 0xf2, 0x13, 0xb7, 0xe6, 0x01, 0xa5, 0x8a, 0x0b, 0x57,
|
||||
0x4c, 0x73, 0xbd, 0x24, 0x2e, 0xaf, 0x4a, 0x3a, 0x9c, 0x96, 0x79, 0xef,
|
||||
0x92, 0x4f, 0x79, 0x6c, 0xdd, 0x7b, 0x31, 0x92, 0x66, 0xb1, 0xae, 0xbc,
|
||||
0x1d, 0xe5, 0x9e, 0x29, 0xd6, 0x27, 0x21, 0xd9, 0xb1, 0x7d, 0x77, 0x6b,
|
||||
0x65, 0x3d, 0x99, 0xb6, 0x2d, 0x4f, 0x5f, 0xba, 0xe5, 0xae, 0x93, 0x81,
|
||||
0x9e, 0x9f, 0xc9, 0x09, 0x59, 0x53, 0x6f, 0x35, 0x43, 0xf3, 0x3a, 0x39,
|
||||
0x75, 0x75, 0x1f, 0x2c, 0xd7, 0xf9, 0x7a, 0xfa, 0xae, 0x64, 0x7d, 0x0e,
|
||||
0xb4, 0x6f, 0xa9, 0xe6, 0xd9, 0x7b, 0x8d, 0xe5, 0xad, 0x15, 0x9c, 0xc1,
|
||||
0x15, 0x19, 0x3a, 0x7f, 0x56, 0x6f, 0xa8, 0xd8, 0x8f, 0xbd, 0x2f, 0x38,
|
||||
0x4f, 0xdb, 0x9b, 0xa6, 0xa8, 0xce, 0x93, 0xf3, 0x97, 0x61, 0xbf, 0xbc,
|
||||
0x8d, 0x3b, 0xa0, 0x75, 0x04, 0x44, 0x5c, 0xe5, 0x78, 0x8b, 0xff, 0x19,
|
||||
0x4b, 0xc0, 0xeb, 0x0a, 0x70, 0xb3, 0x00, 0xdc, 0x5e, 0x7e, 0x7b, 0x83,
|
||||
0x36, 0x70, 0x51, 0x02, 0x1e, 0x17, 0x81, 0x8f, 0xfd, 0x69, 0xee, 0x17,
|
||||
0xbf, 0xe1, 0x18, 0x97, 0x7e, 0x04, 0x00, 0x00};
|
||||
#endif //__favicon_h
|
@ -27,9 +27,9 @@
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#include <ESP8266WebServer.h>
|
||||
#endif // ARDUINO_ARCH_ESP8266
|
||||
#include "../../../core/esp3d_string.h"
|
||||
#include "../../authentication/authentication_service.h"
|
||||
#include "../../filesystem/esp_sd.h"
|
||||
#include "../../../core/esp3d_string.h"
|
||||
|
||||
// SD
|
||||
// SD files list and file commands
|
||||
|
@ -32,8 +32,7 @@
|
||||
#include <ESP8266SSDP.h>
|
||||
#endif // SSDP_FEATURE
|
||||
#endif // ARDUINO_ARCH_ESP8266
|
||||
void HTTP_Server::handle_SSDP()
|
||||
{
|
||||
void HTTP_Server::handle_SSDP() {
|
||||
if (_webserver) {
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
_webserver->send(200, "text/xml", SSDP.getSchema());
|
||||
|
@ -20,9 +20,7 @@
|
||||
#ifndef _INPUT_H
|
||||
#define _INPUT_H
|
||||
|
||||
|
||||
class Input
|
||||
{
|
||||
class Input {
|
||||
public:
|
||||
Input();
|
||||
~Input();
|
||||
@ -30,6 +28,7 @@ public:
|
||||
void end();
|
||||
void handle();
|
||||
bool started();
|
||||
|
||||
private:
|
||||
bool _started;
|
||||
};
|
||||
@ -37,4 +36,3 @@ private:
|
||||
extern Input esp3d_input;
|
||||
|
||||
#endif //_INPUT_H
|
||||
|
||||
|
@ -20,19 +20,15 @@
|
||||
#ifndef _LUA_INTERPRETER_H
|
||||
#define _LUA_INTERPRETER_H
|
||||
|
||||
|
||||
class LuaInterpreter
|
||||
{
|
||||
class LuaInterpreter {
|
||||
public:
|
||||
LuaInterpreter();
|
||||
~LuaInterpreter();
|
||||
bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
bool started() { return _started; }
|
||||
bool begin();
|
||||
void end();
|
||||
void handle();
|
||||
|
||||
private:
|
||||
bool _started;
|
||||
};
|
||||
|
@ -20,15 +20,11 @@
|
||||
#ifndef _MDNS_H
|
||||
#define _MDNS_H
|
||||
#include <Arduino.h>
|
||||
class mDNS_Service
|
||||
{
|
||||
class mDNS_Service {
|
||||
public:
|
||||
mDNS_Service();
|
||||
~mDNS_Service();
|
||||
bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
bool started() { return _started; }
|
||||
bool begin(const char* hostname);
|
||||
void end();
|
||||
void handle();
|
||||
@ -40,6 +36,7 @@ public:
|
||||
uint16_t answerTxtCount(uint16_t index);
|
||||
const char* answerTxtKey(uint16_t index, uint16_t txtIndex);
|
||||
const char* answerTxt(uint16_t index, uint16_t txtIndex);
|
||||
|
||||
private:
|
||||
bool _started;
|
||||
uint16_t _port;
|
||||
|
@ -217,7 +217,8 @@ void NetConfig::onWiFiEvent(WiFiEvent_t event) {
|
||||
#if defined(ESP_GOT_IP_HOOK) && defined(GCODE_HOST_FEATURE)
|
||||
String ipMsg = esp3d_string::expandString(ESP_GOT_IP_HOOK);
|
||||
esp3d_log("Got IP, sending hook: %s", ipMsg.c_str());
|
||||
esp3d_gcode_host.processScript(ipMsg.c_str(), ESP3DAuthenticationLevel::admin);
|
||||
esp3d_gcode_host.processScript(ipMsg.c_str(),
|
||||
ESP3DAuthenticationLevel::admin);
|
||||
#endif // #if defined (ESP_GOT_IP_HOOK) && defined (GCODE_HOST_FEATURE)
|
||||
#endif // #if COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||
} break;
|
||||
@ -261,12 +262,12 @@ void NetConfig::onWiFiEvent(WiFiEvent_t event) {
|
||||
#if defined(ESP_GOT_IP_HOOK) && defined(GCODE_HOST_FEATURE)
|
||||
String ipMsg = esp3d_string::expandString(ESP_GOT_IP_HOOK);
|
||||
esp3d_log("Got IP, sending hook: %s", ipMsg.c_str());
|
||||
esp3d_gcode_host.processScript(ipMsg.c_str(), ESP3DAuthenticationLevel::admin);
|
||||
esp3d_gcode_host.processScript(ipMsg.c_str(),
|
||||
ESP3DAuthenticationLevel::admin);
|
||||
#endif // #if defined (ESP_GOT_IP_HOOK) && defined (GCODE_HOST_FEATURE)
|
||||
#endif // #if COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||
EthConfig::setConnected(true);
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case ARDUINO_EVENT_ETH_STOP:
|
||||
EthConfig::setConnected(false);
|
||||
break;
|
||||
|
@ -488,7 +488,8 @@ void NetServices::handle() {
|
||||
#ifdef NOTIFICATION_FEATURE
|
||||
notificationsservice.handle();
|
||||
#endif // NOTIFICATION_FEATURE
|
||||
#if defined (TIMESTAMP_FEATURE) && (defined (ESP_GOT_IP_HOOK) || defined (ESP_GOT_DATE_TIME_HOOK))
|
||||
#if defined(TIMESTAMP_FEATURE) && \
|
||||
(defined(ESP_GOT_IP_HOOK) || defined(ESP_GOT_DATE_TIME_HOOK))
|
||||
timeService.handle();
|
||||
#endif // TIMESTAMP_FEATURE
|
||||
}
|
||||
|
@ -18,26 +18,19 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _NET_SERVICES_H
|
||||
#define _NET_SERVICES_H
|
||||
|
||||
|
||||
class NetServices
|
||||
{
|
||||
class NetServices {
|
||||
public:
|
||||
static bool begin();
|
||||
static void end();
|
||||
static void handle();
|
||||
static bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
static bool started() { return _started; }
|
||||
|
||||
private:
|
||||
static bool _started;
|
||||
static bool _restart;
|
||||
};
|
||||
|
||||
#endif //_NET_SERVICES_H
|
||||
|
||||
|
@ -103,8 +103,7 @@ void NotificationsService::BearSSLSetup(WiFiClientSecure& Notificationclient) {
|
||||
|
||||
// TODO: put error in variable to allow better error handling
|
||||
template <typename T>
|
||||
bool NotificationsService::Wait4Answer(T& client,
|
||||
const char* linetrigger,
|
||||
bool NotificationsService::Wait4Answer(T& client, const char* linetrigger,
|
||||
const char* expected_answer,
|
||||
uint32_t timeout) {
|
||||
if (client.connected()) {
|
||||
@ -518,21 +517,32 @@ bool NotificationsService::sendHomeAssistantMSG(const char* title,
|
||||
String path = tmp.substring(0, pos);
|
||||
String json = tmp.substring(pos + 1);
|
||||
// build post query
|
||||
String postcmd = "POST " + path + " HTTP/1.1\r\n"
|
||||
"Host: " + _serveraddress.c_str() + "\r\n"
|
||||
String postcmd =
|
||||
"POST " + path +
|
||||
" HTTP/1.1\r\n"
|
||||
"Host: " +
|
||||
_serveraddress.c_str() +
|
||||
"\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"User-Agent: ESP3D\r\n"
|
||||
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
|
||||
"Authorization: Bearer " + _token1 + "\r\n"
|
||||
"Accept: "
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
|
||||
"Authorization: Bearer " +
|
||||
_token1 +
|
||||
"\r\n"
|
||||
"Content-Type: application/json\r\n"
|
||||
"Content-Length: " + json.length() + "\r\n"
|
||||
"\r\n" + json;
|
||||
"Content-Length: " +
|
||||
json.length() +
|
||||
"\r\n"
|
||||
"\r\n" +
|
||||
json;
|
||||
|
||||
// esp3d_log("Query: %s", postcmd.c_str());
|
||||
// send query
|
||||
Notificationclient.print(postcmd);
|
||||
bool res = Wait4Answer(Notificationclient, "200 OK", "200 OK", HOMEASSISTANTTIMEOUT);
|
||||
bool res =
|
||||
Wait4Answer(Notificationclient, "200 OK", "200 OK", HOMEASSISTANTTIMEOUT);
|
||||
Notificationclient.stop();
|
||||
return res;
|
||||
}
|
||||
|
@ -18,13 +18,10 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _RECOVERY_SERVICE_H
|
||||
#define _RECOVERY_SERVICE_H
|
||||
|
||||
class RecoveryService
|
||||
{
|
||||
class RecoveryService {
|
||||
public:
|
||||
RecoveryService();
|
||||
~RecoveryService();
|
||||
@ -32,6 +29,7 @@ public:
|
||||
void end();
|
||||
void handle();
|
||||
bool started();
|
||||
|
||||
private:
|
||||
bool _started;
|
||||
uint32_t _servicetimeout;
|
||||
@ -40,4 +38,3 @@ private:
|
||||
extern RecoveryService recovery_service;
|
||||
|
||||
#endif //_RECOVERY_SERVICE_H
|
||||
|
||||
|
@ -18,15 +18,12 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _ANALOG_SENSOR_H
|
||||
#define _ANALOG_SENSOR_H
|
||||
|
||||
#include "sensor.h"
|
||||
|
||||
class AnalogSensorDevice : ESP3DSensorDevice
|
||||
{
|
||||
class AnalogSensorDevice : ESP3DSensorDevice {
|
||||
public:
|
||||
AnalogSensorDevice();
|
||||
~AnalogSensorDevice();
|
||||
@ -42,4 +39,3 @@ public:
|
||||
};
|
||||
|
||||
#endif //_ANALOG_SENSOR_H
|
||||
|
||||
|
@ -18,14 +18,11 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _BMX280_SENSOR_H
|
||||
#define _BMX280_SENSOR_H
|
||||
#include "sensor.h"
|
||||
|
||||
class BMX280SensorDevice : ESP3DSensorDevice
|
||||
{
|
||||
class BMX280SensorDevice : ESP3DSensorDevice {
|
||||
public:
|
||||
BMX280SensorDevice();
|
||||
~BMX280SensorDevice();
|
||||
@ -41,4 +38,3 @@ public:
|
||||
};
|
||||
|
||||
#endif //_BMX280_SENSOR_H
|
||||
|
||||
|
@ -18,15 +18,12 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _DHT_SENSOR_H
|
||||
#define _DHT_SENSOR_H
|
||||
|
||||
#include "sensor.h"
|
||||
|
||||
class DHTSensorDevice : ESP3DSensorDevice
|
||||
{
|
||||
class DHTSensorDevice : ESP3DSensorDevice {
|
||||
public:
|
||||
DHTSensorDevice();
|
||||
~DHTSensorDevice();
|
||||
@ -42,4 +39,3 @@ public:
|
||||
};
|
||||
|
||||
#endif //_DHT_SENSOR_H
|
||||
|
||||
|
@ -18,53 +18,25 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _ESP3D_SENSOR_H
|
||||
#define _ESP3D_SENSOR_H
|
||||
|
||||
class ESP3DSensorDevice
|
||||
{
|
||||
class ESP3DSensorDevice {
|
||||
public:
|
||||
ESP3DSensorDevice() {}
|
||||
virtual ~ESP3DSensorDevice() {}
|
||||
virtual bool begin()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool begin() { return false; }
|
||||
virtual void end() {}
|
||||
virtual bool isModelValid(uint8_t model)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual uint8_t getIDFromString(const char *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t nbType()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t GetModel(uint8_t i=0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual const char *GetCurrentModelString()
|
||||
{
|
||||
return "None";
|
||||
}
|
||||
virtual const char *GetModelString(uint8_t i=0)
|
||||
{
|
||||
return "None";
|
||||
}
|
||||
virtual const char * GetData()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
virtual bool isModelValid(uint8_t model) { return false; }
|
||||
virtual uint8_t getIDFromString(const char *) { return 0; }
|
||||
virtual uint8_t nbType() { return 0; }
|
||||
virtual uint8_t GetModel(uint8_t i = 0) { return 0; }
|
||||
virtual const char *GetCurrentModelString() { return "None"; }
|
||||
virtual const char *GetModelString(uint8_t i = 0) { return "None"; }
|
||||
virtual const char *GetData() { return ""; }
|
||||
};
|
||||
|
||||
class ESP3DSensor
|
||||
{
|
||||
class ESP3DSensor {
|
||||
public:
|
||||
ESP3DSensor();
|
||||
~ESP3DSensor();
|
||||
@ -76,17 +48,12 @@ public:
|
||||
const char *GetCurrentModelString();
|
||||
uint8_t getIDFromString(const char *s);
|
||||
uint8_t nbType();
|
||||
uint interval()
|
||||
{
|
||||
return _interval;
|
||||
}
|
||||
uint interval() { return _interval; }
|
||||
uint8_t GetModel(uint8_t i = 0);
|
||||
const char *GetModelString(uint8_t i = 0);
|
||||
const char *GetData();
|
||||
bool started()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
bool started() { return _started; }
|
||||
|
||||
protected:
|
||||
bool _started;
|
||||
uint32_t _interval;
|
||||
@ -94,8 +61,6 @@ protected:
|
||||
ESP3DSensorDevice *_device;
|
||||
};
|
||||
|
||||
|
||||
extern ESP3DSensor esp3d_sensor;
|
||||
|
||||
#endif //_ESP3D_SENSOR_H
|
||||
|
||||
|
@ -294,8 +294,10 @@ void ESP3DSerialService::flushbuffer() {
|
||||
// dispatch command
|
||||
if (_started) {
|
||||
ESP3DMessage *message = ESP3DMessageManager::newMsg(
|
||||
_origin, _id== MAIN_SERIAL?ESP3DClientType::all_clients: esp3d_commands.getOutputClient(), (uint8_t *)_buffer, _buffer_size,
|
||||
getAuthentication());
|
||||
_origin,
|
||||
_id == MAIN_SERIAL ? ESP3DClientType::all_clients
|
||||
: esp3d_commands.getOutputClient(),
|
||||
(uint8_t *)_buffer, _buffer_size, getAuthentication());
|
||||
if (message) {
|
||||
// process command
|
||||
message->type = ESP3DMessageType::unique;
|
||||
|
@ -23,8 +23,9 @@
|
||||
|
||||
#if defined(ESP3DLIB_ENV) && COMMUNICATION_PROTOCOL == SOCKET_SERIAL
|
||||
#include <Arduino.h>
|
||||
#include "../../core/esp3d_message.h"
|
||||
|
||||
#include "../../core/esp3d_commands.h"
|
||||
#include "../../core/esp3d_message.h"
|
||||
#include "serial2socket.h"
|
||||
|
||||
Serial_2_Socket Serial2Socket;
|
||||
@ -167,8 +168,8 @@ void Serial_2_Socket::handle_flush() {
|
||||
void Serial_2_Socket::flush(void) {
|
||||
if (_TXbufferSize > 0 && _started && !_paused) {
|
||||
ESP3DMessage *msg = ESP3DMessageManager::newMsg(
|
||||
ESP3DClientType::socket_serial, ESP3DClientType::all_clients,
|
||||
_TXbuffer, _TXbufferSize, _auth);
|
||||
ESP3DClientType::socket_serial, ESP3DClientType::all_clients, _TXbuffer,
|
||||
_TXbufferSize, _auth);
|
||||
// dispatch command
|
||||
if (msg) {
|
||||
// process command
|
||||
|
@ -22,15 +22,14 @@
|
||||
#define _SERIAL_2_SOCKET_H_
|
||||
|
||||
#include <Print.h>
|
||||
|
||||
#include "../authentication/authentication_level_types.h"
|
||||
#define S2S_TXBUFFERSIZE 1200
|
||||
#define S2S_RXBUFFERSIZE 128
|
||||
#define S2S_FLUSHTIMEOUT 500
|
||||
|
||||
|
||||
class ESP3DMessage; // forward declaration
|
||||
|
||||
|
||||
class Serial_2_Socket : public Stream {
|
||||
public:
|
||||
Serial_2_Socket();
|
||||
|
@ -250,7 +250,8 @@ void TimeService::handle() {
|
||||
isSet = true;
|
||||
#if COMMUNICATION_PROTOCOL != MKS_SERIAL
|
||||
#if defined(ESP_GOT_DATE_TIME_HOOK) && defined(GCODE_HOST_FEATURE)
|
||||
String dateMsg = esp3d_string::expandString(ESP_GOT_DATE_TIME_HOOK, true);
|
||||
String dateMsg =
|
||||
esp3d_string::expandString(ESP_GOT_DATE_TIME_HOOK, true);
|
||||
esp3d_gcode_host.processScript(dateMsg.c_str());
|
||||
#endif // #if defined (ESP_GOT_IP_HOOK) && defined (GCODE_HOST_FEATURE)
|
||||
#endif // #if COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
class TimeService {
|
||||
public:
|
||||
TimeService();
|
||||
|
@ -21,10 +21,10 @@
|
||||
#ifndef _ESP_CONFIG_FILE_H
|
||||
#define _ESP_CONFIG_FILE_H
|
||||
#include <Arduino.h>
|
||||
typedef std::function<bool(const char*, const char*,const char*)> TProcessingFunction;
|
||||
typedef std::function<bool(const char *, const char *, const char *)>
|
||||
TProcessingFunction;
|
||||
|
||||
class ESP_ConfigFile
|
||||
{
|
||||
class ESP_ConfigFile {
|
||||
public:
|
||||
ESP_ConfigFile(const char *path, TProcessingFunction fn);
|
||||
~ESP_ConfigFile();
|
||||
@ -37,6 +37,7 @@ public:
|
||||
char *getValue(char *line);
|
||||
bool processFile();
|
||||
bool revokeFile();
|
||||
|
||||
private:
|
||||
bool isScrambleKey(const char *key, const char *str);
|
||||
char *_filename;
|
||||
|
@ -288,7 +288,8 @@ bool processingFileFunction(const char* section, const char* key,
|
||||
b = v;
|
||||
}
|
||||
}
|
||||
// Notification type None / PushOver / Line / Email / Telegram / IFTTT / HomeAssistant
|
||||
// Notification type None / PushOver / Line / Email / Telegram / IFTTT /
|
||||
// HomeAssistant
|
||||
if (!done) {
|
||||
if (strcasecmp("NOTIF_TYPE", key) == 0) {
|
||||
T = 'B';
|
||||
|
@ -21,9 +21,7 @@
|
||||
#ifndef _UPDATE_SERVICES_H
|
||||
#define _UPDATE_SERVICES_H
|
||||
|
||||
|
||||
class UpdateService
|
||||
{
|
||||
class UpdateService {
|
||||
public:
|
||||
UpdateService();
|
||||
~UpdateService();
|
||||
@ -38,4 +36,3 @@ private:
|
||||
extern UpdateService update_service;
|
||||
|
||||
#endif //_UPDATE_SERVICES_H
|
||||
|
||||
|
32
tools/format_sources.py
Normal file
32
tools/format_sources.py
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
# Base directory of the script
|
||||
script_path = os.path.abspath(__file__)
|
||||
|
||||
# Extract dir path
|
||||
script_dir = os.path.dirname(script_path)
|
||||
|
||||
# Build path of sources dir : ../esp3d
|
||||
base_dir = os.path.abspath(os.path.normpath(os.path.join(script_dir, '..', 'esp3d')))
|
||||
|
||||
# Parse all c, h , cpp files in all directories and sub directories
|
||||
file_paths = []
|
||||
for root, dirs, files in os.walk(base_dir):
|
||||
for file in files:
|
||||
if file.endswith(('.c', '.cpp', '.h', '.ino')):
|
||||
file_path = os.path.join(root, file)
|
||||
file_paths.append(os.path.abspath(os.path.normpath(file_path)))
|
||||
|
||||
# Now format all files one by one with clang-format
|
||||
for file_path in file_paths:
|
||||
tmpPath = '"' + file_path + '"'
|
||||
print("Formating " + tmpPath, end="")
|
||||
try:
|
||||
command = ['clang-format', '-i', '--style=Google', file_path]
|
||||
subprocess.run(command, check=False)
|
||||
print("=> Ok")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f'=>Error : {e}')
|
Loading…
x
Reference in New Issue
Block a user