GR-MANGO sample using mbed-os library from my repository.
sample_programs/sample_08_usb_func_mouse.cpp@0:b4c1e32627f2, 2020-10-12 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Mon Oct 12 02:25:49 2020 +0000
- Revision:
- 0:b4c1e32627f2
replaced mbed-os library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| RyoheiHagimoto | 0:b4c1e32627f2 | 1 | /******************************************************************************* |
| RyoheiHagimoto | 0:b4c1e32627f2 | 2 | * DISCLAIMER |
| RyoheiHagimoto | 0:b4c1e32627f2 | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
| RyoheiHagimoto | 0:b4c1e32627f2 | 4 | * intended for use with Renesas products. No other uses are authorized. This |
| RyoheiHagimoto | 0:b4c1e32627f2 | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
| RyoheiHagimoto | 0:b4c1e32627f2 | 6 | * all applicable laws, including copyright laws. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
| RyoheiHagimoto | 0:b4c1e32627f2 | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
| RyoheiHagimoto | 0:b4c1e32627f2 | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
| RyoheiHagimoto | 0:b4c1e32627f2 | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
| RyoheiHagimoto | 0:b4c1e32627f2 | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
| RyoheiHagimoto | 0:b4c1e32627f2 | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
| RyoheiHagimoto | 0:b4c1e32627f2 | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
| RyoheiHagimoto | 0:b4c1e32627f2 | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 16 | * Renesas reserves the right, without notice, to make changes to this software |
| RyoheiHagimoto | 0:b4c1e32627f2 | 17 | * and to discontinue the availability of this software. By using this software, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 18 | * you agree to the additional terms and conditions found by accessing the |
| RyoheiHagimoto | 0:b4c1e32627f2 | 19 | * following link: |
| RyoheiHagimoto | 0:b4c1e32627f2 | 20 | * http://www.renesas.com/disclaimer |
| RyoheiHagimoto | 0:b4c1e32627f2 | 21 | * |
| RyoheiHagimoto | 0:b4c1e32627f2 | 22 | * Copyright (C) 2019 Renesas Electronics Corporation. All rights reserved. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 23 | *******************************************************************************/ |
| RyoheiHagimoto | 0:b4c1e32627f2 | 24 | #include "sample_select.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 25 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 26 | #if (SAMPLE_PROGRAM_NO == 8) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 27 | // SAMPLE_PROGRAM_NO 8 : USBMouse sample |
| RyoheiHagimoto | 0:b4c1e32627f2 | 28 | // |
| RyoheiHagimoto | 0:b4c1e32627f2 | 29 | // The USBMouse interface is used to emulate a mouse over the USB port. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 30 | // You can choose relative or absolute co-ordinates, and send clicks, button state and scroll wheel movements. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 31 | // [Attention!] Delete the "OVERRIDE_CONSOLE_USBSERIAL" macro in "mbed_app.json" file if it is set. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 32 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 33 | #include "mbed.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 34 | #include "USBMouse.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 35 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 36 | int main() { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 37 | USBMouse mouse; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 38 | int16_t x = 0; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 39 | int16_t y = 0; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 40 | int32_t radius = 10; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 41 | int32_t angle = 0; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 42 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 43 | while (1) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 44 | x = cos((double)angle*3.14/180.0)*radius; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 45 | y = sin((double)angle*3.14/180.0)*radius; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 46 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 47 | mouse.move(x, y); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 48 | angle += 3; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 49 | ThisThread::sleep_for(0.001); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 50 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 51 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 52 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 53 | #endif |