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.
main.cpp
- Committer:
- Timmmm
- Date:
- 2016-11-04
- Revision:
- 0:1a3aa2e25db9
- Child:
- 1:0c3b6cc480b6
File content as of revision 0:1a3aa2e25db9:
#include <mbed.h> #include "USBControl.h" //#include "TSISensor.h" #define VENDOR_ID 0x0004 #define PRODUCT_ID 0x0307 #define PRODUCT_RELEASE 0x0001 #define PRODUCT_NAME "Knob" #define MANUFACTURER_NAME "Me" #define WINUSB_GUID "{a451588c-7230-4076-8456-9e544165e90c}" class USBKnob : public USBControl { public: USBKnob() : USBControl(VENDOR_ID, PRODUCT_ID, PRODUCT_RELEASE, PRODUCT_NAME, MANUFACTURER_NAME, WINUSB_GUID) { } void send(uint32_t fraction) { sendData(reinterpret_cast<uint8_t*>(&fraction), sizeof(fraction)); } }; USBKnob usb; //TSISensor touch; DigitalOut red(LED_RED); DigitalOut green(LED_GREEN); DigitalOut blue(LED_BLUE); Serial pc(USBTX, USBRX); AnalogIn knob(A0); int main(int argc, char* argv[]) { pc.baud(115200); pc.printf("\n\n\nmBed WinUSB Knob Example\n"); red = 1; green = 1; blue = 1; usb.connect(); // Touch sensor example (for FRDM-KL25Z). // for (;;) // { // float f = touch.readPercentage(); // if (f != 0.0) // { // // Note that this blocks if no-one is reading it! // usb.send(0xFFFFFFFF * f); // green = !green; // wait_ms(10); // } // } for (;;) { // TODO: Only send when it changes. usb.send(0xFFFFFFFF * knob); wait_ms(100); } return 0; }