Skip to content

Update Submodules and add CI for automated code analysis, building, and releasing #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
RawStringFormats:
- Language: TextProto
Delimiters:
- 'pb'
- 'proto'
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...

21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build

on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Build Examples
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: release-v5.2
target: esp32s3
path: '.'
48 changes: 48 additions & 0 deletions .github/workflows/package_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Package Main

on:
push:
branches: [main]
release:
types: [published]

jobs:
build:

runs-on: ubuntu-latest
continue-on-error: false

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Build Main Code
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: release-v5.2
target: esp32s3
path: '.'
command: 'idf.py build'

- name: Upload Build Outputs
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
build/bootloader/bootloader.bin
build/partition_table/partition-table.bin
build/*.bin
build/flash_args

- name: Attach files to release
uses: softprops/action-gh-release@v1
if: ${{ github.event.release && github.event.action == 'published' }}
with:
files: |
build/*.bin
build/bootloader/bootloader.bin
build/partition_table/partition-table.bin
build/flash_args

25 changes: 25 additions & 0 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Static analysis

on: [pull_request]

jobs:
static_analysis:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Run static analysis
uses: esp-cpp/StaticAnalysis@master
with:
# Do not build the project and do not use cmake to generate compile_commands.json
use_cmake: false

# Use the 5.2 release version since it's what we build with
esp_idf_version: release/v5.2

# (Optional) cppcheck args
cppcheck_args: -i$GITHUB_WORKSPACE/components/espp -i$GITHUB_WORKSPACE/components/esp-protocols --force --enable=all --inline-suppr --inconclusive --platform=mips32 --std=c++17 --suppressions-list=$GITHUB_WORKSPACE/suppressions.txt
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
exclude: |
(?x)(
^components/esp-dsp/|
^components/esp_littlefs/|
^components/lvgl/|
^components/state_machine/include/magic_enum.hpp|
^external/alpaca/|
^external/cli/|
^external/csv2/|
^external/fmt/
)
types_or: [c++, c]
2 changes: 1 addition & 1 deletion components/esp-protocols
Submodule esp-protocols updated 275 files
2 changes: 1 addition & 1 deletion components/espp
Submodule espp updated 358 files
24 changes: 13 additions & 11 deletions components/gui/include/graph_window.hpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
#pragma once

#include <string>
#include <cstring>
#include <string>
#include <unordered_map>

#include "window.hpp"

class GraphWindow : public Window {
public:
GraphWindow() = default;

void init(lv_obj_t *parent, size_t width, size_t height) override;
void update() override;

void clear_plots ( void );
void add_data ( const std::string& plot_name, int new_data );
void remove_plot ( const std::string& plot_name );
void clear_plots(void);
void add_data(const std::string &plot_name, int new_data);
void remove_plot(const std::string &plot_name);

protected:
lv_chart_series_t* create_plot ( const std::string& plotName );
lv_chart_series_t* get_plot ( const std::string& plotName );
lv_chart_series_t *create_plot(const std::string &plotName);
lv_chart_series_t *get_plot(const std::string &plotName);

void update_ticks ( void );
void update_ticks(void);

private:
lv_obj_t *chart_;
lv_obj_t *legend_;
std::string y_ticks_;
std::unordered_map<std::string, lv_chart_series_t*> plot_map_;
lv_obj_t *chart_{nullptr};
lv_obj_t *legend_{nullptr};
std::string y_ticks_{""};
std::unordered_map<std::string, lv_chart_series_t *> plot_map_{};
};
28 changes: 13 additions & 15 deletions components/gui/include/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

#include "converter.hpp"
#include "display.hpp"
#include "task.hpp"
#include "graph_window.hpp"
#include "logger.hpp"
#include "task.hpp"
#include "text_window.hpp"
#include "graph_window.hpp"

class Gui {
public:
const std::string delimeter_data = "::"; ///< Delimeter indicating this contains plottable data
const std::string delimeter_data = "::"; ///< Delimeter indicating this contains plottable data
const std::string delimeter_command = "+++"; ///< Delimeter indicating this contains a command
const std::string command_remove_plot = "RP:"; ///< Command: remove plot
const std::string command_clear_plots = "CP"; ///< Command: clear plots
Expand All @@ -27,17 +27,15 @@ class Gui {
espp::Logger::Verbosity log_level{espp::Logger::Verbosity::WARN};
};

explicit Gui(const Config& config)
: display_(config.display)
, logger_({.tag = "Gui", .level = config.log_level}) {
explicit Gui(const Config &config)
: display_(config.display)
, logger_({.tag = "Gui", .level = config.log_level}) {
init_ui();
// now start the gui updater task
using namespace std::placeholders;
task_ = espp::Task::make_unique({
.name = "Gui Task",
.callback = std::bind(&Gui::update, this, _1, _2),
.stack_size_bytes = 6 * 1024
});
task_ = espp::Task::make_unique({.name = "Gui Task",
.callback = std::bind(&Gui::update, this, _1, _2),
.stack_size_bytes = 6 * 1024});
task_->start();
}

Expand All @@ -48,19 +46,19 @@ class Gui {

void switch_tab();

void push_data(const std::string& data);
void push_data(const std::string &data);
std::string pop_data();

void clear_info();
void add_info(const std::string& info);
void add_info(const std::string &info);

bool handle_data();

protected:
void init_ui();
void deinit_ui();

bool update(std::mutex& m, std::condition_variable& cv) {
bool update(std::mutex &m, std::condition_variable &cv) {
{
std::lock_guard<std::recursive_mutex> lk(mutex_);
lv_task_handler();
Expand All @@ -77,7 +75,7 @@ class Gui {
static void event_callback(lv_event_t *e) {
lv_event_code_t event_code = lv_event_get_code(e);
auto user_data = lv_event_get_user_data(e);
auto gui = static_cast<Gui*>(user_data);
auto gui = static_cast<Gui *>(user_data);
if (!gui) {
return;
}
Expand Down
11 changes: 6 additions & 5 deletions components/gui/include/text_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

class TextWindow : public Window {
public:
TextWindow() = default;

void init ( lv_obj_t *parent, size_t width, size_t height ) override;
void init(lv_obj_t *parent, size_t width, size_t height) override;

void clear_logs( void );
void add_log ( const std::string& log_text );
void clear_logs(void);
void add_log(const std::string &log_text);

private:
std::string log_text_;
lv_obj_t *log_container_;
std::string log_text_{""};
lv_obj_t *log_container_{nullptr};
};
Loading