#include "mbed.h" Serial pc(USBTX, USBRX); DigitalOut myled(LED1); // LED char recieve[6]; bool init = true; void pc_rx () { char c = pc.getc(); memcpy(recieve, recieve + 1, 5); recieve[5] = c; if (memcmp(recieve, "READY\n", 6) == 0) init = true; } int main() { pc.baud(115200); pc.format(8, Serial::None, 1); pc.attach(pc_rx, Serial::RxIrq); float x = 50; float y = 35; float dx = 2; float dy = 2; while(1) { myled = !myled; wait(0.05); if (init) { pc.printf("\nInit 100, 75, #FFFFFF\n"); pc.printf("Image Cat, neko.png, 400, 400\n"); pc.printf("DrawRect 5, 5, 90, 65, #00FF00, FILL\n"); pc.printf("DrawRect 5, 5, 90, 65, #0000FF, 2\n"); init = false; } y = (x - 50)*(x - 50) / 26 + 5; int p1 = x > 70 ? 2 : x > 65 ? 1 : 0; int p2 = x < 30 ? 5 : x < 35 ? 4 : 3; pc.printf("BALL: DrawCircle %f, %f, 5, #FF0000, FILL\n", x, y); pc.printf("SIRO: DrawImage Cat, %d, 75, 30, 25, 25\n", p1); pc.printf("MIKE: DrawImage Cat, %d, 0, 30, 25, 25\n", p2); if (x < 22) dx = 2; if (x > 78) dx = -2; x += dx; } exit(0); }