Skip to content

Instantly share code, notes, and snippets.

@craftyc0der
Last active August 29, 2015 14:19
Show Gist options
  • Save craftyc0der/01d1c322ce6bfe87a97d to your computer and use it in GitHub Desktop.
Save craftyc0der/01d1c322ce6bfe87a97d to your computer and use it in GitHub Desktop.
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="../paper-slider/paper-slider.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-progress/paper-progress.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-item/paper-item.html">
<polymer-element name="motobrain-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
box-sizing: border-box;
}
#core_scaffold {
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
#core_header_panel {
background-color: rgb(255, 255, 255);
}
#core_toolbar {
color: rgb(255, 255, 255);
background-color: rgb(79, 125, 201);
}
#core_menu {
font-size: 16px;
}
#paper_slider {
position: relative;
left: 10px;
top: 15px;
}
#current_list {
position: relative;
left: 10px;
}
#outputOff {
position: relative;
}
#container {
position: relative;
}
#outputStatus {
left: 10px;
position: relative;
}
.tripped::shadow [checked] .toggle {
background-color: #0000FF;
}
#outputStatus {
position: relative;
top: 5px;
}
#currentProgress {
position: relative;
width: 223px;
}
#amps {
position: relative;
top: 10px;
left: 10px;
}
#highamps {
position: relative;
left: 175px;
}
</style>
<core-scaffold id="core_scaffold">
<core-header-panel mode="seamed" id="core_header_panel" navigation flex title="Output 3">
<core-toolbar id="core_toolbar">Outputs</core-toolbar>
<core-menu selected="Output 1" valueattr="label" selecteditem="{{ selectedMenu }}" selectedindex="{{ selectedOutput }}" id="core_menu" theme="core-light-theme">
<core-item id="output0" icon="settings" label="Output 1" horizontal center layout active></core-item>
<core-item id="output1" icon="settings" label="Output 2" horizontal center layout></core-item>
<core-item id="output2" icon="settings" label="Output 3" horizontal center layout></core-item>
<core-item id="output3" icon="settings" label="Output 4" horizontal center layout></core-item>
<core-item id="output4" icon="settings" label="Output 5" horizontal center layout></core-item>
<core-item id="output5" icon="settings" label="Output 6" horizontal center layout></core-item>
<core-item id="output6" icon="settings" label="Output 7" horizontal center layout></core-item>
<core-item id="output7" icon="settings" label="Output 8" horizontal center layout></core-item>
</core-menu>
</core-header-panel>
<div id="div" tool>{{ selectedMenu.label }}</div>
<div id="container">
<paper-toggle-button id="outputStatus" touch-action="pan-y" ></paper-toggle-button>
<paper-slider value="{{ sliderValue }}" max="4096" id="paper_slider" on-change="{{ pwm }}"></paper-slider>
<paper-button id="outputOff" on-tap="{{ off }}">Off</paper-button>
<paper-button id="outputOn" on-tap="{{ on }}">On</paper-button>
<div id="amps">
<paper-progress value="50" ratio="50" id="currentProgress"></paper-progress>
<br></br>
<br></br>
<span id="lowamps">0A</span>
<span id="highamps">{{ }}</span>
</div>
<paper-dropdown-menu id="current_list" label="Motobrain Current Limit">
<paper-dropdown class="dropdown">
<core-menu selected="0" selecteditem="{{ selectedCurrent }}" selectedindex="0" class="menu" on-core-select="{{ fuse }}">
<paper-item active id="500mA" icon="settings" label="500">500mA</paper-item>
<paper-item id="1A" icon="settings" label="1000">1A</paper-item>
<paper-item id="3A" icon="settings" label="3000">3A</paper-item>
<paper-item id="5A" icon="settings" label="5000">5A</paper-item>
<paper-item id="8A" icon="settings" label="8000">8A</paper-item>
<paper-item id="10A" icon="settings" label="10000">10A</paper-item>
<paper-item id="12A" icon="settings" label="12000">12A</paper-item>
<paper-item id="15A" icon="settings" label="15000">15A</paper-item>
</core-menu>
</paper-dropdown>
</paper-dropdown-menu>
</div>
</core-scaffold>
</template>
<script>
Polymer({
selectedMenu: null,
ready: function () {
this.selectedOutput = 0;
this.sliderValue = 0;
},
off: function () {
gapi.client.messaging.messagingEndpoint.toggleChannel({'channel': this.selectedOutput, 'status':false}).execute();
},
on: function () {
gapi.client.messaging.messagingEndpoint.toggleChannel({'channel': this.selectedOutput, 'status':true}).execute();
},
pwm: function () {
gapi.client.messaging.messagingEndpoint.pwmUpdate({'channel': this.selectedOutput, 'pwm': this.sliderValue}).execute();
},
fuse: function () {
gapi.client.messaging.messagingEndpoint.fuseUpdate({'channel': this.selectedOutput, 'fuse': this.selectedCurrent.getAttribute('label')}).execute();
},
getCurrent: function () {
gapi.client.messaging.messagingEndpoint.getCurrent({'channel': this.selectedOutput}).execute(
function(response) {
}
);
},
getStatus: function () {
gapi.client.messaging.messagingEndpoint.getStatus({'channel': this.selectedOutput}).execute(
function(response) {
}
);
},
getPwm: function () {
gapi.client.messaging.messagingEndpoint.getPwm({'channel': this.selectedOutput}).execute(
function(response) {
}
);
},
getFuse: function () {
gapi.client.messaging.messagingEndpoint.getFuse({'channel': this.selectedOutput}).execute(
function(response) {
}
);
},
selectedOutput: 0,
sliderValue: 0,
selectedCurrent: null
});
</script>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment