Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit 55e792a

Browse files
committed
update README.md
1 parent fe39292 commit 55e792a

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

README.md

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ $pFFA->data_mesgs['session']['num_laps']
4949
You could either iterate through the $pFFA->data_mesgs array, or take a look at the debug information you can dump to a webpage:
5050
```php
5151
// Option 1. Iterate through the $pFFA->data_mesgs array
52-
foreach($pFFA->data_mesgs as $mesg_key => $mesg) { // Iterate the array and output the messages
52+
foreach ($pFFA->data_mesgs as $mesg_key => $mesg) { // Iterate the array and output the messages
5353
echo "<strong>Found Message: $mesg_key</strong><br>";
54-
foreach($mesg as $field_key => $field) { // Iterate each message and output the fields
54+
foreach ($mesg as $field_key => $field) { // Iterate each message and output the fields
5555
echo " - Found Field: $mesg_key -> $field_key<br>";
5656
}
5757
echo "<br>";
5858
}
5959

6060
// Option 2. Show the debug information
61-
$pFFA->show_debug_info(); // Quite a lot of info...
61+
$pFFA->showDebugInfo(); // Quite a lot of info...
6262
```
6363
**How about some real-world examples?**
6464
```php
@@ -68,7 +68,7 @@ echo "Average Speed: ".( array_sum($pFFA->data_mesgs['record']['speed']) / count
6868

6969
// Put HR data into a JavaScript array for use in a Chart
7070
echo "var chartData = [";
71-
foreach( $pFFA->data_mesgs['record']['heart_rate'] as $timestamp => $hr_value ) {
71+
foreach ($pFFA->data_mesgs['record']['heart_rate'] as $timestamp => $hr_value) {
7272
echo "[$timestamp,$hr_value],";
7373
}
7474
echo "];";
@@ -79,19 +79,17 @@ The FIT protocol makes use of enumerated data types. Where these values have bee
7979
A public function is available, which will return the enumerated value for a given message type. For example:
8080
```php
8181
// Access data stored within the private class variable $enum_data
82-
// $pFFA->get_enum_data($type, $value)
82+
// $pFFA->enumData($type, $value)
8383
// e.g.
84-
echo $pFFA->get_enum_data('sport', 2)); // returns 'cycling'
85-
echo $pFFA->get_enum_data('manufacturer', $this->data_mesgs['device_info']['manufacturer']); // returns 'Garmin';
86-
echo $pFFA->get_manufacturer(); // Short-hand for above
84+
echo $pFFA->enumData('sport', 2)); // returns 'cycling'
85+
echo $pFFA->enumData('manufacturer', $this->data_mesgs['device_info']['manufacturer']); // returns 'Garmin';
86+
echo $pFFA->manufacturer(); // Short-hand for above
8787
```
8888
In addition, public functions provide a short-hand way to access commonly used enumerated data:
8989

90-
- get_manufacturer()
91-
- get_product()
92-
- get_sport()
93-
- get_sub_sport()
94-
- get_swim_stroke()
90+
- manufacturer()
91+
- product()
92+
- sport()
9593

9694
###Optional Parameters
9795
There are three optional parameters that can be passed as an associative array when the phpFITFileAnalysis object is instantiated. These are:
@@ -174,16 +172,16 @@ For cadence, zeroes are inserted as it is thought that it is likely no data has
174172
**Interpolation of missing data points**
175173
```php
176174
// Do not use code, just for demonstration purposes
177-
var_dump( $pFFA->data_mesgs['record']['temperature'] ); // ['100'=>22, '101'=>22, '102'=>23, '103'=>23, '104'=>23];
178-
var_dump( $pFFA->data_mesgs['record']['distance'] ); // ['100'=>3.62, '101'=>4.01, '104'=>10.88];
175+
var_dump($pFFA->data_mesgs['record']['temperature']); // ['100'=>22, '101'=>22, '102'=>23, '103'=>23, '104'=>23];
176+
var_dump($pFFA->data_mesgs['record']['distance']); // ['100'=>3.62, '101'=>4.01, '104'=>10.88];
179177
```
180178
As you can see from the trivial example above, temperature data have been recorded for each of five timestamps (100, 101, 102, 103, and 104). However, distance information has not been recorded for timestamps 102 and 103.
181179

182180
If *fix_data* includes 'distance', then the class will attempt to insert data into the distance array with the indexes 102 and 103. Values are determined using a linear interpolation between indexes 101(4.01) and 104(10.88).
183181

184182
The result would be:
185183
```php
186-
var_dump( $pFFA->data_mesgs['record']['distance'] ); // ['100'=>3.62, '101'=>4.01, '102'=>6.30, '103'=>8.59, '104'=>10.88];
184+
var_dump($pFFA->data_mesgs['record']['distance']); // ['100'=>3.62, '101'=>4.01, '102'=>6.30, '103'=>8.59, '104'=>10.88];
187185
```
188186

189187
####Set Units
@@ -235,7 +233,7 @@ $options = ['pace' => true];
235233
```
236234
Pace values will be decimal minutes. To get the seconds, you may wish to do something like:
237235
```php
238-
foreach($pFFA->data_mesgs['record']['speed'] as $key => $value) {
236+
foreach ($pFFA->data_mesgs['record']['speed'] as $key => $value) {
239237
$min = floor($value);
240238
$sec = round(60 * ($value - $min));
241239
echo "pace: $min min $sec sec<br>";
@@ -246,28 +244,28 @@ Note that if 'raw' units are requested then this parameter has no effect on the
246244
##Analysis
247245
The following functions return arrays of that could be used to create tables/charts:
248246
```php
249-
$pFFA->hr_partioned_HRmaximum(195); // Input: HRmaximum
250-
$pFFA->hr_partioned_HRreserve(48, 195); // Inputs: HRmaximum and HRresting
251-
$pFFA->power_partioned(312); // Input: Functional Threshold Power
252-
$pFFA->power_histogram(); // Input: bucket width (optional; default=25w)
247+
$pFFA->hrPartionedHRmaximum(195); // Input: HRmaximum
248+
$pFFA->hrPartionedHRreserve(48, 195); // Inputs: HRmaximum and HRresting
249+
$pFFA->powerPartioned(312); // Input: Functional Threshold Power
250+
$pFFA->powerHistogram(); // Input: bucket width (optional; default=25w)
253251
```
254252
For advanced control over these functions, or use with other sensor data (e.g. cadence or speed), use the underlying functions:
255253
```php
256-
$pFFA->partition_data($record_field='', $thresholds=null, $percentages=true, $labels_for_keys=true);
254+
$pFFA->partitionData($record_field='', $thresholds=null, $percentages=true, $labels_for_keys=true);
257255
$pFFA->histogram($bucket_width=25, $record_field='');
258256
```
259257
Functions exist to determine thresholds based on percentages of user-supplied data:
260258
```php
261-
$pFFA->hr_zones_max($hr_maximum, $percentages_array=[0.60, 0.75, 0.85, 0.95]);
262-
$pFFA->hr_zones_reserve($hr_resting, $hr_maximum, $percentages_array=[0.60, 0.65, 0.75, 0.82, 0.89, 0.94 ]) {
263-
$pFFA->power_zones($functional_threshold_power, $percentages_array=[0.55, 0.75, 0.90, 1.05, 1.20, 1.50]);
259+
$pFFA->hrZonesMax($hr_maximum, $percentages_array=[0.60, 0.75, 0.85, 0.95]);
260+
$pFFA->hrZonesReserve($hr_resting, $hr_maximum, $percentages_array=[0.60, 0.65, 0.75, 0.82, 0.89, 0.94 ]) {
261+
$pFFA->powerZones($functional_threshold_power, $percentages_array=[0.55, 0.75, 0.90, 1.05, 1.20, 1.50]);
264262
```
265263
###Heart Rate
266264
A function exists for analysing heart rate data:
267265
```php
268266
// hr_FT is heart rate at Functional Threshold, or Lactate Threshold Heart Rate
269-
$pFFA->hr_metrics($hr_resting, $hr_maximum, $hr_FT, $gender);
270-
// e.g. $pFFA->hr_metrics(52, 189, 172, 'male');
267+
$pFFA->hrMetrics($hr_resting, $hr_maximum, $hr_FT, $gender);
268+
// e.g. $pFFA->hrMetrics(52, 189, 172, 'male');
271269
```
272270
**Heart Rate metrics:**
273271
* TRIMP (TRaining IMPulse)
@@ -276,8 +274,8 @@ $pFFA->hr_metrics($hr_resting, $hr_maximum, $hr_FT, $gender);
276274
###Power
277275
Two functions exist for analysing power data:
278276
```php
279-
$pFFA->power_metrics($functional_threshold_power); // e.g. 312
280-
$pFFA->critical_power($time_periods); // e.g. 300 or [300, 600, 900, 1200]
277+
$pFFA->powerMetrics($functional_threshold_power); // e.g. 312
278+
$pFFA->criticalPower($time_periods); // e.g. 300 or [300, 600, 900, 1200]
281279
```
282280
**Power metrics:**
283281
* Average Power
@@ -289,7 +287,7 @@ $pFFA->critical_power($time_periods); // e.g. 300 or [300, 600, 900, 1200]
289287

290288
**Critical Power** (or Best Effort) is the highest average power sustained for a specified period of time within the activity. You can supply a single time period (in seconds), or an array or time periods.
291289

292-
Note that ```$pFFA->critical_power``` and some power metrics (Normalised Power, Variability Index, Intensity Factor, Training Stress Score) will use the [PHP Trader](http://php.net/manual/en/book.trader.php) extension if it is loaded on the server. If the extension is not loaded then it will use the built-in Simple Moving Average algorithm, which is far less performant particularly for larger files!
290+
Note that ```$pFFA->criticalPower``` and some power metrics (Normalised Power, Variability Index, Intensity Factor, Training Stress Score) will use the [PHP Trader](http://php.net/manual/en/book.trader.php) extension if it is loaded on the server. If the extension is not loaded then it will use the built-in Simple Moving Average algorithm, which is far less performant particularly for larger files!
293291

294292

295293
A demo of power analysis is available [here](http://www.adriangibbons.com/phpFITFileAnalysis-demo/analysis_power.php).

0 commit comments

Comments
 (0)