Utilities classes for the Zumo Robot

Dependents:   ZumoRobotBluetoothControlled Fsl_Zumo

This library represents some useful code for controlling your Zumo Robot.

Committer:
catalincraciun7
Date:
Thu Nov 27 16:08:05 2014 +0000
Revision:
4:dcd52a961392
Child:
5:5e12111ef01f
Minor changes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
catalincraciun7 4:dcd52a961392 1 // Craciun Catalin
catalincraciun7 4:dcd52a961392 2 // Buzzer.cpp
catalincraciun7 4:dcd52a961392 3 // © 2014 Catalin Craciun
catalincraciun7 4:dcd52a961392 4
catalincraciun7 4:dcd52a961392 5 #ifndef BuzzerCpp
catalincraciun7 4:dcd52a961392 6 #define BuzzerCpp
catalincraciun7 4:dcd52a961392 7
catalincraciun7 4:dcd52a961392 8 #include "Buzzer.h"
catalincraciun7 4:dcd52a961392 9
catalincraciun7 4:dcd52a961392 10 Buzzer::Buzzer(PinName buzzerPinName):buzzerPin(buzzerPinName) {
catalincraciun7 4:dcd52a961392 11
catalincraciun7 4:dcd52a961392 12 // Initialising
catalincraciun7 4:dcd52a961392 13 buzzerPin.write(0.0f);
catalincraciun7 4:dcd52a961392 14 }
catalincraciun7 4:dcd52a961392 15
catalincraciun7 4:dcd52a961392 16 Buzzer::~Buzzer() {
catalincraciun7 4:dcd52a961392 17
catalincraciun7 4:dcd52a961392 18 // Deinitialising
catalincraciun7 4:dcd52a961392 19 }
catalincraciun7 4:dcd52a961392 20
catalincraciun7 4:dcd52a961392 21 void Buzzer::stopBeep() {
catalincraciun7 4:dcd52a961392 22
catalincraciun7 4:dcd52a961392 23 buzzerPin.write(0.0f);
catalincraciun7 4:dcd52a961392 24 }
catalincraciun7 4:dcd52a961392 25
catalincraciun7 4:dcd52a961392 26 void Buzzer::startBeep(float frequency, float duration) {
catalincraciun7 4:dcd52a961392 27
catalincraciun7 4:dcd52a961392 28 buzzerPin.period(1/frequency);
catalincraciun7 4:dcd52a961392 29 buzzerPin.write(0.75f);
catalincraciun7 4:dcd52a961392 30 timeout.attach(this, &Buzzer::stopBeep, duration);
catalincraciun7 4:dcd52a961392 31 }
catalincraciun7 4:dcd52a961392 32
catalincraciun7 4:dcd52a961392 33 #endif // BuzzerCpp