-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathads1x15.go
executable file
·81 lines (67 loc) · 1.67 KB
/
ads1x15.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2016-2018
All Rights Reserved
Documentation http://djthorpe.github.io/gopi/
For Licensing and Usage information, please see LICENSE.md
*/
package sensors
import (
// Frameworks
"github.com/djthorpe/gopi"
)
////////////////////////////////////////////////////////////////////////////////
// INTERFACES - ADS1X15 Analog to Digital Convertors
// Note this driver is still in development
type ADS1X15 interface {
gopi.Driver
// Return product
Product() ADS1X15Product
}
type ADS1015 interface {
ADS1X15
}
type ADS1115 interface {
ADS1X15
}
type ADS1X15Product uint
type ADS1X15Rate uint16
////////////////////////////////////////////////////////////////////////////////
// CONSTANTS
const (
ADS1X15_PRODUCT_NONE ADS1X15Product = iota
ADS1X15_PRODUCT_1015 // 12-bit ADC with 4 channels
ADS1X15_PRODUCT_1115 // 16-bit ADC with 4 channels
ADS1X15_PRODUCT_MAX = ADS1X15_PRODUCT_1115
)
const (
ADS1X15_RATE_NONE ADS1X15Rate = iota
ADS1X15_RATE_8
ADS1X15_RATE_16
ADS1X15_RATE_32
ADS1X15_RATE_64
ADS1X15_RATE_128
ADS1X15_RATE_250
ADS1X15_RATE_475
ADS1X15_RATE_490
ADS1X15_RATE_860
ADS1X15_RATE_920
ADS1X15_RATE_1600
ADS1X15_RATE_2400
ADS1X15_RATE_3300
ADS1X15_RATE_MAX = ADS1X15_RATE_3300
)
////////////////////////////////////////////////////////////////////////////////
// STRINGIFY
func (p ADS1X15Product) String() string {
switch p {
case ADS1X15_PRODUCT_NONE:
return "ADS1X15_PRODUCT_NONE"
case ADS1X15_PRODUCT_1015:
return "ADS1X15_PRODUCT_1015"
case ADS1X15_PRODUCT_1115:
return "ADS1X15_PRODUCT_1115"
default:
return "[?? Invalid ADS1X15Product]"
}
}