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
PositionSetter.cpp@0:a4ad8cb94c43, 2015-11-12 (annotated)
- Committer:
- wanchp
- Date:
- Thu Nov 12 03:53:37 2015 +0000
- Revision:
- 0:a4ad8cb94c43
example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wanchp | 0:a4ad8cb94c43 | 1 | #include "PositionSetter.h" |
wanchp | 0:a4ad8cb94c43 | 2 | |
wanchp | 0:a4ad8cb94c43 | 3 | PositionSetter::PositionSetter() { |
wanchp | 0:a4ad8cb94c43 | 4 | // when no arguments, set to default |
wanchp | 0:a4ad8cb94c43 | 5 | // 3 axes (or motors )with 5 positions |
wanchp | 0:a4ad8cb94c43 | 6 | NofAxes = 3; |
wanchp | 0:a4ad8cb94c43 | 7 | NofPositions = 5; |
wanchp | 0:a4ad8cb94c43 | 8 | // first allocate memory |
wanchp | 0:a4ad8cb94c43 | 9 | // for Position |
wanchp | 0:a4ad8cb94c43 | 10 | Position = (Degree **) malloc(sizeof(Degree *) * NofAxes); |
wanchp | 0:a4ad8cb94c43 | 11 | for (int i = 0; i < NofAxes; i++) { |
wanchp | 0:a4ad8cb94c43 | 12 | Position[i] = (Degree *) malloc(sizeof(Degree) * NofPositions); |
wanchp | 0:a4ad8cb94c43 | 13 | } |
wanchp | 0:a4ad8cb94c43 | 14 | // for Duration |
wanchp | 0:a4ad8cb94c43 | 15 | Duration = (Time *) malloc(sizeof(Time) * NofPositions); |
wanchp | 0:a4ad8cb94c43 | 16 | Write = (bool *) malloc (sizeof(bool) * NofPositions); |
wanchp | 0:a4ad8cb94c43 | 17 | for (int i = 0; i < NofPositions; i++) { |
wanchp | 0:a4ad8cb94c43 | 18 | for (int j = 0; j < NofAxes; j++) { |
wanchp | 0:a4ad8cb94c43 | 19 | Position[j][i] = (Degree) i*j; |
wanchp | 0:a4ad8cb94c43 | 20 | } |
wanchp | 0:a4ad8cb94c43 | 21 | Duration[i] = (Time) i; |
wanchp | 0:a4ad8cb94c43 | 22 | Write[i] = true; |
wanchp | 0:a4ad8cb94c43 | 23 | } |
wanchp | 0:a4ad8cb94c43 | 24 | } |