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 ESDC2014 by
Revision 6:7ab57721c0fb, committed 2014-07-07
- Comitter:
- terryLAI
- Date:
- Mon Jul 07 06:10:11 2014 +0000
- Parent:
- 5:098e6a44bd94
- Commit message:
- wait pwm;
Changed in this revision
--- a/buzzer.cpp Fri Jul 04 16:08:29 2014 +0000
+++ b/buzzer.cpp Mon Jul 07 06:10:11 2014 +0000
@@ -33,17 +33,7 @@
Buzzer::Buzzer(MyDigitalOut* buzzer)
{
this->_buzzer = buzzer;
- ON();
- wait(0.1);
- OFF();
- wait(0.1);
- ON();
- wait(0.1);
- OFF();
- wait(0.1);
- ON();
- wait(0.2);
- OFF();
+ boot();
}
Buzzer::~Buzzer(){}
@@ -88,3 +78,54 @@
time_out.detach();
time_out.attach(this, &Buzzer::check_time_out, TIME_OUT);
}
+
+void Buzzer::target_not_found()
+{
+ ON();
+ wait(0.1);
+ OFF();
+ wait(0.1);
+ ON();
+ wait(0.2);
+ OFF();
+}
+
+
+void Buzzer::boot()
+{
+ ON();
+ wait(0.1);
+ OFF();
+ wait(0.1);
+ ON();
+ wait(0.1);
+ OFF();
+ wait(0.1);
+ ON();
+ wait(0.2);
+ OFF();
+}
+
+
+void Buzzer::take_photo()
+{
+ ON();
+ wait(0.2);
+ OFF();
+}
+
+void Buzzer::notice(uint8_t type)
+{
+ switch (type)
+ {
+ case BUZZER_TARGET_NOT_FOUND:
+ target_not_found();
+ break;
+
+ case BUZZER_TAKE_PHOTO:
+ take_photo();
+ break;
+ }
+}
+
+
--- a/buzzer.h Fri Jul 04 16:08:29 2014 +0000
+++ b/buzzer.h Mon Jul 07 06:10:11 2014 +0000
@@ -32,6 +32,9 @@
#include "define.h"
#include "mbed.h"
+#define BUZZER_TARGET_NOT_FOUND 0x01
+#define BUZZER_TAKE_PHOTO 0x02
+
#define TIME_OUT 20 //8 seconds
class Buzzer
@@ -47,10 +50,15 @@
void check_time_out();
void time_out_init();
+ void notice(uint8_t type);
+ void target_not_found();
+ void take_photo();
private:
MyDigitalOut* _buzzer;
uint8_t flag;
Timeout time_out;
+
+ void boot();
};
#endif
\ No newline at end of file
--- a/communication.cpp Fri Jul 04 16:08:29 2014 +0000
+++ b/communication.cpp Mon Jul 07 06:10:11 2014 +0000
@@ -69,6 +69,7 @@
info_ok_IntelToMbed = 0;
info_ok_MbedToArduino = 0;
+ buzzer_type=0;
_MSB = 0;
@@ -185,7 +186,7 @@
}
check_sum = 0;
- if(_x == STARTER || _x == COMPASS_STARTER)
+ if(_x == STARTER || _x == COMPASS_STARTER || _x == BUZZER_STARTER)
{
state_IntelToMbed++;
forward_msg_buffer[0] = _x;
@@ -263,6 +264,7 @@
{
state_IntelToMbed++;
forward_msg_buffer[4] = _x;
+ buzzer_type = _x;
}
else
{
@@ -511,6 +513,7 @@
}
}
}
+
else if(action_type == 1) //lifter
{
uint32_t pulseCountOld = 0;
@@ -628,6 +631,9 @@
else if(action_type == 4)
{
+
+
+
putByte(BUZZER_STARTER ,1); //1 means IntelToMbed
putByte(0,1); //O
putByte(0,1); //K
@@ -732,4 +738,5 @@
void Communication::clearBuffer()
{
_in = _out = 0;
+ memset(buffer_compass,0,BUFFER_SIZE);
}
\ No newline at end of file
--- a/communication.h Fri Jul 04 16:08:29 2014 +0000
+++ b/communication.h Mon Jul 07 06:10:11 2014 +0000
@@ -92,6 +92,8 @@
int read();
+ uint8_t buzzer_type;
+
private:
void init();
uint8_t* buffer_IntelToMbed;
--- a/main.cpp Fri Jul 04 16:08:29 2014 +0000
+++ b/main.cpp Mon Jul 07 06:10:11 2014 +0000
@@ -76,13 +76,7 @@
else if(com.getInfoOK(0) == 5) //buzzer
{
printf("main(). Buzzer action starting...\r\n");
- buzzer.ON();
- wait(0.1);
- buzzer.OFF();
- wait(0.1);
- buzzer.ON();
- wait(0.2);
- buzzer.OFF();
+ buzzer.notice(com.buzzer_type);
com.ACK(&lifter, &camera_platform);
com.resetInfoOK(0);
com.resetInfoOK(1);
