From 28354e343f157e331301bd37d0c71c74e93b5c26 Mon Sep 17 00:00:00 2001 From: zhaohe <1013909206@qq.com> Date: Tue, 19 Jul 2022 09:43:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .clang-format | 5 +++++ .vscode/c_cpp_properties.json | 9 +++++++++ .vscode/settings.json | 1 - main/main.cpp | 38 +++++++++++++++++++------------------- 4 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 .clang-format create mode 100644 .vscode/c_cpp_properties.json diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..7e4b66c --- /dev/null +++ b/.clang-format @@ -0,0 +1,5 @@ +# Defines the Chromium style for automatic reformatting. +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +Language: Cpp +BasedOnStyle: Google +ColumnLimit: 200 \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..38437e0 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,9 @@ +{ + "configurations": [ + { + "name": "Win32", + "compileCommands": "./build/compile_commands.json" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 0e0dcd2..7a73a41 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,2 @@ { - } \ No newline at end of file diff --git a/main/main.cpp b/main/main.cpp index f997e13..60cd77d 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -9,31 +9,31 @@ #include #include + #include "esp_log.h" #include "gpio_cxx.hpp" using namespace idf; using namespace std; -extern "C" void app_main(void) -{ - /* The functions of GPIO_Output throws exceptions in case of parameter errors or if there are underlying driver - errors. */ - try { - /* This line may throw an exception if the pin number is invalid. - * Alternatively to 4, choose another output-capable pin. */ - GPIO_Output gpio(GPIONum(4)); +extern "C" void app_main(void) { + /* The functions of GPIO_Output throws exceptions in case of parameter errors or if there are underlying driver + errors. */ + try { + /* This line may throw an exception if the pin number is invalid. + * Alternatively to 4, choose another output-capable pin. */ + GPIO_Output gpio(GPIONum(4)); - while (true) { - printf("LED ON\n"); - gpio.set_high(); - this_thread::sleep_for(std::chrono::seconds(1)); - printf("LED OFF\n"); - gpio.set_low(); - this_thread::sleep_for(std::chrono::seconds(1)); - } - } catch (GPIOException &e) { - printf("GPIO exception occurred: %s\n", esp_err_to_name(e.error)); - printf("stopping.\n"); + while (true) { + printf("LED ON\n"); + gpio.set_high(); + this_thread::sleep_for(std::chrono::seconds(1)); + printf("LED OFF\n"); + gpio.set_low(); + this_thread::sleep_for(std::chrono::seconds(1)); } + } catch (GPIOException &e) { + printf("GPIO exception occurred: %s\n", esp_err_to_name(e.error)); + printf("stopping.\n"); + } }