"smart" button selection with NG

Hi all

I want to implement a smart select function for my controler.

The goal is simple, let say you have 8 button (and led) in a row,

if you push button 3 and 6, led 3,4,5 and 6 is active

if you push any button again, only this event is active

if you push then button 8 and 4, led 4,5,6,7 and 8 is active

etc…

Any strategy recommanded to achieve this ?

I like to avoid NRG for this function but right now I don’t see how to handle this with NGC only.

 

For the moment I have in mid NGR that get first(A) and second(B) value given by button N°

set a value(C) according to how many button are involved between, C=(B-A)+1

set a value(D) that give the button offset, D=A-1

then conditional for each event M,N,O…T like

if D<1 elsif C>8 set M=on

if D<2 elsif C>7 set N=on

if D<3 elsif C>6 set O=on

if D<8 elsif C>5 set T=on

 

I think I will also need a flip in case first button is higher count

like If C<0 then C=C-(2C)

As a delay (like 500ms) to let the system don’t wait forever if only one button is pressed

 

Input welcome

 

Best

Zam