Skip to content

Instantly share code, notes, and snippets.

@ricehornet
Forked from jjmilburn/SketchSystems.spec
Last active June 21, 2021 19:11
Show Gist options
  • Save ricehornet/914bbb31a86f6b6e38245f3707867c5d to your computer and use it in GitHub Desktop.
Save ricehornet/914bbb31a86f6b6e38245f3707867c5d to your computer and use it in GitHub Desktop.
PAYG Credit Resource Interaction with NXC Links and Credit Origin
PAYG Credit Resource Interaction with NXC Links and Credit Origin
# Initial state -
# implies that link state should be initialized before PAYG credit initializes
NXC Linked?*
No links? -> No NXC links
Any linked accessory has PAYG credit resource? -> Credit Leading
Any linked controller has PAYG credit resource? -> Credit Following
No NXC links
link or unlink event -> NXC Linked?
Remaining Credit with no links
am an accessory only device?*
yes -> am currently unlocked?
no -> maintain last PAYG credit
# only checked for accessories - controllers always preserve last PAYG credit on loss
# of all their links
am currently unlocked?
no -> independent zero credit
yes -> maintain last PAYG credit
independent zero credit
maintain last PAYG credit
1 or more NX Channel Links&
# NXC reset is the same as an 'unlink' event - it will trigger a series of unlink
# events (one for each link)
link or unlink event -> NXC Linked?
# Currently, we model 'leading' and 'following', and do not consider relaying in detail
# (although its technically the combination of leading and following).
Credit Mode
Credit Leading
credit update event -> POST credit update to accessories successfully?
Credit Following
Independently Control Credit
link event -> NXC Linked?
Remaining Credit
# this might be a tick (60 seconds) or new keycode entry - doesn't matter, same effect.
# we will loop through all accessories with PAYG credit resources and update them.
event indicates PAYG credit has updated? -> POST credit update to accessories successfully?
Initialize Credit*
am leading -> independent credit
am following -> mirror controller credit
POST credit update to accessories successfully?
no -> POST credit update to accessories successfully?
yes -> independent credit
mirror controller credit
independent credit
function render(model){
let current_state_name = model.active_states[0].name;
return $("h1",
{style: {color: "darkBlue"}},
`The current state is: ${current_state_name}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment