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: mbed
main.cpp@1:d1e89afbe50c, 2018-02-14 (annotated)
- Committer:
- 2236693B
- Date:
- Wed Feb 14 10:40:30 2018 +0000
- Revision:
- 1:d1e89afbe50c
- Parent:
- 0:005922ecb765
- Child:
- 2:29c3d03c9231
Starting point;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| 2236693B | 1:d1e89afbe50c | 1 | //Rango says, hey there Conor! |
| 2236693B | 0:005922ecb765 | 2 | |
| 2236693B | 0:005922ecb765 | 3 | #include "mbed.h" |
| 2236693B | 0:005922ecb765 | 4 | |
| 2236693B | 0:005922ecb765 | 5 | DigitalOut myled(LED1); |
| 2236693B | 0:005922ecb765 | 6 | AnalogIn Ain(PTB1); |
| 2236693B | 0:005922ecb765 | 7 | |
| 2236693B | 0:005922ecb765 | 8 | int const MAX_B = 20; |
| 2236693B | 0:005922ecb765 | 9 | int const delta = 0.5; |
| 2236693B | 0:005922ecb765 | 10 | int sample_buffer[MAX_B] = {}; |
| 2236693B | 0:005922ecb765 | 11 | int local_buffer[MAX_B] = {}; |
| 2236693B | 0:005922ecb765 | 12 | int read = 0; |
| 2236693B | 0:005922ecb765 | 13 | int write = 0; |
| 2236693B | 0:005922ecb765 | 14 | |
| 2236693B | 0:005922ecb765 | 15 | void data_process() { |
| 2236693B | 1:d1e89afbe50c | 16 | |
| 2236693B | 0:005922ecb765 | 17 | } |
| 2236693B | 0:005922ecb765 | 18 | |
| 2236693B | 0:005922ecb765 | 19 | int main() { |
| 2236693B | 0:005922ecb765 | 20 | sampler.attach(&sampling, 0.0125); //Sample at 80Hz |
| 2236693B | 0:005922ecb765 | 21 | |
| 2236693B | 0:005922ecb765 | 22 | while(1) { |
| 2236693B | 0:005922ecb765 | 23 | if (write-read > MAX_B/2 || read-write > MAX_B/2) { // |write-read| > MAX_B/2 |
| 2236693B | 0:005922ecb765 | 24 | for(int i = 0; i < MAX_B/2; i++) { |
| 2236693B | 0:005922ecb765 | 25 | local_buffer[i] = sample_buffer[read]; |
| 2236693B | 0:005922ecb765 | 26 | read = (++read) % MAX_B; |
| 2236693B | 0:005922ecb765 | 27 | } |
| 2236693B | 0:005922ecb765 | 28 | } |
| 2236693B | 1:d1e89afbe50c | 29 | |
| 2236693B | 0:005922ecb765 | 30 | data_process(); |
| 2236693B | 0:005922ecb765 | 31 | } |
| 2236693B | 0:005922ecb765 | 32 | } |
| 2236693B | 0:005922ecb765 | 33 | |
| 2236693B | 0:005922ecb765 | 34 | |
| 2236693B | 0:005922ecb765 | 35 |

