pimoroni / mote

Mote - drivers for the plug and play USB APA102 controller
https://shop.pimoroni.com/products/mote
MIT License
24 stars 14 forks source link

Encapsulation of channel information in mote-api JSON #16

Closed raruston closed 3 years ago

raruston commented 7 years ago

I've just started reviewing the new api so I can update my Controller for Mote app, and I note that the returned JSON does not neatly encapsulate each channel like it could. While not an insurmountable problem, it does make parsing a little messier than it could be, especially when using libraries which can extract objects from JSON.

One potential alternative format would be as follows:

{ "channels": [
  {"id": 1,
  "state": 1,
  "brightness":255,
  "colour": [255,255,255] },
  {"id": 2,
  "state": 0,
  "brightness":255,
  "colour": [255,255,255] }]
}

This would encapsulate a channel object nicely, and allow libraries (for example Retrofit) to easily parse channel information. I could probably provide a PR for this if interested, but I won't spend time on it if it's not likely to be accepted, since it is a big change.

If this is accepted, then I would also suggest this qualifies for a version bump since it is a breaking change, and highlights why a version endpoint could be useful per Issue #14.