Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
aareyes
Smart-Battery-Module-Info_For_Arduino
Commits
b9390ddf
Commit
b9390ddf
authored
Mar 12, 2020
by
Armin
Browse files
Version 3.1.1 - Better prints at scanning.
parent
a9565084
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
14 deletions
+31
-14
README.md
README.md
+5
-1
src/SBMInfo/SBMInfo.ino
src/SBMInfo/SBMInfo.ino
+26
-13
No files found.
README.md
View file @
b9390ddf
# [SMB](https://github.com/ArminJo/Smart-Battery-Module-Info_For_Arduino) - Smart Battery Module (Laptop Battery Pack) Info
# [SMB](https://github.com/ArminJo/Smart-Battery-Module-Info_For_Arduino) - Smart Battery Module (Laptop Battery Pack) Info
### Version 3.1
### Version 3.1
.1
[

](https://www.gnu.org/licenses/gpl-3.0)
[

](https://www.gnu.org/licenses/gpl-3.0)
[

](https://github.com/brentvollebregt/hit-counter)
[

](https://github.com/brentvollebregt/hit-counter)
...
@@ -132,4 +132,8 @@ Minutes remaining until empty: 2913 min
...
@@ -132,4 +132,8 @@ Minutes remaining until empty: 2913 min
Average minutes remaining until empty: 2913 min
Average minutes remaining until empty: 2913 min
``
`
``
`
# Revision History
### Version 3.1.1
-
Better prints at scanning.
#### If you find this library useful, please give it a star.
#### If you find this library useful, please give it a star.
src/SBMInfo/SBMInfo.ino
View file @
b9390ddf
...
@@ -2,9 +2,16 @@
...
@@ -2,9 +2,16 @@
* SBMInfo.ino
* SBMInfo.ino
* Shows Smart Battery Info
* Shows Smart Battery Info
*
*
* Copyright (C) 2016 Armin Joachimsmeyer
* Copyright (C) 2016
-2020
Armin Joachimsmeyer
* armin.joachimsmeyer@gmail.com
* armin.joachimsmeyer@gmail.com
*
*
* https://github.com/ArminJo/Smart-Battery-Module-Info_For_Arduino
*
* SBMInfo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...
@@ -24,7 +31,12 @@
...
@@ -24,7 +31,12 @@
#define LCD_COLUMNS 20
#define LCD_COLUMNS 20
#define LCD_ROWS 4
#define LCD_ROWS 4
#define VERSION_EXAMPLE "3.1"
#define VERSION_EXAMPLE "3.1.1"
/*
* Version 3.1.1 - 3/2020
* - Better prints at scanning.
*/
//#define DEBUG
//#define DEBUG
/*
/*
...
@@ -198,13 +210,15 @@ void setup() {
...
@@ -198,13 +210,15 @@ void setup() {
/*
/*
* Check for I2C device and blink until device attached
* Check for I2C device and blink until device attached
*/
*/
if
(
!
checkForAttachedI2CDevice
(
SBM_DEVICE_ADDRESS
))
{
if
(
checkForAttachedI2CDevice
(
SBM_DEVICE_ADDRESS
))
{
int
tDeviceAttached
;
sI2CDeviceAddress
=
SBM_DEVICE_ADDRESS
;
}
else
{
Serial
.
println
(
F
(
"Start scanning for device at I2C bus"
));
do
{
do
{
t
DeviceA
ttached
=
scanForAttachedI2CDevice
();
sI2C
DeviceA
ddress
=
scanForAttachedI2CDevice
();
delay
(
500
);
delay
(
500
);
TogglePin
(
LED_BUILTIN
);
TogglePin
(
LED_BUILTIN
);
}
while
(
t
DeviceA
ttached
<
0
);
}
while
(
sI2C
DeviceA
ddress
<
0
);
}
}
uint16_t
tVoltage
;
uint16_t
tVoltage
;
...
@@ -256,22 +270,23 @@ void TogglePin(uint8_t aPinNr) {
...
@@ -256,22 +270,23 @@ void TogglePin(uint8_t aPinNr) {
bool
checkForAttachedI2CDevice
(
uint8_t
aStandardDeviceAddress
)
{
bool
checkForAttachedI2CDevice
(
uint8_t
aStandardDeviceAddress
)
{
Wire
.
beginTransmission
(
aStandardDeviceAddress
);
Wire
.
beginTransmission
(
aStandardDeviceAddress
);
uint8_t
t
OK
=
Wire
.
endTransmission
();
uint8_t
t
RetCode
=
Wire
.
endTransmission
();
if
(
t
OK
==
0
)
{
if
(
t
RetCode
==
0
)
{
Serial
.
print
(
F
(
"Found attached I2C device at 0x"
));
Serial
.
print
(
F
(
"Found attached I2C device at 0x"
));
Serial
.
println
(
aStandardDeviceAddress
,
HEX
);
Serial
.
println
(
aStandardDeviceAddress
,
HEX
);
Serial
.
flush
();
Serial
.
flush
();
sI2CDeviceAddress
=
SBM_DEVICE_ADDRESS
;
return
true
;
return
true
;
}
else
{
}
else
{
Serial
.
print
(
F
(
"Transmission error code="
));
Serial
.
print
(
F
(
"Transmission error code="
));
Serial
.
println
(
tOK
);
Serial
.
print
(
tRetCode
);
Serial
.
print
(
F
(
" while looking for device at default address 0x"
));
Serial
.
println
(
aStandardDeviceAddress
,
HEX
);
return
false
;
return
false
;
}
}
}
}
int
sScanCount
=
0
;
int
scanForAttachedI2CDevice
(
void
)
{
int
scanForAttachedI2CDevice
(
void
)
{
int
sScanCount
=
0
;
int
tFoundAdress
=
-
1
;
int
tFoundAdress
=
-
1
;
for
(
uint8_t
i
=
0
;
i
<
127
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
127
;
i
++
)
{
Wire
.
beginTransmission
(
i
);
Wire
.
beginTransmission
(
i
);
...
@@ -286,7 +301,6 @@ int scanForAttachedI2CDevice(void) {
...
@@ -286,7 +301,6 @@ int scanForAttachedI2CDevice(void) {
Serial
.
print
(
F
(
"Scan found no attached I2C device - "
));
Serial
.
print
(
F
(
"Scan found no attached I2C device - "
));
Serial
.
println
(
sScanCount
);
Serial
.
println
(
sScanCount
);
myLCD
.
setCursor
(
0
,
3
);
myLCD
.
setCursor
(
0
,
3
);
// print the number of seconds since reset:
myLCD
.
print
(
"Scan for device "
);
myLCD
.
print
(
"Scan for device "
);
myLCD
.
print
(
sScanCount
);
myLCD
.
print
(
sScanCount
);
sScanCount
++
;
sScanCount
++
;
...
@@ -294,7 +308,6 @@ int scanForAttachedI2CDevice(void) {
...
@@ -294,7 +308,6 @@ int scanForAttachedI2CDevice(void) {
// clear LCD line
// clear LCD line
myLCD
.
setCursor
(
0
,
3
);
myLCD
.
setCursor
(
0
,
3
);
myLCD
.
print
(
" "
);
myLCD
.
print
(
" "
);
sI2CDeviceAddress
=
tFoundAdress
;
}
}
return
tFoundAdress
;
return
tFoundAdress
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment