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
Fork of Lab_6_WaG by
utility.cpp@35:ad2b3d6f0e5a, 2018-03-22 (annotated)
- Committer:
- spm71
- Date:
- Thu Mar 22 16:41:11 2018 +0000
- Revision:
- 35:ad2b3d6f0e5a
- Parent:
- 31:0dc2b4a3eee6
- Child:
- 74:8881f4aeb174
Started stepper functions
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| spm71 | 23:3da1d39c1ae9 | 1 | /****************************************************************************** |
| spm71 | 23:3da1d39c1ae9 | 2 | * EECS 397 |
| spm71 | 23:3da1d39c1ae9 | 3 | * |
| spm71 | 23:3da1d39c1ae9 | 4 | * Assignment Name: Lab 6: WaG |
| spm71 | 23:3da1d39c1ae9 | 5 | * |
| spm71 | 23:3da1d39c1ae9 | 6 | * Authors: Sam Morrison and Phong Nguyen |
| spm71 | 23:3da1d39c1ae9 | 7 | * File name: utility.cpp |
| spm71 | 23:3da1d39c1ae9 | 8 | * Purpose: Utility functions |
| spm71 | 23:3da1d39c1ae9 | 9 | * |
| spm71 | 23:3da1d39c1ae9 | 10 | * Created: 03/20/2018 |
| spm71 | 23:3da1d39c1ae9 | 11 | * Last Modified: 03/20/2018 |
| spm71 | 23:3da1d39c1ae9 | 12 | * |
| spm71 | 23:3da1d39c1ae9 | 13 | ******************************************************************************/ |
| spm71 | 23:3da1d39c1ae9 | 14 | |
| spm71 | 23:3da1d39c1ae9 | 15 | #include "mbed.h" |
| spm71 | 23:3da1d39c1ae9 | 16 | #include "io_pins.h" |
| spm71 | 23:3da1d39c1ae9 | 17 | #include "utility.h" |
| spm71 | 23:3da1d39c1ae9 | 18 | #include <stdlib.h> |
| spm71 | 23:3da1d39c1ae9 | 19 | #include <stdio.h> |
| spm71 | 23:3da1d39c1ae9 | 20 | #include <string.h> |
| spm71 | 23:3da1d39c1ae9 | 21 | |
| spm71 | 23:3da1d39c1ae9 | 22 | extern DigitalIn my_button; |
| spm71 | 23:3da1d39c1ae9 | 23 | |
| spm71 | 35:ad2b3d6f0e5a | 24 | /* |
| spm71 | 35:ad2b3d6f0e5a | 25 | * int uti_chk_ubutton(); |
| spm71 | 35:ad2b3d6f0e5a | 26 | * Description: returns true when button is pressed and released |
| spm71 | 35:ad2b3d6f0e5a | 27 | * |
| spm71 | 35:ad2b3d6f0e5a | 28 | * Inputs: |
| spm71 | 35:ad2b3d6f0e5a | 29 | * Parameters: |
| spm71 | 35:ad2b3d6f0e5a | 30 | * Globals: |
| spm71 | 35:ad2b3d6f0e5a | 31 | * |
| spm71 | 35:ad2b3d6f0e5a | 32 | * Outputs: |
| spm71 | 35:ad2b3d6f0e5a | 33 | * Returns: void |
| spm71 | 35:ad2b3d6f0e5a | 34 | */ |
| spm71 | 23:3da1d39c1ae9 | 35 | int uti_chk_ubutton() { |
| spm71 | 23:3da1d39c1ae9 | 36 | if (my_button == 0) |
| spm71 | 23:3da1d39c1ae9 | 37 | return 0; // exits if button is not pressed |
| spm71 | 23:3da1d39c1ae9 | 38 | else { |
| spm71 | 26:58befaac9643 | 39 | //cycle until button is released |
| spm71 | 26:58befaac9643 | 40 | do { |
| spm71 | 26:58befaac9643 | 41 | wait(0.02); |
| spm71 | 31:0dc2b4a3eee6 | 42 | } while (my_button == 1); |
| spm71 | 23:3da1d39c1ae9 | 43 | wait(0.02); //delay to prevent debounce |
| spm71 | 23:3da1d39c1ae9 | 44 | return 1; |
| spm71 | 23:3da1d39c1ae9 | 45 | } |
| spm71 | 23:3da1d39c1ae9 | 46 | } |
