Created
June 14, 2016 05:43
-
-
Save massenz/c38c34d6585bccc9d4104414b8a058a9 to your computer and use it in GitHub Desktop.
Platformio fail to printf() floats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AlertAvert.com (c) 2016. All rights reserved | |
// | |
// The code below has been adapted from tutorials on | |
// mbed.org - credits should go to ARM Ltd. | |
// | |
// Author: M. Massenzio | |
#include "mbed.h" | |
// USB out to the host PC - from a terminal window access | |
// using: screen /dev/ttyACM0 (use Ctrl-A Ctrl-K to kill). | |
// | |
// On OS X, to find the dev do: | |
// ls /dev/tty.usbmodem* | |
// | |
Serial pc(USBTX, USBRX); // tx, rx | |
// Board LEDs | |
DigitalOut myled(LED1); | |
DigitalOut yourled(LED2); | |
bool on = true; | |
void quit() { | |
on = false; | |
} | |
void toggle(DigitalOut d1, DigitalOut d2) { | |
d1 = !d1; | |
d2 = !d2; | |
} | |
int main() { | |
float intvl = 0.2f; | |
pc.printf("Starting LED flashing every %.3f sec\r\n", intvl); | |
Timeout to; | |
myled = !(yourled = 1); | |
to.attach(&quit, 5); | |
while(on) { | |
toggle(myled, yourled); | |
wait(0.2); | |
} | |
myled = yourled = 0; | |
pc.printf("Exiting now - %.3f; %d; %f\r\n", 3.14159, 99, 2.768); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment