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.
Fork of Timer by
Revision 44:b1fd7489369f, committed 2016-04-13
- Comitter:
- sype
- Date:
- Wed Apr 13 11:43:10 2016 +0000
- Parent:
- 43:d5aaff7d2bec
- Child:
- 45:b53ae54062c6
- Commit message:
- Refonte du swag du code
Changed in this revision
--- a/Functions/func.cpp Wed Apr 13 11:30:16 2016 +0000
+++ b/Functions/func.cpp Wed Apr 13 11:43:10 2016 +0000
@@ -131,4 +131,18 @@
right_hand.setGoal(180);
left_hand.setGoal(180);
wait(2);
+}
+
+void init_interrupt(void)
+{
+ mybutton.fall(&pressed);
+ mybutton.rise(&unpressed);
+
+ EndL.fall(&ELpressed);
+ EndL.rise(&ELunpressed);
+ EndZ.fall(&EZpressed);
+ EndZ.rise(&EZunpressed);
+ EndR.fall(&ERpressed);
+ EndR.rise(&ERunpressed);
+ ticker.attach_us(&update_main,dt); // 100 Hz
}
\ No newline at end of file
--- a/Functions/func.h Wed Apr 13 11:30:16 2016 +0000 +++ b/Functions/func.h Wed Apr 13 11:43:10 2016 +0000 @@ -21,6 +21,12 @@ extern AnalogIn capt1; extern AnalogIn capt2; extern AnalogIn capt3; +extern InterruptIn mybutton; +extern InterruptIn EndR; +extern InterruptIn EndZ; +extern InterruptIn EndL; +extern AX12 left_hand; +extern AX12 right_hand; extern int i, state; extern bool EL, EZ, ER; @@ -37,6 +43,7 @@ void JPO(void); void init_ax12(void); +void init_interrupt(void); void goHome(void); void checkAround(void);
--- a/main.cpp Wed Apr 13 11:30:16 2016 +0000
+++ b/main.cpp Wed Apr 13 11:43:10 2016 +0000
@@ -49,51 +49,7 @@
int main(void)
{
init();
- /* Code AStar */
-
- /*double angle_v = 2*PI/5;
- double distance_v = 200.0;
- std::vector<SimplePoint> path;
- Map map;
-
-
- //Construction des obstacles
- map.build();
-
- float x=odo.getX();
- float y=odo.getY();
- float the = 0;
-
- map.AStar(x, y, 1600, 1000, 75);
- path = map.path;
-
- for(int i=0; i<path.size();i++) {
- the = (float) atan2((double) (path[i].y - odo.getY()), (double) (path[i].x - odo.getX()));
- odo.GotoXYT(path[i].x, path[i].y, the);
- }
-
- map.AStar(odo.getX(), odo.getY(), 0, 1000, 75);
- path = map.path;
-
- for(int i=0; i<path.size();i++) {
- the = (float) atan2((double) (path[i].y - odo.getY()), (double) (path[i].x - odo.getX()));
- odo.GotoXYT(path[i].x, path[i].y, the);
- }*/
-
- //odo.GotoThet(PI);
- //odo.GotoThet(0);
- //odo.TestEntraxe(3);
-
- //odo.GotoThet(-PI/2);
- //wait(2000);
- //odo.GotoXYT(2250,500,0);
-
- //odo.TestEntraxe(5);
- //odo.Forward(1000);
- while(1)
- {
- JPO();
- }
+ while(1) JPO();
}
void init(void)
@@ -103,30 +59,16 @@
logger.baud(9600);
logger.printf("Hello from main !\n\r");
wait_ms(500);
- bleu = 1;
- blanc = 1;
- rouge = 1;
+ bleu = 1, blanc = 1, rouge = 1;
wait_ms(1000);
- bleu = 0;
- blanc = 0;
- rouge = 0;
+ bleu = 0, blanc = 0, rouge = 0;
- //odo.setPos(0, 1000, 0);
while(button);
wait(1);
-
- mybutton.fall(&pressed);
- mybutton.rise(&unpressed);
-
- EndL.fall(&ELpressed);
- EndL.rise(&ELunpressed);
- EndZ.fall(&EZpressed);
- EndZ.rise(&EZunpressed);
- EndR.fall(&ERpressed);
- EndR.rise(&ERunpressed);
-
+
+ init_ax12();
+ init_interrupt();
wait_ms(100);
- ticker.attach_us(&update_main,dt); // 100 Hz
logger.printf("End init\n\r");
}
