Advertisement
Guest User

Untitled

a guest
Aug 15th, 2015
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.99 KB | None | 0 0
  1. {{
  2.  
  3. ┌──────────────────────────────────────────┐
  4. │ DTMF_Dialer.spin │
  5. │ Author: tymkrs.com │
  6. │ See end of file for terms of use. │
  7. └──────────────────────────────────────────┘
  8.  
  9. Circuit diagram:
  10.  
  11. all caps are 10µf
  12. prop pin 0 ─┬────┬──┐
  13. prop pin 1 ──┘   ←speaker
  14. ┌────────┴──┘
  15. VSS
  16. }}
  17.  
  18. CON
  19.  
  20. _clkmode = xtal1 + pll16x
  21. _xinfreq = 5_000_000
  22.  
  23. Left_Audio_Pin = 1 'First audio pin
  24. Right_Audio_Pin = 0 'Second audio pin
  25.  
  26. OBJ
  27.  
  28. s : "Synth"
  29.  
  30. Pub Main
  31.  
  32. tone("6")
  33. tone("0")
  34. tone("1")
  35.  
  36. waitcnt(clkfreq + cnt)
  37. AllTones
  38.  
  39.  
  40. Pub AllTones
  41.  
  42. tone("`")
  43. tone("~")
  44.  
  45. tone("x")
  46. tone("x")
  47. tone("x")
  48. tone("x")
  49.  
  50. tone("y")
  51. tone("y")
  52. tone("y")
  53. tone("y")
  54.  
  55. tone("z")
  56. tone("z")
  57. tone("z")
  58. tone("z")
  59.  
  60. tone("a")
  61. tone("b")
  62. tone("c")
  63. tone("d")
  64. tone("e")
  65. tone("f")
  66. tone("g")
  67. tone("h")
  68. tone("i")
  69. tone("j")
  70. tone("k")
  71. tone("l")
  72. tone("m")
  73. tone("n")
  74. tone("o")
  75.  
  76. tone("1")
  77. tone("2")
  78. tone("3")
  79. tone("A")
  80.  
  81. tone("4")
  82. tone("5")
  83. tone("6")
  84. tone("B")
  85.  
  86. tone("7")
  87. tone("8")
  88. tone("9")
  89. tone("C")
  90.  
  91. tone("*")
  92. tone("0")
  93. tone("#")
  94. tone("D")
  95.  
  96. PUB tone(key) | Index
  97.  
  98. case key
  99.  
  100. 'Touch Tone DTMF
  101.  
  102. "1":
  103. s.synth("A", Left_Audio_Pin, 1209)
  104. s.synth("B", Right_Audio_Pin, 697)
  105. waitcnt(((clkfreq / 1000) * 200) + cnt)
  106. s.silence_a(Left_Audio_Pin)
  107. s.silence_b(Right_Audio_Pin)
  108. waitcnt(((clkfreq / 1000) * 200) + cnt)
  109. "2":
  110. s.synth("A", Left_Audio_Pin, 1336)
  111. s.synth("B", Right_Audio_Pin, 697)
  112. waitcnt(((clkfreq / 1000) * 200) + cnt)
  113. s.silence_a(Left_Audio_Pin)
  114. s.silence_b(Right_Audio_Pin)
  115. waitcnt(((clkfreq / 1000) * 200) + cnt)
  116. "3":
  117. s.synth("A", Left_Audio_Pin, 1477)
  118. s.synth("B", Right_Audio_Pin, 697)
  119. waitcnt(((clkfreq / 1000) * 200) + cnt)
  120. s.silence_a(Left_Audio_Pin)
  121. s.silence_b(Right_Audio_Pin)
  122. waitcnt(((clkfreq / 1000) * 200) + cnt)
  123. "4":
  124. s.synth("A", Left_Audio_Pin, 1209)
  125. s.synth("B", Right_Audio_Pin, 770)
  126. waitcnt(((clkfreq / 1000) * 200) + cnt)
  127. s.silence_a(Left_Audio_Pin)
  128. s.silence_b(Right_Audio_Pin)
  129. waitcnt(((clkfreq / 1000) * 200) + cnt)
  130. "5":
  131. s.synth("A", Left_Audio_Pin, 1336)
  132. s.synth("B", Right_Audio_Pin, 770)
  133. waitcnt(((clkfreq / 1000) * 200) + cnt)
  134. s.silence_a(Left_Audio_Pin)
  135. s.silence_b(Right_Audio_Pin)
  136. waitcnt(((clkfreq / 1000) * 200) + cnt)
  137. "6":
  138. s.synth("A", Left_Audio_Pin, 1477)
  139. s.synth("B", Right_Audio_Pin, 770)
  140. waitcnt(((clkfreq / 1000) * 200) + cnt)
  141. s.silence_a(Left_Audio_Pin)
  142. s.silence_b(Right_Audio_Pin)
  143. waitcnt(((clkfreq / 1000) * 200) + cnt)
  144. "7":
  145. s.synth("A", Left_Audio_Pin, 1209)
  146. s.synth("B", Right_Audio_Pin, 852)
  147. waitcnt(((clkfreq / 1000) * 200) + cnt)
  148. s.silence_a(Left_Audio_Pin)
  149. s.silence_b(Right_Audio_Pin)
  150. waitcnt(((clkfreq / 1000) * 200) + cnt)
  151. "8":
  152. s.synth("A", Left_Audio_Pin, 1336)
  153. s.synth("B", Right_Audio_Pin, 852)
  154. waitcnt(((clkfreq / 1000) * 200) + cnt)
  155. s.silence_a(Left_Audio_Pin)
  156. s.silence_b(Right_Audio_Pin)
  157. waitcnt(((clkfreq / 1000) * 200) + cnt)
  158. "9":
  159. s.synth("A", Left_Audio_Pin, 1477)
  160. s.synth("B", Right_Audio_Pin, 852)
  161. waitcnt(((clkfreq / 1000) * 200) + cnt)
  162. s.silence_a(Left_Audio_Pin)
  163. s.silence_b(Right_Audio_Pin)
  164. waitcnt(((clkfreq / 1000) * 200) + cnt)
  165. "0":
  166. s.synth("A", Left_Audio_Pin, 1336)
  167. s.synth("B", Right_Audio_Pin, 941)
  168. waitcnt(((clkfreq / 1000) * 200) + cnt)
  169. s.silence_a(Left_Audio_Pin)
  170. s.silence_b(Right_Audio_Pin)
  171. waitcnt(((clkfreq / 1000) * 200) + cnt)
  172. "*":
  173. s.synth("A", Left_Audio_Pin, 1209)
  174. s.synth("B", Right_Audio_Pin, 941)
  175. waitcnt(((clkfreq / 1000) * 200) + cnt)
  176. s.silence_a(Left_Audio_Pin)
  177. s.silence_b(Right_Audio_Pin)
  178. waitcnt(((clkfreq / 1000) * 200) + cnt)
  179. "#":
  180. s.synth("A", Left_Audio_Pin, 1477)
  181. s.synth("B", Right_Audio_Pin, 941)
  182. waitcnt(((clkfreq / 1000) * 200) + cnt)
  183. s.silence_a(Left_Audio_Pin)
  184. s.silence_b(Right_Audio_Pin)
  185. waitcnt(((clkfreq / 1000) * 200) + cnt)
  186. "A":
  187. s.synth("A", Left_Audio_Pin, 1633)
  188. s.synth("B", Right_Audio_Pin, 697)
  189. waitcnt(((clkfreq / 1000) * 200) + cnt)
  190. s.silence_a(Left_Audio_Pin)
  191. s.silence_b(Right_Audio_Pin)
  192. waitcnt(((clkfreq / 1000) * 200) + cnt)
  193. "B":
  194. s.synth("A", Left_Audio_Pin, 1633)
  195. s.synth("B", Right_Audio_Pin, 770)
  196. waitcnt(((clkfreq / 1000) * 200) + cnt)
  197. s.silence_a(Left_Audio_Pin)
  198. s.silence_b(Right_Audio_Pin)
  199. waitcnt(((clkfreq / 1000) * 200) + cnt)
  200. "C":
  201. s.synth("A", Left_Audio_Pin, 1633)
  202. s.synth("B", Right_Audio_Pin, 852)
  203. waitcnt(((clkfreq / 1000) * 200) + cnt)
  204. s.silence_a(Left_Audio_Pin)
  205. s.silence_b(Right_Audio_Pin)
  206. waitcnt(((clkfreq / 1000) * 200) + cnt)
  207. "D":
  208. s.synth("A", Left_Audio_Pin, 1633)
  209. s.synth("B", Right_Audio_Pin, 941)
  210. waitcnt(((clkfreq / 1000) * 200) + cnt)
  211. s.silence_a(Left_Audio_Pin)
  212. s.silence_b(Right_Audio_Pin)
  213. waitcnt(((clkfreq / 1000) * 200) + cnt)
  214.  
  215. 'Supervisory Signals (2600)
  216.  
  217. "`": '2600
  218. s.synth("A", Left_Audio_Pin, 2600)
  219. s.synth("B", Right_Audio_Pin, 2600)
  220. waitcnt(clkfreq + cnt)
  221. s.silence_a(Left_Audio_Pin)
  222. s.silence_b(Right_Audio_Pin)
  223. waitcnt(((clkfreq / 1000) * 200) + cnt)
  224. "~": 'International
  225. s.synth("A", Left_Audio_Pin, 2600)
  226. s.synth("B", Right_Audio_Pin, 2400)
  227. waitcnt(clkfreq + cnt)
  228. s.synth("A", Left_Audio_Pin, 2400)
  229. s.silence_b(Right_Audio_Pin)
  230. waitcnt(clkfreq + cnt)
  231. s.silence_a(Left_Audio_Pin)
  232. waitcnt(((clkfreq / 1000) * 200) + cnt)
  233.  
  234. 'MF / Blue Box
  235.  
  236. "a": '1
  237. s.synth("A", Left_Audio_Pin, 700)
  238. s.synth("B", Right_Audio_Pin, 900)
  239. waitcnt(((clkfreq / 1000) * 60) + cnt)
  240. s.silence_a(Left_Audio_Pin)
  241. s.silence_b(Right_Audio_Pin)
  242. waitcnt(((clkfreq / 1000) * 60) + cnt)
  243. "b": '2
  244. s.synth("A", Left_Audio_Pin, 700)
  245. s.synth("B", Right_Audio_Pin, 1100)
  246. waitcnt(((clkfreq / 1000) * 60) + cnt)
  247. s.silence_a(Left_Audio_Pin)
  248. s.silence_b(Right_Audio_Pin)
  249. waitcnt(((clkfreq / 1000) * 60) + cnt)
  250. "c": '3
  251. s.synth("A", Left_Audio_Pin, 900)
  252. s.synth("B", Right_Audio_Pin, 1100)
  253. waitcnt(((clkfreq / 1000) * 60) + cnt)
  254. s.silence_a(Left_Audio_Pin)
  255. s.silence_b(Right_Audio_Pin)
  256. waitcnt(((clkfreq / 1000) * 60) + cnt)
  257. "d": '4
  258. s.synth("A", Left_Audio_Pin, 700)
  259. s.synth("B", Right_Audio_Pin, 1300)
  260. waitcnt(((clkfreq / 1000) * 60) + cnt)
  261. s.silence_a(Left_Audio_Pin)
  262. s.silence_b(Right_Audio_Pin)
  263. waitcnt(((clkfreq / 1000) * 60) + cnt)
  264. "e": '5
  265. s.synth("A", Left_Audio_Pin, 900)
  266. s.synth("B", Right_Audio_Pin, 1300)
  267. waitcnt(((clkfreq / 1000) * 60) + cnt)
  268. s.silence_a(Left_Audio_Pin)
  269. s.silence_b(Right_Audio_Pin)
  270. waitcnt(((clkfreq / 1000) * 60) + cnt)
  271. "f": '6
  272. s.synth("A", Left_Audio_Pin, 1100)
  273. s.synth("B", Right_Audio_Pin, 1300)
  274. waitcnt(((clkfreq / 1000) * 60) + cnt)
  275. s.silence_a(Left_Audio_Pin)
  276. s.silence_b(Right_Audio_Pin)
  277. waitcnt(((clkfreq / 1000) * 60) + cnt)
  278. "g": '7
  279. s.synth("A", Left_Audio_Pin, 700)
  280. s.synth("B", Right_Audio_Pin, 1500)
  281. waitcnt(((clkfreq / 1000) * 60) + cnt)
  282. s.silence_a(Left_Audio_Pin)
  283. s.silence_b(Right_Audio_Pin)
  284. waitcnt(((clkfreq / 1000) * 60) + cnt)
  285. "h": '8
  286. s.synth("A", Left_Audio_Pin, 900)
  287. s.synth("B", Right_Audio_Pin, 1500)
  288. waitcnt(((clkfreq / 1000) * 60) + cnt)
  289. s.silence_a(Left_Audio_Pin)
  290. s.silence_b(Right_Audio_Pin)
  291. waitcnt(((clkfreq / 1000) * 60) + cnt)
  292. "i": '9
  293. s.synth("A", Left_Audio_Pin, 1100)
  294. s.synth("B", Right_Audio_Pin, 1500)
  295. waitcnt(((clkfreq / 1000) * 60) + cnt)
  296. s.silence_a(Left_Audio_Pin)
  297. s.silence_b(Right_Audio_Pin)
  298. waitcnt(((clkfreq / 1000) * 60) + cnt)
  299. "j": '0/10
  300. s.synth("A", Left_Audio_Pin, 1300)
  301. s.synth("B", Right_Audio_Pin, 1500)
  302. waitcnt(((clkfreq / 1000) * 60) + cnt)
  303. s.silence_a(Left_Audio_Pin)
  304. s.silence_b(Right_Audio_Pin)
  305. waitcnt(((clkfreq / 1000) * 60) + cnt)
  306. "k": '11/ST3
  307. s.synth("A", Left_Audio_Pin, 700)
  308. s.synth("B", Right_Audio_Pin, 1700)
  309. waitcnt(((clkfreq / 1000) * 60) + cnt)
  310. s.silence_a(Left_Audio_Pin)
  311. s.silence_b(Right_Audio_Pin)
  312. waitcnt(((clkfreq / 1000) * 60) + cnt)
  313. "l": '12/ST2
  314. s.synth("A", Left_Audio_Pin, 900)
  315. s.synth("B", Right_Audio_Pin, 1700)
  316. waitcnt(((clkfreq / 1000) * 60) + cnt)
  317. s.silence_a(Left_Audio_Pin)
  318. s.silence_b(Right_Audio_Pin)
  319. waitcnt(((clkfreq / 1000) * 60) + cnt)
  320. "m": 'KP
  321. s.synth("A", Left_Audio_Pin, 1100)
  322. s.synth("B", Right_Audio_Pin, 1700)
  323. waitcnt(((clkfreq / 1000) * 100) + cnt)
  324. s.silence_a(Left_Audio_Pin)
  325. s.silence_b(Right_Audio_Pin)
  326. waitcnt(((clkfreq / 1000) * 100) + cnt)
  327. "n": 'KP2
  328. s.synth("A", Left_Audio_Pin, 1300)
  329. s.synth("B", Right_Audio_Pin, 1700)
  330. waitcnt(((clkfreq / 1000) * 100) + cnt)
  331. s.silence_a(Left_Audio_Pin)
  332. s.silence_b(Right_Audio_Pin)
  333. waitcnt(((clkfreq / 1000) * 100) + cnt)
  334. "o": 'ST
  335. s.synth("A", Left_Audio_Pin, 1500)
  336. s.synth("B", Right_Audio_Pin, 1700)
  337. waitcnt(((clkfreq / 1000) * 60) + cnt)
  338. s.silence_a(Left_Audio_Pin)
  339. s.silence_b(Right_Audio_Pin)
  340. waitcnt(((clkfreq / 1000) * 60) + cnt)
  341.  
  342. 'Automated Coin Toll Service tones / Red Box
  343.  
  344. "x": 'Nickel
  345. s.synth("A", Left_Audio_Pin, 1700)
  346. s.synth("B", Right_Audio_Pin, 2200)
  347. waitcnt(((clkfreq / 1000) * 66) + cnt)
  348. s.silence_a(Left_Audio_Pin)
  349. s.silence_b(Right_Audio_Pin)
  350. waitcnt(((clkfreq / 1000) * 66) + cnt)
  351. "y": 'Dime
  352. repeat Index from 0 to 1
  353. s.synth("A", Left_Audio_Pin, 1700)
  354. s.synth("B", Right_Audio_Pin, 2200)
  355. waitcnt(((clkfreq / 1000) * 66) + cnt)
  356. s.silence_a(Left_Audio_Pin)
  357. s.silence_b(Right_Audio_Pin)
  358. waitcnt(((clkfreq / 1000) * 66) + cnt)
  359. "z": 'Quarter
  360. repeat Index from 0 to 4
  361. s.synth("A", Left_Audio_Pin, 1700)
  362. s.synth("B", Right_Audio_Pin, 2200)
  363. waitcnt(((clkfreq / 1000) * 33) + cnt)
  364. s.silence_a(Left_Audio_Pin)
  365. s.silence_b(Right_Audio_Pin)
  366. waitcnt(((clkfreq / 1000) * 33) + cnt)
  367.  
  368. DAT
  369.  
  370. {{
  371. ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  372. │ TERMS OF USE: MIT License │
  373. ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  374. │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │
  375. │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │
  376. │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│
  377. │is furnished to do so, subject to the following conditions: │
  378. │ │
  379. │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│
  380. │ │
  381. │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │
  382. │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │
  383. │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
  384. │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
  385. └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
  386. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement