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.
Dependencies: ds3_si mbed omuni solenoid
Fork of 2017_Robocon_mother by
Diff: main.cpp
- Revision:
- 8:030080071a4a
- Parent:
- 7:c24e61f00404
- Child:
- 9:8fd838e5a0a1
--- a/main.cpp Mon Oct 16 11:12:46 2017 +0000
+++ b/main.cpp Wed Oct 25 08:53:38 2017 +0000
@@ -2,7 +2,7 @@
#include "omuni.h"
#include "solenoid.h"
-//#define DEBUG
+#define DEBUG 0
#define CON_OFFSET 15
@@ -16,19 +16,21 @@
BusOut serialsel(p19,p20,LED1,LED2);
Timer serialtimer;
-Ticker readtimer;
+//Ticker readtimer;
char ConData[2][12];
char offset[4];
+/*
void mbedreset()
{
NVIC_SystemReset();
}
+*/
void GetData()
{
- readtimer.attach(&mbedreset, 1);
+ //readtimer.attach(&mbedreset, 1);
static bool main_flag = 1 ;
if ( con.getc() == 'H' ) {
ConData[0][0] = 'H';
@@ -52,24 +54,27 @@
}
if(main_flag)
{
+ /*
+
offset[0] = ConData[0][1];
offset[1] = ConData[0][2];
offset[2] = ConData[1][1];
offset[3] = ConData[1][2];
+ */
serialtimer.start();
main_flag = 0;
}
- ConData[0][1] -= offset[0];
- ConData[0][2] -= offset[1];
- ConData[1][1] -= offset[2];
- ConData[1][2] -= offset[3];
+ //ConData[0][1] -= offset[0];
+ //ConData[0][2] -= offset[1];
+ //ConData[1][1] -= offset[2];
+ //ConData[1][2] -= offset[3];
if( (char)255 - CON_OFFSET < ConData[1][1] || ConData[1][1] < CON_OFFSET)
ConData[1][1] = 0;
serialtimer.reset();
}
- readtimer.detach();
+ //readtimer.detach();
}
@@ -83,10 +88,7 @@
serialtimer.stop();
serialtimer.reset();
- pc.printf("start\n\n\n\n");
-
while(1){
-
char MotorData[] = {'H', ConData[0][1], ConData[0][2], ConData[1][1], ConData[1][2]};
omu.out(MotorData);
@@ -97,9 +99,11 @@
{
serialsel = ~serialsel;
serialtimer.reset();
+ char MotorReset[] = {'H', 0, 0, 0, 0};
+ omu.out(MotorReset);
}
- #ifdef DEBUG
+ #if DEBUG
for(int i = 0; i < 12; i++)
{
pc.printf("%3d ",ConData[0][i]);
