PT2258 Arduino Library
PT2258.h
Go to the documentation of this file.
1/**
2 @file PT2258.h
3
4 @mainpage PT2258 Arduino Library
5
6 @section author Author
7
8 Created by Marco Lurati, April 21, 2023
9
10 @section license License
11
12 MIT License
13
14 Copyright (c) 2023 marclura
15
16 Permission is hereby granted, free of charge, to any person obtaining a copy
17 of this software and associated documentation files (the "Software"), to deal
18 in the Software without restriction, including without limitation the rights
19 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20 copies of the Software, and to permit persons to whom the Software is
21 furnished to do so, subject to the following conditions:
22
23 The above copyright notice and this permission notice shall be included in all
24 copies or substantial portions of the Software.
25
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 SOFTWARE.
33
34*/
35
36
37#ifndef PT2258_h
38#define PT2258_h
39
40#include <Arduino.h>
41
42/* channel addresses */
43#define PT2258_CLEAR_REGISTER 0b11000000 // 0xC0
44#define PT2258_CHALL_1 0b11100000 // 0xE0
45#define PT2258_CHALL_10 0b11010000 // 0xD0
46#define PT2258_CH3_1 0b00010000 // 0x10
47#define PT2258_CH3_10 0b00000000 // 0x00
48#define PT2258_CH4_1 0b00110000 // 0x30
49#define PT2258_CH4_10 0b00100000 // 0x20
50#define PT2258_CH2_1 0b01010000 // 0x50
51#define PT2258_CH2_10 0b01000000 // 0x40
52#define PT2258_CH5_1 0b01110000 // 0x70
53#define PT2258_CH5_10 0b01100000 // 0x60
54#define PT2258_CH1_1 0b10010000 // 0x90
55#define PT2258_CH1_10 0b10000000 // 0x80
56#define PT2258_CH6_1 0b10110000 // 0xB0
57#define PT2258_CH6_10 0b10100000 // 0xA0
58#define PT2258_CHALL_MUTE 0b11111000 // 0xF8
59
60
61class PT2258 {
62public:
63
64 PT2258(uint8_t address);
65
66 uint8_t begin(void);
67 void attenuation(uint8_t channel, uint8_t attenuation);
68 void attenuationAll(uint8_t attenuation);
69 void volume(uint8_t channel, uint8_t volume);
70 void volumeAll(uint8_t volume);
71 void mute(bool mute);
72
73private:
74 /*!
75 * @param current - IC address
76 */
77 uint8_t address;
78 void PT2258Send(uint8_t a, uint8_t b);
79
80};
81
82
83#endif
Definition: PT2258.h:61
void PT2258Send(uint8_t a, uint8_t b)
Send the datas to the IC.
Definition: PT2258.cpp:228
void volumeAll(uint8_t volume)
Set the volume of all the channels at once.
Definition: PT2258.cpp:201
uint8_t address
Definition: PT2258.h:77
uint8_t begin(void)
Start the I2C communication.
Definition: PT2258.cpp:137
void volume(uint8_t channel, uint8_t volume)
Set the individual channel volume.
Definition: PT2258.cpp:187
void mute(bool mute)
Mute control for all the channels. No matter the volume, the channels will stay silent....
Definition: PT2258.cpp:215
void attenuationAll(uint8_t attenuation)
Set the attenuation of all the channels at once in db.
Definition: PT2258.cpp:172
void attenuation(uint8_t channel, uint8_t attenuation)
Set the individual channel attenuation in db.
Definition: PT2258.cpp:158