aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2019-05-01 09:36:10 -0400
committerClyne Sullivan <tullivan99@gmail.com>2019-05-01 09:36:10 -0400
commit4f8b7f39f5d404a076142b1f62c85eb09df9061d (patch)
tree88fd0fa2c11abc5d10763895bf8914787cadba5c
parentfa8974a5dd710e8352ebde9ade6b9d22eb98b96c (diff)
show object voltage
-rwxr-xr-xmain.c5
-rwxr-xr-xtemp.c5
-rwxr-xr-xtemp.h11
3 files changed, 19 insertions, 2 deletions
diff --git a/main.c b/main.c
index 3cab384..5e678c2 100755
--- a/main.c
+++ b/main.c
@@ -41,11 +41,12 @@ int main(void)
while (1);
}
- char buf[8];
+ char buf[32];
while (1) {
lcdClear();
int16_t temp = tempGetDieTemperature();
- sprintf(buf, "%04d", temp);
+ int16_t vobj = tempGetObjVoltage();
+ sprintf(buf, "T: %4d V: %4d", temp, vobj);
lcdPuts(buf);
delay(1000);
}
diff --git a/temp.c b/temp.c
index e094d6f..e617a58 100755
--- a/temp.c
+++ b/temp.c
@@ -69,6 +69,11 @@ int16_t tempGetDieTemperature(void)
return (raw >> 2) / 32;
}
+int16_t tempGetObjVoltage(void)
+{
+ return tempI2CRead(TMP006_VOBJ);
+}
+
void tempI2CWrite(uint8_t reg, uint16_t value)
{
uint8_t data[3] = {
diff --git a/temp.h b/temp.h
index aec66c9..ab28b84 100755
--- a/temp.h
+++ b/temp.h
@@ -27,6 +27,17 @@
*/
int tempInit(void);
+/**
+ * Gets the object's voltage, which may be used in calculations to get the
+ * object's temperature.
+ * @return The object's voltage
+ */
+int16_t tempGetObjVoltage(void);
+
+/**
+ * Gets the current ambient temperature, in Celsius.
+ * @return The ambient temperature
+ */
int16_t tempGetDieTemperature(void);
#endif // TEMP_H_