C语言 Arduino封库编程规范
*首字母小写, 下个单词首字母大写 *专有名词要大写
正确的写法
int sensorValue;
int SDCard,IIS,I2C;
错误的写法
int sensor_value;
float sensorvalue;
byte sensor_Value;
所有字母都要大写 正确的写法
#define MAX 1000
#define SENSOR_REG1 1
错误的写法:
#define Max 1000
#define sensorReg1 1
前面要加e,后面首字母大写
enum eDAY
{
eSunday=0,
eMonday,
eTuesday,
eWednesday,
eThursday,
eFriday,
eSaturday,
}
以DFRobot_开头,后面接ClassName,ClassName首字母要大些 正确的写法
class DFRobot_SIM7000;
class DFRobot_BME280;
class DFRobot_Lora;
错误的写法
class DFRobot_sim7000;
class Lora;
class DFRobotLora;
全部使用空格缩进,不要使用tab缩进(除了特殊用途,比如keywords makefile里),请用notepad++检查
在函数中,{}顶格写,例如
void func()
{
//do something
}
{写在语句后面,}写在新行,这样很方便调试。例如
if(conditon1){
//do something
}else if(conditon2){
//do something
}else{
//do something
}
case与switch对其,{跟在switch语句后面,例如
switch(value){
case x:
//do something
case y:
//do something
default:
//do something
}
前后需要留空格(此条根据具体情况,不强制)
for(int x = 0; x <= 10; x++)
采用doxygen注释规则描述参数
/*!
* @brief Set operational mode to VL53L0X
*
* @param mode Work mode settings
* Single : Single mode
* Continuous : Back-to-back mode
* @param precision Set measurement precision
* High:High precision(0.25mm)
* Low: Low precision(1mm)
* @return true if execute successfully, false otherwise.
*/
bool setMode(uint8_t mode, uint8_t precision);
/*!
* file 文件名(不能使用中文)
*
* 如何做这个实验,描述实验步骤(只需要下载程序就能肉眼观测到的简单小实验例如blink,这步可以不写)(不能使用中文)
* @n 实验现象是什么(不能使用中文)
*
* Copyright [DFRobot](http://www.dfrobot.com), 2016
* Copyright GNU Lesser General Public License
*
* version V1.0
* date 2017-10-9
*/