ECE 4180 - Final Project Team / Mbed 2 deprecated WalkieTalkie

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

Speaker.cpp

Committer:
Nurchu
Date:
2018-04-25
Revision:
33:5d86c111d9bc
Parent:
20:e068469ffb89

File content as of revision 33:5d86c111d9bc:

#include "Speaker.h"
#define UINT8_MAX 255

Speaker::Speaker(PinName pin) : _pin(pin), dc(0.67f / 3.3f) {}

void Speaker::rawWrite(float value) {
    _pin = value;
}

void Speaker::write(uint8_t value) {
    float sample = (float)value / UINT8_MAX;
    
    _pin = sample;
}

void Speaker::turnOff() {
    _pin = 0.0f;
}