Guest User

Altimeter Barometer Thermometer

a guest
Apr 25th, 2012
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. OBJ
  2.  
  3. pst : "parallax serial terminal"
  4. alt : "29124_altimeter"
  5.  
  6. CON
  7.  
  8. _clkmode = xtal1 + pll16x
  9. _xinfreq = 5_000_000
  10.  
  11. START_ALT = 1317 ' Your starting altitude in feet. You can get this from a local airport
  12.  
  13. PUB start | a, p, t
  14.  
  15. pst.start(38400) ' Start Parallax serial terminal.
  16. alt.start(alt#QUICKSTART, alt#BACKGROUND) ' Start altimeter for QuickStart with background processing.
  17. alt.set_resolution(alt#HIGHEST) ' Set to highest resolution.
  18. alt.set_altitude(alt.m_from_ft(START_ALT * 100)) ' Set the starting altitude, based on average local pressure.
  19. repeat
  20. a := alt.altitude(alt.average_press) ' Get the current altitude in cm, from new average local pressure.
  21. pst.str(string(pst#HM, "Altitude:")) ' Print header. HM = home
  22. pst.str(alt.formatn(a, alt#METERS | alt#CECR, 8)) ' Print altitude in meters, clear-to-end, and CR.
  23. pst.str(alt.formatn(a, alt#TO_FEET | alt#CECR, 18)) ' Print altitude in feet, clear-to-end, and CR.
  24.  
  25. p := alt.current_press
  26. pst.str(string("Barometric Pressure:"))
  27. pst.str(alt.formatn(p, alt#MILLIBARS | alt#CECR, 8))
  28. pst.str(alt.formatn(p, alt#TO_INCHES | alt#CECR, 27))
  29.  
  30. t := alt.current_temp
  31. pst.str(string("Temperature:"))
  32. pst.str(alt.formatn(t, alt#DEGC | alt#CECR, 8))
  33. pst.str(alt.formatn(t, alt#TO_DEGF | alt#CECR, 20))
  34.  
  35. if (pst.rxcount) ' Respond to any key by clearing screen.
  36. pst.rxflush
  37. pst.char(pst#CS)
Advertisement
Add Comment
Please, Sign In to add comment