test

Dependencies:   PM2_Libary Eigen

Committer:
belmo057
Date:
Thu May 19 11:55:37 2022 +0200
Revision:
46:cf97e2ff152e
Parent:
45:ced6486325ab
uyktjthfg

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pmic 36:8c75783c1eca 1 #include <mbed.h>
pmic 36:8c75783c1eca 2
pmic 17:c19b471f05cb 3 #include "PM2_Libary.h"
pmic 36:8c75783c1eca 4 #include "Eigen/Dense.h"
belmo057 46:cf97e2ff152e 5 #include <cstdlib>
pmic 36:8c75783c1eca 6 # define M_PI 3.14159265358979323846 // number pi
pmic 6:e1fa1a2d7483 7
belmo057 45:ced6486325ab 8 // workshop
belmo057 46:cf97e2ff152e 9 InterruptIn user_button(PC_13);
belmo057 46:cf97e2ff152e 10 void user_button_pressed();
belmo057 46:cf97e2ff152e 11 Timer timer1;
belmo057 46:cf97e2ff152e 12 DigitalOut led1(LED1);
pmic 6:e1fa1a2d7483 13
pmic 1:93d997d6b232 14 int main()
pmic 23:26b3a25fc637 15 {
belmo057 46:cf97e2ff152e 16 const int main_task_period_ms = 10;
belmo057 46:cf97e2ff152e 17 user_button.fall(&user_button_pressed);
belmo057 46:cf97e2ff152e 18 timer1.start();
pmic 6:e1fa1a2d7483 19
pmic 24:86f1a63e35a0 20 while (true) { // this loop will run forever
pmic 6:e1fa1a2d7483 21
pmic 1:93d997d6b232 22 }
pmic 1:93d997d6b232 23 }
pmic 6:e1fa1a2d7483 24
belmo057 46:cf97e2ff152e 25 void user_button_pressed()
belmo057 46:cf97e2ff152e 26 {
belmo057 46:cf97e2ff152e 27 int curTime = std::chrono::duration_cast<std::chrono::microseconds>(timer1.elapsed_time()).count();
belmo057 46:cf97e2ff152e 28 if(curTime > 2000)
belmo057 46:cf97e2ff152e 29 {
belmo057 46:cf97e2ff152e 30 led1 =! led1;
belmo057 46:cf97e2ff152e 31 }
belmo057 46:cf97e2ff152e 32 timer1.reset();
belmo057 46:cf97e2ff152e 33 timer1.start();
pmic 6:e1fa1a2d7483 34
belmo057 46:cf97e2ff152e 35 }