SDG+USBHost(Mouse) Sample

Dependencies:   Sound_Generator USBHost_custom

Fork of SDG_Mouse_Sample by GR-PEACH_producer_meeting

Information

Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.

What is this?

This program is a demonstration that sounds the sound by mouse operation by using USBHost(Mouse) and Sound Generator.

Settings

Close JP3 of GR-PEACH.
/media/uploads/RyoheiHagimoto/sdg-mouse.jpg

Operation

operationeffect
Right clickSounds
Left clickReset to base tone (C)
Moves the mouse to the rightLower the sound
Moves the mouse to the leftHigher the sound
Center cursorAdjust the sensitivity.
Reset the reference value in the click.

Others

The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication


概要

このプログラムは、USBHost(Mouse) + Sound Generatorで、マウス操作による擬似笛デモです。

設定

GR-PEACHのJP3をショートする必要があります。
/media/uploads/RyoheiHagimoto/sdg-mouse.jpg

操作方法

操作内容
右クリック音出力開始
左クリック基準音(ド)にリセット
マウス右移動高音になります
マウス左移動低音になります
センターカーソル音高低の変化量調整(クリックで基準値にリセット)

Others

mbedのシリアル通信(ボーレート等)のデフォルト設定は以下のリンクに示しています。
リンクを参考に、お使いのPCターミナルソフトの設定を変更して下さい。
mbedでのボーレートのデフォルト値は9600で、このサンプルではボーレート9600を使います。
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

Committer:
samux
Date:
Wed Mar 06 17:10:32 2013 +0000
Revision:
1:0a457e34fa9e
Parent:
0:a554658735bf
Child:
2:5e8fdc541b98
add doxygen comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:a554658735bf 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
mbed_official 0:a554658735bf 2 *
mbed_official 0:a554658735bf 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mbed_official 0:a554658735bf 4 * and associated documentation files (the "Software"), to deal in the Software without
mbed_official 0:a554658735bf 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
mbed_official 0:a554658735bf 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
mbed_official 0:a554658735bf 7 * Software is furnished to do so, subject to the following conditions:
mbed_official 0:a554658735bf 8 *
mbed_official 0:a554658735bf 9 * The above copyright notice and this permission notice shall be included in all copies or
mbed_official 0:a554658735bf 10 * substantial portions of the Software.
mbed_official 0:a554658735bf 11 *
mbed_official 0:a554658735bf 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mbed_official 0:a554658735bf 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mbed_official 0:a554658735bf 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mbed_official 0:a554658735bf 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbed_official 0:a554658735bf 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mbed_official 0:a554658735bf 17 */
mbed_official 0:a554658735bf 18
mbed_official 0:a554658735bf 19 #ifndef USBHOSTKEYBOARD_H
mbed_official 0:a554658735bf 20 #define USBHOSTKEYBOARD_H
mbed_official 0:a554658735bf 21
mbed_official 0:a554658735bf 22 #include "USBHostConf.h"
mbed_official 0:a554658735bf 23
mbed_official 0:a554658735bf 24 #if USBHOST_KEYBOARD
mbed_official 0:a554658735bf 25
mbed_official 0:a554658735bf 26 #include "USBHost.h"
mbed_official 0:a554658735bf 27
samux 1:0a457e34fa9e 28 /**
samux 1:0a457e34fa9e 29 * A class to communicate a USB keyboard
samux 1:0a457e34fa9e 30 */
mbed_official 0:a554658735bf 31 class USBHostKeyboard : public IUSBEnumerator {
mbed_official 0:a554658735bf 32 public:
mbed_official 0:a554658735bf 33
mbed_official 0:a554658735bf 34 /**
mbed_official 0:a554658735bf 35 * Constructor
mbed_official 0:a554658735bf 36 */
mbed_official 0:a554658735bf 37 USBHostKeyboard();
mbed_official 0:a554658735bf 38
mbed_official 0:a554658735bf 39 /**
mbed_official 0:a554658735bf 40 * Try to connect a keyboard device
mbed_official 0:a554658735bf 41 *
mbed_official 0:a554658735bf 42 * * @return true if connection was successful
mbed_official 0:a554658735bf 43 */
mbed_official 0:a554658735bf 44 bool connect();
mbed_official 0:a554658735bf 45
mbed_official 0:a554658735bf 46 /**
mbed_official 0:a554658735bf 47 * Check if a keyboard is connected
mbed_official 0:a554658735bf 48 *
mbed_official 0:a554658735bf 49 * @returns true if a keyboard is connected
mbed_official 0:a554658735bf 50 */
mbed_official 0:a554658735bf 51 bool connected();
mbed_official 0:a554658735bf 52
mbed_official 0:a554658735bf 53 /**
mbed_official 0:a554658735bf 54 * Attach a callback called when a keyboard event is received
mbed_official 0:a554658735bf 55 *
mbed_official 0:a554658735bf 56 * @param fptr function pointer
mbed_official 0:a554658735bf 57 */
mbed_official 0:a554658735bf 58 inline void attach(void (*ptr)(uint8_t key)) {
mbed_official 0:a554658735bf 59 if (ptr != NULL) {
mbed_official 0:a554658735bf 60 onKey = ptr;
mbed_official 0:a554658735bf 61 }
mbed_official 0:a554658735bf 62 }
mbed_official 0:a554658735bf 63
mbed_official 0:a554658735bf 64 /**
mbed_official 0:a554658735bf 65 * Attach a callback called when a keyboard event is received
mbed_official 0:a554658735bf 66 *
mbed_official 0:a554658735bf 67 * @param fptr function pointer
mbed_official 0:a554658735bf 68 */
mbed_official 0:a554658735bf 69 inline void attach(void (*ptr)(uint8_t keyCode, uint8_t modifier)) {
mbed_official 0:a554658735bf 70 if (ptr != NULL) {
mbed_official 0:a554658735bf 71 onKeyCode = ptr;
mbed_official 0:a554658735bf 72 }
mbed_official 0:a554658735bf 73 }
mbed_official 0:a554658735bf 74
mbed_official 0:a554658735bf 75 protected:
mbed_official 0:a554658735bf 76 //From IUSBEnumerator
mbed_official 0:a554658735bf 77 virtual void setVidPid(uint16_t vid, uint16_t pid);
mbed_official 0:a554658735bf 78 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
mbed_official 0:a554658735bf 79 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
mbed_official 0:a554658735bf 80
mbed_official 0:a554658735bf 81 private:
mbed_official 0:a554658735bf 82 USBHost * host;
mbed_official 0:a554658735bf 83 USBDeviceConnected * dev;
mbed_official 0:a554658735bf 84 USBEndpoint * int_in;
mbed_official 0:a554658735bf 85 uint8_t report[9];
mbed_official 0:a554658735bf 86 int keyboard_intf;
mbed_official 0:a554658735bf 87 bool keyboard_device_found;
mbed_official 0:a554658735bf 88
mbed_official 0:a554658735bf 89 bool dev_connected;
mbed_official 0:a554658735bf 90
mbed_official 0:a554658735bf 91 void rxHandler();
mbed_official 0:a554658735bf 92
mbed_official 0:a554658735bf 93 void (*onKey)(uint8_t key);
mbed_official 0:a554658735bf 94 void (*onKeyCode)(uint8_t key, uint8_t modifier);
mbed_official 0:a554658735bf 95
mbed_official 0:a554658735bf 96 int report_id;
mbed_official 0:a554658735bf 97
mbed_official 0:a554658735bf 98 void init();
mbed_official 0:a554658735bf 99
mbed_official 0:a554658735bf 100 };
mbed_official 0:a554658735bf 101
mbed_official 0:a554658735bf 102 #endif
mbed_official 0:a554658735bf 103
mbed_official 0:a554658735bf 104 #endif
mbed_official 0:a554658735bf 105