Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
I messed up saving for XYPads
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-uk committed Oct 13, 2019
1 parent 8f65775 commit f512a95
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 0 additions & 2 deletions lib/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ class Encoder {

// Now trigger all MIDI actions
for (var i = 0; i < this.midiactions.length; i++) {
console.log("DOING "+this.val);

this.midiactions[i].trigger(this.val);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class MidiAction {
}

trigger(value) {
console.log(this)
//console.log(this)
switch (this.type) {
case "note":
if(this.on) {
Expand Down
9 changes: 7 additions & 2 deletions lib/touchmidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function init() {
let storedval = getWidgetValue(pad);
if(storedval) {
pad.xval = storedval.split('|')[0];
pad.yval = storedval.split('|')[0];
pad.yval = storedval.split('|')[1];
widgets_with_saved_vals.push(pad);
}
}
Expand Down Expand Up @@ -347,7 +347,12 @@ function saveWidgetValue(widget) {
if(widget.no_save) return;
var filename = window.location.pathname.substring(window.location.pathname.lastIndexOf('/')+1);
let id = hashCode(`${widget.constructor.name}_${widget.midiactions[0]}`);
localStorage.setItem(`touchmidi.${filename}.${id}`, widget.val);

if(widget.constructor.name.toLowerCase() == 'xypad') {
localStorage.setItem(`touchmidi.${filename}.${id}`, `${widget.xval}|${widget.yval}`);
} else {
localStorage.setItem(`touchmidi.${filename}.${id}`, widget.val);
}
}

// =============================================================================
Expand Down
7 changes: 3 additions & 4 deletions lib/xypad.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ class XYPad {

this.xval = Math.round(new_val_x);
this.yval = Math.round(new_val_y);
// if(this.store_id) {
// saveWidgetValue(this.store_id + "_x", this.xval);
// saveWidgetValue(this.store_id + "_y", this.yval);
// }
saveWidgetValue(this);
this.redraw();
}

Expand All @@ -89,6 +86,8 @@ class XYPad {
// Redraw the crosshair based on x & y position, and trigger MIDI actions
// =============================================================================
redraw() {
console.log("herere");

var ctx = this.ctx;
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);

Expand Down

0 comments on commit f512a95

Please sign in to comment.