Skip to content

Allow keyboard input for keypad - #1138

Merged
peternewman merged 11 commits into
OpenLightingProject:masterfrom
FloEdelmann:keypad
Oct 24, 2016
Merged

Allow keyboard input for keypad#1138
peternewman merged 11 commits into
OpenLightingProject:masterfrom
FloEdelmann:keypad

Conversation

@FloEdelmann

Copy link
Copy Markdown
Member

Until now, one had to click the buttons in the web interface to control the keypad. I've enabled keyboard input for this.

Until now, one had to click the buttons in the web interface to control
the keypad. I've enabled keyboard input for this.
@peternewman peternewman self-assigned this Oct 21, 2016
@peternewman peternewman added this to the 0.11.0 milestone Oct 21, 2016

@peternewman peternewman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you have a look at the readme here:
https://github.com/OpenLightingProject/ola/blob/master/javascript/new-src/README.md

You'll need to make the changes here:
https://github.com/OpenLightingProject/ola/blob/master/javascript/new-src/src/controllers/keypad_universe.js

Then rebuild and commit app.js, app.min.js and app.min.js.map using the instructions in the readme.

Comment thread olad/www/new/js/app.js Outdated
case 'a':
$scope.input(' @ ');
break;
case '-':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be inclined to leave out -, so we can do 1 THRU 10 - 5 + 15 in future, without confusing things.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I did not know about that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was popular on Strand, and probably other consoles. The above would select channels 1, 2, 3, 4, 6, 7, 8, 9, 10 and 15.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite intuitive 😉

I already thought about adding support for comma-separated lists of channels / channel ranges, but that would be another pull request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What else would you expect it to do (aside from maths)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comma-separated list? I'd expect it to do something like this:
1 THRU 3, 9 @ FULL would set channels 1, 2, 3 and 9.

@peternewman peternewman Oct 21, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was meaning the Strand style. Your comma syntax would need 1 THRU 4, 6 THRU 10, 15 to get the same effect as my example.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit I did not read closely enough, now I get how the syntax works. Nevertheless, sometimes commas might be better, e.g. 1 THRU 10, 50 THRU 60 @ FULL. But one does not forbid the other, so why not consider both?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, in that case a comma would be perfectly acceptable I'd think.

You can also do things like 1 THRU 10 - 3 THRU 5. I can't really think of a +/, equivalent for that that makes sense. I'm not sure in Strand land, but it might make sense to keep , for multiple entries at once, or we could use ; for that. So 1 @ 5, 2 @ 7 as one simultaneous statement.

@peternewman

Copy link
Copy Markdown
Member

Thanks for this!

@FloEdelmann

Copy link
Copy Markdown
Member Author

Should the directive also go into the file you mentioned?

@peternewman

Copy link
Copy Markdown
Member

Possibly a question for @daveol but from my understanding of directives and given what he did with filters, I'd say make a new folder and put it in there, similar to this:
https://github.com/OpenLightingProject/ola/tree/master/javascript/new-src/src/filters

I'm assuming that directive can be used to grab focus anywhere in the UI we might need to?

@FloEdelmann

Copy link
Copy Markdown
Member Author

Exactly. I'll do that then.

* created new directives directory
* removed '-' as 'THRU' shortcut
* fix code style
@FloEdelmann

Copy link
Copy Markdown
Member Author

Travis failed again because of the GitHub outage.

@peternewman peternewman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments

Comment thread javascript/new-src/Gruntfile.js Outdated
'src/constants.js',
'src/directives/autofocus.js',
'src/factories/ola.js',
'src/filters/start_form.js'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're here, can I be cheeky and get you to fix this, it's a typo and should be start_from.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll fix it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

var key = $event.key;

if ($event.altKey || $event.ctrlKey || $event.metaKey
|| ($event.which == 0 && key != 'Enter' && key != 'Backspace')) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put the or on the line above please (leave the ($event indented by one from the ( above).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted

var key = $event.key;

if ($event.altKey || $event.ctrlKey || $event.metaKey
|| ($event.which == 0 && key != 'Enter' && key != 'Backspace')) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a constant for this 0 or anything?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$event.which is 0 for non-printable keys (like the F1 - F12 keys I had in mind). Those won't interfere with the input's value anyway, so we just exclude them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha.

* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Allows an element to obtail focus whenever a variable is set to true.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SPaG obtain

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@peternewman

Copy link
Copy Markdown
Member

Here is what the old web UI used to do on the keypad front. It would be good to add > for THRU at least:
https://github.com/OpenLightingProject/ola/blob/master/javascript/ola/common/keypad_parser.js#L186

@FloEdelmann

Copy link
Copy Markdown
Member Author

Yeah, > is good but I think * does not really suit here. I'd rather expect all channels for that.

* Typo form -> from
* Typo obtail -> obtain
* indention
* added '>' as 'THRU' shortcut
@peternewman

Copy link
Copy Markdown
Member

You'll need to add the new file here to fix Travis: https://github.com/OpenLightingProject/ola/blob/master/javascript/Makefile.mk#L22

Comment thread javascript/Makefile.mk
javascript/new-src/src/controllers/setting_universe.js \
javascript/new-src/src/controllers/header.js \
javascript/new-src/src/controllers/overview.js \
javascript/new-src/src/directives/autofocus.js \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to change start_from to form here too.

Can we fix the sorting please, by folder then file; so move factories and filters up (and above img).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I pushed the moment you commented. Wait for another commit ;)

@FloEdelmann

Copy link
Copy Markdown
Member Author

Travis does still fail 😢

@peternewman

Copy link
Copy Markdown
Member

Yeah * did all channels before (min channel to max channel).

@peternewman

Copy link
Copy Markdown
Member

Travis is now working again, there are a chunk of JS lint issues you'll need to fix please:
https://travis-ci.org/OpenLightingProject/ola/jobs/169594371#L417

@FloEdelmann

Copy link
Copy Markdown
Member Author

jshint and jscs are don't agree on the case indentation. When I comply with one, the other fails.

@peternewman

Copy link
Copy Markdown
Member

I'm inclined to say we should stick with jscs as you've currently done, as that's our own custom JS style, rather than a default one. So then it's just a case of stopping jshint complaining.

It looks like this got resolved in jshint here, which should be in jshint 2.2.0 upwards:
jshint/jshint@c64fb5c

Which we're already running, so needs a little more digging.

This is the first switch/case in our JS code, hence the issue.

@peternewman

Copy link
Copy Markdown
Member

Actually I think it may be the {} block within the case @FloEdelmann . Have you tried removing that?

@FloEdelmann

FloEdelmann commented Oct 23, 2016

Copy link
Copy Markdown
Member Author

I have actually never used {} blocks for case statements but added them after jscs complained.

@peternewman

Copy link
Copy Markdown
Member

I've taken the {} back out, as we need to fix our JCSC config instead.

@peternewman

Copy link
Copy Markdown
Member

Travis should be fixed by OpenLightingProject/javascript-style#9 .

@peternewman

Copy link
Copy Markdown
Member

As promised, now all green.

@peternewman
peternewman merged commit ef9ab39 into OpenLightingProject:master Oct 24, 2016
@FloEdelmann
FloEdelmann deleted the keypad branch October 25, 2016 12:11
@FloEdelmann

Copy link
Copy Markdown
Member Author

Nice, thank you :)

@peternewman

Copy link
Copy Markdown
Member

@daveol if you want to retrospectively review this, let us know if there are any issues.

@FloEdelmann I realised I forgot to regenerate the JS after fixing lint issues and it looks like you did the same. Would you mind updating them and pushing a new PR please.

@FloEdelmann

Copy link
Copy Markdown
Member Author

Unfortunately, I won't find the time until maybe Monday. If it's still relevant then, just let me know.

peternewman added a commit that referenced this pull request Nov 2, 2016
Regenerate JS after we forgot in #1138
@peternewman peternewman mentioned this pull request Jul 12, 2026
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

Successfully merging this pull request may close these issues.

2 participants