mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge branch 'master' of https://github.com/littlevgl/lvgl
This commit is contained in:
commit
9f333d50d7
94
docs/CODING_STYLE.md
Normal file
94
docs/CODING_STYLE.md
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
|
||||||
|
## File format
|
||||||
|
Use [lv_misc/lv_templ.c](https://github.com/littlevgl/lvgl/blob/master/lv_misc/lv_templ.c) and [lv_misc/lv_templ.h](https://github.com/littlevgl/lvgl/blob/master/lv_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):
|
||||||
|
* starts 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` and `typedef enum` instead of `struct name` and `enum name`
|
||||||
|
* always end `typedef struct` and `typedef enum` type names with `_t`
|
||||||
|
* Abbreviations:
|
||||||
|
* Use abbreviations on public names only if they become longer than 32 characters
|
||||||
|
* Use only very straightforward (e.g. pos: position) or well-established (e.g. pr: press) abbreviations
|
||||||
|
|
||||||
|
## Coding guide
|
||||||
|
* Functions:
|
||||||
|
* Try to write function shorter than is 50 lines
|
||||||
|
* Always shorter than 100 lines (except very straightforwards)
|
||||||
|
* Variables:
|
||||||
|
* One line, one declaration (BAD: char x, y;)
|
||||||
|
* Use `<stdint.h>` (*uint8_t*, *int32_t* etc)
|
||||||
|
* Declare variables when 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:
|
||||||
|
|
||||||
|
```c
|
||||||
|
/**
|
||||||
|
* 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:
|
||||||
|
```c
|
||||||
|
/**
|
||||||
|
* 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. The required config flies are: `docs/astyle_c` and `docs/astyle_h`.
|
||||||
|
To format the source files:
|
||||||
|
`$ find . -type f -name "*.c" | xargs astyle --options=docs/astyle_c`
|
||||||
|
|
||||||
|
To format the header files:
|
||||||
|
`$ find . -type f -name "*.h" | xargs astyle --options=docs/astyle_h`
|
||||||
|
|
||||||
|
Append `-n` to the end to skip creation of backup file OR use `$ find . -type f -name "*.bak" -delete` (for source file's backups) and `find . -type f -name "*.orig" -delete` (for header file's backups)
|
@ -1,95 +1,96 @@
|
|||||||
# Contributing to Littlev Graphics Library
|
# Contributing to Littlev Graphics Library
|
||||||
|
|
||||||
**Welcome! It's glad to see that you are interested in contributing to LittlevGL! There are several types of task where you can help to build a better library! Let's see how to get started!**
|
**Do you have some free time to spend with programming?
|
||||||
|
Are you working on an Embedded GUI project with LittlevGL?
|
||||||
|
See how can you help to improve the graphics library!**
|
||||||
|
|
||||||
|
There are many ways to join the community. If you have some time to work with us I'm sure you will find something that fits you! You can:
|
||||||
There are many different possibilities to join the community. If you have some time to work with us I'm sure you will find something that fits you! You can:
|
- help others in the [Forum](https://forum.littlevgl.com/)
|
||||||
- answer other's questions
|
|
||||||
- report and/or fix bugs
|
|
||||||
- suggest and/or implement new features
|
|
||||||
- improve and/or translate the documentation
|
- improve and/or translate the documentation
|
||||||
- write a blog post about your experiences
|
- write a blog post about your experiences
|
||||||
|
- report and/or fix bugs
|
||||||
|
- suggest and/or implement new features
|
||||||
|
|
||||||
But first, start with the most Frequently Asked Questions.
|
But first, start with the most Frequently Asked Questions.
|
||||||
|
|
||||||
## FAQ about contributing
|
# FAQ about contributing
|
||||||
|
|
||||||
### What license does my code need to be under?
|
## Where can I write my question and remarks?
|
||||||
|
|
||||||
Any code added to LittlevGL must be licensed under [MIT](https://choosealicense.com/licenses/mit/) or another license that is fully compatible. Contributions under other licenses are highly likely to be rejected.
|
We use the [Forum](https://forum.littlevgl.com/) to ask and answer questions and [GitHub's issue tracker](https://github.com/littlevgl/lvgl/issues) for development-related discussion.
|
||||||
|
|
||||||
If you borrow code from another project, please make sure to add their copyright notice to your contribution.
|
But there are some simple rules:
|
||||||
|
|
||||||
### Where do I ask questions, give feedback, or report bugs?
|
|
||||||
|
|
||||||
We use the [forum](http://forum.littlevgl.com/) for questions, feature suggestions, and discussions.
|
|
||||||
|
|
||||||
We use [GitHub's issue tracker](https://github.com/littlevgl/lvgl/issues) to report bugs.
|
|
||||||
|
|
||||||
For both of these there are some rules:
|
|
||||||
- Be kind and friendly.
|
- Be kind and friendly.
|
||||||
- Speak about one thing in one issue.
|
- Speak about one thing in one issue/topic.
|
||||||
- Give feedback and close the issue if your question is answered.
|
- Give feedback and close the issue or mark the topic as solved if your question is answered.
|
||||||
- Explain exactly what you experience or expect. _"The button is not working"_ is not enough info to get help.
|
- Tell what you experience or expect. _"The button is not working"_ is not enough info to get help.
|
||||||
- For most issues you should send an absolute minimal code example in order to reproduce the issue. Ideally this should be easily usable in the PC simulator.
|
- If possible send an absolute minimal code example in order to reproduce the issue
|
||||||
- Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to format your post.
|
- Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to format your post.
|
||||||
- If you don't get any answer in a week write a comment like "Can somebody help?". Maybe your issue wasn't noticed.
|
|
||||||
|
|
||||||
### How can I send fixes and improvements?
|
## How can I send fixes and improvements?
|
||||||
Merging new code happens via Pull Requests. If you are still not familiar with the Pull Requests (PR for short) here is a quick guide about them:
|
|
||||||
|
Merging new code happens via Pull Requests. If you are still not familiar with the Pull Requests (PR for short) here is a quick guide:
|
||||||
1. **Fork** the [lvgl repository](https://github.com/littlevgl/lvgl). To do this click the "Fork" button in the top right corner. It will "copy" the `lvgl` repository to your GitHub account (`https://github.com/your_name?tab=repositories`)
|
1. **Fork** the [lvgl repository](https://github.com/littlevgl/lvgl). To do this click the "Fork" button in the top right corner. It will "copy" the `lvgl` repository to your GitHub account (`https://github.com/your_name?tab=repositories`)
|
||||||
2. **Clone** the forked repository and add your updates
|
2. **Clone** the forked repository and add your changes
|
||||||
3. **Create a PR** on the GitHub on the page of you `lvgl` repository(`https://github.com/your_name/lvgl`) by hitting the "New pull request" button
|
3. **Create a PR** on GitHub from the page of your `lvgl` repository (`https://github.com/your_name/lvgl`) by hitting the "New pull request" button
|
||||||
4. **Set the base branch**. It means where you want to merge your update. Bugfixes for the last release go to `master`, new features to the actual `dev-x.y` branch.
|
4. **Set the base branch**. It means where you want to merge your update. Fixes go to `master`, new features to the actual `dev-x.y` branch.
|
||||||
5. **Describe** what is in the update. An example code is welcome if applicable.
|
5. **Describe** what is in the update. An example code is welcome if applicable.
|
||||||
|
|
||||||
Some advice:
|
Some advice:
|
||||||
- If you are not sure about your fix or feature it's better to open an issue first, and discuss the details there.
|
- If you are not sure about your fix or feature it's better to open an issue first and discuss the details there.
|
||||||
- Maybe your fix or update won't be perfect at first. Don't be afraid, just improve it and push the new commits. The PR will be updated accordingly.
|
- Maybe your fix or update won't be perfect at first. Don't be afraid, just improve it and push the new commits. The PR will be updated accordingly.
|
||||||
- If your update needs some extra work it's okay to say: _"I'm busy now and I will improve it soon"_ or _"Sorry, I don't have time to improve it, I hope it helps in this form too"_. So it's better to say don't have time to continue then saying nothing.
|
- If your update needs some extra work it's okay to say: _"I'm busy now and I will improve it soon"_ or _"Sorry, I don't have time to improve it, I hope it helps in this form too"_.
|
||||||
- Please read and follow this [guide about the coding style](https://docs.littlevgl.com/#Coding-Style-Guide)
|
So it's better to say don't have time to continue than saying nothing.
|
||||||
|
- Please read and follow this [guide about the coding style](https://github.com/littlevgl/lvgl/blob/master/docs/CODING_STYLE.md)
|
||||||
|
|
||||||
|
|
||||||
### Where is the documentation?
|
## Where is the documentation?
|
||||||
|
|
||||||
You can read the documentation here: https://docs.littlevgl.com/
|
You can read the documentation here: <https://docs.littlevgl.com/>
|
||||||
You can edit the documentation here: https://github.com/littlevgl/doc
|
You can edit the documentation here: <https://github.com/littlevgl/doc>
|
||||||
|
|
||||||
### Where is the blog?
|
## Where is the blog?
|
||||||
|
|
||||||
You can read the blog here: https://blog.littlevgl.com/
|
You can read the blog here: <https://blog.littlevgl.com/>
|
||||||
You can edit the blog here: https://github.com/littlevgl/blog
|
You can edit the blog here: <https://github.com/littlevgl/blog>
|
||||||
|
|
||||||
|
# So how and where can you contribute?
|
||||||
|
|
||||||
|
## Help others in the Forum
|
||||||
|
|
||||||
|
It's a great way to contribute to the library if you already use it.
|
||||||
|
Just go to [https://forum.littlevgl.com/](https://forum.littlevgl.com/) a register (Google and GitHub login also works).
|
||||||
|
Log in, read the titles and if you are already familiar with a topic, don't be shy, and write your suggestion.
|
||||||
|
|
||||||
|
## Improving and/or translating the documentation
|
||||||
|
|
||||||
|
If you would like to contribute to LittlevGL the documentation is the best place to start.
|
||||||
|
|
||||||
|
### Fix typos, add missing parts
|
||||||
|
|
||||||
|
If you find a typo, an obscure sentence or something which is not explained well enough in the [English documentation](https://docs.littlevgl.com/en/html/index.html)
|
||||||
|
click the *"Edit on GitHub"* button in the top right corner and fix the issue by sending a Pull Request.
|
||||||
|
|
||||||
|
### Translate the documentation
|
||||||
|
|
||||||
|
If you have time and interest you can translate the documentation to your native language or any language you speak.
|
||||||
|
You can join others to work on an already existing language or you can start a new one.
|
||||||
|
|
||||||
|
To translate the documentation we use [Zanata](https://zanata.org) which is an online translation platform.
|
||||||
|
You will find the LittlevGL project here: [LittlevGL on Zanata](https://translate.zanata.org/iteration/view/littlevgl-docs/v6.0-doc1?dswid=3430)
|
||||||
|
|
||||||
|
To get started you need to:
|
||||||
|
- register at [Zanata](https://zanata.org) which is an online translation platform.
|
||||||
|
- comment to [this post](https://forum.littlevgl.com/t/translate-the-documentation/238?u=kisvegabor)
|
||||||
|
- tell your username at *Zanata* and your selected language(s) to get permission the edit the translations
|
||||||
|
|
||||||
|
Note that a translation will be added to the documentation only if at least the [Porting section](https://docs.littlevgl.com/en/html/porting/index.html) is translated.
|
||||||
|
|
||||||
|
|
||||||
## So how and where can I contribute?
|
## Writing a blog post about your experiences
|
||||||
|
|
||||||
### Answering other's questions
|
Have you ported LittlevGL to a new platform? Have you created a fancy GUI? Do you know a great trick?
|
||||||
|
You can share your knowledge on LittlevGL's blog! It's super easy to add your own post:
|
||||||
It's a great way to contribute to the library if you already use it. Just go the [issue tracker](https://github.com/littlevgl/lvgl/issues), read the titles and if you are already familiar with a topic, don't be shy, and write your suggestion.
|
|
||||||
|
|
||||||
### Reporting and/or fixing bugs
|
|
||||||
For simple bugfixes (typos, missing error handling, fixing a warning) is fine to send a Pull request directly. However, for more complex bugs it's better to open an issue first. In the issue, you should describe how to reproduce the bug and even add the minimal code snippet.
|
|
||||||
|
|
||||||
### Suggesting and/or implementing new features
|
|
||||||
If you have a good idea don't hesitate to share with us. It's even better if you have time to deal with its implementation. Don't be afraid if you still don't know LittlevGL well enough. We will help you to get started.
|
|
||||||
|
|
||||||
During the implementation don't forget the [Code style guide](https://docs.littlevgl.com/#Coding-Style-Guide).
|
|
||||||
|
|
||||||
### Improving and/or translating the documentation
|
|
||||||
|
|
||||||
The documentation of LittlevGL is written in Markdown and available [here](https://github.com/littlevgl/doc) for editing. If you find some parts of the documentation obscure or insufficient just search the related `.md` file, hit the edit icon and add your updates. This way a new Pull request will be generated automatically.
|
|
||||||
|
|
||||||
If you can devote more time to improve the documentation you can translate it!
|
|
||||||
1. Just copy the English `.md` files from the root folder to `locale/LANGUAGE_CODE` (language code is e.g. DE, FR, ES etc)
|
|
||||||
2. Append the language code the end of files (e.g. Welcome_fr.md)
|
|
||||||
3. Update the filenames in `_Sidebar.md`
|
|
||||||
4. Translate the page(s) you want
|
|
||||||
5. Create a Pull request
|
|
||||||
|
|
||||||
### Writing a blog post about your experiences
|
|
||||||
|
|
||||||
Have ported LittlevGL to a new platform? Have you created a fancy GUI? Do you know a great trick?
|
|
||||||
You can share your knowledge on LittelvGL's blog! It's super easy to add your own post:
|
|
||||||
- Fork and clone the [blog repository](https://github.com/littlevgl/blog)
|
- Fork and clone the [blog repository](https://github.com/littlevgl/blog)
|
||||||
- Add your post in Markdown to the `_posts` folder.
|
- Add your post in Markdown to the `_posts` folder.
|
||||||
- Store the images and other resources in a dedicated folder in `assets`
|
- Store the images and other resources in a dedicated folder in `assets`
|
||||||
@ -97,7 +98,14 @@ You can share your knowledge on LittelvGL's blog! It's super easy to add your ow
|
|||||||
|
|
||||||
The blog uses [Jekyll](https://jekyllrb.com/) to convert the `.md` files to a webpage. You can easily [run Jekyll offline](https://jekyllrb.com/docs/) to check your post before creating the Pull request
|
The blog uses [Jekyll](https://jekyllrb.com/) to convert the `.md` files to a webpage. You can easily [run Jekyll offline](https://jekyllrb.com/docs/) to check your post before creating the Pull request
|
||||||
|
|
||||||
## Summary
|
## Reporting and/or fixing bugs
|
||||||
|
For simple bugfixes (typos, missing error handling, fixing a warning) is fine to send a Pull request directly. However, for more complex bugs it's better to open an issue first. In the issue, you should describe how to reproduce the bug and even add the minimal code snippet.
|
||||||
|
|
||||||
I hope you have taken a liking to contribute to LittelvGL. A helpful and friendly community is waiting for you! :)
|
## Suggesting and/or implementing new features
|
||||||
|
If you have a good idea don't hesitate to share with us. It's even better if you have time to deal with its implementation. Don't be afraid if you still don't know LittlevGL well enough. We will help you to get started.
|
||||||
|
|
||||||
|
During the implementation don't forget the [Code style guide](https://github.com/littlevgl/lvgl/blob/master/docs/CODING_STYLE.md).
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
|
||||||
|
I hope you have taken a liking to contribute to LittlevGL. A helpful and friendly community is waiting for you! :)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user