After much exhaustive work I have put a new Hannah class online. It detects and supports both rev2 and rev3 (the temperature sensor and accelerometers are different) and all components are coded for in a mostly uniform way. I have some cleaning up to do, lots of documentation to add and I want to include some code for battery saving shallow sleep, but for now, it is there for you to enjoy.
You may or may not like the way I have added the event handlers and I may change that at some stage, but this only affects the example “application” not the individual device classes.
I now like Hannah again
After having a quick look, I can only say: "WOW"
Thanks a lot!
I should fess up … Tom and Brandon wrote the main GPIO and SX150x classes and did an amazing job. The other classes were all in various forms all over the place. I really just assembled them and standardised them.
Designed in China, assembled in California? I think not!
Thank you very much!
I just got my hannah board and tested it using your example - my potentiometer only returns values between 0.044 and 0.046 (after removing the scaling - with scaling it returns 4 or 5). I’m afraid it’s broken, it moves without much resistance. Before I go complain (likely to be futile anyways) - is there any chance your code misinterprets any readings?
I have a Rev3 board, so a quick “code works for me” or “code is broken” would help much
Sounds like you might have a hardware problem. But I haven’t got much experience in diagnosing pot problems, being a software developer. Someone else out there might have some more experience. Having said that, on my rev3 … the “code works for me”.
Thanks Aron, much appreciated.
I just pushed a fix and a new feature to the Servo class. Nothing changed in the pot class other than to confirm again it works in both rev2 and rev3.
when I load your revision on a rev3 I still get this error:
2014-01-08 23:19:03 UTC+1: [Device] ERROR: The device at I2C address 0x38 is not a LIS331DL accelerometer. 2014-01-08 23:19:03 UTC+1: [Device] ERROR: The device at I2C address 0x98 is not a SA5004X temperature sensor.
This is what I would expect on a rev3 - the SA5004X temperature sensor is found in a rev2 (rev3 uses TMP112) and the rev2 accelerometer is the LIS331DL (while the rev3 is LIS3DH)
for example, the block starting at line 1410 attempts to initialize rev2 - which is bound to fail on a rev3 board, hence the error - and when rev2 failed to initialize, it uses rev3 handling (and doesn’t bother if that would fail too)
// Accelerometer on i2c port 0x38 or 0x30 with alert in pin on IO pin 3 acc = Accelerometer_rev2(i2c, 0x38, ioexp, 3); if (acc._disabled) acc = Accelerometer_rev3(i2c, 0x30, ioexp, 3); acc.alert(call_callback("on_acc_changed"));
If the errors annoy you, only use the rev3 initialisation:
// Accelerometer on i2c port 0x38 or 0x30 with alert in pin on IO pin 3 //acc = Accelerometer_rev2(i2c, 0x38, ioexp, 3); //if (acc._disabled) acc = Accelerometer_rev3(i2c, 0x30, ioexp, 3); acc = Accelerometer_rev3(i2c, 0x30, ioexp, 3); acc.alert(call_callback("on_acc_changed"));
This goes very similar for temperature sensor at line 1415.
My issue was a hardware problem and a replacement unit is on its way
That is correct. The error is intentional and if you don’t like it you can either comment it out or remove all reference to the hardware you don’t have.
thanks, I found the solution.
I only don’t understand this line:
if (acc._disabled) acc = Accelerometer_rev3(i2c, 0x30, ioexp, 3); because it never executes…
If does if you have a rev3. If you have a rev3 the rev2 accelerometer isn’t present so the object gets disabled.
Does the rev2 accelerometer run?
Then that code does execute as its the only place the rev3 accelerometer is instantiated
in the hannah class constructor I changed this line:
acc = Accelerometer_rev2(i2c, 0x38, ioexp, 3);
acc = Accelerometer_rev3(i2c, 0x30, ioexp, 3);
Well that changes everything
The second instantiation is then redundant and you can delete it.
I know, but I wanted to keep as much as possible, just for reference.
Thanks again, for this impressive piece of work!