Changed compiler behavior for i2c. I2C library is still broken

- Firmware does still compile correctly when I2C is disabled
This commit is contained in:
pyr0ball 2019-07-19 15:05:17 -07:00
parent 56c06008d4
commit 29fd45db23
2 changed files with 20 additions and 12 deletions

View file

@ -1,16 +1,25 @@
#ifdef I2C_INPUT
#include <Arduino.h>
#include "pP_config.h"
#include "pP_i2c.h"
#include <Wire.h>
pP_i2c::pP_i2c(){
}
void pP_i2c::init() {
Wire.begin(pP_i2c_address)
Wire.begin(pP_i2c_address);
}
void pP_i2c::i2cInput(int bytesReceived) {
for (int a = 0; a < bytesReceived; a++) {
if (a < maxBytes) {
cmdRcvd[a] = Wire.receive();
cmdRcvd[a] = Wire.read();
}
else {
longRcvd[a] = Wire.receive();
longRcvd[a] = Wire.read();
}
}
if (bytesReceived == 1 && (cmdRcvd[0] < regMapSize)) {
@ -22,11 +31,11 @@ void pP_i2c::i2cInput(int bytesReceived) {
}
switch (cmdRcvd[0]) {
case 0x00:
senseInt = (uint8_t) cmdRcvd[1];
senseInt = (long) cmdRcvd[1];
return;
break
break;
case 0x01:
compInt = (uint8_t) cmdRcvd[1];
compInt = (long) cmdRcvd[1];
return;
break;
case 0x02:
@ -53,3 +62,4 @@ void pP_i2c::i2cInput(int bytesReceived) {
return;
}
}
#endif

View file

@ -1,10 +1,7 @@
#ifdef I2C
#ifndef _pP_i2c_h_
#define _pP_i2c_h_
#ifdef I2C_INPUT
#include <Wire.h>
#define pP_i2c_address 0xa0 // I2C Bus Address
#define senseInt_Offset 0x00 // Integer of sense threshold in millivolts
#define compInt_Offset 0x01 // Integer of comparator threshold in millivolts
@ -16,13 +13,14 @@
/*-------------------------Variables------------------------*/
#define regMapSize 7
#define maxBytes 2
uint8_t maxBytes = 2;
#define longBytes 4
byte regMap[regMapSize];
byte regMapTemp[regMapSize];
byte cmdRcvd[maxBytes];
byte longRcvd[longBytes];
/*------------------------------------------------*/
class pP_i2c {
@ -30,7 +28,7 @@ class pP_i2c {
pP_i2c(uint8_t address=pP_i2c_address);
void init();
void i2cInput();
void i2cInput(int bytesReceived);
};
#endif