dhiltonp/hexbright

hexbright.cpp fails to compile on ubuntu 12.04.1 "precise"

eichin opened this issue · 4 comments

Wire.h comes from arduino-core 1:1.0+dfsg-9.

hexbright/libraries/hexbright/hexbright.cpp: In static member function 'static void hexbright::read_accelerometer()':
hexbright/libraries/hexbright/hexbright.cpp:634:28: error: call of overloaded 'write(int)' is ambiguous
/usr/share/arduino/libraries/Wire/Wire.h:55:20: note: candidates are: virtual size_t TwoWire::write(uint8_t)
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h:49:12: note:                 size_t Print::write(const char*)
hexbright/libraries/hexbright/hexbright.cpp:635:31: error: no matching function for call to 'TwoWire::endTransmission(int)'
/usr/share/arduino/libraries/Wire/Wire.h:52:13: note: candidate is: uint8_t TwoWire::endTransmission()
hexbright/libraries/hexbright/hexbright.cpp: In static member function 'static unsigned char hexbright::read_accelerometer(unsigned char)':
hexbright/libraries/hexbright/hexbright.cpp:659:31: error: no matching function for call to 'TwoWire::endTransmission(int)'
/usr/share/arduino/libraries/Wire/Wire.h:52:13: note: candidate is: uint8_t TwoWire::endTransmission()

This diff actually gets it to compile, and is enough to make at least tactical.ino actually work on the hexbright...

diff --git a/libraries/hexbright/hexbright.cpp b/libraries/hexbright/hexbright.cpp
index 0e0eee9..f57e084 100755
--- a/libraries/hexbright/hexbright.cpp
+++ b/libraries/hexbright/hexbright.cpp
@@ -631,8 +631,8 @@ void hexbright::read_accelerometer() {
   next_vector();
   while(1) {
     Wire.beginTransmission(ACC_ADDRESS);
-    Wire.write(ACC_REG_XOUT);          // starting with ACC_REG_XOUT,
-    Wire.endTransmission(false);
+    Wire.write(ACC_REG_XOUT, sizeof(ACC_REG_XOUT));          // starting with ACC_REG_XOUT,
+    Wire.endTransmission();
     Wire.requestFrom(ACC_ADDRESS, 4);  // read 4 registers (X,Y,Z), TILT
     for(int i=0; i<4; i++) {
       if (!Wire.available())
@@ -656,7 +656,7 @@ unsigned char hexbright::read_accelerometer(unsigned char acc_reg) {
   if (!digitalReadFast(DPIN_ACC_INT)) {
     Wire.beginTransmission(ACC_ADDRESS);
     Wire.write(acc_reg);
-    Wire.endTransmission(false);       // End, but do not stop!
+    Wire.endTransmission();       // End, but do not stop!
     Wire.requestFrom(ACC_ADDRESS, 1);
     return Wire.read();
   }

The Arduino package provided by precise is too old. You need to use Arduino 1.0.2 or later.

If I understand correctly, you are running arduino 1.0? I have verified functionality with arduino back to version 1.0.1

Looking at https://launchpad.net/ubuntu/precise/i386/arduino-core and https://launchpad.net/ubuntu/quantal/i386/arduino-core it looks like Precise has 1.0, quantal has 1.0.1, and precise-backports has 1.0.1. Might be worth noting in the top level readme (quantal is current but precise is LTS, ie the long-term-support version.) Thanks.

I've added additional information on linux setup to the main readme.