updated app-templates
[apps/agl-service-unicens.git] / ucs2-vol / inc / device_container.h
1 /*
2  * libmostvolume example
3  *
4  * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
5  *
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.
10  *
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.
15  *
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/>.
18  *
19  * You may also obtain this software under a propriety license from Microchip.
20  * Please contact Microchip for further information.
21  *
22  */
23
24 #ifndef DEVICECONTAINER_H
25 #define DEVICECONTAINER_H
26
27 #include "device_value.h"
28 #include "libmostvolume.h"
29
30 class CDeviceContainer {
31
32 public:
33     CDeviceContainer();
34     virtual ~CDeviceContainer();
35
36     void AssignService(lib_most_volume_service_cb_t service_fptr, Ucs_Inst_t *ucs_ptr) {_service_fptr = service_fptr; _ucs_inst_ptr = ucs_ptr;}
37
38     void RegisterValues(CDeviceValue** list_pptr, uint16_t list_sz);
39     void SetValue(uint16_t key, uint8_t value);
40     void ClearValues();
41     void Update();
42
43 private:
44     void RequestService(uint16_t timeout);
45     void IncrementProcIndex(void);
46     void HandleI2cResult(Ucs_I2c_Result_t result);
47
48     static void OnI2cResult(Ucs_I2c_Result_t result, void *obj_ptr);
49
50     Ucs_Inst_t *_ucs_inst_ptr;
51     uint16_t _idx_processing;
52     uint16_t _values_sz;
53     CDeviceValue **_values_pptr;
54     bool _tx_busy;
55     bool _service_requested;
56     lib_most_volume_service_cb_t _service_fptr;
57 };
58
59 #endif  /* DEVICECONTAINER_H */
60