-
Notifications
You must be signed in to change notification settings - Fork 7
/
dell_psu.h
47 lines (35 loc) · 1.05 KB
/
dell_psu.h
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
/*
Copyright (c) 2017, Tim Jager
This library reads data from a Dell laptop power supply using 1 wire protocol
MIT license, check license.txt for more information
*/
#ifndef dell_psu_h
#define dell_psu_h
//this library requires the OneWire library (https://github.com/PaulStoffregen/OneWire)
#include <OneWire.h>
//we try to read up to x bytes from the device (17 bytes is the minimum to extract the power supply wattage, voltage, & amps
#define DELL_PSU_BYTES_TO_READ 17
class DellPSU
{
private:
uint16_t _watts = 0;
uint16_t _millivolts = 0;
uint16_t _milliamps = 0;
OneWire _onewire;
char _resp[DELL_PSU_BYTES_TO_READ];
public:
DellPSU(uint8_t pin);
//Determine if a device is present, return true on success
boolean psu_detected(void);
//Read the data stream from the psu, return true on success
boolean read_data(void);
//get the watts
uint16_t watts(void);
//get the millivolts
uint16_t millivolts(void);
//get the milliamps
uint16_t milliamps(void);
//get the raw response char array
char *raw_response(void);
};
#endif