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 football_project by
Diff: proto_code.cpp
- Revision:
- 28:8e74ddc4f70f
- Parent:
- 26:40a0c775ff27
- Child:
- 29:ae208b014987
- Child:
- 30:c60b0d52b067
diff -r b7b8a2441353 -r 8e74ddc4f70f proto_code.cpp
--- a/proto_code.cpp Thu Dec 31 17:47:15 2015 +0000
+++ b/proto_code.cpp Sun Jan 03 20:05:15 2016 +0000
@@ -45,15 +45,14 @@
static bool active_cones[NUM_CONES + 1]; // + 1 so we can be 1 based like the cone numbers are
+const static int CONTROL_CONE = 1;
+
#ifdef MASTER
static Mode_t mode = PATTERN;
static patternState_t state_p = IDLE_P;
static inputState_t state_i = IDLE_I;
-#define ADDRESS NODE_ID
#else
State_t state = IDLE;
-#define CONTROL_CONE 1
-#define ADDRESS NODE_ID
#endif
static Message m1 = { 'm',0,2 };
@@ -136,7 +135,7 @@
#ifdef MASTER
static void master_setup()
{
- ta.initialize(ADDRESS);
+ ta.initialize(NODE_ID);
uint16_t sent = 0;
uint16_t lost = 0;
@@ -151,13 +150,16 @@
//ta.beep(100);
int i;
- //for(i=3;i<=3;i++)active_cones[i] = true;
- for(i=1;i<NUM_CONES+1;i++)active_cones[i] = true;
+ for(i = 1; i < NUM_CONES + 1; ++i)
+ {
+ active_cones[i] = false;
+ }
- unsigned long time = 0;
+ unsigned long time = 0;
// pull course sequences from non-volatile memory
- for(uint8_t i=0;i<STATIONS * SEQUENCES;i++){
+ for(uint8_t i = 0; i <STATIONS * SEQUENCES; ++i)
+ {
cone_table[i] = i+1;
mask_table[i] = 1;
time_table[i] = 1000;
@@ -168,7 +170,7 @@
#else
static void slave_setup()
{
- ta.initialize(ADDRESS);
+ ta.initialize(NODE_ID);
ta.beep(250);
}
#endif
@@ -191,6 +193,7 @@
static bool process_next_as_mask = false;
static unsigned long timer;
static State_t last_state = IDLE;
+ static int counter = 0;
if(last_state != state)
{
@@ -211,7 +214,10 @@
if(ta.recieve(m_in))
{
- ta.beep(1000);
+ //ta.beep(1000);
+
+ writeToPhone("got message\r\n");
+
message = m_in->command;
switch(m_in->command)
{
@@ -273,7 +279,7 @@
if(message == 'q')
{ // Quit
- //serial.printf("Clear!\n");
+ writeToPhone("Clear!\r\n");
ta.pulse_off();
ta.mask_color(0xFF0000);
state = IDLE;
@@ -295,7 +301,7 @@
{
m->value = m_in->value;
m->command = 'z';
- m->cone = 3;
+ m->cone = 1;
ta.send(m);
}
@@ -339,6 +345,7 @@
static void master_loop()
{
static Mode_t last_mode = mode;
+ static int counter = 0;
if (last_mode != mode)
{
@@ -944,7 +951,7 @@
if(sound == 2)
{
- if(active_cone == ADDRESS)
+ if(active_cone == NODE_ID)
{
ta.powerup(sound);
}
@@ -1035,20 +1042,19 @@
static void find_cones(void)
{
-#if 1
while(ta.get_buffer_size())
{
ta.spin(); // wait for all messages to leave queue
- }
+ }
ta.beep_off();
uint8_t i;
m->command = 'z';
-
+
lonely = true;
writeToPhone("Finding cones\r\n");
- //for (i=3; i <=3; ++i)
+
for(i = 2; i < NUM_CONES + 1; ++i)
{
active_cones[i] = false;
@@ -1070,7 +1076,7 @@
{
writeToPhone("Find timeout for: %d\r\n", i);
break;
- }
+ }
//ta.spin();
@@ -1079,12 +1085,6 @@
lonely = false;
active_cones[m_in->cone] = true;
- writeToPhone("Reply from: %d\r\n", m_in->cone);
- DEBUG("Reply from cone: ");
- DEBUG("%d",m_in->cone);
- DEBUG(", ");
- DEBUG("%d",delta);
- DEBUG("ms\n");
break;
}
}
@@ -1101,29 +1101,14 @@
}
writeToPhone(")\r\n");
-
- #endif
}
static void printMsAsSeconds(unsigned long number)
{
uint16_t remainder;
- //DEBUG("%d",number/1000);
- //DEBUG(".");
-
remainder = number%1000;
- /*
- if(remainder < 100)
- //DEBUG("0");
-
- if(remainder < 10)
- //DEBUG("0");
-
- //DEBUG("%d",remainder);
- */
-
writeToPhone( "%d.%03d", number/1000, remainder );
}
