Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Revision 7:7e1a474ca416, committed 2016-01-13
- Comitter:
- haydenball
- Date:
- Wed Jan 13 21:36:17 2016 +0000
- Parent:
- 6:808cfc0b9480
- Commit message:
- Final Changes
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 23 15:48:07 2015 +0000
+++ b/main.cpp Wed Jan 13 21:36:17 2016 +0000
@@ -29,7 +29,6 @@
// Inputs
AnalogIn ecg(p6);
-AnalogIn pulse(p1);
AnalogIn temp(p2);
// N.B. The devkit and prospeckz are different - DK is active low, prospeckz is active high.
@@ -38,23 +37,20 @@
// END IO
+Serial pc(USBTX, USBRX);
BLE ble;
const static char DEVICE_NAME[] = "UberVest";
static const uint16_t uuid16_list[] = {UberVestService::UBER_VEST_SERVICE_UUID};
static int8_t ecgValue;
-static int8_t pulseValue;
static int8_t tempValue;
static volatile bool sampleEcg = false;
-static volatile bool samplePulse = false;
static volatile bool sampleTemp = false;
UberVestService *uberVestServicePtr;
-Serial pc(USBTX, USBRX);
-
void connectionCallback(const Gap::ConnectionCallbackParams_t *params)
{
connectionLed = LED_OFF;
@@ -71,11 +67,6 @@
sampleEcg = true;
}
-void samplePulseCallback(void)
-{
- //samplePulse = true;
-}
-
void sampleTempCallback(void)
{
sampleTemp = true;
@@ -90,28 +81,28 @@
float getTemp(void)
{
- const int TEMP_RESISTOR_VALUE = 10830;
+ const int TEMP_RESISTOR_VALUE = 10900;
float rawValue;
float r; // Thermistor resistance
double convertedTemp;
rawValue = temp.read();
// The thermistor is set up as a simple voltage divider. We can get the resistance as follows:
- r = ((1 / rawValue) * TEMP_RESISTOR_VALUE) - TEMP_RESISTOR_VALUE;
+ r = ((TEMP_RESISTOR_VALUE * 5.0f) / (rawValue * 4.3f)) - TEMP_RESISTOR_VALUE;
// Now calculate the temperature from the resistance
// From the thermistor data sheet (http://www.farnell.com/datasheets/1784420.pdf):
- const float R_REF = 10000;
+ const float R_REF = 10000.0f;
const double A = 3.354016e-03;
const double B = 2.569850e-04;
const double C = 2.620131e-06;
const double D = 6.383091e-08;
convertedTemp = A + B * (log(r / R_REF)) + C * pow(log(r / R_REF), 2.0f) + D * pow(log(r / R_REF), 3.0f);
- convertedTemp = 1 / convertedTemp;
+ convertedTemp = 1.0f / convertedTemp;
// convert to degrees celsius:
- convertedTemp = convertedTemp - 273;
+ convertedTemp = convertedTemp - 273.0f;
pc.printf("Raw: %f, Resisance: %f, Temp: %f\r\n", rawValue, r, convertedTemp);
@@ -133,9 +124,6 @@
Ticker ecgSampler;
ecgSampler.attach(sampleEcgCallback, 0.02);
- //Ticker pulseSampler;
- //pulseSampler.attach(samplePulseCallback, 0.1);
-
Ticker tempSampler;
tempSampler.attach(sampleTempCallback, 1);
@@ -155,17 +143,10 @@
if (sampleEcg) {
sampleEcg = false;
- ecgValue = (ecg.read() * 1024);
+ ecgValue = (ecg.read() * 512);
uberVestServicePtr->updateEcg(ecgValue);
}
- if (samplePulse) {
- samplePulse = false;
-
- pulseValue = (pulse.read() * 1024);
- }
-
-
if (sampleTemp) {
sampleTemp = false;