2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.AltosLib;
20 public class AltosMs5607 {
42 dT = raw_temp - ((int) tref << 8);
44 TEMP = (int) (2000 + (((long) dT * tempsens) >> 23));
46 OFF = ((long) off << 17) + (((long) tco * dT) >> 6);
48 SENS = ((long) sens << 16) + (((long) tcs * dT) >> 7);
51 int T2 = (int) (((long) dT * (long) dT) >> 31);
52 int TEMPM = TEMP - 2000;
53 long OFF2 = (61 * (long) TEMPM * (long) TEMPM) >> 4;
54 long SENS2 = 2 * (long) TEMPM * (long) TEMPM;
56 int TEMPP = TEMP + 1500;
57 long TEMPP2 = TEMPP * TEMPP;
58 OFF2 = OFF2 + 15 * TEMPP2;
59 SENS2 = SENS2 + 8 * TEMPP2;
66 pa = (int) (((((long) raw_pres * SENS) >> 21) - OFF) >> 15);
70 public int set(int in_pres, int in_temp) {
77 public AltosMs5607() {
78 raw_pres = AltosRecord.MISSING;
79 raw_temp = AltosRecord.MISSING;
80 pa = AltosRecord.MISSING;
81 cc = AltosRecord.MISSING;