GY-63_MS5611/libraries/PT2314/PT2314.h

120 lines
2.5 KiB
C
Raw Normal View History

2023-07-31 13:23:13 -04:00
#pragma once
//
// FILE: PT2314.h
// AUTHOR: Rob Tillaart
// DATE: 2023-07-30
2023-12-08 11:20:42 -05:00
// VERSION: 0.2.0
2023-07-31 13:23:13 -04:00
// PURPOSE: Arduino library for PT2314 i2C 4 channel audio processor.
// URL: https://github.com/RobTillaart/PT2314
#include "Arduino.h"
#include "Wire.h"
2023-12-08 11:20:42 -05:00
#define PT2314_LIB_VERSION (F("0.2.0"))
2023-07-31 13:23:13 -04:00
class PT2314
{
public:
PT2314(TwoWire *wire = &Wire);
bool begin();
bool isConnected();
// AUDIO
void setChannel(uint8_t channel = 0); // 0..3
uint8_t getChannel();
void setMute(bool on = true);
bool getMute();
void setLoudness(bool on = true);
bool getLoudness();
void setVolume(uint8_t volume = 0); // 0..63
uint8_t getVolume();
void setBass(int8_t bass = 0); // -14..14
int8_t getBass();
void setTreble(int8_t treble = 0); // -14..14
int8_t getTreble();
2023-09-24 11:31:03 -04:00
2023-12-08 11:20:42 -05:00
// GAIN
2023-07-31 13:23:13 -04:00
void setGain(uint8_t gain = 0); // 0..3
uint8_t getGain();
2023-12-08 11:20:42 -05:00
// ATTENUATION
2023-07-31 13:23:13 -04:00
void setAttnLeft(uint8_t value = 31); // 0..31
uint8_t getAttnLeft();
void setAttnRight(uint8_t value = 31); // 0..31
uint8_t getAttnRight();
2023-12-08 11:20:42 -05:00
// set all to same level
void setAttn(uint8_t attn);
2023-07-31 13:23:13 -04:00
protected:
void write(const uint8_t value);
void updateAudioRegister();
TwoWire *_wire;
uint8_t _address = 0x44;
uint8_t _channel = 0;
bool _mute = false;
bool _loudness = false;
uint8_t _volume = 0;
int8_t _bass = 0;
int8_t _treble = 0;
uint8_t _gain = 0;
uint8_t _attnLeft = 0;
uint8_t _attnRight = 0;
// to be elaborated.
int _error = 0;
};
2023-12-08 11:20:42 -05:00
2023-07-31 13:23:13 -04:00
///////////////////////////////////////////////////////////////
//
// DERIVED
//
class PT7314 : public PT2314
{
public:
PT7314(TwoWire *wire = &Wire);
};
2023-08-01 11:07:32 -04:00
// 3 input 2 output version
class PT7313 : public PT2314
{
public:
PT7313(TwoWire *wire = &Wire);
2023-09-24 11:31:03 -04:00
2023-08-01 11:07:32 -04:00
void setMute(bool on);
void setChannel(uint8_t channel = 0); // 0..2
2023-09-24 11:31:03 -04:00
2023-12-08 11:20:42 -05:00
// BACK
2023-08-01 11:07:32 -04:00
void setAttnLeftBack(uint8_t value = 31); // 0..31
uint8_t getAttnLeftBack();
void setAttnRightBack(uint8_t value = 31); // 0..31
uint8_t getAttnRightBack();
2023-12-08 11:20:42 -05:00
// FRONT
2023-08-01 11:07:32 -04:00
void setAttnLeftFront(uint8_t value = 31); // 0..31
uint8_t getAttnLeftFront();
void setAttnRightFront(uint8_t value = 31); // 0..31
uint8_t getAttnRightFront();
2023-12-08 11:20:42 -05:00
// ALL
void setAttn(uint8_t attn);
2023-08-01 11:07:32 -04:00
protected:
uint8_t _attnLeftFront = 0;
uint8_t _attnRightFront = 0;
};
2023-07-31 13:23:13 -04:00
// -- END OF FILE --