MAX17048_HelloWorld chages with SDA SCL pins changes for STM32F401RE NUCLIO
Fork of MAX17048_HelloWorld by
main.cpp@10:0bb44b369624, 2018-03-07 (annotated)
- Committer:
- Harshal93
- Date:
- Wed Mar 07 11:36:09 2018 +0000
- Revision:
- 10:0bb44b369624
- Parent:
- 6:20e76649ba57
Battery_status
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
neilt6 | 0:54ca3b1d1f75 | 1 | #include "mbed.h" |
neilt6 | 0:54ca3b1d1f75 | 2 | #include "MAX17048.h" |
neilt6 | 0:54ca3b1d1f75 | 3 | |
Harshal93 | 10:0bb44b369624 | 4 | MAX17048 gauge(PB_9, PB_8); |
neilt6 | 0:54ca3b1d1f75 | 5 | |
neilt6 | 1:d098c4448f6d | 6 | int main() |
neilt6 | 1:d098c4448f6d | 7 | { |
neilt6 | 1:d098c4448f6d | 8 | //Try to open the MAX17048 |
neilt6 | 1:d098c4448f6d | 9 | if (gauge.open()) { |
neilt6 | 1:d098c4448f6d | 10 | printf("Device detected!\n"); |
neilt6 | 0:54ca3b1d1f75 | 11 | |
neilt6 | 6:20e76649ba57 | 12 | //Load the default compensation value |
neilt6 | 6:20e76649ba57 | 13 | gauge.compensation(MAX17048::RCOMP0); |
neilt6 | 6:20e76649ba57 | 14 | |
neilt6 | 1:d098c4448f6d | 15 | while (1) { |
neilt6 | 3:2152dd143ba3 | 16 | //Print the current state of charge |
neilt6 | 3:2152dd143ba3 | 17 | printf("SOC = %f%%\n", (float)gauge); |
neilt6 | 1:d098c4448f6d | 18 | |
neilt6 | 1:d098c4448f6d | 19 | //Sleep for 0.5 seconds |
neilt6 | 1:d098c4448f6d | 20 | wait(0.5); |
neilt6 | 1:d098c4448f6d | 21 | } |
neilt6 | 1:d098c4448f6d | 22 | } else { |
neilt6 | 3:2152dd143ba3 | 23 | error("Device not detected!\n"); |
neilt6 | 0:54ca3b1d1f75 | 24 | } |
neilt6 | 0:54ca3b1d1f75 | 25 | } |