summaryrefslogtreecommitdiff
path: root/usb-bmp180/usb-bmp180.c
diff options
context:
space:
mode:
Diffstat (limited to 'usb-bmp180/usb-bmp180.c')
-rw-r--r--usb-bmp180/usb-bmp180.c162
1 files changed, 0 insertions, 162 deletions
diff --git a/usb-bmp180/usb-bmp180.c b/usb-bmp180/usb-bmp180.c
deleted file mode 100644
index dabca95..0000000
--- a/usb-bmp180/usb-bmp180.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * spreadspace avr utils - usb-bmp180 example
- *
- *
- * Copyright (C) 2016 Bernhard Tittelbach <bernhard@tittelbach.org>
- * basically this is refactored and enhanced code from:
- * https://github.com/sparkfun/BMP180_Breakout_Arduino_Library
- * Please buy the sparkfun people Beer when you see them!!!!
- *
- * This file is part of spreadspace avr utils.
- *
- * spreadspace avr utils is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * spreadspace avr utils is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <avr/io.h>
-#include <avr/wdt.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
-#include <stdio.h>
-
-#include "util.h"
-#include "led.h"
-#include "usbio.h"
-
-#include "Arduino.h"
-#include "SFE_BMP180.h"
-
-
-SFE_BMP180 pressure;
-
-#define ALTITUDE 353.0 // Altitude of Graz in Austria
-
-
-int main(void)
-{
- MCUSR &= ~(1 << WDRF);
- wdt_disable();
-
- cpu_init();
- led_init();
- usbio_init();
- sei();
-
- arduino_init();
-
- if (pressure.begin())
- printf("BMP180 init success");
- else
- {
- // Oops, something went wrong, this is usually a connection problem,
- // see the comments at the top of this sketch for the proper connections.
-
- printf("BMP180 init fail\n\n");
- while(1); // Pause forever.
- }
-
- for(;;) {
- usbio_task();
-
- char status;
- double T,P,p0,a;
-
- // Loop here getting pressure readings every 10 seconds.
-
- // If you want sea-level-compensated pressure, as used in weather reports,
- // you will need to know the altitude at which your measurements are taken.
- // We're using a constant called ALTITUDE in this sketch:
-
- printf("\nprovided altitude: ");
- printf(ALTITUDE,0);
- printf(" meters, ");
- printf(ALTITUDE*3.28084,0);
- printf(" feet\n");
-
- // If you want to measure altitude, and not pressure, you will instead need
- // to provide a known baseline pressure. This is shown at the end of the sketch.
-
- // You must first get a temperature measurement to perform a pressure reading.
-
- // Start a temperature measurement:
- // If request is successful, the number of ms to wait is returned.
- // If request is unsuccessful, 0 is returned.
-
- status = pressure.startTemperature();
- if (status != 0)
- {
- // Wait for the measurement to complete:
- _delay_ms(status);
-
- // Retrieve the completed temperature measurement:
- // Note that the measurement is stored in the variable T.
- // Function returns 1 if successful, 0 if failure.
-
- status = pressure.getTemperature(T);
- if (status != 0)
- {
- // Print out the measurement:
- printf("temperature: %02d degC\n",T);
-
- // Start a pressure measurement:
- // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
- // If request is successful, the number of ms to wait is returned.
- // If request is unsuccessful, 0 is returned.
-
- status = pressure.startPressure(3);
- if (status != 0)
- {
- // Wait for the measurement to complete:
- _delay_ms(status);
-
- // Retrieve the completed pressure measurement:
- // Note that the measurement is stored in the variable P.
- // Note also that the function requires the previous temperature measurement (T).
- // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
- // Function returns 1 if successful, 0 if failure.
-
- status = pressure.getPressure(P,T);
- if (status != 0)
- {
- // Print out the measurement:
- printf("absolute pressure: %02d mb, %02d inHg\n", P, P*0.0295333727);
-
- // The pressure sensor returns abolute pressure, which varies with altitude.
- // To remove the effects of altitude, use the sealevel function and your current altitude.
- // This number is commonly used in weather reports.
- // Parameters: P = absolute pressure in mb, ALTITUDE = current altitude in m.
- // Result: p0 = sea-level compensated pressure in mb
-
- p0 = pressure.sealevel(P,ALTITUDE); // we're at 1655 meters (Boulder, CO)
- printf("relative (sea-level) pressure: %02d mb, %0d2 inHg", p0, p0*0.0295333727);
-
- // On the other hand, if you want to determine your altitude from the pressure reading,
- // use the altitude function along with a baseline pressure (sea-level or other).
- // Parameters: P = absolute pressure in mb, p0 = baseline pressure in mb.
- // Result: a = altitude in m.
-
- a = pressure.altitude(P,p0);
- printf("computed altitude: %dm\n",a);
- }
- else printf("error retrieving pressure measurement\n");
- }
- else printf("error starting pressure measurement\n");
- }
- else printf("error retrieving temperature measurement\n");
- }
- else printf("error starting temperature measurement\n");
-
- _delay_ms(5000); // Pause for 5 seconds.
-
- }
-}