daily pastebin goal
88%
SHARE
TWEET

Untitled

a guest Mar 7th, 2018 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* OpenGarage Firmware
  2.  *
  3.  * OpenGarage macro defines and hardware pin assignments
  4.  * Mar 2016 @ OpenGarage.io
  5.  *
  6.  * This file is part of the OpenGarage library
  7.  *
  8.  * This program is free software: you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation, either version 3 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program.  If not, see
  20.  * <http://www.gnu.org/licenses/>.
  21.  */
  22.  
  23. #ifndef _DEFINES_H
  24. #define _DEFINES_H
  25.  
  26. /** Firmware version, hardware version, and maximal values */
  27. #define OG_FWV    107   // Firmware version: 107 means 1.0.7
  28.  
  29. /** GPIO pins */
  30. #define PIN_RELAY   5 //D1=5 on nodemcu.
  31. #define PIN_BUTTON  6
  32. #define PIN_TRIG   12 //D6 on nodemcu
  33. #define PIN_ECHO   14 //D5 on nodemcu
  34. #define PIN_LED     5
  35. #define PIN_RESET  16
  36. #define PIN_BUZZER 13
  37. #define PIN_SWITCH  4  //D2=4 on nodemcu.
  38. #define DHTPIN      0 //D3=0 on nodemcu.
  39. #define DHTTYPE    DHT22
  40.  
  41. // Default device name
  42. #define DEFAULT_NAME    "OpenGarage"
  43. // Default device key
  44. #define DEFAULT_DKEY    "o"
  45. // Config file name
  46. #define CONFIG_FNAME    "/config.dat"
  47. // Log file name
  48. #define LOG_FNAME       "/log.dat"
  49.  
  50. #define OG_MNT_CEILING  0x00
  51. #define OG_MNT_SIDE     0x01
  52. #define OG_SWITCH_LOW   0x02
  53. #define OG_SWITCH_HIGH  0x03
  54.  
  55. #define OG_ALM_NONE     0x00
  56. #define OG_ALM_5        0x01
  57. #define OG_ALM_10       0x02
  58.  
  59. #define OG_MOD_AP       0xA9
  60. #define OG_MOD_STA      0x2A
  61.  
  62. #define OG_AUTO_NONE    0x00
  63. #define OG_AUTO_NOTIFY  0x01
  64. #define OG_AUTO_CLOSE   0x02
  65.  
  66. //Automation Option C - Notify settings
  67. #define OG_NOTIFY_NONE  0x00
  68. #define OG_NOTIFY_DO    0x01
  69. #define OG_NOTIFY_DC    0x02
  70. #define OG_NOTIFY_VL    0x04
  71. #define OG_NOTIFY_VA    0x08
  72.  
  73. #define OG_STATE_INITIAL        0
  74. #define OG_STATE_CONNECTING     1
  75. #define OG_STATE_CONNECTED      2
  76. #define OG_STATE_TRY_CONNECT    3
  77. #define OG_STATE_WAIT_RESTART   4
  78. #define OG_STATE_RESET          9
  79.  
  80. #define BLYNK_PIN_LED   V0
  81. #define BLYNK_PIN_RELAY V1
  82. #define BLYNK_PIN_LCD   V2
  83. #define BLYNK_PIN_DIST  V3
  84. #define BLYNK_PIN_IP    V5
  85. //#define BLYNK_PIN_HUM  V10
  86. //#define BLYNK_PIN_TEMP V11                           
  87.  
  88. #define MAX_LOG_RECORDS    100
  89. #define ALARM_FREQ         1000
  90. // door status histogram
  91. // number of values (maximum is 8)
  92. #define DOOR_STATUS_HIST_K  4
  93. #define DOOR_STATUS_REMAIN_CLOSED 0
  94. #define DOOR_STATUS_REMAIN_OPEN   1
  95. #define DOOR_STATUS_JUST_OPENED   2
  96. #define DOOR_STATUS_JUST_CLOSED   3
  97. #define DOOR_STATUS_MIXED         4
  98.  
  99. typedef enum {
  100.   OPTION_FWV = 0, // firmware version
  101.   OPTION_MNT,     // mount type
  102.   OPTION_DTH,     // distance threshold door
  103.   OPTION_VTH,     // distance threshold vehicle detection
  104.   OPTION_RIV,     // read interval
  105.   OPTION_ALM,     // alarm mode
  106.   OPTION_HTP,     // http port
  107.   OPTION_CDT,     // click delay time
  108.   OPTION_MOD,     // mode
  109.   OPTION_ATI,     // automation interval (in minutes)
  110.   OPTION_ATO,     // automation options
  111.   OPTION_ATIB,    // automation interval B (in hours)
  112.   OPTION_ATOB,    // automation options B
  113.   OPTION_NOTO,    // notification options
  114.   OPTION_USI,     // use static IP
  115.   OPTION_SSID,    // wifi ssid
  116.   OPTION_PASS,    // wifi password
  117.   OPTION_AUTH,    // Blynk authentication token
  118.   OPTION_DKEY,    // device key
  119.   OPTION_NAME,    // device name
  120.   OPTION_IFTT,    // IFTTT token
  121.   OPTION_MQTT,    // MQTT IP
  122.   OPTION_DVIP,    // device IP
  123.   OPTION_GWIP,    // gateway IP
  124.   OPTION_SUBN,    // subnet
  125.   NUM_OPTIONS     // number of options
  126. } OG_OPTION_enum;
  127.  
  128. // if button is pressed for 1 seconds, report IP
  129. #define BUTTON_REPORTIP_TIMEOUT 800
  130. // if button is pressed for at least 5 seconds, reset to AP mode
  131. #define BUTTON_APRESET_TIMEOUT 4500
  132. // if button is pressed for at least 10 seconds, factory reset
  133. #define BUTTON_FACRESET_TIMEOUT  9500
  134.  
  135. #define LED_FAST_BLINK 100
  136. #define LED_SLOW_BLINK 500
  137.  
  138. #define TIME_SYNC_TIMEOUT  1800 //Issues connecting to MQTT can throw off the time function, sync more often
  139.  
  140. /** Serial debug functions */
  141. //#define SERIAL_DEBUG
  142. #if defined(SERIAL_DEBUG)
  143.  
  144.   #define DEBUG_BEGIN(x)   { Serial.begin(x); }
  145.   #define DEBUG_PRINT(x)   Serial.print(x)
  146.   #define DEBUG_PRINTLN(x) Serial.println(x)
  147.  
  148. #else
  149.  
  150.   #define DEBUG_BEGIN(x)   { Serial.begin(x); }
  151.   #define DEBUG_PRINT(x)   {}
  152.   #define DEBUG_PRINTLN(x) {}
  153.  
  154. #endif
  155.  
  156. typedef unsigned char byte;
  157. typedef unsigned long ulong;
  158. typedef unsigned int  uint;
  159.  
  160. #endif  // _DEFINES_H
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top