arduino_ci 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +77 -1
  3. data/cpp/arduino/Arduino.cpp +17 -7
  4. data/cpp/arduino/Arduino.h +151 -5
  5. data/cpp/arduino/ArduinoDefines.h +90 -0
  6. data/cpp/arduino/AvrMath.h +18 -28
  7. data/cpp/arduino/Godmode.cpp +62 -0
  8. data/cpp/arduino/Godmode.h +74 -0
  9. data/cpp/arduino/HardwareSerial.h +81 -0
  10. data/cpp/arduino/Print.h +67 -0
  11. data/cpp/arduino/Stream.h +210 -0
  12. data/cpp/arduino/WCharacter.h +96 -0
  13. data/cpp/arduino/WString.h +164 -0
  14. data/cpp/arduino/binary.h +518 -0
  15. data/cpp/arduino/include/README.md +3 -0
  16. data/cpp/arduino/include/common.h +333 -0
  17. data/cpp/arduino/include/fuse.h +274 -0
  18. data/cpp/arduino/include/io.h +643 -0
  19. data/cpp/arduino/include/io1200.h +274 -0
  20. data/cpp/arduino/include/io2313.h +385 -0
  21. data/cpp/arduino/include/io2323.h +210 -0
  22. data/cpp/arduino/include/io2333.h +461 -0
  23. data/cpp/arduino/include/io2343.h +214 -0
  24. data/cpp/arduino/include/io43u32x.h +440 -0
  25. data/cpp/arduino/include/io43u35x.h +432 -0
  26. data/cpp/arduino/include/io4414.h +500 -0
  27. data/cpp/arduino/include/io4433.h +489 -0
  28. data/cpp/arduino/include/io4434.h +588 -0
  29. data/cpp/arduino/include/io76c711.h +499 -0
  30. data/cpp/arduino/include/io8515.h +501 -0
  31. data/cpp/arduino/include/io8534.h +217 -0
  32. data/cpp/arduino/include/io8535.h +589 -0
  33. data/cpp/arduino/include/io86r401.h +309 -0
  34. data/cpp/arduino/include/io90pwm1.h +1157 -0
  35. data/cpp/arduino/include/io90pwm161.h +918 -0
  36. data/cpp/arduino/include/io90pwm216.h +1225 -0
  37. data/cpp/arduino/include/io90pwm2b.h +1466 -0
  38. data/cpp/arduino/include/io90pwm316.h +1272 -0
  39. data/cpp/arduino/include/io90pwm3b.h +1466 -0
  40. data/cpp/arduino/include/io90pwm81.h +1036 -0
  41. data/cpp/arduino/include/io90pwmx.h +1415 -0
  42. data/cpp/arduino/include/io90scr100.h +1719 -0
  43. data/cpp/arduino/include/ioa5272.h +803 -0
  44. data/cpp/arduino/include/ioa5505.h +803 -0
  45. data/cpp/arduino/include/ioa5702m322.h +2591 -0
  46. data/cpp/arduino/include/ioa5782.h +1843 -0
  47. data/cpp/arduino/include/ioa5790.h +907 -0
  48. data/cpp/arduino/include/ioa5790n.h +922 -0
  49. data/cpp/arduino/include/ioa5791.h +923 -0
  50. data/cpp/arduino/include/ioa5795.h +756 -0
  51. data/cpp/arduino/include/ioa5831.h +1949 -0
  52. data/cpp/arduino/include/ioa6285.h +740 -0
  53. data/cpp/arduino/include/ioa6286.h +740 -0
  54. data/cpp/arduino/include/ioa6289.h +847 -0
  55. data/cpp/arduino/include/ioa6612c.h +795 -0
  56. data/cpp/arduino/include/ioa6613c.h +795 -0
  57. data/cpp/arduino/include/ioa6614q.h +798 -0
  58. data/cpp/arduino/include/ioa6616c.h +865 -0
  59. data/cpp/arduino/include/ioa6617c.h +865 -0
  60. data/cpp/arduino/include/ioa664251.h +857 -0
  61. data/cpp/arduino/include/ioa8210.h +1843 -0
  62. data/cpp/arduino/include/ioa8510.h +1949 -0
  63. data/cpp/arduino/include/ioat94k.h +565 -0
  64. data/cpp/arduino/include/iocan128.h +100 -0
  65. data/cpp/arduino/include/iocan32.h +100 -0
  66. data/cpp/arduino/include/iocan64.h +100 -0
  67. data/cpp/arduino/include/iocanxx.h +2020 -0
  68. data/cpp/arduino/include/iom103.h +735 -0
  69. data/cpp/arduino/include/iom128.h +1299 -0
  70. data/cpp/arduino/include/iom1280.h +101 -0
  71. data/cpp/arduino/include/iom1281.h +101 -0
  72. data/cpp/arduino/include/iom1284.h +1099 -0
  73. data/cpp/arduino/include/iom1284p.h +1219 -0
  74. data/cpp/arduino/include/iom1284rfr2.h +2690 -0
  75. data/cpp/arduino/include/iom128a.h +1070 -0
  76. data/cpp/arduino/include/iom128rfa1.h +5385 -0
  77. data/cpp/arduino/include/iom128rfr2.h +2706 -0
  78. data/cpp/arduino/include/iom16.h +676 -0
  79. data/cpp/arduino/include/iom161.h +726 -0
  80. data/cpp/arduino/include/iom162.h +1022 -0
  81. data/cpp/arduino/include/iom163.h +686 -0
  82. data/cpp/arduino/include/iom164.h +101 -0
  83. data/cpp/arduino/include/iom164a.h +34 -0
  84. data/cpp/arduino/include/iom164p.h +34 -0
  85. data/cpp/arduino/include/iom164pa.h +1016 -0
  86. data/cpp/arduino/include/iom165.h +887 -0
  87. data/cpp/arduino/include/iom165a.h +832 -0
  88. data/cpp/arduino/include/iom165p.h +889 -0
  89. data/cpp/arduino/include/iom165pa.h +948 -0
  90. data/cpp/arduino/include/iom168.h +97 -0
  91. data/cpp/arduino/include/iom168a.h +35 -0
  92. data/cpp/arduino/include/iom168p.h +942 -0
  93. data/cpp/arduino/include/iom168pa.h +843 -0
  94. data/cpp/arduino/include/iom168pb.h +899 -0
  95. data/cpp/arduino/include/iom169.h +1174 -0
  96. data/cpp/arduino/include/iom169a.h +44 -0
  97. data/cpp/arduino/include/iom169p.h +1097 -0
  98. data/cpp/arduino/include/iom169pa.h +1485 -0
  99. data/cpp/arduino/include/iom16a.h +923 -0
  100. data/cpp/arduino/include/iom16hva.h +80 -0
  101. data/cpp/arduino/include/iom16hva2.h +883 -0
  102. data/cpp/arduino/include/iom16hvb.h +1052 -0
  103. data/cpp/arduino/include/iom16hvbrevb.h +1052 -0
  104. data/cpp/arduino/include/iom16m1.h +1571 -0
  105. data/cpp/arduino/include/iom16u2.h +1000 -0
  106. data/cpp/arduino/include/iom16u4.h +1423 -0
  107. data/cpp/arduino/include/iom2560.h +101 -0
  108. data/cpp/arduino/include/iom2561.h +101 -0
  109. data/cpp/arduino/include/iom2564rfr2.h +2691 -0
  110. data/cpp/arduino/include/iom256rfr2.h +2707 -0
  111. data/cpp/arduino/include/iom3000.h +237 -0
  112. data/cpp/arduino/include/iom32.h +755 -0
  113. data/cpp/arduino/include/iom323.h +744 -0
  114. data/cpp/arduino/include/iom324a.h +1014 -0
  115. data/cpp/arduino/include/iom324p.h +1016 -0
  116. data/cpp/arduino/include/iom324pa.h +1372 -0
  117. data/cpp/arduino/include/iom325.h +886 -0
  118. data/cpp/arduino/include/iom3250.h +982 -0
  119. data/cpp/arduino/include/iom3250a.h +34 -0
  120. data/cpp/arduino/include/iom3250p.h +34 -0
  121. data/cpp/arduino/include/iom3250pa.h +1042 -0
  122. data/cpp/arduino/include/iom325a.h +34 -0
  123. data/cpp/arduino/include/iom325p.h +34 -0
  124. data/cpp/arduino/include/iom325pa.h +937 -0
  125. data/cpp/arduino/include/iom328.h +34 -0
  126. data/cpp/arduino/include/iom328p.h +948 -0
  127. data/cpp/arduino/include/iom329.h +1069 -0
  128. data/cpp/arduino/include/iom3290.h +1227 -0
  129. data/cpp/arduino/include/iom3290a.h +34 -0
  130. data/cpp/arduino/include/iom3290pa.h +1123 -0
  131. data/cpp/arduino/include/iom329a.h +34 -0
  132. data/cpp/arduino/include/iom329p.h +1164 -0
  133. data/cpp/arduino/include/iom329pa.h +34 -0
  134. data/cpp/arduino/include/iom32a.h +686 -0
  135. data/cpp/arduino/include/iom32c1.h +1320 -0
  136. data/cpp/arduino/include/iom32hvb.h +1052 -0
  137. data/cpp/arduino/include/iom32hvbrevb.h +953 -0
  138. data/cpp/arduino/include/iom32m1.h +1625 -0
  139. data/cpp/arduino/include/iom32u2.h +1000 -0
  140. data/cpp/arduino/include/iom32u4.h +1512 -0
  141. data/cpp/arduino/include/iom32u6.h +1431 -0
  142. data/cpp/arduino/include/iom406.h +783 -0
  143. data/cpp/arduino/include/iom48.h +93 -0
  144. data/cpp/arduino/include/iom48a.h +35 -0
  145. data/cpp/arduino/include/iom48p.h +936 -0
  146. data/cpp/arduino/include/iom48pa.h +839 -0
  147. data/cpp/arduino/include/iom48pb.h +890 -0
  148. data/cpp/arduino/include/iom64.h +1311 -0
  149. data/cpp/arduino/include/iom640.h +101 -0
  150. data/cpp/arduino/include/iom644.h +101 -0
  151. data/cpp/arduino/include/iom644a.h +34 -0
  152. data/cpp/arduino/include/iom644p.h +101 -0
  153. data/cpp/arduino/include/iom644pa.h +1387 -0
  154. data/cpp/arduino/include/iom644rfr2.h +2685 -0
  155. data/cpp/arduino/include/iom645.h +881 -0
  156. data/cpp/arduino/include/iom6450.h +978 -0
  157. data/cpp/arduino/include/iom6450a.h +34 -0
  158. data/cpp/arduino/include/iom6450p.h +34 -0
  159. data/cpp/arduino/include/iom645a.h +34 -0
  160. data/cpp/arduino/include/iom645p.h +34 -0
  161. data/cpp/arduino/include/iom649.h +1061 -0
  162. data/cpp/arduino/include/iom6490.h +1182 -0
  163. data/cpp/arduino/include/iom6490a.h +34 -0
  164. data/cpp/arduino/include/iom6490p.h +34 -0
  165. data/cpp/arduino/include/iom649a.h +34 -0
  166. data/cpp/arduino/include/iom649p.h +1490 -0
  167. data/cpp/arduino/include/iom64a.h +1084 -0
  168. data/cpp/arduino/include/iom64c1.h +1321 -0
  169. data/cpp/arduino/include/iom64hve.h +1034 -0
  170. data/cpp/arduino/include/iom64hve2.h +767 -0
  171. data/cpp/arduino/include/iom64m1.h +1572 -0
  172. data/cpp/arduino/include/iom64rfr2.h +2701 -0
  173. data/cpp/arduino/include/iom8.h +665 -0
  174. data/cpp/arduino/include/iom8515.h +687 -0
  175. data/cpp/arduino/include/iom8535.h +772 -0
  176. data/cpp/arduino/include/iom88.h +97 -0
  177. data/cpp/arduino/include/iom88a.h +35 -0
  178. data/cpp/arduino/include/iom88p.h +941 -0
  179. data/cpp/arduino/include/iom88pa.h +1185 -0
  180. data/cpp/arduino/include/iom88pb.h +899 -0
  181. data/cpp/arduino/include/iom8a.h +621 -0
  182. data/cpp/arduino/include/iom8hva.h +76 -0
  183. data/cpp/arduino/include/iom8u2.h +997 -0
  184. data/cpp/arduino/include/iomx8.h +808 -0
  185. data/cpp/arduino/include/iomxx0_1.h +1692 -0
  186. data/cpp/arduino/include/iomxx4.h +954 -0
  187. data/cpp/arduino/include/iomxxhva.h +550 -0
  188. data/cpp/arduino/include/iotn10.h +512 -0
  189. data/cpp/arduino/include/iotn11.h +255 -0
  190. data/cpp/arduino/include/iotn12.h +288 -0
  191. data/cpp/arduino/include/iotn13.h +395 -0
  192. data/cpp/arduino/include/iotn13a.h +394 -0
  193. data/cpp/arduino/include/iotn15.h +363 -0
  194. data/cpp/arduino/include/iotn1634.h +914 -0
  195. data/cpp/arduino/include/iotn167.h +883 -0
  196. data/cpp/arduino/include/iotn20.h +776 -0
  197. data/cpp/arduino/include/iotn22.h +221 -0
  198. data/cpp/arduino/include/iotn2313.h +702 -0
  199. data/cpp/arduino/include/iotn2313a.h +812 -0
  200. data/cpp/arduino/include/iotn24.h +94 -0
  201. data/cpp/arduino/include/iotn24a.h +846 -0
  202. data/cpp/arduino/include/iotn25.h +93 -0
  203. data/cpp/arduino/include/iotn26.h +422 -0
  204. data/cpp/arduino/include/iotn261.h +93 -0
  205. data/cpp/arduino/include/iotn261a.h +987 -0
  206. data/cpp/arduino/include/iotn28.h +297 -0
  207. data/cpp/arduino/include/iotn4.h +477 -0
  208. data/cpp/arduino/include/iotn40.h +767 -0
  209. data/cpp/arduino/include/iotn4313.h +813 -0
  210. data/cpp/arduino/include/iotn43u.h +604 -0
  211. data/cpp/arduino/include/iotn44.h +94 -0
  212. data/cpp/arduino/include/iotn441.h +903 -0
  213. data/cpp/arduino/include/iotn44a.h +844 -0
  214. data/cpp/arduino/include/iotn45.h +93 -0
  215. data/cpp/arduino/include/iotn461.h +94 -0
  216. data/cpp/arduino/include/iotn461a.h +987 -0
  217. data/cpp/arduino/include/iotn48.h +806 -0
  218. data/cpp/arduino/include/iotn5.h +512 -0
  219. data/cpp/arduino/include/iotn828.h +911 -0
  220. data/cpp/arduino/include/iotn84.h +94 -0
  221. data/cpp/arduino/include/iotn841.h +903 -0
  222. data/cpp/arduino/include/iotn84a.h +844 -0
  223. data/cpp/arduino/include/iotn85.h +93 -0
  224. data/cpp/arduino/include/iotn861.h +94 -0
  225. data/cpp/arduino/include/iotn861a.h +988 -0
  226. data/cpp/arduino/include/iotn87.h +859 -0
  227. data/cpp/arduino/include/iotn88.h +806 -0
  228. data/cpp/arduino/include/iotn9.h +477 -0
  229. data/cpp/arduino/include/iotnx4.h +482 -0
  230. data/cpp/arduino/include/iotnx5.h +442 -0
  231. data/cpp/arduino/include/iotnx61.h +541 -0
  232. data/cpp/arduino/include/iousb1286.h +101 -0
  233. data/cpp/arduino/include/iousb1287.h +101 -0
  234. data/cpp/arduino/include/iousb162.h +101 -0
  235. data/cpp/arduino/include/iousb646.h +102 -0
  236. data/cpp/arduino/include/iousb647.h +102 -0
  237. data/cpp/arduino/include/iousb82.h +95 -0
  238. data/cpp/arduino/include/iousbxx2.h +807 -0
  239. data/cpp/arduino/include/iousbxx6_7.h +1336 -0
  240. data/cpp/arduino/include/iox128a1.h +7236 -0
  241. data/cpp/arduino/include/iox128a1u.h +8305 -0
  242. data/cpp/arduino/include/iox128a3.h +6987 -0
  243. data/cpp/arduino/include/iox128a3u.h +7697 -0
  244. data/cpp/arduino/include/iox128a4u.h +7309 -0
  245. data/cpp/arduino/include/iox128b1.h +6872 -0
  246. data/cpp/arduino/include/iox128b3.h +6288 -0
  247. data/cpp/arduino/include/iox128c3.h +6264 -0
  248. data/cpp/arduino/include/iox128d3.h +5749 -0
  249. data/cpp/arduino/include/iox128d4.h +5562 -0
  250. data/cpp/arduino/include/iox16a4.h +6748 -0
  251. data/cpp/arduino/include/iox16a4u.h +7309 -0
  252. data/cpp/arduino/include/iox16c4.h +6078 -0
  253. data/cpp/arduino/include/iox16d4.h +5717 -0
  254. data/cpp/arduino/include/iox16e5.h +7699 -0
  255. data/cpp/arduino/include/iox192a3.h +6987 -0
  256. data/cpp/arduino/include/iox192a3u.h +7697 -0
  257. data/cpp/arduino/include/iox192c3.h +6264 -0
  258. data/cpp/arduino/include/iox192d3.h +5749 -0
  259. data/cpp/arduino/include/iox256a3.h +6987 -0
  260. data/cpp/arduino/include/iox256a3b.h +6983 -0
  261. data/cpp/arduino/include/iox256a3bu.h +7706 -0
  262. data/cpp/arduino/include/iox256a3u.h +7697 -0
  263. data/cpp/arduino/include/iox256c3.h +6264 -0
  264. data/cpp/arduino/include/iox256d3.h +5709 -0
  265. data/cpp/arduino/include/iox32a4.h +6747 -0
  266. data/cpp/arduino/include/iox32a4u.h +7309 -0
  267. data/cpp/arduino/include/iox32c3.h +6264 -0
  268. data/cpp/arduino/include/iox32c4.h +6078 -0
  269. data/cpp/arduino/include/iox32d3.h +5105 -0
  270. data/cpp/arduino/include/iox32d4.h +5685 -0
  271. data/cpp/arduino/include/iox32e5.h +7699 -0
  272. data/cpp/arduino/include/iox384c3.h +6849 -0
  273. data/cpp/arduino/include/iox384d3.h +5833 -0
  274. data/cpp/arduino/include/iox64a1.h +7236 -0
  275. data/cpp/arduino/include/iox64a1u.h +8305 -0
  276. data/cpp/arduino/include/iox64a3.h +6987 -0
  277. data/cpp/arduino/include/iox64a3u.h +7697 -0
  278. data/cpp/arduino/include/iox64a4u.h +7309 -0
  279. data/cpp/arduino/include/iox64b1.h +6454 -0
  280. data/cpp/arduino/include/iox64b3.h +6288 -0
  281. data/cpp/arduino/include/iox64c3.h +6264 -0
  282. data/cpp/arduino/include/iox64d3.h +5764 -0
  283. data/cpp/arduino/include/iox64d4.h +5555 -0
  284. data/cpp/arduino/include/iox8e5.h +7699 -0
  285. data/cpp/arduino/include/lock.h +239 -0
  286. data/cpp/arduino/include/portpins.h +549 -0
  287. data/cpp/arduino/include/version.h +90 -0
  288. data/cpp/arduino/include/xmega.h +71 -0
  289. data/cpp/unittest/Assertion.h +9 -4
  290. data/cpp/unittest/Compare.h +93 -0
  291. data/lib/arduino_ci/arduino_installation.rb +1 -1
  292. data/lib/arduino_ci/cpp_library.rb +4 -1
  293. data/lib/arduino_ci/version.rb +1 -1
  294. data/misc/default.yaml +7 -0
  295. metadata +285 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a38212612227d3adec2b30ed2303de39f506f12a31c06b2205ee1e703dccfbb6
4
- data.tar.gz: '033169c0b7531d90c089296cf3cd5b708995bb2e89db068813fa515ab0022b17'
3
+ metadata.gz: b23f7b008729652fa65a7e3ed99bd86e703d847ccb13b56d8483eb557242633c
4
+ data.tar.gz: bcb9729486d9326e45cb07b8f3c61311f9fd61290460548c0d6130eb7986a521
5
5
  SHA512:
6
- metadata.gz: 7def94f0fe1d00fc32ccac118766da3cc8272f69b19123eaca24b78592e171b99687cead667c7506acb4e62f7b0445f141ed6ca716053b9d78061d66b5fafd19
7
- data.tar.gz: af306adce91faa99e433a8006de72aa0a04a0d5f06e47187672f7d6db07254e6850c374684753e45708ce3e53cee7dd51dfffa17e63c4f58d15a20ee1e72513c
6
+ metadata.gz: 047e0f22cfc56a8802817ef49f5bac03c6037b755d4d36651661a7bba0a46590765867233f8c8e488cc414180dee89e385745e788036558a1eff04c1216f90cc
7
+ data.tar.gz: 962d9c99d23d4bb341663cc1a3b222f3272badbcffdf774c7efce449e930fbafc2be3a55d27e1edabc0d09066bf94575e5d19e1d147355fe60bcf7ede38b46e8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci)
2
2
  [![Build Status](https://travis-ci.org/ifreecarve/arduino_ci.svg)](https://travis-ci.org/ifreecarve/arduino_ci)
3
- [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/0.1.3)
3
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/0.1.4)
4
4
 
5
5
  # ArduinoCI Ruby gem (`arduino_ci`)
6
6
 
@@ -49,6 +49,82 @@ unittest_main()
49
49
  This test defines one `unittest` (a macro provided by `ArduionUnitTests.h`), called `your_test_name`, which makes some assertions on the target library. The `unittest_main()` is a macro for the `int main()` boilerplate required for unit testing.
50
50
 
51
51
 
52
+ ### Using `GODMODE`
53
+
54
+ Complete control of the Arduino environment is available in your unit tests through a construct called `GODMODE()`.
55
+
56
+ ```C++
57
+ unittest(example_godmode_stuff)
58
+ {
59
+ GodmodeState* state = GODMODE(); // get access to the state
60
+ state->reset(); // does a full reset of the state.
61
+ state->resetClock(); // - you can reset just the clock (to zero)
62
+ state->resetPins(); // - or just the pins
63
+ state->micros = 1; // manually set the clock such that micros() returns 1
64
+ state->digitalPin[4]; // stores the commanded state of digital pin 4
65
+ state->digitalPin[4] = HIGH; // digitalRead(4) will now return HIGH
66
+ state->analogPin[3]; // stores the commanded state of analog pin 3
67
+ state->analogPin[3] = 99; // analogRead(3) will now return 99
68
+ }
69
+ ```
70
+
71
+ A more complicated example: working with serial port IO. Let's say I have the following function:
72
+
73
+ ```C++
74
+ void smartLightswitchSerialHandler(int pin) {
75
+ if (Serial.available() > 0) {
76
+ int incomingByte = Serial.read();
77
+ int val = incomingByte == '0' ? LOW : HIGH;
78
+ Serial.print("Ack ");
79
+ digitalWrite(pin, val);
80
+ Serial.print(String(pin));
81
+ Serial.print(" ");
82
+ Serial.print((char)incomingByte);
83
+ }
84
+ }
85
+ ```
86
+
87
+ This function has 3 side effects: it drains the serial port's receive buffer, affects a pin, and puts data in the serial port's send buffer. Or, if the receive buffer is empty, it does nothing at all.
88
+
89
+ ```C++
90
+ unittest(does_nothing_if_no_data)
91
+ {
92
+ // configure initial state
93
+ GodmodeState* state = GODMODE();
94
+ int myPin = 3;
95
+ state->serialPort[0].dataIn = "";
96
+ state->serialPort[0].dataOut = "";
97
+ state->digitalPin[myPin] = LOW;
98
+
99
+ // execute action
100
+ smartLightswitchSerialHandler(myPin);
101
+
102
+ // assess final state
103
+ assertEqual(LOW, state->digitalPin[myPin]);
104
+ assertEqual("", state->serialPort[0].dataIn);
105
+ assertEqual("", state->serialPort[0].dataOut);
106
+ }
107
+
108
+ unittest(two_flips)
109
+ {
110
+ GodmodeState* state = GODMODE();
111
+ int myPin = 3;
112
+ state->serialPort[0].dataIn = "10junk";
113
+ state->serialPort[0].dataOut = "";
114
+ state->digitalPin[myPin] = LOW;
115
+ smartLightswitchSerialHandler(myPin);
116
+ assertEqual(HIGH, state->digitalPin[myPin]);
117
+ assertEqual("0junk", state->serialPort[0].dataIn);
118
+ assertEqual("Ack 3 1", state->serialPort[0].dataOut);
119
+
120
+ state->serialPort[0].dataOut = "";
121
+ smartLightswitchSerialHandler(myPin);
122
+ assertEqual(LOW, state->digitalPin[myPin]);
123
+ assertEqual("junk", state->serialPort[0].dataIn);
124
+ assertEqual("Ack 3 0", state->serialPort[0].dataOut);
125
+ }
126
+ ```
127
+
52
128
  ## More Documentation
53
129
 
54
130
  This software is in alpha. But [SampleProjects/DoSomething](SampleProjects/DoSomething) has a decent writeup and is a good bare-bones example of all the features.
@@ -1,13 +1,23 @@
1
1
  #include "Arduino.h"
2
+ #include "Godmode.h"
2
3
 
3
- struct unit_test_state godmode = {
4
- 0, // micros
5
- };
6
4
 
7
- unsigned long millis() {
8
- return godmode.micros / 1000;
5
+ void digitalWrite(unsigned char pin, unsigned char val) {
6
+ GodmodeState* godmode = GODMODE();
7
+ godmode->digitalPin[pin] = val;
9
8
  }
10
9
 
11
- unsigned long micros() {
12
- return godmode.micros;
10
+ int digitalRead(unsigned char pin) {
11
+ GodmodeState* godmode = GODMODE();
12
+ return godmode->digitalPin[pin];
13
+ }
14
+
15
+ int analogRead(unsigned char pin) {
16
+ GodmodeState* godmode = GODMODE();
17
+ return godmode->analogPin[pin];
18
+ }
19
+
20
+ void analogWrite(unsigned char pin, int val) {
21
+ GodmodeState* godmode = GODMODE();
22
+ godmode->analogPin[pin] = val;
13
23
  }
@@ -5,15 +5,161 @@ Mock Arduino.h library.
5
5
  Where possible, variable names from the Arduino library are used to avoid conflicts
6
6
 
7
7
  */
8
+ // Chars and strings
8
9
 
10
+ #include "ArduinoDefines.h"
9
11
 
12
+ #include "WCharacter.h"
13
+ #include "WString.h"
14
+ #include "Print.h"
15
+ #include "Stream.h"
16
+ #include "HardwareSerial.h"
10
17
 
18
+ typedef bool boolean;
19
+ typedef uint8_t byte;
20
+
21
+ #include "binary.h"
22
+
23
+ // Math and Trig
11
24
  #include "AvrMath.h"
12
25
 
13
- struct unit_test_state {
14
- unsigned long micros;
15
- };
26
+ #include "Godmode.h"
27
+
28
+
29
+ // Bits and Bytes
30
+ #define bit(b) (1UL << (b))
31
+ #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
32
+ #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
33
+ #define bitSet(value, bit) ((value) |= (1UL << (bit)))
34
+ #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
35
+ #define highByte(w) ((uint8_t) ((w) >> 8))
36
+ #define lowByte(w) ((uint8_t) ((w) & 0xff))
37
+
38
+ // Arduino defines this
39
+ #define _NOP() do { 0; } while (0)
40
+
41
+ // might as well use that NO-op macro for these, while unit testing
42
+ // you need interrupts? interrupt yourself
43
+ #define yield() _NOP()
44
+ #define interrupts() _NOP()
45
+ #define noInterrupts() _NOP()
46
+ #define attachInterrupt(...) _NOP()
47
+ #define detachInterrupt(...) _NOP()
48
+
49
+
50
+ // TODO: correctly establish this per-board!
51
+ #define F_CPU 1000000UL
52
+ #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
53
+ #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
54
+ #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
55
+
56
+ typedef unsigned int word;
57
+
58
+ #define bit(b) (1UL << (b))
59
+
60
+ // io pins
61
+ #define pinMode(...) _NOP()
62
+ #define analogReference(...) _NOP()
63
+
64
+ void digitalWrite(uint8_t, uint8_t);
65
+ int digitalRead(uint8_t);
66
+ int analogRead(uint8_t);
67
+ void analogWrite(uint8_t, int);
68
+ #define analogReadResolution(...) _NOP()
69
+ #define analogWriteResolution(...) _NOP()
70
+
71
+
72
+ /*
73
+ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
74
+ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
75
+
76
+ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
77
+ uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
78
+
79
+ */
80
+
81
+ // Get the bit location within the hardware port of the given virtual pin.
82
+ // This comes from the pins_*.c file for the active board configuration.
83
+
84
+ #define analogInPinToBit(P) (P)
85
+ #define digitalPinToInterrupt(P) (P)
86
+
87
+ /*
88
+ // On the ATmega1280, the addresses of some of the port registers are
89
+ // greater than 255, so we can't store them in uint8_t's.
90
+ extern const uint16_t PROGMEM port_to_mode_PGM[];
91
+ extern const uint16_t PROGMEM port_to_input_PGM[];
92
+ extern const uint16_t PROGMEM port_to_output_PGM[];
93
+
94
+ extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
95
+ // extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
96
+ extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
97
+ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
98
+
99
+ // Get the bit location within the hardware port of the given virtual pin.
100
+ // This comes from the pins_*.c file for the active board configuration.
101
+ //
102
+ // These perform slightly better as macros compared to inline functions
103
+ //
104
+ #define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
105
+ #define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
106
+ #define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
107
+ #define analogInPinToBit(P) (P)
108
+ #define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
109
+ #define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
110
+ #define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
111
+
112
+ */
113
+
114
+
115
+ /* TODO
116
+ #include "WString.h"
117
+ #include "HardwareSerial.h"
118
+ #include "USBAPI.h"
119
+ */
120
+
121
+ // uint16_t makeWord(uint16_t w);
122
+ // uint16_t makeWord(byte h, byte l);
123
+ inline unsigned int makeWord(unsigned int w) { return w; }
124
+ inline unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }
125
+
126
+ #define word(...) makeWord(__VA_ARGS__)
127
+
128
+ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
129
+ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
130
+
131
+ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
132
+ void noTone(uint8_t _pin);
133
+
134
+
135
+ // BIG TODO ON THIS ONE
136
+ // $ find . | grep pins_
137
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/circuitplay32u4/pins_arduino.h
138
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/eightanaloginputs/pins_arduino.h
139
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/ethernet/pins_arduino.h
140
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/gemma/pins_arduino.h
141
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/leonardo/pins_arduino.h
142
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/mega/pins_arduino.h
143
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/micro/pins_arduino.h
144
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/robot_control/pins_arduino.h
145
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/robot_motor/pins_arduino.h
146
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/standard/pins_arduino.h
147
+ // ./arduino-1.8.5/hardware/arduino/avr/variants/yun/pins_arduino.h
148
+ // #include "pins_arduino.h"
149
+
150
+
151
+
152
+ /*
153
+
154
+
155
+ // Communication
156
+ serial
157
+ stream
158
+
159
+ // USB
160
+ Keyboard
161
+ Mouse
162
+
163
+ */
16
164
 
17
- unsigned long millis();
18
165
 
19
- unsigned long micros();
@@ -0,0 +1,90 @@
1
+ #pragma once
2
+
3
+ #define HIGH 0x1
4
+ #define LOW 0x0
5
+
6
+ #define INPUT 0x0
7
+ #define OUTPUT 0x1
8
+ #define INPUT_PULLUP 0x2
9
+
10
+ #define PI 3.1415926535897932384626433832795
11
+ #define HALF_PI 1.5707963267948966192313216916398
12
+ #define TWO_PI 6.283185307179586476925286766559
13
+ #define DEG_TO_RAD 0.017453292519943295769236907684886
14
+ #define RAD_TO_DEG 57.295779513082320876798154814105
15
+ #define EULER 2.718281828459045235360287471352
16
+
17
+ #define SERIAL 0x0
18
+ #define DISPLAY 0x1
19
+
20
+ #define LSBFIRST 0
21
+ #define MSBFIRST 1
22
+
23
+ #define CHANGE 1
24
+ #define FALLING 2
25
+ #define RISING 3
26
+
27
+ #if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
28
+ #define DEFAULT 0
29
+ #define EXTERNAL 1
30
+ #define INTERNAL1V1 2
31
+ #define INTERNAL INTERNAL1V1
32
+ #elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
33
+ #define DEFAULT 0
34
+ #define EXTERNAL 4
35
+ #define INTERNAL1V1 8
36
+ #define INTERNAL INTERNAL1V1
37
+ #define INTERNAL2V56 9
38
+ #define INTERNAL2V56_EXTCAP 13
39
+ #else
40
+ #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
41
+ #define INTERNAL1V1 2
42
+ #define INTERNAL2V56 3
43
+ #else
44
+ #define INTERNAL 3
45
+ #endif
46
+ #define DEFAULT 1
47
+ #define EXTERNAL 0
48
+ #endif
49
+
50
+ #define NOT_A_PIN 0
51
+ #define NOT_A_PORT 0
52
+
53
+ #define NOT_AN_INTERRUPT -1
54
+
55
+ #ifdef ARDUINO_MAIN
56
+ #define PA 1
57
+ #define PB 2
58
+ #define PC 3
59
+ #define PD 4
60
+ #define PE 5
61
+ #define PF 6
62
+ #define PG 7
63
+ #define PH 8
64
+ #define PJ 10
65
+ #define PK 11
66
+ #define PL 12
67
+ #endif
68
+
69
+ #define NOT_ON_TIMER 0
70
+ #define TIMER0A 1
71
+ #define TIMER0B 2
72
+ #define TIMER1A 3
73
+ #define TIMER1B 4
74
+ #define TIMER1C 5
75
+ #define TIMER2 6
76
+ #define TIMER2A 7
77
+ #define TIMER2B 8
78
+
79
+ #define TIMER3A 9
80
+ #define TIMER3B 10
81
+ #define TIMER3C 11
82
+ #define TIMER4A 12
83
+ #define TIMER4B 13
84
+ #define TIMER4C 14
85
+ #define TIMER4D 15
86
+ #define TIMER5A 16
87
+ #define TIMER5B 17
88
+ #define TIMER5C 18
89
+
90
+ #include "include/io.h"
@@ -1,37 +1,27 @@
1
- //#include <math.h>
2
1
  #pragma once
2
+ #include <math.h>
3
3
 
4
- template <typename A> inline A abs(A x) { return x > 0 ? x : -x; }
4
+ #define constrain(x,l,h) ((x)<(l)?(l):((x)>(h)?(h):(x)))
5
+ #define map(x,inMin,inMax,outMin,outMax) (((x)-(inMin))*((outMax)-(outMin))/((inMax)-(inMin))+outMin)
5
6
 
6
- //max
7
- template <typename A> inline float max(A a, float b) { return a > b ? a : b; }
8
- template <typename A> inline float max(float a, A b) { return a > b ? a : b; }
9
- template <typename A, typename B> inline long max(A a, B b) { return a > b ? a : b; }
7
+ #ifdef abs
8
+ #undef abs
9
+ #endif
10
+ #define abs(x) ((x)>0?(x):-(x))
10
11
 
11
- //min
12
- template <typename A> inline float min(A a, float b) { return a < b ? a : b; }
13
- template <typename A> inline float min(float a, A b) { return a < b ? a : b; }
14
- template <typename A, typename B> inline long min(A a, B b) { return a < b ? a : b; }
12
+ #ifdef max
13
+ #undef max
14
+ #endif
15
+ #define max(a,b) ((a)>(b)?(a):(b))
15
16
 
16
- //constrain
17
- template <typename A> inline A constrain(A x, A a, A b) { return max(a, min(b, x)); }
17
+ #ifdef min
18
+ #undef min
19
+ #endif
20
+ #define min(a,b) ((a)<(b)?(a):(b))
18
21
 
19
- //map
20
- template <typename A> inline A map(A x, A in_min, A in_max, A out_min, A out_max)
21
- {
22
- return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
23
- }
22
+ #define sq(x) ((x)*(x))
24
23
 
25
- //sq
26
- template <typename A> A inline sq(A x) { return x * x; }
24
+ #define radians(deg) ((deg)*DEG_TO_RAD)
25
+ #define degrees(rad) ((rad)*RAD_TO_DEG)
27
26
 
28
- // ??? too lazy to sort these now
29
- //pow
30
- //sqrt
31
-
32
- // http://www.ganssle.com/approx.htm
33
- // http://www.ganssle.com/approx/sincos.cpp
34
- //cos
35
- //sin
36
- //tan
37
27