Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMUMonitorPage added #89

Merged
merged 71 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
bd9cb0c
Netbeans project folder added
ronzeiller Dec 9, 2017
ab7ccfb
initial commit with some settings for IMUService & IMUMonitorPage
ronzeiller Dec 9, 2017
9fc5355
initial commit with some settings for IMUService & IMUMonitorPage
ronzeiller Dec 9, 2017
9cc6d2e
Start of simplified IMUMonitorPage
ronzeiller Dec 9, 2017
1e183f4
Start of simplified IMUMonitorPage
ronzeiller Dec 9, 2017
e9ad204
include KBoxConfig, IMUMonitorPage, settings for service intervals
ronzeiller Dec 9, 2017
14a7546
MagHdg and heel/pitch update separated to diff. calibration settings
ronzeiller Dec 9, 2017
7898cb9
Some functions added for IMUMonitorPage
ronzeiller Dec 11, 2017
e9b4cea
Some functions added for the IMUMonitorPage
ronzeiller Dec 11, 2017
b67754c
more defines, passing a reference to IMUService for IMUMonitorPage
ronzeiller Dec 11, 2017
f041061
reference to IMUService added
ronzeiller Dec 11, 2017
de083c1
getLastValues from IMUService added
ronzeiller Dec 11, 2017
d11d220
KBoxConfig moved to src/common/config, 2 more service-defines added
ronzeiller Dec 11, 2017
db7fa77
extended with button long click for offset-to-zero of heel/pitch
ronzeiller Dec 11, 2017
100a6d4
extended with button long click for offset-to-zero of heel/pitch
ronzeiller Dec 11, 2017
24b5ec4
make write8() public to access from IMUService
ronzeiller Dec 11, 2017
1229eb4
axis- and sign remapping cancelled here as made on start of IMUService
ronzeiller Dec 11, 2017
f45d445
ButtonEvent LongClick added, default for switch page is Click now
ronzeiller Dec 11, 2017
91f52d2
changed to ButtonEventTypeClick for switching patches
ronzeiller Dec 11, 2017
a58f66e
Long Button press for setOffset in IMUService implemented
ronzeiller Dec 11, 2017
0f883bd
Long button click added
ronzeiller Dec 11, 2017
65add4f
Long button click added
ronzeiller Dec 11, 2017
6948ccf
setOffset, recall and saveCalibration, axis & sign setting added
ronzeiller Dec 11, 2017
7b61c06
setOffset, recall and saveCalibration, axis & sign setting added
ronzeiller Dec 11, 2017
48fe0a3
debug msg commented out
ronzeiller Dec 11, 2017
1bcc7a3
Merge remote-tracking branch 'upstream/master' into rz_imu-page
ronzeiller Dec 11, 2017
644643a
put back to original + overload begin function for KBox mounting
ronzeiller Dec 14, 2017
f67950a
restore original + overload begin function for KBox mounting
ronzeiller Dec 14, 2017
b1b4552
Axis & Sign config now in bno055.begin function
ronzeiller Dec 14, 2017
0eb4e27
restore to original (w/o config) just new IMUPage added
ronzeiller Dec 14, 2017
dd57cd3
original restored w/o config settings, just IMUPage added
ronzeiller Dec 14, 2017
098756f
settings now private, w/o config file, all angle values radians
ronzeiller Dec 14, 2017
1e23958
settings now private, w/o config file, all angle values radians
ronzeiller Dec 14, 2017
841c3de
settings now private, w/o config file, all angle values radians
ronzeiller Dec 14, 2017
94e5f17
settings now private, w/o config file, all angle values radians
ronzeiller Dec 14, 2017
0e0f54e
KBoxConfig deleted as it will come in another PR
ronzeiller Dec 14, 2017
35e1662
back to Sarfatas BNO055 library but with extended begin() function
ronzeiller Dec 14, 2017
55f0e11
back to Sarfatas BNO055 library but with extended begin() function
ronzeiller Dec 14, 2017
6f3652c
removed unnecessary include
ronzeiller Dec 14, 2017
7c7f608
extra lines removed
ronzeiller Dec 14, 2017
406aee7
moved #include here
ronzeiller Dec 14, 2017
add7009
Removed bug in calculating offset, some comments added
ronzeiller Dec 14, 2017
16d732a
NaN for not available values in N2k and SKUpdate
ronzeiller Dec 27, 2017
7ff16fc
TODO deleted as SDIO has no sdcard_cs
ronzeiller Dec 29, 2017
ab61dcc
more config for IMU-sensor added
ronzeiller Dec 29, 2017
51247f0
more IMU-sensor config settings
ronzeiller Dec 29, 2017
ab5b665
netbeans added
ronzeiller Dec 29, 2017
ef4e46a
some corrections for new config
ronzeiller Dec 29, 2017
d9311b5
correction for new config
ronzeiller Dec 29, 2017
5082ee0
Merge branch 'rz_more-config' into rz_imu-page
ronzeiller Dec 29, 2017
fe6c5cf
IMUMonitorPage if IMU enabled, imuConfig added
ronzeiller Dec 29, 2017
f37782a
IMUConfig for settings of IMU-cal values added
ronzeiller Dec 29, 2017
8e03c94
IMUConfig for settings of IMU-cal values added
ronzeiller Dec 29, 2017
2c0b16f
IMUConfig for settings of IMU-cal values added
ronzeiller Dec 29, 2017
d68ec3d
IMUConfig for settings of IMU-cal values added
ronzeiller Dec 29, 2017
cc71273
config for different KBox mounting positions added
ronzeiller Dec 30, 2017
621c5d0
ident to tab 2
ronzeiller Dec 31, 2017
a818895
small corrections, config for mounting
ronzeiller Dec 31, 2017
4edf570
indent corrected
ronzeiller Jan 1, 2018
fe3ee96
Merge branch 'rz_imu-page' of https://github.com/ronzeiller/kbox-firm…
ronzeiller Jan 1, 2018
cb01893
indention corrected
ronzeiller Jan 1, 2018
f2aa14d
indent corrected, not used function deleted
ronzeiller Jan 1, 2018
333242e
indent corrected, not used function deleted
ronzeiller Jan 1, 2018
69007d2
IMU calibration values deleted from config
ronzeiller Jan 1, 2018
03c048c
IMU calibration values deleted from config
ronzeiller Jan 1, 2018
dc36c58
IMU calibration values deleted from config
ronzeiller Jan 1, 2018
2c87d62
IMU calibration values deleted from config
ronzeiller Jan 1, 2018
019d7e7
put back updateReceived due to error message....
ronzeiller Jan 1, 2018
2be63c3
put back updateReceived due to error message....
ronzeiller Jan 1, 2018
2abe954
not needed debug msg deleted
ronzeiller Jan 1, 2018
9b18505
prevent overflow by setOffset
ronzeiller Jan 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Network Trash Folder
Temporary Items
.apdisk

# Netbeans project folder
nbproject

# Platformio likes to auto-create this
lib/readme.txt
CMakeListsPrivate.txt
Expand Down
7 changes: 5 additions & 2 deletions extras/config/default-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"imu": {
"enabled": true,
"frequency": 20
"frequency": 20,
"enableHdg": true,
"enableHeelPitch": true,
"calHdg": 3,
"calHeelPitch": 2
},
"barometer": {
"enabled": true,
Expand Down Expand Up @@ -49,4 +53,3 @@
"rxEnabled": true
}
}

23 changes: 9 additions & 14 deletions lib/Adafruit_BNO055/Adafruit_BNO055.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,14 @@ Adafruit_BNO055::Adafruit_BNO055(int32_t sensorID, uint8_t address)
PUBLIC FUNCTIONS
***************************************************************************/


/**************************************************************************/
/*!
@brief Sets up the HW
Sets up the IMU Sensor for KBox, including axis- and sign mapping
*/
/**************************************************************************/
bool Adafruit_BNO055::begin(adafruit_bno055_opmode_t mode)
bool Adafruit_BNO055::begin(adafruit_bno055_opmode_t mode, uint8_t axis_remap_orientation, uint8_t axis_remap_sign)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{
/* Enable I2C */
//Wire.begin();

/* Make sure we have the right device */
uint8_t id = read8(BNO055_CHIP_ID_ADDR);
if(id != BNO055_ID)
Expand Down Expand Up @@ -90,8 +88,7 @@ bool Adafruit_BNO055::begin(adafruit_bno055_opmode_t mode)
//delay(100);
//}
//delay(50);

DEBUG("rebooted");
//DEBUG("rebooted");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should just remove this I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do not need your remarks anymore, I can delete them.
But added you as collaborator, so you can make modifications too, if you want.


/* Set to normal power mode */
DEBUG("going into normal power mode");
Expand All @@ -111,14 +108,12 @@ bool Adafruit_BNO055::begin(adafruit_bno055_opmode_t mode)
write8(BNO055_UNIT_SEL_ADDR, unitsel);
*/

/* Configure axis mapping (see section 3.4) */
//write8(BNO055_AXIS_MAP_CONFIG_ADDR, REMAP_CONFIG_P2); // P0-P7, Default is P1
write8(BNO055_AXIS_MAP_CONFIG_ADDR, 0b00001001); // P0-P7, Default is P1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should eventually try to remove any modifications from 3rd party libraries. Would make it a lot easier to upgrade them. Is this what you did here? Are we back to the original file?

All those comments confuse me. I don't remember what was part of the library and what I added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
for the BNO055 library, the original code is (line 33 ff):

/* Set the output units */
  /*
  uint8_t unitsel = (0 << 7) | // Orientation = Android
                    (0 << 4) | // Temperature = Celsius
                    (0 << 2) | // Euler = Degrees
                    (1 << 1) | // Gyro = Rads
                    (0 << 0);  // Accelerometer = m/s^2
  write8(BNO055_UNIT_SEL_ADDR, unitsel);
  */

  /* Configure axis mapping (see section 3.4) */
  /*
  write8(BNO055_AXIS_MAP_CONFIG_ADDR, REMAP_CONFIG_P2); // P0-P7, Default is P1
  delay(10);
  write8(BNO055_AXIS_MAP_SIGN_ADDR, REMAP_SIGN_P2); // P0-P7, Default is P1
  delay(10);
  */

The rest was by done by you.

Then you did some corrections to wire at the beginning of the Adafruit_BNO055.cpp
So I am afraid we are not back at the original yet.

/* Configure axis mapping (see section 3.4 Bosch manual) */
write8(BNO055_AXIS_MAP_CONFIG_ADDR, axis_remap_orientation);
delay(10);
//write8(BNO055_AXIS_MAP_SIGN_ADDR, REMAP_SIGN_P2); // P0-P7, Default is P1
write8(BNO055_AXIS_MAP_SIGN_ADDR, 0b00000000); // P0-P7, Default is P1
write8(BNO055_AXIS_MAP_SIGN_ADDR, axis_remap_sign);
delay(10);

write8(BNO055_SYS_TRIGGER_ADDR, 0x0);
delay(10);
/* Set the requested operating mode (see section 3.3) */
Expand Down Expand Up @@ -612,7 +607,7 @@ byte Adafruit_BNO055::read8(adafruit_bno055_reg_t reg )
#else
value = Wire.receive();
#endif

//DEBUG("read => %x", value);

return value;
Expand Down
5 changes: 4 additions & 1 deletion lib/Adafruit_BNO055/Adafruit_BNO055.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,11 @@ class Adafruit_BNO055 : public Adafruit_Sensor
} adafruit_vector_type_t;

Adafruit_BNO055 ( int32_t sensorID = -1, uint8_t address = BNO055_ADDRESS_A );
// MOD for KBox to set axis and sign
bool begin ( adafruit_bno055_opmode_t mode = OPERATION_MODE_NDOF,
uint8_t axis_remap_orientation = REMAP_CONFIG_P1,
uint8_t axis_remap_sign = REMAP_SIGN_P1);

bool begin ( adafruit_bno055_opmode_t mode = OPERATION_MODE_NDOF );
void setMode ( adafruit_bno055_opmode_t mode );
void getRevInfo ( adafruit_bno055_rev_info_t* );
void displayRevInfo ( void );
Expand Down
1 change: 0 additions & 1 deletion lib/KBoxHardware/src/KBoxHardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ void KBoxHardware::espRebootInProgram() {
}

bool KBoxHardware::sdCardInit() {
//TODO: check if sdcard_cs is working with SdFatSdio
#if defined(__MK66FX1M0__)
// SDIO support for Builtin SD-Card in Teensy 3.6
if (!_sd.begin()){
Expand Down
2 changes: 1 addition & 1 deletion src/common/signalk/SKUnits.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ inline double SKNormalizeAngle(double x) {
return x - M_PI;
}


const double SKDoubleNAN = -1e9;
12 changes: 9 additions & 3 deletions src/common/ui/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ class Event {
};

enum ButtonEventType {
// Those two events are always sent when button goes up/down
ButtonEventTypePressed,
ButtonEventTypeReleased
ButtonEventTypeReleased,

// Those events are also sent when a single click, or a double click happen
ButtonEventTypeClick,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very very nice 👍

ButtonEventTypeLongClick,

// This event is sent multiple times, as long as button is maintained
ButtonEventTypeMaintained,
};
class ButtonEvent : public Event {
private:
Expand All @@ -68,5 +76,3 @@ class TickEvent : public Event {
TickEvent(unsigned long int millis) : Event(EventTypeTick), millis(millis) {};
time_ms_t getMillis() const { return millis; };
};


9 changes: 6 additions & 3 deletions src/common/ui/Page.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "Event.h"
#include "Layer.h"

#include <KBoxLogging.h>

/* A page is one simple app available on the MFD.
*
* - Only one page can be active at a time.
Expand All @@ -44,7 +46,9 @@ class BasePage {

virtual bool processEvent(const ButtonEvent &e) {
// By default button down will force switching to the next page.
return !(e.clickType == ButtonEventTypePressed);
DEBUG("EventTypeButton: %i", e.clickType);
// false -> next page
return !(e.clickType == ButtonEventTypeClick);
}
virtual bool processEvent(const EncoderEvent &e) {
// By default this will be ignored.
Expand All @@ -59,7 +63,7 @@ class BasePage {
virtual ~BasePage() {};
};

/* BasePage offers a very generic paint implementation.
/* BasePage offers a very generic paint implementation.
* Page assumes the use of Layers.
*
* Adding a layer via addLayer() will transfer ownership to the Page who will
Expand All @@ -76,4 +80,3 @@ class Page : public BasePage {
void addLayer(Layer *l);
void paint(GC &context);
};

5 changes: 4 additions & 1 deletion src/host/config/IMUConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@
struct IMUConfig {
bool enabled;
int frequency;
bool enableHdg;
bool enableHeelPitch;
int calHdg;
int calHeelPitch;
};

11 changes: 10 additions & 1 deletion src/host/config/KBoxConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ void KBoxConfigParser::defaultConfig(KBoxConfig &config) {

config.imuConfig.enabled = true;
config.imuConfig.frequency = 20;
config.imuConfig.enabled = true; // enable internal IMU sensor
config.imuConfig.enableHdg = true; // true if values taken from internal sensor
config.imuConfig.enableHeelPitch = true; // true if values taken from internal sensor
config.imuConfig.calHdg = 3; // hdg valid, if calibration value greater equal
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not convinced we need this. Besides you, and to a lesser extent me, nobody is going to understand what those values mean.

If I agree to make 3 and 2 the defaults, are you ok removing this? ;)

Copy link
Contributor Author

@ronzeiller ronzeiller Dec 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-))
yes, this is ok.
As I can see the heading on the IMUPage now (independently from the SKUpdate, which means independently from any cal-value) it is ok for me.

I have to delete it then in the config too. But would prefer to do it in a separate PR after merging, if it is ok for you.

config.imuConfig.calHeelPitch = 2; // heel (roll) & pitch valid, if calibration value greater equal

config.barometerConfig.enabled = true;
config.barometerConfig.frequency = 1;
Expand All @@ -75,6 +80,10 @@ void KBoxConfigParser::parseKBoxConfig(const JsonObject &json, KBoxConfig &confi
void KBoxConfigParser::parseIMUConfig(const JsonObject &json, IMUConfig &config) {
READ_BOOL_VALUE(enabled);
READ_INT_VALUE_WRANGE(frequency, 1, 100);
READ_BOOL_VALUE(enableHdg);
READ_BOOL_VALUE(enableHeelPitch);
READ_INT_VALUE_WRANGE(calHdg, 0, 3);
READ_INT_VALUE_WRANGE(calHeelPitch, 0, 3);
}

void KBoxConfigParser::parseBarometerConfig(const JsonObject &json, BarometerConfig &config){
Expand Down Expand Up @@ -131,4 +140,4 @@ enum SerialMode KBoxConfigParser::convertSerialMode(const String &s) {
return SerialModeNMEA;
}
return SerialModeDisabled;
}
}
9 changes: 8 additions & 1 deletion src/host/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "host/services/ADCService.h"
#include "host/services/BarometerService.h"
#include "host/services/IMUService.h"
#include "host/pages/IMUMonitorPage.h"
#include "host/services/NMEA2000Service.h"
#include "host/services/SerialService.h"
#include "host/services/RunningLightService.h"
Expand Down Expand Up @@ -98,7 +99,7 @@ void setup() {

ADCService *adcService = new ADCService(skHub, KBox.getADC());
BarometerService *baroService = new BarometerService(skHub);
IMUService *imuService = new IMUService(skHub);
IMUService *imuService = new IMUService(config.imuConfig, skHub);

NMEA2000Service *n2kService = new NMEA2000Service(config.nmea2000Config,
skHub);
Expand Down Expand Up @@ -134,6 +135,12 @@ void setup() {
BatteryMonitorPage *batPage = new BatteryMonitorPage(skHub);
mfd.addPage(batPage);

if (config.imuConfig.enabled) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 great idea.

// At the moment the IMUMonitorPage is working with built-in sensor only
IMUMonitorPage *imuPage = new IMUMonitorPage(config.imuConfig, skHub, *imuService);
mfd.addPage(imuPage);
}

StatsPage *statsPage = new StatsPage();
statsPage->setSDCardTask(sdcardTask);

Expand Down
102 changes: 102 additions & 0 deletions src/host/pages/IMUMonitorPage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
__ __ ______ ______ __ __
/\ \/ / /\ == \ /\ __ \ /\_\_\_\
\ \ _"-. \ \ __< \ \ \/\ \ \/_/\_\/_
\ \_\ \_\ \ \_____\ \ \_____\ /\_\/\_\
\/_/\/_/ \/_____/ \/_____/ \/_/\/_/

The MIT License

Copyright (c) 2017 Thomas Sarlandie [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include <stdio.h>
#include "common/signalk/SKUpdate.h"
#include "IMUMonitorPage.h"
#include <KBoxLogging.h>
#include "signalk/SKUnits.h"

IMUMonitorPage::IMUMonitorPage(IMUConfig &config, SKHub& hub, IMUService &imuService) : _config(config), _imuService(imuService) {

static const int col1 = 5;
static const int col2 = 200;
static const int row1 = 26;
static const int row2 = 50;
static const int row3 = 152;
static const int row4 = 182;

addLayer(new TextLayer(Point(col1, row1), Size(20, 20), "HDG ° Mag", ColorWhite, ColorBlack, FontDefault));
addLayer(new TextLayer(Point(col2, row1), Size(20, 20), "Cal: Mag/Acc", ColorWhite, ColorBlack, FontDefault));
addLayer(new TextLayer(Point(col1, row3), Size(20, 20), "Heel °", ColorWhite, ColorBlack, FontDefault));
addLayer(new TextLayer(Point(col2, row3), Size(20, 20), "Pitch °", ColorWhite, ColorBlack, FontDefault));

_hdgTL = new TextLayer(Point(col1, row2), Size(20, 20), "--", ColorWhite, ColorBlack, FontLarge);
_calTL = new TextLayer(Point(col2, row2), Size(20, 20), "--", ColorWhite, ColorBlack, FontLarge);
_rollTL = new TextLayer(Point(col1, row4), Size(20, 20), "--", ColorWhite, ColorBlack, FontLarge);
_pitchTL = new TextLayer(Point(col2, row4), Size(20, 20), "--", ColorWhite, ColorBlack, FontLarge);

addLayer(_hdgTL);
addLayer(_calTL);
addLayer(_rollTL);
addLayer(_pitchTL);

hub.subscribe(this);
}

bool IMUMonitorPage::processEvent(const ButtonEvent &be){
// DEBUG("EventTypeButton: %i", be.clickType);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to come up with a better way to disable logging for just one class. Commenting DEBUG is really not ideal, and removing them is also not great. I need to come up with something!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of this DEBUG I just need during inventing of code. Then, when I think it works as I expect, I think it is a pity to delete them....

if (be.clickType == ButtonEventTypeClick) {
DEBUG("Button ButtonEventTypeClick !!!");
// Change page on single click.
return false;
}
if (be.clickType == ButtonEventTypeLongClick) {
_imuService.setOffset();
}
return true;
}

bool IMUMonitorPage::processEvent(const TickEvent &te){
_imuService.getLastValues(_accelCalibration, _pitch, _roll, _magCalibration, _heading);
//DEBUG("AccelCalibration: %i | MagCalibration: %i", _accelCalibration, _magCalibration);

// TODO: Some damping for the display
_hdgTL->setText(String( SKRadToDeg(_heading), 1) + "° ");
_calTL->setText(String( _magCalibration) + "/" + String( _accelCalibration) + " ");
_pitchTL->setText(String( SKRadToDeg(_pitch), 1) + "° ");
_rollTL->setText(String( SKRadToDeg(_roll), 1) + "° ");

// Always show Hdg from IMU-sensor, but if the value is not trusted (which means
// calibration below config setting, change color to red
if ((_magCalibration <= _config.calHdg)||(_accelCalibration <= _config.calHeelPitch)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: indentation problem here

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the IMUService should expose a isMagCalibrated() and is isHeelAndPitchCalibrated() methods. This way the actual technique we use to decide if we are calibrated is not duplicated in two completely different part of the code.

Copy link
Contributor Author

@ronzeiller ronzeiller Dec 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: indentation problem here

I do not know how to get rid of ident-problem. In every editor I have it shows a 2-ident tab.
In Github it shows wrong. If I correct 8 -> 2 in github I can not save because it is said "no changes"

I think the IMUService should expose a isMagCalibrated() and is isHeelAndPitchCalibrated() methods. This way the actual technique we use to decide if we are calibrated is not duplicated in two completely different part of the code.

Good idea!!
implemented, coming when all corrections pushed

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-Indent: this article might help: https://stackoverflow.com/questions/4119872/netbeans-removing-trailing-whitespace-on-save-and-tabs-to-spaces

I think your editor is configured to show tabs as 2 spaces. this is why it looks good to you. But since they are actually tabs, it does not look good in github (they do this on purpose to make it easier to detect).

I can push a commit to fix it if needed.

_hdgTL->setColor(ColorRed);
_calTL->setColor(ColorRed);
} else {
_hdgTL->setColor(ColorWhite);
_calTL->setColor(ColorWhite);
};

return true;
}

void IMUMonitorPage::updateReceived(const SKUpdate& up) {
// may be needed for something....
}
53 changes: 53 additions & 0 deletions src/host/pages/IMUMonitorPage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
__ __ ______ ______ __ __
/\ \/ / /\ == \ /\ __ \ /\_\_\_\
\ \ _"-. \ \ __< \ \ \/\ \ \/_/\_\/_
\ \_\ \_\ \ \_____\ \ \_____\ /\_\/\_\
\/_/\/_/ \/_____/ \/_____/ \/_/\/_/

The MIT License

Copyright (c) 2017 Thomas Sarlandie [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include "common/ui/Page.h"
#include "common/ui/TextLayer.h"
#include "common/signalk/SKHub.h"
#include "common/signalk/SKSubscriber.h"
#include "services/IMUService.h"
#include "host/config/IMUConfig.h"

class IMUMonitorPage : public Page, public SKSubscriber {
private:
TextLayer *_hdgTL, *_rollTL, *_pitchTL, *_calTL;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is wrong here. Should 2 space for private and then 4 for the properties and methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repaired

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent issues here too (tabs instead of spaces)

IMUConfig &_config;
IMUService &_imuService;

int _magCalibration, _accelCalibration;
double _pitch, _roll, _heading;

public:
IMUMonitorPage(IMUConfig &config, SKHub& hub, IMUService &imuService);
virtual void updateReceived(const SKUpdate& up);

bool processEvent(const TickEvent &te);
bool processEvent(const ButtonEvent &be);
};
Loading