Neha Kadam
/
OFN_Hello_World_Demo
Demo code for Parallax OFN module 27903
main.cpp@0:912ec450e32b, 2015-03-09 (annotated)
- Committer:
- nkadam
- Date:
- Mon Mar 09 03:21:08 2015 +0000
- Revision:
- 0:912ec450e32b
Demo code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nkadam | 0:912ec450e32b | 1 | |
nkadam | 0:912ec450e32b | 2 | //@Authors: Guru Das Srinagesh, Neha Kadam |
nkadam | 0:912ec450e32b | 3 | /* Copyright (c) March, 2015 MIT License |
nkadam | 0:912ec450e32b | 4 | * |
nkadam | 0:912ec450e32b | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
nkadam | 0:912ec450e32b | 6 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
nkadam | 0:912ec450e32b | 7 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
nkadam | 0:912ec450e32b | 8 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
nkadam | 0:912ec450e32b | 9 | * furnished to do so, subject to the following conditions: |
nkadam | 0:912ec450e32b | 10 | * |
nkadam | 0:912ec450e32b | 11 | * The above copyright notice and this permission notice shall be included in all copies or |
nkadam | 0:912ec450e32b | 12 | * substantial portions of the Software. |
nkadam | 0:912ec450e32b | 13 | * |
nkadam | 0:912ec450e32b | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
nkadam | 0:912ec450e32b | 15 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
nkadam | 0:912ec450e32b | 16 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
nkadam | 0:912ec450e32b | 17 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
nkadam | 0:912ec450e32b | 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
nkadam | 0:912ec450e32b | 19 | */ |
nkadam | 0:912ec450e32b | 20 | |
nkadam | 0:912ec450e32b | 21 | #include "ofn.h" |
nkadam | 0:912ec450e32b | 22 | |
nkadam | 0:912ec450e32b | 23 | OFN ofn(p9, p10); |
nkadam | 0:912ec450e32b | 24 | Serial pc(USBTX, USBRX); |
nkadam | 0:912ec450e32b | 25 | |
nkadam | 0:912ec450e32b | 26 | int x, y, orient; |
nkadam | 0:912ec450e32b | 27 | |
nkadam | 0:912ec450e32b | 28 | int main(){ |
nkadam | 0:912ec450e32b | 29 | while(true) |
nkadam | 0:912ec450e32b | 30 | { |
nkadam | 0:912ec450e32b | 31 | while(ofn.checkMotion()){ |
nkadam | 0:912ec450e32b | 32 | x = ofn.readX(); |
nkadam | 0:912ec450e32b | 33 | y = ofn.readY(); |
nkadam | 0:912ec450e32b | 34 | orient = ofn.readOrientation(); |
nkadam | 0:912ec450e32b | 35 | pc.printf("X, Y: (%d, %d) & Orientation = %d \n", x, y, orient); |
nkadam | 0:912ec450e32b | 36 | } |
nkadam | 0:912ec450e32b | 37 | } |
nkadam | 0:912ec450e32b | 38 | } |