summaryrefslogtreecommitdiffstats
path: root/.vim/snippets/arduino.snippets
blob: 4855a5f34b5d16bbda16d7fb5e6e181b27718cef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
####################
#   Main structs   #
####################
# loop()
snippet loop
	loop()
	{
	 	${1}
	}
# setup()
snippet setup
	setup()
	{
	 	${1}
	}
#####################
#    Digital I/O    #
#####################
# pinMode()
snippet pinM
	pinMode(${1:/* pin */}, ${2:OUTPUT});${3}
# digitalWrite()
snippet diW
	digitalWrite(${1:/* pin */}, ${2:HIGH});${3}
# digitalRead()
snippet diR
	digitalRead(${1:/* pin */});${3}		

#####################
#     Analog I/O    #
#####################
# analogReference()
snippet anRef
	analogReference(${1:/* ref */});${2}
# analogRead()
snippet anR
	analogRead(${1:/* pin */});${2}
# analogWrite()
snippet anW
	analogWrite(${1:/* pin */}, ${2:/* value */});${3}

#####################
#   Advanced I/O    #
#####################
# tone()
snippet tone
	tone(${1:/* pin */}, ${2:/* Frequency */});${3}
# noTone()
snippet noTone
	noTone(${1:/* pin */});${2}
# shiftOut()
snippet shiftO
	shiftOut(${1:/* data pin */}, ${2:/* clockPin */}, ${3:/* bit order */}, ${4:/* value */});${5}
# shiftIn()
snippet shiftI
	shiftIn(${1:/* data pin */}, ${2:/* clockPin */}, ${3:/* bit order */});${4}
# pulseIn()
snippet pulI
	pulseIn(${1:/* pin */}, ${2:/* value */});${3}

#######################
#       Timing        #
#######################
# delay()
snippet delay
	delay(${1});${2}
# delayMicroseconds()
snippet delayMS
	delayMicroseconds(${1});${2}

######################
#   Bits and Bytes   #
######################
# lowByte()
snippet lowB
	lowByte(${1});${2}
# highByte()
snippet highB
	highByte(${1});${2}
# bitRead()
snippet bR
	bitRead(${1:/* number */}, ${2:/* bit to read */});${3}
# bitWrite()
snippet bW
	bitWrite(${1:/* number */}, ${2:/* bit to write */}, ${3:/* value */});${4}
# bitSet()
snippet bS
	bitSet(${1:/* number */}, ${2:/* bit to set */});${3}
# bitClear()
snippet bC
	bitClear(${1:/* number */}, ${2:/* bit to clear */});${3}

#######################
# External Interrupts #
#######################
# attachInterrupt()
snippet aInter
	attachInterrupt(${1:/* interrupt */}, ${2:/* function */}, ${3:/* mode */});${4}
# detachInterrupt()
snippet dInter
	detachInterrupt(${1:/* interrupt */});${2}
	
#######################
#     C  snippets     #
#######################

# Note : This part comes from the classic snipMate installation
#	(c.snippets). I've just deleted the printf and fprintf snippets
# 	which are not useful with arduino.

# #include <...>
snippet inc
	#include <${1:stdio}.h>${2}
# #include "..."
snippet Inc
	#include "${1:`Filename("$1.h")`}"${2}
# #ifndef ... #define ... #endif
snippet Def
	#ifndef $1
	#define ${1:SYMBOL} ${2:value}
	#endif${3}
snippet def
	#define 
snippet ifdef
	#ifdef ${1:FOO}
		${2:#define }
	#endif
snippet #if
	#if ${1:FOO}
		${2}
	#endif
# Header Include-Guard
# (the randomizer code is taken directly from TextMate; it could probably be
# cleaner, I don't know how to do it in vim script)
snippet once
	#ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`}

	#define $1

	${2}

	#endif /* end of include guard: $1 */
# If Condition
snippet if
	if (${1:/* condition */}) {
		${2:/* code */}
	}
snippet el
	else {
		${1}
	}
# Tertiary conditional
snippet t
	${1:/* condition */} ? ${2:a} : ${3:b}
# Do While Loop
snippet do
	do {
		${2:/* code */}
	} while (${1:/* condition */});
# While Loop
snippet wh
	while (${1:/* condition */}) {
		${2:/* code */}
	}
# For Loop
snippet for
	for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
		${4:/* code */}
	}
# Custom For Loop
snippet forr
	for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
		${5:/* code */}
	}
# Function
snippet fun
	${1:void} ${2:function_name}(${3})
	{
		${4:/* code */}
	}
# Function Declaration
snippet fund
	${1:void} ${2:function_name}(${3});${4}
# Typedef
snippet td
	typedef ${1:int} ${2:MyCustomType};${3}
# Struct
snippet st
	struct ${1:`Filename('$1_t', 'name')`} {
		${2:/* data */}
	}${3: /* optional variable list */};${4}
# Typedef struct
snippet tds
	typedef struct ${2:_$1 }{
		${3:/* data */}
	} ${1:`Filename('$1_t', 'name')`};
# Typdef enum
snippet tde
	typedef enum {
		${1:/* data */}
	} ${2:foo};
snippet .
	[${1}]${2}
snippet un
	unsigned