154 lines
4.0 KiB
C++
154 lines
4.0 KiB
C++
/***************************************************************************
|
|
|
|
BionxControl
|
|
Copyright © 2025 christoph holzheuer
|
|
christoph.holzheuer@gmail.com
|
|
|
|
Using:
|
|
|
|
mhs_can_drv.c
|
|
© 2011 - 2023 by MHS-Elektronik GmbH & Co. KG, Germany
|
|
Klaus Demlehner, klaus@mhs-elektronik.de
|
|
@see www.mhs-elektronik.de
|
|
|
|
Based on Bionx data type descriptions from:
|
|
|
|
BigXionFlasher USB V 0.2.4 rev. 97
|
|
© 2011-2013 by Thomas Koenig <info@bigxionflasher.org>
|
|
@see www.bigxionflasher.org
|
|
|
|
Bionx Bike Info
|
|
© 2018 Thorsten Schmidt (tschmidt@ts-soft.de)
|
|
@see www.ts-soft.de
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
@see https://github.com/bikemike/bionx-bikeinfo
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
#include <QMetaEnum>
|
|
|
|
#include <bcvalue.h>
|
|
|
|
|
|
///-------------------------------
|
|
|
|
|
|
BCValue::BCValue( BCDevice::ID deviceID_, BC::ID registerID_)
|
|
: deviceID{deviceID_}, registerID{registerID_}
|
|
{
|
|
visibleValue = "--";
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
BionxControl
|
|
Copyright © 2025 christoph holzheuer
|
|
christoph.holzheuer@gmail.com
|
|
|
|
Using:
|
|
|
|
mhs_can_drv.c
|
|
© 2011 - 2023 by MHS-Elektronik GmbH & Co. KG, Germany
|
|
Klaus Demlehner, klaus@mhs-elektronik.de
|
|
@see www.mhs-elektronik.de
|
|
|
|
Based on Bionx data type descriptions from:
|
|
|
|
BigXionFlasher USB V 0.2.4 rev. 97
|
|
© 2011-2013 by Thomas Koenig <info@bigxionflasher.org>
|
|
@see www.bigxionflasher.org
|
|
|
|
Bionx Bike Info
|
|
© 2018 Thorsten Schmidt (tschmidt@ts-soft.de)
|
|
@see www.ts-soft.de
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
@see https://github.com/bikemike/bionx-bikeinfo
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/// reader functions
|
|
|
|
|
|
|
|
TransmitResult readDummy( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )
|
|
{
|
|
qDebug() << " --- NO: Read DUMMY: " << registerID;
|
|
return std::unexpected( QString("NO: Read DUMMY: %1 : %2 ").arg( deviceID, registerID ) );
|
|
}
|
|
|
|
TransmitResult readByteValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )
|
|
{
|
|
qDebug() << " --- YES: Read ByteValue: " << registerID;
|
|
// Wir lesen nur ein Byte und gut.
|
|
return transmitter.readByte( deviceID, registerID );
|
|
}
|
|
|
|
|
|
TransmitResult readWordValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )
|
|
{
|
|
qDebug() << " --- YES: Read WordValue: " << registerID;
|
|
|
|
//getValue(CONSOLE, CONSOLE_SN_PN_HI) << 8) + getValue(CONSOLE, CONSOLE_SN_PN_LO)),
|
|
uint32_t result{};
|
|
// hi byte Leseversuch.
|
|
TransmitResult value = transmitter.readByte( deviceID, registerID );
|
|
// Fehler? dann weg
|
|
if( !value)
|
|
return std::unexpected( value.error() );
|
|
// hi byte speichern
|
|
result = *value << 8;
|
|
// low byte, liegt im followup register: +1
|
|
value = transmitter.readByte( deviceID, registerID+1 );
|
|
if( !value)
|
|
return std::unexpected( value.error() );
|
|
result += *value;
|
|
return result;
|
|
}
|
|
|
|
TransmitResult readSpeedValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )
|
|
{
|
|
return 0x0;
|
|
}
|
|
|
|
TransmitResult readODOValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )
|
|
{
|
|
return 0x0;
|
|
}
|
|
|
|
TransmitResult readVoltValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )
|
|
{
|
|
return 0x0;
|
|
}
|
|
|
|
TransmitResult readCircValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )
|
|
{
|
|
return 0x0;
|
|
}
|
|
|
|
|
|
|
|
QString BCValue::formatValue( uint32_t value ) const
|
|
{
|
|
if( factor == 1 )
|
|
return QString::number( value );
|
|
|
|
double result = value * factor;
|
|
return QString::number(result, 'f', 2);
|
|
}
|
|
|
|
|
|
/// ----
|