2022年11月28日 星期一

Arduino函式庫建立

1.建立三個檔案分別為.cpp .h .txt


  1-1.lib檔名.cpp 1-2. lib檔名.h  1-3. keywords.txt

2.cpp負責:函式庫的指令動作

 #if ARDUINO >= 100
       #include "Arduino.h"
 #else
   #include "WProgram.h"
 #endif
//----------------------------------------------

#include <lib檔名.h>

lib檔名::lib檔名(){}

 //****各項函式,例如果***/ 

void lib檔名::Speed(int Left,int Right) { Balbalbal... }


3.h負責:宣告各項函式的參數類型

 #ifndef SiXlib_h
 #define SiXlib_h

class SiX
 {

    public:

    //***這裡放各項函式參數設定,如: 

    void Speed(int, int);
    private:

    //***這裡放各項變數宣告如:

    double MOD;
};
 #endif

4.keywords.txt:這是用來的負責,設定指令高亮

  #######################################
 # Syntax Coloring Map For YourLibraryName
 #######################################

  

#######################################
 # Datatypes (KEYWORD1)
 #######################################

#######################################
 # Methods and Functions (KEYWORD2)
 #######################################

#######################################
# Constants (LITERAL1)
#######################################

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。