diff --git a/lib/bluetooth/devices/shimano/shimano_di2.dart b/lib/bluetooth/devices/shimano/shimano_di2.dart index e2db386..ede94cd 100644 --- a/lib/bluetooth/devices/shimano/shimano_di2.dart +++ b/lib/bluetooth/devices/shimano/shimano_di2.dart @@ -38,16 +38,22 @@ class ShimanoDi2 extends BluetoothDevice { Future processCharacteristic(String characteristic, Uint8List bytes) { if (characteristic.toLowerCase() == ShimanoDi2Constants.D_FLY_CHANNEL_UUID) { final channels = bytes.sublist(1); - + // On first data reception, just initialize the state without triggering buttons if (!_isInitialized) { channels.forEachIndexed((int value, int index) { + final readableIndex = index + 1; _lastButtons[index] = value; + + getOrAddButton( + 'D-Fly Channel $readableIndex', + () => ControllerButton('D-Fly Channel $readableIndex'), + ); }); _isInitialized = true; return Future.value(); } - + final clickedButtons = []; channels.forEachIndexed((int value, int index) {