Giter Club home page Giter Club logo

programming's Introduction

编程规范

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-else

{写在语句后面,}写在新行,这样很方便调试。例如

if(conditon1){
  //do something
}else if(conditon2){
  //do something
}else{
  //do something
}

switch-case

case与switch对其,{跟在switch语句后面,例如

switch(value){
case x:
  //do something
case y:
  //do something
default:
  //do something
}

运算符

前后需要留空格(此条根据具体情况,不强制)

for(int x = 0; x <= 10; x++)

Readme中多个参数函数写法

采用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);

ino文件头部写法

 /*!
  * file 文件名(不能使用中文)
  *
  * 如何做这个实验,描述实验步骤(只需要下载程序就能肉眼观测到的简单小实验例如blink,这步可以不写)(不能使用中文)
  * @n 实验现象是什么(不能使用中文)
  *
  * Copyright   [DFRobot](http://www.dfrobot.com), 2016
  * Copyright   GNU Lesser General Public License
  *
  * version  V1.0
  * date  2017-10-9
  */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.