Naming and coding style convention, new linter tool. (#945)

* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
This commit is contained in:
あく
2022-01-05 19:10:18 +03:00
committed by GitHub
parent c98e54da10
commit 389ff92cc1
899 changed files with 379245 additions and 373421 deletions

View File

@@ -0,0 +1,47 @@
#include "lfrfid_debug_app_scene_start.h"
typedef enum {
SubmenuTune,
} SubmenuIndex;
void LfRfidDebugAppSceneStart::on_enter(LfRfidDebugApp* app, bool need_restore) {
auto submenu = app->view_controller.get<SubmenuVM>();
auto callback = cbc::obtain_connector(this, &LfRfidDebugAppSceneStart::submenu_callback);
submenu->add_item("Tune", SubmenuTune, callback, app);
if(need_restore) {
submenu->set_selected_item(submenu_item_selected);
}
app->view_controller.switch_to<SubmenuVM>();
}
bool LfRfidDebugAppSceneStart::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) {
bool consumed = false;
if(event->type == LfRfidDebugApp::EventType::MenuSelected) {
submenu_item_selected = event->payload.menu_index;
switch(event->payload.menu_index) {
case SubmenuTune:
app->scene_controller.switch_to_next_scene(LfRfidDebugApp::SceneType::TuneScene);
break;
}
consumed = true;
}
return consumed;
}
void LfRfidDebugAppSceneStart::on_exit(LfRfidDebugApp* app) {
app->view_controller.get<SubmenuVM>()->clean();
}
void LfRfidDebugAppSceneStart::submenu_callback(void* context, uint32_t index) {
LfRfidDebugApp* app = static_cast<LfRfidDebugApp*>(context);
LfRfidDebugApp::Event event;
event.type = LfRfidDebugApp::EventType::MenuSelected;
event.payload.menu_index = index;
app->view_controller.send_event(&event);
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "../lfrfid_debug_app.h"
class LfRfidDebugAppSceneStart : public GenericScene<LfRfidDebugApp> {
public:
void on_enter(LfRfidDebugApp* app, bool need_restore) final;
bool on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) final;
void on_exit(LfRfidDebugApp* app) final;
private:
void submenu_callback(void* context, uint32_t index);
uint32_t submenu_item_selected = 0;
};

View File

@@ -0,0 +1,60 @@
#include "lfrfid_debug_app_scene_tune.h"
#include <furi_hal.h>
extern COMP_HandleTypeDef hcomp1;
static void comparator_trigger_callback(void* hcomp, void* comp_ctx) {
COMP_HandleTypeDef* _hcomp = static_cast<COMP_HandleTypeDef*>(hcomp);
if(hcomp == &hcomp1) {
hal_gpio_write(&gpio_ext_pa7, HAL_COMP_GetOutputLevel(_hcomp) == COMP_OUTPUT_LEVEL_HIGH);
}
}
void LfRfidDebugAppSceneTune::on_enter(LfRfidDebugApp* app, bool need_restore) {
app->view_controller.switch_to<LfRfidViewTuneVM>();
hal_gpio_init_simple(&gpio_ext_pa7, GpioModeOutputPushPull);
api_interrupt_add(comparator_trigger_callback, InterruptTypeComparatorTrigger, this);
hcomp1.Init.InputMinus = COMP_INPUT_MINUS_1_2VREFINT;
hcomp1.Init.InputPlus = COMP_INPUT_PLUS_IO1;
hcomp1.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
hcomp1.Init.Hysteresis = COMP_HYSTERESIS_HIGH;
hcomp1.Init.BlankingSrce = COMP_BLANKINGSRC_NONE;
hcomp1.Init.Mode = COMP_POWERMODE_MEDIUMSPEED;
hcomp1.Init.WindowMode = COMP_WINDOWMODE_DISABLE;
hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_IT_RISING_FALLING;
if(HAL_COMP_Init(&hcomp1) != HAL_OK) {
Error_Handler();
}
HAL_COMP_Start(&hcomp1);
furi_hal_rfid_pins_read();
furi_hal_rfid_tim_read(125000, 0.5);
furi_hal_rfid_tim_read_start();
}
bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) {
bool consumed = false;
LfRfidViewTuneVM* tune = app->view_controller;
if(tune->is_dirty()) {
furi_hal_rfid_set_read_period(tune->get_ARR());
furi_hal_rfid_set_read_pulse(tune->get_CCR());
}
return consumed;
}
void LfRfidDebugAppSceneTune::on_exit(LfRfidDebugApp* app) {
HAL_COMP_Stop(&hcomp1);
api_interrupt_remove(comparator_trigger_callback, InterruptTypeComparatorTrigger);
hal_gpio_init_simple(&gpio_ext_pa7, GpioModeAnalog);
furi_hal_rfid_tim_read_stop();
furi_hal_rfid_tim_reset();
furi_hal_rfid_pins_reset();
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "../lfrfid_debug_app.h"
class LfRfidDebugAppSceneTune : public GenericScene<LfRfidDebugApp> {
public:
void on_enter(LfRfidDebugApp* app, bool need_restore) final;
bool on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) final;
void on_exit(LfRfidDebugApp* app) final;
};