Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Contributors:
Stefan Krüger, added APA102 support to the SPI Plugin
Tobi Schäfer, for the MacPort files
Stefan S, improved timing with monotonic clock
Comment on lines 30 to 32
Copy link
Member

Choose a reason for hiding this comment

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

Sort the file:

Suggested change
Stefan Krüger, added APA102 support to the SPI Plugin
Tobi Schäfer, for the MacPort files
Stefan S, improved timing with monotonic clock
Stefan Krüger, added APA102 support to the SPI Plugin
Stefan S, improved timing with monotonic clock
Tobi Schäfer, for the MacPort files

Christian Mouttet, fix in new web-ui
3 changes: 3 additions & 0 deletions README.developer
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ Javascript
Javascript is used for the olad web UI. Instructions for building the
javascript can be found in javascript/README.

The sources for the new UI is located in javascript/new-src. The built artifact
is copied to olad/www/new/js/app.min.js.

Closure Compiler
----------------

Expand Down
1 change: 1 addition & 0 deletions javascript/new-src/src/controllers/universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ola.controller('universeCtrl',
'use strict';
$scope.dmx = [];
$scope.Universe = $routeParams.id;
$ola.resetHighestChannelNumberUsed();
Copy link
Member

Choose a reason for hiding this comment

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

We're better off calling a function here than just initialising a scope variable then are we (like the DMX array)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not very familiar with JavaScript. My home is Java on the backend. :)
I tried to to work with something like this $scope.highestChannelNumberUsed = 0 but I failed.

Copy link
Member

Choose a reason for hiding this comment

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

So it seems like $scope should work if you change it everywhere, but only within one controller, or there's $rootScope, or our $ola might be able to take a variable.

Otherwise @daveol or @FloEdelmann might be able to help, all this whizzy JavaScript library stuff isn't really my area of expertise either unfortunately.


var interval = $interval(function() {
$ola.get.Dmx($scope.Universe).then(function(data) {
Expand Down
36 changes: 29 additions & 7 deletions javascript/new-src/src/factories/ola.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
ola.factory('$ola', ['$http', '$window', 'OLA',
function($http, $window, OLA) {
'use strict';
var highestChannelNumberUsed = 0;

var updateHighestChannelNumberUsed = function(dmx) {
for (var channel = dmx.length; channel > highestChannelNumberUsed;
Copy link
Member

Choose a reason for hiding this comment

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

A comment might be nice here, just so we don't automatically assume it's iterating from dmx.length to zero as I did. Something like "we only care about checking channels higher than our existing highest" or similar maybe.

channel--) {

if ((dmx[channel - 1] > OLA.MIN_CHANNEL_VALUE) &&
(highestChannelNumberUsed < channel)) {
Copy link
Member

Choose a reason for hiding this comment

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

If it did say (which as below I don't think it needs to, swapping the two variables around so it matches the for loop would be less confusing).

Copy link
Contributor Author

@cmouttet cmouttet Aug 11, 2021

Choose a reason for hiding this comment

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

When using max only the > OLA.MIN_CHANNEL_VALUE part is needed. I removed the part highestChannelNumberUsed < channel.

highestChannelNumberUsed = channel;
}
}
};

// TODO(Dave_o): once olad supports json post data postEncode
// can go away and the header in post requests too.
var postEncode = function(data) {
Expand Down Expand Up @@ -52,20 +65,28 @@ ola.factory('$ola', ['$http', '$window', 'OLA',
return i;
};
var dmxConvert = function(dmx) {
var strip = true;
var integers = [];
for (var i = OLA.MAX_CHANNEL_NUMBER; i >= OLA.MIN_CHANNEL_NUMBER; i--) {
var value = channelValueCheck(dmx[i - 1]);
for (var channel = OLA.MAX_CHANNEL_NUMBER;
channel >= OLA.MIN_CHANNEL_NUMBER;
channel--) {

var value = channelValueCheck(dmx[channel - 1]);
if (value > OLA.MIN_CHANNEL_VALUE ||
!strip ||
i === OLA.MIN_CHANNEL_NUMBER) {
integers[i - 1] = value;
strip = false;
channel <= highestChannelNumberUsed) {

integers[channel - 1] = value;

if (highestChannelNumberUsed < channel) {
highestChannelNumberUsed = channel;
}
Copy link
Member

Choose a reason for hiding this comment

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

Again would $window.Math.max be easier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it works. Thanks.

}
}
return integers.join(',');
};
return {
resetHighestChannelNumberUsed: function() {
highestChannelNumberUsed = 0;
},
get: {
ItemList: function() {
return $http.get('/json/universe_plugin_list')
Expand Down Expand Up @@ -118,6 +139,7 @@ ola.factory('$ola', ['$http', '$window', 'OLA',
}
})
.then(function(response) {
updateHighestChannelNumberUsed(response.data.dmx);
return response.data;
});
},
Expand Down
2 changes: 1 addition & 1 deletion olad/www/new/css/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading