acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
CONTRIBUTING.md (4759B)
1 # Contributing to RadioLib 2 3 First of all, thank you very much for taking the time to contribute! All feedback and ideas are greatly appreciated. 4 To keep this library organized, please follow these rules. 5 6 ## Issues 7 8 The following rules guide submission of new issues. These rules are in place mainly so that the issue author can get help as quickly as possible. 9 10 1. **Questions are welcome, spam is not.** 11 Any issues without description will be considered spam and as such will be **CLOSED** and **LOCKED** immediately! 12 2. **This repository has issue templates.** 13 To report bugs or suggest new features, use the provided issue templates. Use the default issue only if the templates do not fit your issue type. 14 3. **Be as clear as possible when creating issues.** 15 Issues with generic titles (e.g. "not working", "lora", etc.) will be **CLOSED** until the title is fixed, since the title is supposed to categorize the issue. The same applies for issues with very little information and extensive grammatical or formatting errors that make it difficult to find out what is the actual issue. 16 4. **Issues deserve some attention too.** 17 Issues that are left for 2 weeks without response by the original author when asked for further information will be closed due to inactivity. This is to keep track of important issues, the author is encouraged to reopen the issue at a later date. 18 19 ## Code style guidelines 20 21 I like pretty code! Or at least, I like *consistent* code style. When creating pull requests, please follow these style guidelines, they're in place to keep high code readability. 22 23 1. **Bracket style** 24 This library uses the following style of bracket indentation (1TBS, or "javascript" style): 25 26 ```c++ 27 if (foo) { 28 bar(); 29 } else { 30 baz(); 31 } 32 ``` 33 34 2. **Tabs** 35 Use 2 space characters for tabs. 36 37 3. **Single-line comments** 38 Comments can be very useful - and they can become the bane of readability. Every single-line comment should start at new line, have one space between comment delimiter `//` and the start of the comment itself. The comment should also start with a lower-case letter. 39 40 ```c++ 41 // this function does something 42 foo("bar"); 43 44 // here it does something else 45 foo(12345); 46 ``` 47 48 4. **Split code into blocks** 49 It is very easy to write code that machine can read. It is much harder to write one that humans can read. That's why it's a great idea to split code into blocks - even if the block is just a single line! 50 51 ```c++ 52 // build a temporary buffer (first block) 53 uint8_t* data = new uint8_t[len + 1]; 54 if(!data) { 55 return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED); 56 } 57 58 // read the received data (second block) 59 state = readData(data, len); 60 61 // add null terminator (third block) 62 data[len] = 0; 63 ``` 64 65 5. **Doxygen** 66 If you're adding a new method, make sure to add appropriate Doxygen comments, so that the documentation is always complete. 67 68 6. **Keywords** 69 This is an Arduino library, so it needs to comply with the Arduino library specification. To add a new keyword to the Arduino IDE syntax highlighting, add it to the keywords.txt file. **Use true tabs in keywords.txt! No spaces there!** 70 71 7. **Dynamic memory** 72 Sometimes, RadioLib might be used in critical applications where dynamic memory allocation using `new` or `malloc` might cause issues. For such cases, RadioLib provides the option to compile using only static arrays. This means that every dynamically allocated array must have a sufficiently large static counterpart. Naturally, all dynamically allocated memory must be properly de-allocated using `delete` or `free`. 73 74 ```c++ 75 // build a temporary buffer 76 #if defined(RADIOLIB_STATIC_ONLY) 77 uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1]; 78 #else 79 uint8_t* data = new uint8_t[length + 1]; 80 if(!data) { 81 return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED); 82 } 83 #endif 84 85 // read the received data 86 readData(data, length); 87 88 // deallocate temporary buffer 89 #if !defined(RADIOLIB_STATIC_ONLY) 90 delete[] data; 91 #endif 92 ``` 93 94 8. **God Mode** 95 During development, it can be useful to have access to the low level drivers, such as the SPI commands. These are incredibly powerful, since they will basically let user do anything he wants with the module, outside of the normal level of sanity checks. As such, they are normally protected using C++ access modifiers `private` or `protected`. God mode disables this protection, and so any newly implemented `class` must contain the appropriate macro check: 96 97 ```c++ 98 class Module { 99 void publicMethod(); 100 101 #if defined(RADIOLIB_GODMODE) 102 private: 103 #endif 104 105 void privateMethod(); 106 }; 107 ``` 108 109 9. **No Arduino Strings** 110 Arduino `String` class should never be used internally in the library. The only allowed occurence of Arduino `String` is in public API methods, and only at the top-most layer.