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.
Android.cpp@1:6d9353593c3c, 2018-01-08 (annotated)
- Committer:
- maskas
- Date:
- Mon Jan 08 16:09:56 2018 +0000
- Revision:
- 1:6d9353593c3c
- Parent:
- 0:9b41a36d03d9
- Child:
- 2:aeecb6277fc7
Calibrate carousel;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maskas | 0:9b41a36d03d9 | 1 | |
maskas | 0:9b41a36d03d9 | 2 | |
maskas | 0:9b41a36d03d9 | 3 | #include "mbed.h" |
maskas | 0:9b41a36d03d9 | 4 | #include "Android.h" |
maskas | 0:9b41a36d03d9 | 5 | |
maskas | 1:6d9353593c3c | 6 | Android::Android(PinName txPin, PinName rxPin, Carousel& carousel): serial(txPin, rxPin), myled(LED1), carousel(carousel) { |
maskas | 0:9b41a36d03d9 | 7 | //Serial pc(USBTX, USBRX); // tx, rx |
maskas | 0:9b41a36d03d9 | 8 | |
maskas | 0:9b41a36d03d9 | 9 | this->serial.baud(115200); |
maskas | 0:9b41a36d03d9 | 10 | this->serial.attach(callback(this, &Android::onData)); |
maskas | 0:9b41a36d03d9 | 11 | |
maskas | 1:6d9353593c3c | 12 | this->ticker.attach(callback(this, &Android::hearthBeat), 5.0f); |
maskas | 1:6d9353593c3c | 13 | |
maskas | 1:6d9353593c3c | 14 | this->carousel.callibrate(); |
maskas | 0:9b41a36d03d9 | 15 | } |
maskas | 0:9b41a36d03d9 | 16 | |
maskas | 0:9b41a36d03d9 | 17 | void Android::hearthBeat(void) |
maskas | 0:9b41a36d03d9 | 18 | { |
maskas | 0:9b41a36d03d9 | 19 | printf("HEARTH BEAT SENT\n"); |
maskas | 0:9b41a36d03d9 | 20 | this->serial.printf("ARD_HB"); |
maskas | 0:9b41a36d03d9 | 21 | this->serial.putc(-91); |
maskas | 0:9b41a36d03d9 | 22 | this->serial.printf("OK"); |
maskas | 0:9b41a36d03d9 | 23 | this->serial.putc(-91); |
maskas | 0:9b41a36d03d9 | 24 | |
maskas | 0:9b41a36d03d9 | 25 | } |
maskas | 0:9b41a36d03d9 | 26 | |
maskas | 0:9b41a36d03d9 | 27 | void Android::onData(void) |
maskas | 0:9b41a36d03d9 | 28 | { |
maskas | 0:9b41a36d03d9 | 29 | char command[50]; |
maskas | 0:9b41a36d03d9 | 30 | int product; |
maskas | 0:9b41a36d03d9 | 31 | if (this->serial.readable()) { |
maskas | 0:9b41a36d03d9 | 32 | this->serial.scanf("%s", &command); |
maskas | 0:9b41a36d03d9 | 33 | this->serial.scanf("%d", &product); |
maskas | 0:9b41a36d03d9 | 34 | printf(command); |
maskas | 0:9b41a36d03d9 | 35 | printf("%d", product); |
maskas | 0:9b41a36d03d9 | 36 | |
maskas | 0:9b41a36d03d9 | 37 | printf("Command Received: \r\n"); |
maskas | 0:9b41a36d03d9 | 38 | } |
maskas | 0:9b41a36d03d9 | 39 | } |