Skip to content

Commit c96372d

Browse files
authored
Pr/70 (#77)
* Changed wording in the readme to air quality estimate New address of Timelab ESP32? * i2c dev update * type casting * type casts
1 parent 97dcfd6 commit c96372d

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

README.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
image::https://api.travis-ci.org/timelab/ADEM.svg[alt="Build Status", link="https://travis-ci.org/timelab/ADEM", align="left", float]
55

6-
The http://www.timelab.org/[Timelab] ADEM project enables cyclists to measure particulate matter (PM~1~ and PM~2.5~). The quality based on these measurements are displayed on the device, temporarily stored and sent via WiFi to a central data collection service.
6+
The http://www.timelab.org/[Timelab] ADEM project enables cyclists to measure particulate matter (PM~1~ and PM~2.5~). The air quality estimate based on these measurements is displayed on the device, temporarily stored and sent via WiFi to a central data collection service.
77

88
The aim of this project is to create a low-cost open-source DIY hardware and firmware kit that is modular and adjustable, can be locally reproduced and repaired.
99

adem/libraries/I2Cdev/I2Cdev.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ I2Cdev::I2Cdev() {
100100
* @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout)
101101
* @return Status of read operation (true = success)
102102
*/
103+
103104
int8_t I2Cdev::readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout) {
104105
uint8_t b;
105106
uint8_t count = readByte(devAddr, regAddr, &b, timeout);
@@ -224,12 +225,13 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
224225
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
225226
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
226227
// smaller chunks instead of all at once
227-
for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {
228+
229+
for (uint8_t k = 0; k < length; k += min((int)length, BUFFER_LENGTH)) {
228230
Wire.beginTransmission(devAddr);
229231
Wire.send(regAddr);
230232
Wire.endTransmission();
231233
Wire.beginTransmission(devAddr);
232-
Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH));
234+
Wire.requestFrom(devAddr, (uint8_t)min((int)length - k, BUFFER_LENGTH));
233235

234236
for (; Wire.available() && (timeout == 0 || millis() - t1 < timeout); count++) {
235237
data[count] = Wire.receive();
@@ -248,15 +250,15 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
248250
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
249251
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
250252
// smaller chunks instead of all at once
251-
for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {
253+
for (uint8_t k = 0; k < length; k += min((int)length, BUFFER_LENGTH)) {
252254
Wire.beginTransmission(devAddr);
253255
Wire.write(regAddr);
254256
Wire.endTransmission();
255257
for(int retry_cnt=0; retry_cnt < MAX_RETRY; retry_cnt++)
256258
{
257259
Wire.beginTransmission(devAddr);
258-
uint8_t receive_cnt = Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH));
259-
if (receive_cnt == (uint8_t)min(length - k, BUFFER_LENGTH)){
260+
uint8_t receive_cnt = Wire.requestFrom(devAddr, (uint8_t)min((int)length - k, BUFFER_LENGTH));
261+
if (receive_cnt == (uint8_t)min((int)length - k, BUFFER_LENGTH)){
260262
for (; Wire.available() && (timeout == 0 || millis() - t1 < timeout); count++) {
261263
data[count] = Wire.read();
262264
#ifdef I2CDEV_SERIAL_DEBUG
@@ -292,14 +294,14 @@ int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8
292294
Wire.write(regAddr);
293295
Wire.endTransmission();
294296
// Wire.beginTransmission(devAddr);
295-
uint8_t receive_cnt = Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH));
297+
uint8_t receive_cnt = Wire.requestFrom(devAddr, (uint8_t)min((int)length - k, BUFFER_LENGTH));
296298
#ifdef I2CDEV_SERIAL_DEBUG
297299
Serial.print("received ");
298300
Serial.print(receive_cnt);
299301
Serial.print(" of ");
300302
Serial.print(length);
301303
#endif
302-
if (receive_cnt >= (uint8_t)min(length - k, BUFFER_LENGTH)){
304+
if (receive_cnt >= (uint8_t)min((int)length - k, BUFFER_LENGTH)){
303305
#ifdef I2CDEV_SERIAL_DEBUG
304306
Serial.print(" read data ");
305307
#endif
@@ -382,7 +384,7 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
382384
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
383385
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
384386
// smaller chunks instead of all at once
385-
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
387+
for (uint8_t k = 0; k < length * 2; k += min((int)length * 2, BUFFER_LENGTH)) {
386388
Wire.beginTransmission(devAddr);
387389
Wire.send(regAddr);
388390
Wire.endTransmission();
@@ -415,7 +417,7 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
415417
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
416418
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
417419
// smaller chunks instead of all at once
418-
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
420+
for (uint8_t k = 0; k < length * 2; k += min((int)length * 2, BUFFER_LENGTH)) {
419421
Wire.beginTransmission(devAddr);
420422
Wire.write(regAddr);
421423
Wire.endTransmission();
@@ -448,7 +450,7 @@ int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint1
448450
// I2C/TWI subsystem uses internal buffer that breaks with large data requests
449451
// so if user requests more than BUFFER_LENGTH bytes, we have to do it in
450452
// smaller chunks instead of all at once
451-
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
453+
for (uint8_t k = 0; k < length * 2; k += min((int)length * 2, BUFFER_LENGTH)) {
452454
Wire.beginTransmission(devAddr);
453455
Wire.write(regAddr);
454456
Wire.endTransmission();

adem/libraries/accelero_MPU6050/accelero_MPU6050.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,16 @@ void MPU6050Sensor::read() {
175175
bool MPU6050Sensor::isMoving()
176176
{
177177
long now = measuredData._timestamp;
178-
if ((now - _movingTimestamp) > notmovingDelay)
178+
if ((now - (long) _movingTimestamp) > notmovingDelay)
179179
return false;
180180
else
181-
if (now > _movingTimestamp)
181+
if (now > (long) _movingTimestamp)
182182
return true;
183183
else // we have wrapped around (can it happen ?)
184184
{
185185
// quick and dirty fix.
186186
// if we wrapped around assume lastmoving = now
187-
_movingTimestamp = now;
187+
_movingTimestamp = (unsigned long)now;
188188
}
189189
}
190190

docs/01-getting-started.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Project contact::
1313

1414
....
1515
Timelab vzw
16-
Brusselsepoortstraat 97
16+
Kogelstraat 34
1717
9000 Gent, Belgium
1818
Telephone: +32 9 391 96 10
1919

docs/0a-questions-and-answers.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ We already established that sensor-records will be stored in memory in binary fo
6666
This ensures efficient use of scarce memory, while retaining augmented information to the back-end.
6767

6868
image::http://timelab.github.io/ADEM-Logos/svg/adem_logo-txt_stroke.svg[alt="ADEM logo", link="http://ik-adem.be/", align="right", float]
69+
70+
== Will the project make use of the newer and faster ESP32 ?
71+
72+
The ESP8266 has its limits. We have ran into problems with the amount of RAM and the available number of I/O pins. In the current stage of the project we are using a secondary processor (AVR) as a serial-to-I2C bridge for the GPS. This could probably be eliminated when switching to ESP32.

0 commit comments

Comments
 (0)