ECE 4180 - Final Project Team / Mbed 2 deprecated WalkieTalkie

Dependencies:   mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Speaker.cpp Source File

Speaker.cpp

00001 #include "Speaker.h"
00002 #define UINT8_MAX 255
00003 
00004 Speaker::Speaker(PinName pin) : _pin(pin), dc(0.67f / 3.3f) {}
00005 
00006 void Speaker::rawWrite(float value) {
00007     _pin = value;
00008 }
00009 
00010 void Speaker::write (uint8_t value) {
00011     float sample = (float)value / UINT8_MAX;
00012     
00013     _pin = sample;
00014 }
00015 
00016 void Speaker::turnOff() {
00017     _pin = 0.0f;
00018 }