pico-scale
scale_adaptor.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2023 Daniel Robertson
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #ifndef SCALE_ADAPTOR_H_49094126_20AB_4B6A_B881_97D7D0DDD91E
24 #define SCALE_ADAPTOR_H_49094126_20AB_4B6A_B881_97D7D0DDD91E
25 
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include "pico/types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 typedef struct scale_adaptor {
35 
39  void* _data;
40 
46  bool (*get_value)(
47  struct scale_adaptor* const sa,
48  int32_t* const value);
49 
57  struct scale_adaptor* const sa,
58  int32_t* const value,
59  const uint timeout);
60 
62 
64  scale_adaptor_t* const sa,
65  void* data);
66 
68  scale_adaptor_t* const sa);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif
void * scale_adaptor_get_data(scale_adaptor_t *const sa)
Definition: scale_adaptor.c:35
bool scale_adaptor_init(scale_adaptor_t *const sa, void *data)
Definition: scale_adaptor.c:27
struct scale_adaptor scale_adaptor_t
bool(* get_value)(struct scale_adaptor *const sa, int32_t *const value)
Function pointer to function.
Definition: scale_adaptor.h:46
bool(* get_value_timeout)(struct scale_adaptor *const sa, int32_t *const value, const uint timeout)
Function pointer to function.
Definition: scale_adaptor.h:56
void * _data
Arbitrary user data.
Definition: scale_adaptor.h:39