Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include <math.h> 00002 00003 #include "mbed.h" 00004 #include "USBMouse.h" 00005 00006 USBMouse mouse(ABS_MOUSE); 00007 00008 int main(void) { 00009 int x_center = (X_MAX_ABS - X_MIN_ABS)/2; 00010 int y_center = (Y_MAX_ABS - Y_MIN_ABS)/2; 00011 int16_t x_screen = 0; 00012 int16_t y_screen = 0; 00013 00014 int32_t x_origin = x_center; 00015 int32_t y_origin = y_center; 00016 int32_t radius = 5000; 00017 int32_t angle = 0; 00018 00019 while (1) { 00020 x_screen = x_origin + cos((double)angle*3.14/180.0)*radius; 00021 y_screen = y_origin + sin((double)angle*3.14/180.0)*radius; 00022 printf("cos: %f, sin: %f\r\n", cos((double)angle*3.14/180.0)*radius, sin((double)angle)*radius); 00023 00024 mouse.move(x_screen, y_screen); 00025 angle += 3; 00026 wait(0.01); 00027 } 00028 }
Generated on Sun Jul 17 2022 08:25:26 by 1.7.2