|
@@ -1,33 +1,19 @@
|
|
|
<template>
|
|
|
<div id="app">
|
|
|
- <h2 id="titolone" class="subtitle" style="background:beige;position:absolute;bottom:0">
|
|
|
- Second attempt at building a web interface for ESP8266
|
|
|
- </h2>
|
|
|
- <div style="margin-top:1em;margin-bottom:1em;display:flex;width:100%;height:3em;background:#3333333;align-items:center;justify-content:center">
|
|
|
- <div>
|
|
|
- <div class="icon-button" style="flex:1 1 auto" v-on:click="addLine()">
|
|
|
- <img style="margin:auto;" src="~/assets/img/add.png">
|
|
|
+ <div id="app-wrapper">
|
|
|
+ <div id="gadgety-view">
|
|
|
+ <div id="left-bar">
|
|
|
+ <div class="sequencer-wrapper" v-for="line in lines" :key='line.id'>
|
|
|
+ <sequencer class="jsonSequencer" :id='line.id' :line='line'></sequencer>
|
|
|
+ </div>
|
|
|
+ <div class="icon-button" v-on:click="addLine()"></div>
|
|
|
</div>
|
|
|
+ <div class="icon-wrapper">
|
|
|
+ <input type="number" style="width:5em;height:2em;background:red;border:none;color:white;" v-model="bpm" >
|
|
|
+ <input type="submit" value="Send!" style="width:5em;height:2em;background:red;border:none;color:white;" v-on:click="getSequencerData()">
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div v-for="line in lines" :key='line.id'>
|
|
|
- <sequencer class="jsonSequencer" :id='line.id' :line='line'></sequencer>
|
|
|
- </div>
|
|
|
- <div class="icon-wrapper">
|
|
|
- <div class="icon-button">
|
|
|
- <img style="margin:auto;" src="~/assets/img/barrier.png">
|
|
|
- </div>
|
|
|
- <div class="icon-button">
|
|
|
- <img style="margin:auto;" src="~/assets/img/pixel.png">
|
|
|
- </div>
|
|
|
- <div class="icon-button">
|
|
|
- <img style="margin:auto;" src="~/assets/img/squares.png">
|
|
|
- </div>
|
|
|
- <div class="icon-button">
|
|
|
- <img style="margin:auto;" src="~/assets/img/bell.png">
|
|
|
- </div>
|
|
|
- <input type="submit" value="Send!" style="width:5em;height:2em;background:red;border:none;color:white;" v-on:click="getSequencerData()">
|
|
|
- </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -40,9 +26,10 @@ import moduleData from '~/assets/js/moduleData.json'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- lines: []
|
|
|
+ lines: [],
|
|
|
// https://stackoverflow.com/questions/44869287/set-object-in-data-from-a-method-in-vue-js#44869373
|
|
|
// creata object in data vue
|
|
|
+ bpm:120
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
@@ -62,7 +49,7 @@ export default {
|
|
|
},
|
|
|
getSequencerData: function(){
|
|
|
var modelEsp = {
|
|
|
- 'millis_per_slot': 500, // bpm = 60000 / millis_per_slot
|
|
|
+ 'millis_per_slot': Math.floor(60000 / this.bpm), // bpm = 60000 / millis_per_slot
|
|
|
'lines': this.lines.map(function(line) {
|
|
|
return line.euclideanList.reduce(function(acc, x) { return acc + x.toString(); }, '');
|
|
|
})
|
|
@@ -74,27 +61,51 @@ export default {
|
|
|
xhr.onreadystatechange = function () {
|
|
|
if(xhr.readyState === 4 && xhr.status === 200) {
|
|
|
//self.commits = JSON.parse(xhr.responseText);
|
|
|
- console.log("Recv", xhr.responseText);
|
|
|
+ console.log("Sent", xhr.responseText);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
|
+ console.log("Sending", modelEsp);
|
|
|
xhr.send(JSON.stringify(modelEsp));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
+
|
|
|
<style>
|
|
|
+#app{
|
|
|
+ height:100vh;
|
|
|
+ background-color: cornflowerblue;
|
|
|
+}
|
|
|
+
|
|
|
+#app-wrapper{
|
|
|
+ height: 100%;
|
|
|
+ background: brown;
|
|
|
+ display: flex;
|
|
|
+}
|
|
|
+
|
|
|
+#left-bar{
|
|
|
+ flex:1 1 3em;
|
|
|
+ background-color: crimson;
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+}
|
|
|
+
|
|
|
.icon-button{
|
|
|
- display:flex;
|
|
|
- background-color:red;
|
|
|
- width:3em;
|
|
|
- height:3em;
|
|
|
- border-radius:3em;
|
|
|
- margin:0.2em;
|
|
|
+ width: 3em;
|
|
|
+ height: 3em;
|
|
|
+ background: white;
|
|
|
+ background-image: url("~/assets/img/add.png");
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-position: center;
|
|
|
}
|
|
|
|
|
|
-.icon-wrapper{
|
|
|
- display:flex;
|
|
|
+.sequencer-wrapper{
|
|
|
+ flex:1 1 100%;
|
|
|
+}
|
|
|
+#gadgety-view{
|
|
|
+ flex: 1 1 auto;
|
|
|
+ top:0;
|
|
|
}
|
|
|
</style>
|