mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-04 20:20:39 +08:00

### Maintenance page * Add add tab color for mobile view * Add spellcheck off / autocorect off in input * Add disconnect button when authenticate enabled * Add Invalid user or password message when authentication failed ### Board support * Add ESP32 S2 support * Add ESP32 S3 support * Add ESP32 C3 support ### ESP commands * Add command 701 to control GCODE streaming * Remove command 901 as duplicate * Update command 420 to add more details * Use text as default output * All json on all commands for formated output ### Core * Add benchmak function to check transfer speed (for test only-not production) * Merge code for ESP3DLib support * Add better printer display support (M117 / Serial TFT) * Use ESP32 analogWrite instead of emulated one ### Modules * Display * Refactor code * Remove SPI ILI 9341 / 9488 support as not suitable * Add ST7789 support (135x240 / 240x240) * Filesystem * Bug fixes due to esp core updates * Better SD sharing mecanism * Better global FS management * FTP * Add SD sharing support * Better global FS management * GCODE Host * Add basic support for macro files * Add ESP command support * Use not blocking method to stream commands / handle response * Notifications * Add IFTTT notification service * Add WebUI notification * Add ESP3D display notification * WebDav * Add SD sharing support * Add bug fix from https://github.com/d-a-v/ESPWebDAV * Better global FS management * Websocket * Add function to handle zombies connections * WiFi * Fix connection to AP sometime fail * Fix low signal not diplayed in ESP420 even connected * Add AP Setup mode ### Libraries * Update SDFat-2.0.6 to 2.1.2 * Update ESP32SSDP 1.1.1 to 1.2.0 * Update TFT_eSPI-1.4.11 to 2.4.61 * Update arduinoWebSockets-2.3.5 to 2.3.6 * Update esp8266-oled-ssd1306-4.0.0 to 4.3.0 * Remove lvgl support ### Tools * Add I2C scanner script * Add python script to simulate/stress printer serial communication ### PlatformIO * Use latest 4.4.0 Espressif32 release (ESP32-arduino core 2.0.3) * Add fix for Flash more than 4MB * Add Esp32 S2/S3/C3 env * Add ESP32-ST7789 / esp32-TTGO_T_Display env
3.1 KiB
3.1 KiB
Coding style
File format
Use misc/lv_templ.c and misc/lv_templ.h
Naming conventions
- Words are separated by '_'
- In variable and function names use only lower case letters (e.g. height_tmp)
- In enums and defines use only upper case letters (e.g. e.g. MAX_LINE_NUM)
- Global names (API):
- start with lv
- followed by module name: btn, label, style etc.
- followed by the action (for functions): set, get, refr etc.
- closed with the subject: name, size, state etc.
- Typedefs
- prefer
typedef struct
andtypedef enum
instead ofstruct name
andenum name
- always end
typedef struct
andtypedef enum
type names with_t
- prefer
- Abbreviations:
- Only words longer or equal than 6 characters can be abbreviated.
- Abbreviate only if it makes the word at least half as long
- Use only very straightforward and well-known abbreviations (e.g. pos: position, def: default, btn: button)
Coding guide
- Functions:
- Try to write function shorter than is 50 lines
- Always shorter than 200 lines (except very straightforwards)
- Variables:
- One line, one declaration (BAD: char x, y;)
- Use
<stdint.h>
(uint8_t, int32_t etc) - Declare variables where needed (not all at function start)
- Use the smallest required scope
- Variables in a file (outside functions) are always static
- Do not use global variables (use functions to set/get static variables)
Comments
Before every function have a comment like this:
/**
* Return with the screen of an object
* @param obj pointer to an object
* @return pointer to a screen
*/
lv_obj_t * lv_obj_get_scr(lv_obj_t * obj);
Always use /*Something*/
format and NOT //Something
Write readable code to avoid descriptive comments like:
x++; /*Add 1 to x*/
.
The code should show clearly what you are doing.
You should write why have you done this:
x++; /*Because of closing '\0' of the string*/
Short "code summaries" of a few lines are accepted. E.g. /*Calculate the new coordinates*/
In comments use ` ` when referring to a variable. E.g. /*Update the value of `x_act`*/
Formatting
Here is example to show bracket placing and using of white spaces:
/**
* Set a new text for a label. Memory will be allocated to store the text by the label.
* @param label pointer to a label object
* @param text '\0' terminated character string. NULL to refresh with the current text.
*/
void lv_label_set_text(lv_obj_t * label, const char * text)
{ /*Main brackets of functions in new line*/
if(label == NULL) return; /*No bracket only if the command is inline with the if statement*/
lv_obj_inv(label);
lv_label_ext_t * ext = lv_obj_get_ext(label);
/*Comment before a section*/
if(text == ext->txt || text == NULL) { /*Bracket of statements start inline*/
lv_label_refr_text(label);
return;
}
...
}
Use 4 spaces indentation instead of tab.
You can use astyle to format the code. Run code-formatter.sh
from the scrips
folder.