-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add RemoteControl (#88010) #96
Comments
+1, I receive same think with my remote control |
I enabled logging and It stop at this check : info: SharpBrick.PoweredUp.Functions.DiscoverPorts[0] |
I debugged this a bit, and the This is the specific line that's causing trouble for this device:
Apparently the call to get the possible mode combinations can fail and return an error message, maybe simply because this device doesn't support any mode combinations? I removed the actual sending of the messages, nice and crude way to at least get the device list output for this device: |
Awesome work. I think the solution is indeed a warning but maybe also lowering the expected return messages when the request fails with a error message. LWP is really a nice protocol, just when its prime implementer randomly acts weird ... it is annoying ;) |
btw.. since you have the hardware ... can you create the needed port dumps? I also started a documentation project here: https://github.com/sharpbrick/docs ... not for the purpose of API documentation for this project, but as a dumping place for these port (mode) information dumps. They are flying around a little bit too easy ;) |
sharpbrick#96 non-breaking
Sure, and since I had the port dumps, I also created the hub & devices. Couldn't resist, wanted to know if the buttons work 🙂. Created a draft PR. Some noteworthy stuff about this device:
|
Regards the Properties Regards the Buttons |
You can turn the buttons yes, but there's no rotary encoder or whatever, sadly. That would've made it a great device to control lots of stuff. You can see the internals here: https://www.eurobricks.com/forum/index.php?/forums/topic/162288-powered-up-a-tear-down/ So I still have no idea where all the modes are for, since the button state of all three buttons can be retrieved with the KEYSD mode. |
So I only just figured out that a port can only be operated in a single (input?) mode at a time, which makes sense of course, I just never interpreted it that way for some reason 🤷♂️🤦♂️. About the modes: RCKEY mode: values , 0 for release, So modes KEYD and KEYSD are similar in function but return the data in a different format. KEYD uses 1 byte, KEYSD uses 3 bytes for the same information. KEY(S)D seem to be the most useful mode to use, since with the other modes, you miss information if you press multiple buttons at once (when releasing only though). RCKEY, KEYA & KEYR modes all seem to behave exactly the same. Maybe the difference is only in the way they register button press/depress, maybe some trigger on rising/falling edge, maybe some trigger on level, I'm not sure. Also I only tried things with delta interval 1.
So I guess Lego's interpretation of specifying min/max values is a bit wonky. Isn't 127 the special stop command for the (train) motor? Seems like an ugly hack to me. If you ask me, I'd say let's only implement KEYD mode now, seperate into 3 booleans, one for each button and ignore the other modes for now. Document the way they work and if some other devices pop up that supplies input values outside of their own specified range, deal with it properly then? It does already throw a decent enough error, so it won't be hard to trace. |
Agree with going ahead on your plan. My educated guess for all these variants: Provide easy to convert stimulus for the hubs which pair with them. In the end they flow data from one port to another and someone has to convert it. Next lesson learnt for you: min/max is a brain bug. Raw min/max is a scaling basis for the Si min/max or Pct min/max. In both ranges, raw and SI you can get values outside of the ranges. Read this about it. |
Hmm ok, so if I understand this correctly, raw min/max simply maps to si min/max or pct min/max, but raw values can exceed the raw range, and thus will be mapped to values outside the si or pct range too. At first I didn't understand why you'd need that specific formula (I thought it was simply determining the factor between raw & si / pct ranges and multiplying that with the value) but seeing that example of a device that reports both raw and si ranges of 10 / 10 I can see why. Now for this remote (in RCKEY, KEYA, KEYR modes), the formula does not work, or rather, it does work, but the type conversion afterwards fails :) The raw value range is [-1 .. 1] and the pct range is [-100 .. 100]. Now the red button outputs 127. This is translated to 12700 for the pct range, which is correct (weird though, but whatever). But this is then converted to the value type (in this case sbyte). This obviously does not work and throws an exception. It's not an issue right now for this device, since I only need to use the KEYD mode, which does not have this issue. But I think we should create a separate issue to address this. |
sharpbrick#96 non-breaking
sharpbrick#96 non-breaking
sharpbrick#96 non-breaking
sharpbrick#96 non-breaking
Yeah .. I thought about that for some milliseonds when I implemented it and than was so happy that each conversion just worked that I forgot about it. Nasty. So far I do not see really a problem for practical use (PCT here is pretty useless considering that this is either 0 or 100... i suspect that they leave these default values in just to not emit 0 and 0), but I will keep an eye on it. Yeah, please separate it out. |
ps: Sorry for the late reply. |
Add support for the Remote Control (#88010) which is used in the train sets. I tried to use the
poweredup device list
CLI function but it hangs even after several tries and two different remote controls.The text was updated successfully, but these errors were encountered: