# HG changeset patch # User Drew Perttula # Date 2017-06-02 07:32:58 # Node ID 2dde8da33662e87977799c3d1c5a22ae73db0801 # Parent 6059de6659c3f712d0ad2e4e52a2e2802f384927 start making choice widgets on live Ignore-this: ad54a94a02be707e2e497a03f19b7096 diff --git a/light9/collector/device.py b/light9/collector/device.py --- a/light9/collector/device.py +++ b/light9/collector/device.py @@ -97,6 +97,13 @@ def toOutputAttrs(deviceType, deviceAttr hi = _8bit(x) lo = _8bit((x * 255) % 1.0) return hi, lo + + def choiceAttr(attr): + # todo + if deviceAttrSettings.get(attr) == L9['g1']: + return 3 + if deviceAttrSettings.get(attr) == L9['g2']: + return 10 if deviceType == L9['ChauvetColorStrip']: r, g, b = rgbAttr(L9['color']) @@ -115,7 +122,7 @@ def toOutputAttrs(deviceType, deviceAttr L9['colorChange']: 0, L9['colorSpeed']: 0, L9['goboShake']: _8bit(floatAttr(L9['goboShake'])), - L9['goboChoose']: _8bit(floatAttr(L9['mini15GoboChoice'])), + L9['goboChoose']: choiceAttr(L9['mini15GoboChoice']), } out[L9['red']], out[L9['green']], out[L9['blue']] = rgbAttr(L9['color']) out[L9['xRotation']], out[L9['xFine']] = fine16Attr(L9['rx'], 1/540) diff --git a/light9/web/live/index.html b/light9/web/live/index.html --- a/light9/web/live/index.html +++ b/light9/web/live/index.html @@ -15,6 +15,7 @@ + @@ -41,15 +42,19 @@ - - - + + + + + + diff --git a/light9/web/live/live.coffee b/light9/web/live/live.coffee --- a/light9/web/live/live.coffee +++ b/light9/web/live/live.coffee @@ -19,6 +19,8 @@ Polymer onSlider: -> @value = @immediateSlider goWhite: -> @value = "#ffffff" goBlack: -> @value = "#000000" + onChoice: (ev) -> + console.log('ch', ev) onChange: (value) -> @lastSent = [[@device, @deviceAttr.uri, value]] @@ -30,8 +32,56 @@ Polymer @value = '#000000' else @value = @immediateSlider = 0 - - + +Polymer + is: "light9-live-device-control" + properties: + graph: { type: Object, notify: true } + uri: { type: String, notify: true } + label: { type: String, notify: true } + deviceClass: { type: String, notify: true } + deviceAttrs: { type: Array, notify: true } + observers: [ + 'onGraph(graph)' + ] + onGraph: -> + @graph.runHandler(@update.bind(@), "#{@uri} update") + update: -> + U = (x) => @graph.Uri(x) + + @zlabel = (try + @graph.stringValue(@uri, U('rdfs:label')) + catch + words = @uri.split('/') + words[words.length-1] + ) + @deviceClass = @graph.uriValue(@uri, U('rdf:type')) + + @deviceAttrs = [] + for da in _.unique(_.sortBy(@graph.objects(@deviceClass, U(':deviceAttr')))) + dataType = @graph.uriValue(da, U(':dataType')) + daRow = { + uri: da + dataType: dataType + showColorPicker: dataType == U(':color') + } + if dataType == 'http://light9.bigasterisk.com/color' + daRow.useColor = true + + else if dataType == U(':choice') + daRow.useChoice = true + daRow.choices = @graph.objects(da, U(':choice')) + else + + daRow.useSlider = true + daRow.max = 1 + if dataType == U(':angle') + # varies + daRow.max = 1 + + @push('deviceAttrs', daRow) + + Polymer is: "light9-live-controls" properties: @@ -118,34 +168,4 @@ Polymer @set('devices', []) for dc in _.sortBy(@graph.subjects(U('rdf:type'), U(':DeviceClass'))) for dev in _.sortBy(@graph.subjects(U('rdf:type'), dc)) - row = {uri: dev, label: (try - @graph.stringValue(dev, U('rdfs:label')) - catch - words = dev.split('/') - words[words.length-1] - ), deviceClass: dc} - row.deviceAttrs = [] - for da in _.sortBy(@graph.objects(dc, U(':deviceAttr'))) - dataType = @graph.uriValue(da, U(':dataType')) - daRow = { - uri: da - dataType: dataType - showColorPicker: dataType == U(':color') - } - if dataType == 'http://light9.bigasterisk.com/color' - daRow.useColor = true - - else if dataType == U(':choice') - daRow.useChoice = true - daRow.choices = @graph.objects(da, U(':choice')) - else - - daRow.useSlider = true - daRow.max = 1 - if dataType == U(':angle') - # varies - daRow.max = 1 - - row.deviceAttrs.push(daRow) - - @push('devices', row) \ No newline at end of file + @push('devices', {uri: dev}) diff --git a/light9/web/style.css b/light9/web/style.css --- a/light9/web/style.css +++ b/light9/web/style.css @@ -160,6 +160,8 @@ a.resource { } .resource a { color: rgb(150, 150, 255); + padding: 1px; + display: inline-block; } .sub { display: inline-block;