Uses a Sparkfun Thumb Joystick to control the X and Y coordinate returned from the mbed device acting as a HID based absolute mouse.
main.cpp
- Committer:
- AdamGreen
- Date:
- 2011-11-18
- Revision:
- 0:b2c327d045a2
- Child:
- 2:ceb3218c3229
File content as of revision 0:b2c327d045a2:
/* Copyright 2011 Adam Green (http://mbed.org/users/AdamGreen/) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Uses two 10k potentiometers conntected to AnalogIn pins 15 and 16 to control the X and Y coordinate returned from the mbed device which is acting as HID based absolute mouse. */ #include <mbed.h> #include <USBMouse.h> int main(void) { static const float Width = (float)(X_MAX_ABS - X_MIN_ABS); static const float Height = (float)(Y_MAX_ABS - Y_MIN_ABS); AnalogIn AnalogX(p15); AnalogIn AnalogY(p16); USBMouse Mouse(ABS_MOUSE); while (1) { float AnalogXReading = AnalogX.read(); float AnalogYReading = AnalogY.read(); uint16_t X = X_MIN_ABS + (uint16_t)(Width * AnalogXReading); uint16_t Y = Y_MIN_ABS + (uint16_t)(Height * AnalogYReading); Mouse.move(X, Y); wait(0.01f); } }