2 * libmostvolume example
4 * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * You may also obtain this software under a propriety license from Microchip.
20 * Please contact Microchip for further information.
30 uint32_t devInst; /*instance if multiple devices are using the same group id*/
37 const uint8_t *pPayload;
42 uint32_t devInst; /*instance if multiple devices are using the same group id*/
48 const uint8_t *pPayload;
52 enum DeviceValueType {
53 DEVICE_VAL_MASTER = 0,
61 CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key);
62 virtual ~CDeviceValue();
64 uint16_t GetKey(){return _key;}
65 DeviceValueType GetType(){return _type;} // returns the assigned type
66 void SetValue(uint8_t value){_target_value = value;} // sets desired value
68 bool RequiresUpdate(); // returns true if target is not actual value
69 // returns true if success, false if failed
70 // -> stop transmission
71 bool FireUpdateMessage(void);// fires message & updates actual value
74 void HandleI2cResult(Ucs_I2c_Result_t result);
75 void ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t tx_payload[]);
77 bool _is_initial; // ensure first update
78 DeviceValueType _type; // determines the remote i2c command
79 uint16_t _key; // lookup key
80 uint16_t _address; // target node/group address
81 uint8_t _target_value; // desired value
82 uint8_t _actual_value; // value set and confirmed via network
83 uint8_t _tx_payload[20];
84 uint8_t _tx_payload_sz;
87 #endif /* DEVICEPROPERTY_H */