Skip to content

Conversation

@Eelviny
Copy link

@Eelviny Eelviny commented Jun 22, 2025

I've been experimenting with trying to get my Eggrider V2 working with bbs-fw. The eggrider has 2 ways in which it can switch between "road" and "offroad" profiles:

  1. Hold 2 sets of parameters for the PAS settings etc and reprogram the controller on the fly when switched
  2. Just change the display speed limit value when switched.

Neither of these methods work with bbs-fw. For 1, the protocol is different, and for 2, bbs-fw ignores the command from the display, instead only using the global limit programmed by the tool.

This PR attempts to implement functionality where when the display limit is set to a certain value, the controller will switch to sport mode. The Eggrider can then be set to have that speed limit value in off-road mode, therefore switching between the profiles in bbs-fw.

Note that this does not attempt to implement any ability for the Eggrider to program the firmware, that would be impractical as the Eggrider would not support the same parameters exposed by bbs-fw. That would be something for the Eggrider folks to work on; I emailed them a month ago to ask, here's the response:

At the moment, we don’t have any plans to support the bbs-fw open-source firmware for Bafang motors.

This PR is in draft as it's my first time really getting this deep on a BBS02, and I'm currently a little stuck on how to debug this. All I can confirm right now is that it compiles and the motor works as normal, but the new functionality does not work at all yet.

@Eelviny
Copy link
Author

Eelviny commented Jun 22, 2025

My IDE's auto-formatter seems to have done its job, to the detriment of diff readability. Apologies for that, especially in extcom.c I really couldn't get it to not do that. My suspicion is something to do with the line endings as I'm making my changes from a Linux machine.

Let me know if it's an issue and I'll try to fix it up. For extcom.c, just focus on the process_bafang_display_write_speed_limit() function in the file.

@danielnilsson9 if you're available, I would really appreciate some background info on how far you got with implementing the display speed limit functionality (and ultimately why you disabled it), and any tips on how to debug the display communication. I uncommented some of the code in process_bafang_display_write_speed_limit() but I have no idea if that code worked in the first place.

@Eelviny Eelviny mentioned this pull request Jun 22, 2025
@dav0000000
Copy link
Contributor

Do you want to be able to change the motor configuration using eggrider or just switch between modes. I'm not familiar with the eggrider so I probably should just stay quiet. I suspect the eggrider just has two copies of standard bafang configuration and when you switch modes it writes the selected config just like the standard bafang config tool does. If so you could implement a dummy read and write function in extcom and use it to trigger the mode change function. Daniel has already created the placeholder for the read and write functions for this. It's never as simple as I think things are though. Also note that display speed is in wheel rpm, not mph or kph. I haven't looked at your code as I just have my phone now.

@dav0000000
Copy link
Contributor

Just a quick look at your code. I think you should leave this code in process_bafang_display_write_speed_limit() even though it may receive the extra bytes in one go otherwise you are going to have mismatch between buffer and msg_len.

if (msg_len < 5)
{
	return KEEP;
}

@Eelviny
Copy link
Author

Eelviny commented Jun 23, 2025

Do you want to be able to change the motor configuration using eggrider or just switch between modes.

Just switch between modes. I think attempting to implement functionality for dummy reads/writes might be more complicated as the Eggrider will be expecting certain responses for all fields that I would need to implement. Instead, Eggrider has an alternative mode that just changes the display speed limit between 2 preset values, and I think that method will be more versatile (and possibly also usable by other displays!)

Also note that display speed is in wheel rpm, not mph or kph

Accounted for this already. The config value in kph is converted to RPM before it is compared against the display value.

To try and isolate the problem a bit, I removed all the comparison logic and just tried to make it switch to sport mode when the display attempts to set the speed limit to any value. I've got both an Eggrider V2 and a C965 display, so tried it on both. No bueno.

I think you should leave this code in process_bafang_display_write_speed_limit() [...]

Good catch, I thought that the code was just there as a dummy return, so removed it and replaced it with the commented code. I'll add it back in and see if there's any difference!

@Eelviny
Copy link
Author

Eelviny commented Jun 24, 2025

Thanks again @dav0000000 for catching my mistake, adding back in the KEEP makes it work like a charm. The only other part was to make sure the Eggrider's wheel size matches the bbs-fw wheel size, so the RPM value matches. I added extra instructions to the comments of fwconfig on how to set this up.

I've tested it on a motor sitting on my desk, seems to work as expected. Hopefully will be able to test it on a real bike in a couple weeks. PR is ready for prime time.

@Eelviny Eelviny marked this pull request as ready for review June 24, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants