Skip to content
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

Channels #1

Open
ratmice opened this issue Jan 17, 2022 · 1 comment
Open

Channels #1

ratmice opened this issue Jan 17, 2022 · 1 comment

Comments

@ratmice
Copy link
Owner

ratmice commented Jan 17, 2022

It is going to take some thinking/experimentation on the best representation for channels, particularly in appstate.

  • a list of channels each channel sharing a single Light
  • but also you need to have a list of PeripheralIds for the channel, to switch individual devices between channels.

We're also somewhat limited by what we can implement the druid List trait for, which requires iter_mut.
I believe the easiest thing is to make it a
Vector<((PeripheralId, Light), Arc<BTreeMap<PeripheralId, Light>>)>

But that means we get to go hunting through a vec of HashMaps, when the device changes underneath the gui.

the alternative is making it something like:

enum {
   ChannelMode(Vector<Light>),
   DeviceMode(Arc<BTreeMap<PeripheralId, Light>>),
}

and a [Vector<PeripheralId>; 8] or something in the backend.

I suppose the problem with this is that, I either need to rebuild the DeviceMode when switching modes,
or have a way to access the state and synchronize the copy of the state that the prism is not currently in.

which will require thought...

@ratmice
Copy link
Owner Author

ratmice commented Jan 17, 2022

So I think the right thing might be changing AppState to (something to the effect of):

struct AppState {
     mode: AppStateMode
     devices: Map<PeripheralId, usize>
     channels: Vector<Light>
}

enum AppStateMode {
     Device,
     Channel,
}

Along with an impl Prism<AppState, ..> for ...,
Which is a bit odd, because its implementing Prism for a struct which holds an enum, rather than being an enum itself.
But need to see how these non-enum prisms work out...

This would overall be good because it means we've bounded the amount of work that needs to be done in the idle callback to the number of channels.

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

No branches or pull requests

1 participant