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
@@ -0,0 +1,32 @@
#include "byte_input_vm.h"
ByteInputVM::ByteInputVM() {
byte_input = byte_input_alloc();
}
ByteInputVM::~ByteInputVM() {
byte_input_free(byte_input);
}
View* ByteInputVM::get_view() {
return byte_input_get_view(byte_input);
}
void ByteInputVM::clean() {
byte_input_set_header_text(byte_input, "");
byte_input_set_result_callback(byte_input, NULL, NULL, NULL, NULL, 0);
}
void ByteInputVM::set_result_callback(
ByteInputCallback input_callback,
ByteChangedCallback changed_callback,
void* callback_context,
uint8_t* bytes,
uint8_t bytes_count) {
byte_input_set_result_callback(
byte_input, input_callback, changed_callback, callback_context, bytes, bytes_count);
}
void ByteInputVM::set_header_text(const char* text) {
byte_input_set_header_text(byte_input, text);
}
@@ -0,0 +1,37 @@
#pragma once
#include "generic_view_module.h"
#include <gui/modules/byte_input.h>
class ByteInputVM : public GenericViewModule {
public:
ByteInputVM();
~ByteInputVM() final;
View* get_view() final;
void clean() final;
/**
* @brief Set byte input result callback
*
* @param input_callback input callback fn
* @param changed_callback changed callback fn
* @param callback_context callback context
* @param bytes buffer to use
* @param bytes_count buffer length
*/
void set_result_callback(
ByteInputCallback input_callback,
ByteChangedCallback changed_callback,
void* callback_context,
uint8_t* bytes,
uint8_t bytes_count);
/**
* @brief Set byte input header text
*
* @param text text to be shown
*/
void set_header_text(const char* text);
private:
ByteInput* byte_input;
};
@@ -0,0 +1,61 @@
#include "dialog_ex_vm.h"
DialogExVM::DialogExVM() {
dialog_ex = dialog_ex_alloc();
}
DialogExVM::~DialogExVM() {
dialog_ex_free(dialog_ex);
}
View* DialogExVM::get_view() {
return dialog_ex_get_view(dialog_ex);
}
void DialogExVM::clean() {
set_result_callback(NULL);
set_context(NULL);
set_header(NULL, 0, 0, AlignLeft, AlignBottom);
set_text(NULL, 0, 0, AlignLeft, AlignBottom);
set_icon(0, 0, NULL);
set_left_button_text(NULL);
set_center_button_text(NULL);
set_right_button_text(NULL);
}
void DialogExVM::set_result_callback(DialogExResultCallback callback) {
dialog_ex_set_result_callback(dialog_ex, callback);
}
void DialogExVM::set_context(void* context) {
dialog_ex_set_context(dialog_ex, context);
}
void DialogExVM::set_header(
const char* text,
uint8_t x,
uint8_t y,
Align horizontal,
Align vertical) {
dialog_ex_set_header(dialog_ex, text, x, y, horizontal, vertical);
}
void DialogExVM::set_text(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical) {
dialog_ex_set_text(dialog_ex, text, x, y, horizontal, vertical);
}
void DialogExVM::set_icon(uint8_t x, uint8_t y, const Icon* icon) {
dialog_ex_set_icon(dialog_ex, x, y, icon);
}
void DialogExVM::set_left_button_text(const char* text) {
dialog_ex_set_left_button_text(dialog_ex, text);
}
void DialogExVM::set_center_button_text(const char* text) {
dialog_ex_set_center_button_text(dialog_ex, text);
}
void DialogExVM::set_right_button_text(const char* text) {
dialog_ex_set_right_button_text(dialog_ex, text);
}
@@ -0,0 +1,73 @@
#pragma once
#include "generic_view_module.h"
#include <gui/modules/dialog_ex.h>
class DialogExVM : public GenericViewModule {
public:
DialogExVM();
~DialogExVM() final;
View* get_view() final;
void clean() final;
/**
* Set dialog result callback
* @param callback - result callback function
*/
void set_result_callback(DialogExResultCallback callback);
/**
* Set dialog context
* @param context - context pointer, will be passed to result callback
*/
void set_context(void* context);
/**
* Set dialog header text
* If text is null, dialog header will not be rendered
* @param text - text to be shown, can be multiline
* @param x, y - text position
* @param horizontal, vertical - text aligment
*/
void set_header(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical);
/**
* Set dialog text
* If text is null, dialog text will not be rendered
* @param text - text to be shown, can be multiline
* @param x, y - text position
* @param horizontal, vertical - text aligment
*/
void set_text(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical);
/**
* Set dialog icon
* If x or y is negative, dialog icon will not be rendered
* @param x, y - icon position
* @param name - icon to be shown
*/
void set_icon(uint8_t x, uint8_t y, const Icon* icon);
/**
* Set left button text
* If text is null, left button will not be rendered and processed
* @param text - text to be shown
*/
void set_left_button_text(const char* text);
/**
* Set center button text
* If text is null, center button will not be rendered and processed
* @param text - text to be shown
*/
void set_center_button_text(const char* text);
/**
* Set right button text
* If text is null, right button will not be rendered and processed
* @param text - text to be shown
*/
void set_right_button_text(const char* text);
private:
DialogEx* dialog_ex;
};
@@ -0,0 +1,10 @@
#pragma once
#include <gui/view.h>
class GenericViewModule {
public:
GenericViewModule(){};
virtual ~GenericViewModule(){};
virtual View* get_view() = 0;
virtual void clean() = 0;
};
@@ -0,0 +1,54 @@
#include "popup_vm.h"
PopupVM::PopupVM() {
popup = popup_alloc();
}
PopupVM::~PopupVM() {
popup_free(popup);
}
View* PopupVM::get_view() {
return popup_get_view(popup);
}
void PopupVM::clean() {
set_callback(NULL);
set_context(NULL);
set_header(NULL, 0, 0, AlignLeft, AlignBottom);
set_text(NULL, 0, 0, AlignLeft, AlignBottom);
set_icon(0, 0, NULL);
disable_timeout();
set_timeout(1000);
}
void PopupVM::set_callback(PopupCallback callback) {
popup_set_callback(popup, callback);
}
void PopupVM::set_context(void* context) {
popup_set_context(popup, context);
}
void PopupVM::set_header(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical) {
popup_set_header(popup, text, x, y, horizontal, vertical);
}
void PopupVM::set_text(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical) {
popup_set_text(popup, text, x, y, horizontal, vertical);
}
void PopupVM::set_icon(int8_t x, int8_t y, const Icon* icon) {
popup_set_icon(popup, x, y, icon);
}
void PopupVM::set_timeout(uint32_t timeout_in_ms) {
popup_set_timeout(popup, timeout_in_ms);
}
void PopupVM::enable_timeout() {
popup_enable_timeout(popup);
}
void PopupVM::disable_timeout() {
popup_enable_timeout(popup);
}
@@ -0,0 +1,68 @@
#pragma once
#include "generic_view_module.h"
#include <gui/modules/popup.h>
class PopupVM : public GenericViewModule {
public:
PopupVM();
~PopupVM() final;
View* get_view() final;
void clean() final;
/**
* Set popup header text
* @param text - text to be shown
*/
void set_callback(PopupCallback callback);
/**
* Set popup context
* @param context - context pointer, will be passed to result callback
*/
void set_context(void* context);
/**
* Set popup header text
* If text is null, popup header will not be rendered
* @param text - text to be shown, can be multiline
* @param x, y - text position
* @param horizontal, vertical - text aligment
*/
void set_header(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical);
/**
* Set popup text
* If text is null, popup text will not be rendered
* @param text - text to be shown, can be multiline
* @param x, y - text position
* @param horizontal, vertical - text aligment
*/
void set_text(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical);
/**
* Set popup icon
* If icon position is negative, popup icon will not be rendered
* @param x, y - icon position
* @param name - icon to be shown
*/
void set_icon(int8_t x, int8_t y, const Icon* icon);
/**
* Set popup timeout
* @param timeout_in_ms - popup timeout value in milliseconds
*/
void set_timeout(uint32_t timeout_in_ms);
/**
* Enable popup timeout
*/
void enable_timeout();
/**
* Disable popup timeout
*/
void disable_timeout();
private:
Popup* popup;
};
@@ -0,0 +1,33 @@
#include "submenu_vm.h"
SubmenuVM::SubmenuVM() {
submenu = submenu_alloc();
}
SubmenuVM::~SubmenuVM() {
submenu_free(submenu);
}
View* SubmenuVM::get_view() {
return submenu_get_view(submenu);
}
void SubmenuVM::clean() {
submenu_clean(submenu);
}
void SubmenuVM::add_item(
const char* label,
uint32_t index,
SubmenuItemCallback callback,
void* callback_context) {
submenu_add_item(submenu, label, index, callback, callback_context);
}
void SubmenuVM::set_selected_item(uint32_t index) {
submenu_set_selected_item(submenu, index);
}
void SubmenuVM::set_header(const char* header) {
submenu_set_header(submenu, header);
}
@@ -0,0 +1,42 @@
#pragma once
#include "generic_view_module.h"
#include <gui/modules/submenu.h>
class SubmenuVM : public GenericViewModule {
public:
SubmenuVM();
~SubmenuVM() final;
View* get_view() final;
void clean() final;
/**
* @brief Add item to submenu
*
* @param label - menu item label
* @param index - menu item index, used for callback, may be the same with other items
* @param callback - menu item callback
* @param callback_context - menu item callback context
*/
void add_item(
const char* label,
uint32_t index,
SubmenuItemCallback callback,
void* callback_context);
/**
* @brief Set submenu item selector
*
* @param index index of the item to be selected
*/
void set_selected_item(uint32_t index);
/**
* @brief Set optional header for submenu
*
* @param header header to set
*/
void set_header(const char* header);
private:
Submenu* submenu;
};
@@ -0,0 +1,31 @@
#include "text_input_vm.h"
TextInputVM::TextInputVM() {
text_input = text_input_alloc();
}
TextInputVM::~TextInputVM() {
text_input_free(text_input);
}
View* TextInputVM::get_view() {
return text_input_get_view(text_input);
}
void TextInputVM::clean() {
text_input_clean(text_input);
}
void TextInputVM::set_result_callback(
TextInputCallback callback,
void* callback_context,
char* text,
uint8_t max_text_length,
bool clear_default_text) {
text_input_set_result_callback(
text_input, callback, callback_context, text, max_text_length, clear_default_text);
}
void TextInputVM::set_header_text(const char* text) {
text_input_set_header_text(text_input, text);
}
@@ -0,0 +1,37 @@
#pragma once
#include "generic_view_module.h"
#include <gui/modules/text_input.h>
class TextInputVM : public GenericViewModule {
public:
TextInputVM();
~TextInputVM() final;
View* get_view() final;
void clean() final;
/**
* @brief Set text input result callback
*
* @param callback - callback fn
* @param callback_context - callback context
* @param text - text buffer to use
* @param max_text_length - text buffer length
* @param clear_default_text - clears given buffer on OK event
*/
void set_result_callback(
TextInputCallback callback,
void* callback_context,
char* text,
uint8_t max_text_length,
bool clear_default_text);
/**
* @brief Set text input header text
*
* @param text - text to be shown
*/
void set_header_text(const char* text);
private:
TextInput* text_input;
};