Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SX1276GenericLib USBDevice
Fork of NonPingPong_PICO_LoRa_LP0 by
Diff: AO32Lib/AO32_lib.cpp
- Revision:
- 5:9e751733a6f3
- Parent:
- 3:85fc843a9d7d
--- a/AO32Lib/AO32_lib.cpp Mon Oct 12 21:56:39 2020 +0000
+++ b/AO32Lib/AO32_lib.cpp Tue Oct 13 00:45:46 2020 +0000
@@ -119,7 +119,8 @@
int error = AO32_read_register(i2c, I2C_add, AO32_HARV_H, data, 2); // burst read AO32_HARV_H and AO32_HARV_L
// Calculate harvesting counts from data
- countHi = int(data[0] << 8); // might cause trouble, * 256 instead?
+// countHi = int(data[0] << 8); // might cause trouble, * 256 instead?
+ countHi = int(data[0]) * 256;
countLo = int(data[1]);
counts = countHi + countLo;
@@ -129,35 +130,24 @@
return resp;
}
-
-//******************************************************************************
-// get_luxvalue(char) read lux value from AO32 device register
-// char I2C address
-// returns LuxResponse luxValue = light intensity in lux
-// status = register read result
-//******************************************************************************
+double calc_OCV(char *data) {
+
+ // data is an array of size 2, only needs the first byte
+
+ double voltage = (double)(data[0]) / 100;
+
+ return voltage;
+
+}
-//LuxResponse get_luxvalue(I2C *i2c, char I2C_add){
-// char data[2]; // 2 bytes of raw Lux Register
-// double lux;
-//// int count;
-//
-// // Read lux value, 2 bytes
-// int error = AO32_read_lux_register(i2c, I2C_add, AO32_LUX_HI, data);
-//
-// //calculate lux from data
-//// count = (int)(data[0]*256 + data[1]);
-//// if (count >= 32768)count = count - 65536; // 2s comp
-//// T = (double)count*0.005;
-//
-// int exponent;
-// int mantissa;
-// exponent = data[0] >> 4;
-// mantissa = (data[0] << 4) + data[1];
-// lux = 0.045 * mantissa * pow(2, exponent);
-//
-// LuxResponse resp;
-// resp.luxValue = lux;
-// resp.status = error; // 1 for nack/error. 0 for ack/success
-// return resp;
-//}
\ No newline at end of file
+int calc_Harvest(char *data) {
+
+ // data is an array of size 2
+
+ int countHi = int(data[0]) * 256;
+ int countLo = int(data[1]);
+ int harvest_counts = countHi + countLo;
+
+ return harvest_counts;
+
+}
\ No newline at end of file
