summaryrefslogtreecommitdiffstats
path: root/MOST_UNICENS/ucs2-vol/src/device_value.cpp
diff options
context:
space:
mode:
authorTobias Jahnke <tobias.jahnke@microchip.com>2018-10-10 15:52:57 +0200
committerTobias Jahnke <tobias.jahnke@microchip.com>2018-10-12 12:32:24 +0000
commit178a830b8ad85813b7bf0b271be79f3a8d3a6277 (patch)
tree8d31174db1ff79796c91588c2fc47fe1fbdad648 /MOST_UNICENS/ucs2-vol/src/device_value.cpp
parentf938776e3cdeba1375a866e12f66a5b9c4151627 (diff)
Bug-AGL: SPEC-1758 As preparation before introducing UNICENS 4a plugin: - Init volume library at first - Add fiberdyne master volume - Introduce commands sent by control messages - Removes outdated controls - Known issue: turn ALSA volume above "93" to hear some sound Change-Id: I591c6b109a51c9da602ad08514b67c2ec573e09c Signed-off-by: Tobias Jahnke <tobias.jahnke@microchip.com>
Diffstat (limited to 'MOST_UNICENS/ucs2-vol/src/device_value.cpp')
-rw-r--r--MOST_UNICENS/ucs2-vol/src/device_value.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/MOST_UNICENS/ucs2-vol/src/device_value.cpp b/MOST_UNICENS/ucs2-vol/src/device_value.cpp
index 7103192..22b8dfb 100644
--- a/MOST_UNICENS/ucs2-vol/src/device_value.cpp
+++ b/MOST_UNICENS/ucs2-vol/src/device_value.cpp
@@ -32,11 +32,12 @@
#define CONTROL_CH_1 0x08U
#define CONTROL_CH_2 0x09U
-CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key)
+CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key, bool is_i2c)
{
this->_is_available = false;
this->_is_busy = false;
this->_address = address;
+ this->_is_i2c = is_i2c;
this->_target_value = 0x01u;
this->_actual_value = 0x01u;
@@ -49,7 +50,11 @@ CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key)
_tx_payload[0] = CONTROL_MASTER;// 7: master, 8: channel 1, 9: Channel 2
_tx_payload[1] = MUTE_VALUE_HB; //HB:Volume
_tx_payload[2] = MUTE_VALUE_LB; //LB:Volume
- _tx_payload_sz = 3u;
+
+ if (type == DEVICE_VAL_FIBERDYNE_MASTER)
+ _tx_payload_sz = 2u;
+ else
+ _tx_payload_sz = 3u;
}
CDeviceValue::~CDeviceValue()
@@ -60,6 +65,14 @@ void CDeviceValue::ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t t
{
uint16_t tmp = MUTE_VALUE;
+ if (type == DEVICE_VAL_FIBERDYNE_MASTER)
+ {
+ tx_payload[0] = 0x00U;
+ tx_payload[1] = value;
+
+ return;
+ }
+
switch (type)
{
case DEVICE_VAL_LEFT:
@@ -75,7 +88,7 @@ void CDeviceValue::ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t t
tx_payload[0] = CONTROL_CH_2;
break;
default:
- /*std::cerr << "CDeviceValue::ApplyMostValue() error matching incorrect" << std::endl;*/
+ /*std::cerr << "CDeviceValue::ApplyMostValue() error matching incorrect" << std::endl;*/
case DEVICE_VAL_MASTER:
tmp = (uint16_t)(0x100U + 0x2FFU - (0x2FFU * ((int32_t)value) / (0xFFU)));
tx_payload[0] = CONTROL_MASTER;
@@ -97,6 +110,20 @@ bool CDeviceValue::RequiresUpdate()
return false;
}
+bool CDeviceValue::FireControlMessage(lib_most_volume_sendmessage_cb_t sendmsg_fptr)
+{
+ ApplyMostValue(this->_target_value, _type, _tx_payload);
+
+ if (this->_is_available && !this->_is_busy)
+ {
+ sendmsg_fptr(this->_address, 0x100U, _tx_payload, _tx_payload_sz);
+
+ this->_actual_value = this->_target_value;
+ }
+
+ return true;
+}
+
bool CDeviceValue::FireUpdateMessage(lib_most_volume_writei2c_cb_t writei2c_fptr,
lib_most_volume_writei2c_result_cb_t result_fptr,
void *result_user_ptr)