Permalink
Browse files

uploading varius code

some of my code and some is not my code, waht is not mine should have
info in comment
  • Loading branch information...
1 parent 20b5089 commit 5fc066bd46907b850a5de822a8dbb99e6a795f19 lestofante committed Aug 22, 2012
Showing with 38,487 additions and 13 deletions.
  1. +51 −0 AsincWritePPMChannel/AsincWritePPMChannel.pde
  2. +220 −0 BMP085/BMP085.pde
  3. +232 −0 ClassPPM/ClassPPM.pde
  4. +81 −0 ClassPPM/InputPin.cpp
  5. +22 −0 ClassPPM/InputPin.cpp~
  6. +15 −0 ClassPPM/InputPin.h
  7. +16 −0 ClassPPM/InputPin.h~
  8. +53 −0 ControlloMotoriSeriale/ControlloMotoriSeriale.pde
  9. +74 −0 ControlloMotoriSeriale/ReadSerial.cpp
  10. +22 −0 ControlloMotoriSeriale/ReadSerial.h
  11. +37 −0 DCMtest1/DCMtest1.pde
  12. +102 −0 DCMtest1/IMU.cpp
  13. +37 −0 DCMtest1/IMU.h
  14. +38 −0 DS18B20/DS18B20.ino
  15. +738 −0 DS18B20/DallasTemperature.cpp
  16. +242 −0 DS18B20/DallasTemperature.h
  17. +527 −0 DS18B20/OneWire.cpp
  18. +192 −0 DS18B20/OneWire.h
  19. +47 −0 DistanzaSeriale/DistanzaSeriale.pde
  20. +127 −0 FreqCounter/FreqCounter.cpp
  21. +127 −0 FreqCounter/FreqCounter.cpp~
  22. +36 −0 FreqCounter/FreqCounter.h
  23. +45 −0 FreqCounter/FreqCounter.pde
  24. +166 −0 GPS_test/GPS_test.ino
  25. +251 −0 HMC5883L/HMC5883L.ino
  26. +73 −0 HeartSensor/HeartSensor.pde
  27. +22 −0 HeartSensor2/HeartSensor2.pde
  28. +14 −0 IMU9DOFtest/IMU9DOFtest.ino
  29. +8 −0 IMU9DOFtest/ITG3200.cpp
  30. +16 −0 IMU9DOFtest/ITG3200.h
  31. +82 −0 ITG3200/ITG3200.ino
  32. +132 −0 ITG3200test/ITG3200.cpp
  33. +90 −0 ITG3200test/ITG3200.h
  34. +11 −0 ITG3200test/ITG3200test.pde
  35. +112 −0 ITG3200test/twi.c
  36. +14 −0 ITG3200test/twi.h
  37. +12 −0 LedDistanzaAnalogica/LedDistanzaAnalogica.pde
  38. +84 −0 LedRadar/LedRadar.pde
  39. +34 −0 Lettore/Lettore.pde
  40. +148 −0 MotionPlusTest1/MotionPlusTest1.pde
  41. +27 −0 NumeroLettureAlSecondoDigitali/NumeroLettureAlSecondoDigitali.pde
  42. +312 −0 NunAndMotionTest1/NunAndMotionTest1.pde
  43. +217 −0 NunAndMotionTest2/NunAndMotionTest2.pde
  44. +309 −0 NunAndMotionTest3/NunAndMotionTest3.pde
  45. +35 −0 NunAndMotionTest4/NunAndMotionTest4.pde
  46. +408 −0 NunAndMotionTest4/WMPandNun.cpp
  47. +25 −0 NunAndMotionTest4/WMPandNun.h
  48. +173 −0 QuadricotteroCompleto/LogicaMotori/EngineMindPID.cpp
  49. +173 −0 QuadricotteroCompleto/LogicaMotori/EngineMindPID.cpp~
  50. +29 −0 QuadricotteroCompleto/LogicaMotori/EngineMindPID.h
  51. +26 −0 QuadricotteroCompleto/LogicaMotori/EngineMindPID.h~
  52. +60 −0 QuadricotteroCompleto/LogicaMotori/PID/PID.cpp
  53. +60 −0 QuadricotteroCompleto/LogicaMotori/PID/PID.cpp~
  54. +19 −0 QuadricotteroCompleto/LogicaMotori/PID/PID.h
  55. +397 −0 QuadricotteroCompleto/QuadricotteroCompleto.pde
  56. +101 −0 QuadricotteroCompleto/RX/InputPin.cpp
  57. +101 −0 QuadricotteroCompleto/RX/InputPin.cpp~
  58. +17 −0 QuadricotteroCompleto/RX/InputPin.h
  59. +11 −0 QuadricotteroCompleto/Utils/Utils.cpp
  60. +11 −0 QuadricotteroCompleto/Utils/Utils.cpp~
  61. +15 −0 QuadricotteroCompleto/Utils/Utils.h
  62. +15 −0 QuadricotteroCompleto/Utils/Utils.h~
  63. +103 −0 QuadricotteroCompleto/stabilization/IMU/IMULast.cpp
  64. +103 −0 QuadricotteroCompleto/stabilization/IMU/IMULast.cpp~
  65. +15 −0 QuadricotteroCompleto/stabilization/IMU/IMULast.h
  66. +15 −0 QuadricotteroCompleto/stabilization/IMU/IMULast.h~
  67. +138 −0 QuadricotteroCompleto/stabilization/IMU/sensor/Fastwire.cpp
  68. +41 −0 QuadricotteroCompleto/stabilization/IMU/sensor/Fastwire.h
  69. +293 −0 QuadricotteroCompleto/stabilization/IMU/sensor/WMP.cpp
  70. +293 −0 QuadricotteroCompleto/stabilization/IMU/sensor/WMP.cpp~
  71. +26 −0 QuadricotteroCompleto/stabilization/IMU/sensor/WMP.h
  72. +26 −0 QuadricotteroCompleto/stabilization/IMU/sensor/WMP.h~
  73. +416 −0 QuadricotteroCompleto/stabilization/Stabilizzazione.cpp
  74. +416 −0 QuadricotteroCompleto/stabilization/Stabilizzazione.cpp~
  75. +52 −0 QuadricotteroCompleto/stabilization/Stabilizzazione.h
  76. +51 −0 QuadricotteroCompleto/stabilization/Stabilizzazione.h~
  77. +141 −0 RFIDread/RFIDread.pde
  78. +45 −0 RFIDtest2/RFIDtest2.pde
  79. +23 −0 RTCleo72/RTCleo72.pde
  80. +217 −0 RTCleo72/swRTC.cpp
  81. +37 −0 RTCleo72/swRTC.h
  82. +35 −0 ReadPPMChannel/ReadPPMChannel.pde
  83. +136 −0 SQRTtest/SQRTtest.pde
  84. +319 −0 TestERER/ERER.cpp
  85. +15 −0 TestERER/ERER.h
  86. +59 −0 TestERER/TestERER.pde
  87. +35 −0 TestGiro3/Giroscopio.cpp
  88. +35 −0 TestGiro3/Giroscopio.cpp~
  89. +16 −0 TestGiro3/Giroscopio.h
  90. +60 −0 TestGiro3/TestGiro3.pde
  91. +87 −0 TestGyro4/TestGyro4.pde
  92. +90 −0 TestInterrupt/TestInterrupt.pde
  93. +19 −0 TestMioProtocolloComunicazione/LestoCommReader.cpp
  94. +18 −0 TestMioProtocolloComunicazione/LestoCommReader.h
  95. +48 −0 TestMioProtocolloComunicazione/LestoCommWriter.cpp
  96. +14 −0 TestMioProtocolloComunicazione/LestoCommWriter.h
  97. +32 −0 TestMioProtocolloComunicazione/TestMioProtocolloComunicazione.pde
  98. +44 −0 TestNumeroALettera/TestNumeroALettera.pde
  99. +51 −0 TestOverflowMicros/TestOverflowMicros.pde
  100. +44 −0 TestPotenzaMotori/TestPotenzaMotori.pde
  101. +301 −0 TestReattivitaMotore/NunchukFarlocco.cpp
  102. +22 −0 TestReattivitaMotore/NunchukFarlocco.h
  103. +131 −0 TestReattivitaMotore/TestReattivitaMotore.pde
  104. +26 −0 TestSerioNunchukGyro/Giroscopio.cpp
  105. +16 −0 TestSerioNunchukGyro/Giroscopio.h
  106. +207 −0 TestSerioNunchukGyro/IMU.cpp
  107. +37 −0 TestSerioNunchukGyro/IMU.h
  108. +80 −0 TestSerioNunchukGyro/InputPin.cpp
  109. +15 −0 TestSerioNunchukGyro/InputPin.h
  110. +13 −0 TestSerioNunchukGyro/Motore.cpp
  111. +14 −0 TestSerioNunchukGyro/Motore.h
  112. +219 −0 TestSerioNunchukGyro/NunchukFarlocco.cpp
  113. +20 −0 TestSerioNunchukGyro/NunchukFarlocco.h
  114. +17 −0 TestSerioNunchukGyro/PID.cpp
  115. +14 −0 TestSerioNunchukGyro/PID.h
  116. +329 −0 TestSerioNunchukGyro/TestSerioNunchukGyro.pde
  117. +138 −0 TestWMP/Fastwire.cpp
  118. +41 −0 TestWMP/Fastwire.h
  119. +236 −0 TestWMP/Stabilizzazione.cpp
  120. +53 −0 TestWMP/Stabilizzazione.h
  121. +98 −0 TestWMP/TestWMP.pde
  122. +295 −0 TestWMP/WMP.cpp
  123. +26 −0 TestWMP/WMP.h
  124. +84 −0 TsteAnalogico/TsteAnalogico.pde
  125. +48 −0 WritePPMChannel/WritePPMChannel.pde
  126. +1,102 −0 XXcontrol/XXcontrol.pde
  127. +53 −0 XXcontrol/io_cfg.h
  128. +62 −0 XXcontrol/typedefs.h
  129. +44 −0 XbeeTest/XbeeTest.pde
  130. +1 −1 asincI2C/asincI2C.ino
  131. +23 −4 asincI2Ctest2/asincI2Ctest2.ino
  132. +8 −8 asincI2Ctest2_asinc/asincI2Ctest2_asinc.ino
  133. +225 −0 bigNumberTest/BigNumber.cpp
  134. +110 −0 bigNumberTest/BigNumber.h
  135. +225 −0 bigNumberTest/BigNumber/BigNumber.cpp
  136. +110 −0 bigNumberTest/BigNumber/BigNumber.h
  137. +24 −0 bigNumberTest/BigNumber/bcconfig.h
  138. BIN bigNumberTest/BigNumber/examples/.DS_Store
  139. +40 −0 bigNumberTest/BigNumber/examples/Calculate_E/Calculate_E.pde
  140. +31 −0 bigNumberTest/BigNumber/examples/Factorials/Factorials.pde
  141. +28 −0 bigNumberTest/BigNumber/examples/Multiplication/Multiplication.pde
  142. +57 −0 bigNumberTest/BigNumber/examples/Natural_Log/Natural_Log.pde
  143. +51 −0 bigNumberTest/BigNumber/examples/Power_of_E/Power_of_E.pde
  144. +47 −0 bigNumberTest/BigNumber/examples/Powers/Powers.pde
  145. +51 −0 bigNumberTest/BigNumber/examples/Sine/Sine.pde
  146. +339 −0 bigNumberTest/BigNumber/gpl.txt
  147. +11 −0 bigNumberTest/BigNumber/keywords.txt
  148. +1,597 −0 bigNumberTest/BigNumber/number.c
  149. +161 −0 bigNumberTest/BigNumber/number.h
  150. +24 −0 bigNumberTest/bcconfig.h
  151. +459 −0 bigNumberTest/bigNumberTest.ino
  152. +1,626 −0 bigNumberTest/number.c
  153. +160 −0 bigNumberTest/number.h
  154. +23 −0 cellLoad/cellLoad.pde
  155. +25 −0 dialogoLed/dialogoLed.pde
  156. +362 −0 fixedPointMath/fixedPointMath.pde
  157. +362 −0 fixedPointMath/fixedptc.h
  158. +72 −0 i2cscanner/i2cScanner.pde
  159. +75 −0 i2cscanner/i2cscanner.ino
  160. +218 −0 interruptOK/interruptOK.pde
  161. +48 −0 invioSeriale/invioSeriale.pde
  162. +48 −0 ledFastDistanza/ledFastDistanza.pde
  163. +112 −0 max6675test/MAX6675.cpp
  164. +25 −0 max6675test/MAX6675.h
  165. +71 −0 max6675test/max6675test.ino
  166. +138 −0 newQuad/Fastwire.cpp
  167. +44 −0 newQuad/Fastwire.h
  168. +7 −0 newQuad/newQuad.pde
  169. +108 −0 oldADXL345/oldADXL345.pde
  170. +1 −0 oldITG3200/ITG3200.pde
  171. +138 −0 oldTestImu/Fastwire.cpp
  172. +41 −0 oldTestImu/Fastwire.h
  173. +31 −0 oldTestImu/Giroscopio.cpp
  174. +19 −0 oldTestImu/Giroscopio.h
  175. +62 −0 oldTestImu/IMU.cpp
  176. +13 −0 oldTestImu/IMU.h
  177. +92 −0 oldTestImu/IMULast.cpp
  178. +15 −0 oldTestImu/IMULast.h
  179. +292 −0 oldTestImu/NunchukFarlocco.cpp
  180. +22 −0 oldTestImu/NunchukFarlocco.h
  181. +1 −0 oldTestImu/SensorInput.cpp
  182. +11 −0 oldTestImu/SensorInput.h
  183. +278 −0 oldTestImu/Stabilizzazione.cpp
  184. +217 −0 oldTestImu/Stabilizzazione.cpp~
  185. +71 −0 oldTestImu/Stabilizzazione.h
  186. +134 −0 oldTestImu/TestImu.pde
  187. +187 −0 oldTestImu/WMP.cpp
  188. +205 −0 oldTestImu/WMP.cpp~
  189. +22 −0 oldTestImu/WMP.h
  190. +25 −0 optiLoader/optiLoader.h
  191. +861 −0 optiLoader/optiLoader.pde
  192. +861 −0 optiLoader_pde/optiLoader_pde.pde
  193. +121 −0 oveflowTestSerio/oveflowTestSerio.ino
  194. +16 −0 seconds/seconds.ino
  195. +169 −0 swRTClesto/core_build_options.h
  196. +349 −0 swRTClesto/swRTC.cpp
  197. +54 −0 swRTClesto/swRTC.h
  198. +34 −0 swRTClesto/swRTClesto.pde
  199. +125 −0 test/AF_SDLog.cpp
  200. +36 −0 test/AF_SDLog.h
  201. +1,608 −0 test/fat16.cpp
  202. +175 −0 test/fat16.h
  203. +84 −0 test/fat16_config.h
  204. +163 −0 test/partition.cpp
  205. +201 −0 test/partition.h
  206. +35 −0 test/partition_config.h
  207. +890 −0 test/sd_raw.cpp
  208. +139 −0 test/sd_raw.h
  209. +121 −0 test/sd_raw_config.h
  210. +44 −0 test/sd_reader_config.h
  211. +390 −0 test/test.pde
  212. +18 −0 test/util.cpp
  213. +8 −0 test/util.h
  214. +44 −0 test2Gyro/test2Gyro.pde
  215. +178 −0 testADXL/ADXL345.cpp
  216. +84 −0 testADXL/ADXL345.h
  217. +40 −0 testADXL/testADXL.ino
  218. +15 −0 testAccelerometroAnalogico/testAccelerometroAnalogico.pde
  219. +1,581 −0 testDouble/avr_f64.c
  220. +243 −0 testDouble/avr_f64.h
  221. +126 −0 testDouble/testDouble.ino
  222. +62 −0 testFastSqrt/testFastSqrt.pde
  223. +60 −0 testGiro/Gyro.cpp
  224. +12 −0 testGiro/Gyro.h
  225. +21 −0 testGiro/Sensor.h
  226. +5 −0 testGiro/Struct.h
  227. +19 −0 testGiro/testGiro.ino
  228. +223 −0 testI2Cspeed/I2cMaster.cpp
  229. +129 −0 testI2Cspeed/I2cMaster.h
  230. +64 −0 testI2Cspeed/I2cMaster/examples/i2cScanAddress/i2cScanAddress.pde
  231. +38 −0 testI2Cspeed/I2cMaster/examples/i2cScopeTest/i2cScopeTest.pde
  232. +344 −0 testI2Cspeed/I2cMaster/examples/softDS1307/softDS1307.pde
  233. +60 −0 testI2Cspeed/TwiMap.h
  234. +33 −0 testI2Cspeed/keywords.txt
  235. +711 −0 testI2Cspeed/old/I2C.cpp
  236. +135 −0 testI2Cspeed/old/I2C.h
  237. +138 −0 testI2Cspeed/testI2Cspeed.ino
  238. +119 −0 testIMU/ADXL345.cpp
  239. +24 −0 testIMU/ADXL345.h
  240. +201 −0 testIMU/DCM.cpp
  241. +38 −0 testIMU/DCM.h
  242. +187 −0 testIMU/HMC5883L.cpp
  243. +23 −0 testIMU/HMC5883L.h
  244. +102 −0 testIMU/ITG3200.cpp
  245. +24 −0 testIMU/ITG3200.h
  246. +314 −0 testIMU/MahonyAHRS.cpp
  247. +45 −0 testIMU/MahonyAHRS.h
  248. +47 −0 testIMU/MemoryFree.cpp
  249. +20 −0 testIMU/MemoryFree.h
  250. +17 −0 testIMU/Sensor.h
  251. +16 −0 testIMU/SensorDataStruct.h
  252. +274 −0 testIMU/testIMU.ino
  253. +35 −0 testIR/testIR.pde
  254. +68 −0 testIR2/testIR2.pde
  255. +129 −0 testITG/ITG3200.cpp
  256. +129 −0 testITG/ITG3200.h
  257. +60 −0 testITG/main.h
  258. +1 −0 testITG/testITG.ino
  259. +112 −0 testITG/twi.c
  260. +14 −0 testITG/twi.h
  261. +260 −0 testNunchuck4/NunchukFarlocco.cpp
  262. +22 −0 testNunchuck4/NunchukFarlocco.h
  263. +62 −0 testNunchuck4/testNunchuck4.pde
  264. +260 −0 testNunchuckSlaveI2C/NunchukFarlocco.cpp
  265. +22 −0 testNunchuckSlaveI2C/NunchukFarlocco.h
  266. +98 −0 testNunchuckSlaveI2C/testNunchuckSlaveI2C.pde
  267. +241 −0 testNunchuk2/testNunchuk2.pde
  268. +357 −0 testNunchuk3/testNunchuk3.pde
  269. +32 −0 testOverflow/testOverflow.ino
  270. +9 −0 testPotenziometro/testPotenziometro.pde
  271. +60 −0 testTimerInterrupt/testTimerInterrupt.pde
  272. +213 −0 testnunchuk/WiiChuck.h
  273. +1 −0 testnunchuk/WiiChuck.h~
  274. +47 −0 testnunchuk/testnunchuk.pde
  275. +178 −0 vecchi file/FatswireDebig.cpp
  276. +35 −0 vecchi file/Giroscopio.cpp
  277. +16 −0 vecchi file/Giroscopio.h
  278. +23 −0 vecchi file/IMU.cpp
  279. +18 −0 vecchi file/IMU.h
  280. +80 −0 vecchi file/MyFastwire.pde
  281. +292 −0 vecchi file/NunchukFarlocco.cpp
  282. +22 −0 vecchi file/NunchukFarlocco.h
  283. +10 −0 velocit_Led/velocit_Led.pde
@@ -0,0 +1,51 @@
+//data HIGH goes from 900 to 1700
+//data LOW go to 19000
+
+#define MINSERVO 50 //value to test
+#define MAXSERVO 1024 //value to test
+#define SERVOLOWSIGNALDURATION 2000
+
+unsigned long duration1=MINSERVO;
+unsigned long duration2=19000;
+
+struct PPMPIN{
+ byte pin;
+ boolean pinstate = false;
+ unsigned long lastChange;
+ byte
+}
+
+struct PPMPIN test;
+
+void setup()
+{
+ Serial.begin(9600);
+ pinMode(PINOUTPUT, OUTPUT);
+ test.pin=2;
+ test.lastChange=micros();
+}
+
+void loop()
+{
+ updatePPM();
+ digitalWrite(PINOUTPUT, HIGH);
+ delayMicroseconds(duration1);
+ digitalWrite(PINOUTPUT, LOW);
+ delayMicroseconds(1000);
+
+ duration1+=10;
+ if (duration1>MAXSERVO){
+ duration1=MINSERVO;
+ }
+ Serial.print("Moving to: ");
+ Serial.println(duration1);
+}
+
+void updatePPM(){
+ if (micros()-test.lastChange < SERVOLOWSIGNALDURATION){
+ test.lastChange=micros();
+
+ }
+
+}
+
View
@@ -0,0 +1,220 @@
+/* BMP085 Extended Example Code
+ by: Jim Lindblom
+ SparkFun Electronics
+ date: 1/18/11
+ license: CC BY-SA v3.0 - http://creativecommons.org/licenses/by-sa/3.0/
+
+ Get pressure and temperature from the BMP085 and calculate altitude.
+ Serial.print it out at 9600 baud to serial monitor.
+
+ Update (7/19/11): I've heard folks may be encountering issues
+ with this code, who're running an Arduino at 8MHz. If you're
+ using an Arduino Pro 3.3V/8MHz, or the like, you may need to
+ increase some of the delays in the bmp085ReadUP and
+ bmp085ReadUT functions.
+*/
+
+#include <Wire.h>
+
+#define BMP085_ADDRESS 0x77 // I2C address of BMP085
+
+const unsigned char OSS = 0; // Oversampling Setting
+
+// Calibration values
+int ac1;
+int ac2;
+int ac3;
+unsigned int ac4;
+unsigned int ac5;
+unsigned int ac6;
+int b1;
+int b2;
+int mb;
+int mc;
+int md;
+
+// b5 is calculated in bmp085GetTemperature(...), this variable is also used in bmp085GetPressure(...)
+// so ...Temperature(...) must be called before ...Pressure(...).
+long b5;
+
+short temperature;
+long pressure;
+
+void setup()
+{
+ Serial.begin(9600);
+ delay(2000);
+ Wire.begin();
+ bmp085Calibration();
+}
+
+void loop()
+{
+ temperature = bmp085GetTemperature(bmp085ReadUT());
+ pressure = bmp085GetPressure(bmp085ReadUP());
+ Serial.print("Temperature: ");
+ Serial.print(temperature, DEC);
+ Serial.println(" *0.1 deg C");
+ Serial.print("Pressure: ");
+ Serial.print(pressure, DEC);
+ Serial.println(" Pa");
+ Serial.println();
+ delay(1000);
+}
+
+// Stores all of the bmp085's calibration values into global variables
+// Calibration values are required to calculate temp and pressure
+// This function should be called at the beginning of the program
+void bmp085Calibration()
+{
+ ac1 = bmp085ReadInt(0xAA);
+ ac2 = bmp085ReadInt(0xAC);
+ ac3 = bmp085ReadInt(0xAE);
+ ac4 = bmp085ReadInt(0xB0);
+ ac5 = bmp085ReadInt(0xB2);
+ ac6 = bmp085ReadInt(0xB4);
+ b1 = bmp085ReadInt(0xB6);
+ b2 = bmp085ReadInt(0xB8);
+ mb = bmp085ReadInt(0xBA);
+ mc = bmp085ReadInt(0xBC);
+ md = bmp085ReadInt(0xBE);
+}
+
+// Calculate temperature given ut.
+// Value returned will be in units of 0.1 deg C
+short bmp085GetTemperature(unsigned int ut)
+{
+ long x1, x2;
+
+ x1 = (((long)ut - (long)ac6)*(long)ac5) >> 15;
+ x2 = ((long)mc << 11)/(x1 + md);
+ b5 = x1 + x2;
+
+ return ((b5 + 8)>>4);
+}
+
+// Calculate pressure given up
+// calibration values must be known
+// b5 is also required so bmp085GetTemperature(...) must be called first.
+// Value returned will be pressure in units of Pa.
+long bmp085GetPressure(unsigned long up)
+{
+ long x1, x2, x3, b3, b6, p;
+ unsigned long b4, b7;
+
+ b6 = b5 - 4000;
+ // Calculate B3
+ x1 = (b2 * (b6 * b6)>>12)>>11;
+ x2 = (ac2 * b6)>>11;
+ x3 = x1 + x2;
+ b3 = (((((long)ac1)*4 + x3)<<OSS) + 2)>>2;
+
+ // Calculate B4
+ x1 = (ac3 * b6)>>13;
+ x2 = (b1 * ((b6 * b6)>>12))>>16;
+ x3 = ((x1 + x2) + 2)>>2;
+ b4 = (ac4 * (unsigned long)(x3 + 32768))>>15;
+
+ b7 = ((unsigned long)(up - b3) * (50000>>OSS));
+ if (b7 < 0x80000000)
+ p = (b7<<1)/b4;
+ else
+ p = (b7/b4)<<1;
+
+ x1 = (p>>8) * (p>>8);
+ x1 = (x1 * 3038)>>16;
+ x2 = (-7357 * p)>>16;
+ p += (x1 + x2 + 3791)>>4;
+
+ return p;
+}
+
+// Read 1 byte from the BMP085 at 'address'
+char bmp085Read(unsigned char address)
+{
+ unsigned char data;
+
+ Wire.beginTransmission(BMP085_ADDRESS);
+ Wire.send(address);
+ Wire.endTransmission();
+
+ Wire.requestFrom(BMP085_ADDRESS, 1);
+ while(!Wire.available())
+ ;
+
+ return Wire.receive();
+}
+
+// Read 2 bytes from the BMP085
+// First byte will be from 'address'
+// Second byte will be from 'address'+1
+int bmp085ReadInt(unsigned char address)
+{
+ unsigned char msb, lsb;
+
+ Wire.beginTransmission(BMP085_ADDRESS);
+ Wire.send(address);
+ Wire.endTransmission();
+
+ Wire.requestFrom(BMP085_ADDRESS, 2);
+ while(Wire.available()<2)
+ ;
+ msb = Wire.receive();
+ lsb = Wire.receive();
+
+ return (int) msb<<8 | lsb;
+}
+
+// Read the uncompensated temperature value
+unsigned int bmp085ReadUT()
+{
+ unsigned int ut;
+
+ // Write 0x2E into Register 0xF4
+ // This requests a temperature reading
+ Wire.beginTransmission(BMP085_ADDRESS);
+ Wire.send(0xF4);
+ Wire.send(0x2E);
+ Wire.endTransmission();
+
+ // Wait at least 4.5ms
+ delay(5);
+
+ // Read two bytes from registers 0xF6 and 0xF7
+ ut = bmp085ReadInt(0xF6);
+ return ut;
+}
+
+// Read the uncompensated pressure value
+unsigned long bmp085ReadUP()
+{
+ unsigned char msb, lsb, xlsb;
+ unsigned long up = 0;
+
+ // Write 0x34+(OSS<<6) into register 0xF4
+ // Request a pressure reading w/ oversampling setting
+ Wire.beginTransmission(BMP085_ADDRESS);
+ Wire.send(0xF4);
+ Wire.send(0x34 + (OSS<<6));
+ Wire.endTransmission();
+
+ // Wait for conversion, delay time dependent on OSS
+ delay(2 + (3<<OSS));
+
+ // Read register 0xF6 (MSB), 0xF7 (LSB), and 0xF8 (XLSB)
+ Wire.beginTransmission(BMP085_ADDRESS);
+ Wire.send(0xF6);
+ Wire.endTransmission();
+ Wire.requestFrom(BMP085_ADDRESS, 3);
+
+ // Wait for data to become available
+ while(Wire.available() < 3)
+ ;
+ msb = Wire.receive();
+ lsb = Wire.receive();
+ xlsb = Wire.receive();
+
+ up = (((unsigned long) msb << 16) | ((unsigned long) lsb << 8) | (unsigned long) xlsb) >> (8-OSS);
+
+ return up;
+}
Oops, something went wrong.

0 comments on commit 5fc066b

Please sign in to comment.