Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CON
- _clkmode = xtal1 + pll16x
- _xinfreq = 5_000_000
- XB_Rx = 0 ' XBee DOUT
- XB_Tx = 1 ' XBee DIN
- XB_Baud = 9600
- CR = 13 ' Carriage Return value
- START_ALT = 1317 ' Your starting altitude in feet.
- OBJ
- XB : "FullDuplexSerial"
- alt : "29124_altimeter"
- Pub Start | a, p, t
- XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee
- waitcnt(clkfreq + cnt)
- alt.start(alt#QUICKSTART, alt#BACKGROUND) ' Start altimeter for QuickStart with background processing.
- alt.set_resolution(alt#HIGHEST) ' Set to highest resolution.
- alt.set_altitude(alt.m_from_ft(START_ALT * 100)) ' Set the starting altitude, based on average local pressure.
- repeat
- a := alt.altitude(alt.average_press) ' Get the current altitude in cm, from new average local pressure.
- XB.str(string("Altitude:"))
- XB.str(alt.formatn(a, alt#METERS, 8)) ' Print altitude in meters
- XB.tx(13)
- XB.str(alt.formatn(a, alt#TO_FEET, 18)) ' Print altitude in feet, clear-to-end, and CR. \
- XB.tx(13)
- p := alt.current_press
- XB.str(string("Barometric Pressure:"))
- XB.str(alt.formatn(p, alt#MILLIBARS, 8))
- XB.tx(13)
- XB.str(alt.formatn(p, alt#TO_INCHES, 18))
- XB.tx(13)
- t := alt.current_temp
- XB.str(string("Temperature:"))
- XB.str(alt.formatn(t, alt#DEGC, 8))
- XB.tx(13)
- XB.str(alt.formatn(t, alt#TO_DEGF, 18))
- XB.tx(13)
- XB.tx(13)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement