Browse Source

Merged in espurna/dev (pull request #46)

Conflicts:
	code/html/custom.js
i18n
Xose Pérez 7 years ago
parent
commit
1d558891b6
9 changed files with 1041 additions and 970 deletions
  1. +2
    -2
      code/build.sh
  2. BIN
      code/espurna/data/index.html.gz
  3. +0
    -1
      code/espurna/pwm.c
  4. +3
    -2
      code/espurna/sensors/EmonSensor.h
  5. +677
    -675
      code/espurna/static/index.html.gz.h
  6. +14
    -6
      code/gulpfile.js
  7. +50
    -45
      code/html/checkboxes.js
  8. +292
    -236
      code/html/custom.js
  9. +3
    -3
      code/ota.py

+ 2
- 2
code/build.sh View File

@ -5,7 +5,7 @@ echo "--------------------------------------------------------------"
echo "ESPURNA FIRMWARE BUILDER"
# Available environments
available=`cat platformio.ini | grep env: | grep -v ota | grep -v ssl | sed 's/\[env://' | sed 's/\]/ /' | sort`
available=$(grep env: platformio.ini | grep -v ota | grep -v ssl | sed 's/\[env://' | sed 's/\]/ /' | sort)
environments=$@
if [ "$environments" == "list" ]; then
echo "--------------------------------------------------------------"
@ -22,7 +22,7 @@ if [ $# -eq 0 ]; then
fi
# Get current version
version=`cat espurna/config/version.h | grep APP_VERSION | awk '{print $3}' | sed 's/"//g'`
version=$(grep APP_VERSION espurna/config/version.h | awk '{print $3}' | sed 's/"//g')
echo "Building for version $version"
# Create output folder


BIN
code/espurna/data/index.html.gz View File


+ 0
- 1
code/espurna/pwm.c View File

@ -209,7 +209,6 @@ _pwm_phases_prep(struct pwm_phase* pwm)
{
uint8_t n, phases;
uint16_t off_mask = 0;
for (n = 0; n < pwm_channels + 2; n++) {
pwm[n].ticks = 0;
pwm[n].on_mask = 0;


+ 3
- 2
code/espurna/sensors/EmonSensor.h View File

@ -147,15 +147,16 @@ class EmonSensor : public I2CSensor {
double read(unsigned char channel) {
int sample;
int max = 0;
int min = _adc_counts;
double filtered;
double sum = 0;
unsigned long time_span = millis();
for (unsigned long i=0; i<_samples; i++) {
int sample;
double filtered;
// Read analog value
sample = readADC(channel);
if (sample > max) max = sample;


+ 677
- 675
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 14
- 6
code/gulpfile.js View File

@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*eslint quotes: ["error", "single"]*/
/*eslint-env es6*/
// -----------------------------------------------------------------------------
// File system builder
// -----------------------------------------------------------------------------
@ -57,19 +60,22 @@ var toHeader = function(filename) {
var data = fs.readFileSync(source);
wstream.write('#define ' + safename + '_len ' + data.length + '\n');
wstream.write('const uint8_t ' + safename + '[] PROGMEM = {')
wstream.write('const uint8_t ' + safename + '[] PROGMEM = {');
for (i=0; i<data.length; i++) {
if (i % 20 == 0) wstream.write("\n");
for (var i=0; i<data.length; i++) {
if (i % 20 == 0) wstream.write('\n');
wstream.write('0x' + ('00' + data[i].toString(16)).slice(-2));
if (i<data.length-1) wstream.write(',');
if (i<data.length-1) {
wstream.write(',');
}
}
wstream.write('\n};')
wstream.write('\n};');
wstream.end();
}
function htmllintReporter(filepath, issues) {
if (issues.length > 0) {
issues.forEach(function (issue) {
@ -79,6 +85,7 @@ function htmllintReporter(filepath, issues) {
}
}
gulp.task('build_certs', function() {
toHeader('server.cer');
toHeader('server.key');
@ -112,6 +119,7 @@ gulp.task('buildfs_inline', function() {
}))
.pipe(gzip())
.pipe(gulp.dest(dataFolder));
})
});
gulp.task('default', ['buildfs_embeded']);

+ 50
- 45
code/html/checkboxes.js View File

@ -1,4 +1,7 @@
// Generated by CoffeeScript 1.6.2
/*eslint quotes: ["error", "double"]*/
/*eslint-env es6*/
(function() {
var iOSCheckbox, matched, userAgent,
__slice = [].slice;
@ -33,8 +36,10 @@
this.elem = $(elem);
opts = $.extend({}, iOSCheckbox.defaults, options);
for (key in opts) {
value = opts[key];
this[key] = value;
if ({}.hasOwnProperty.call(opts, key)) {
value = opts[key];
this[key] = value;
}
}
this.elem.data(this.dataName, this);
this.wrapCheckboxWithDivs();
@ -45,27 +50,27 @@
iOSCheckbox.prototype.calculateDimensions = function() {
if (this.resizeHandle) {
this.optionallyResize('handle');
this.optionallyResize("handle");
}
if (this.resizeContainer) {
this.optionallyResize('container');
this.optionallyResize("container");
}
return this.initialPosition();
};
iOSCheckbox.prototype.isDisabled = function() {
return this.elem.is(':disabled');
return this.elem.is(":disabled");
};
iOSCheckbox.prototype.wrapCheckboxWithDivs = function() {
this.elem.wrap("<div class='" + this.containerClass + "' />");
this.container = this.elem.parent();
this.offLabel = $("<label class='" + this.labelOffClass + "'>\n <span>" + this.uncheckedLabel + "</span>\n</label>").appendTo(this.container);
this.offSpan = this.offLabel.children('span');
this.offSpan = this.offLabel.children("span");
this.onLabel = $("<label class='" + this.labelOnClass + "'>\n <span>" + this.checkedLabel + "</span>\n</label>").appendTo(this.container);
this.onBorder = $("<div class='iPhoneCheckBorderOn'</div>").appendTo(this.container);
this.offBorder = $("<div class='iPhoneCheckBorderOff'</div>").appendTo(this.container);
this.onSpan = this.onLabel.children('span');
this.onSpan = this.onLabel.children("span");
this.handle = $("<div class='" + this.handleClass + "'></div>").appendTo(this.container);
this.handleCenter = $("<div class='" + this.handleCenterClass + "'></div>").appendTo(this.handle);
this.handleRight = $("<div class='" + this.handleRightClass + "'></div>").appendTo(this.handle);
@ -89,12 +94,12 @@
iOSCheckbox.prototype.optionallyResize = function(mode) {
var newWidth, offLabelWidth, offSpan, onLabelWidth, onSpan;
onSpan = this.onLabel.find('span');
onSpan = this.onLabel.find("span");
onLabelWidth = this._getDimension(onSpan, "width");
onLabelWidth += parseInt(onSpan.css('padding-left'), 10);
offSpan = this.offLabel.find('span');
onLabelWidth += parseInt(onSpan.css("padding-left"), 10);
offSpan = this.offLabel.find("span");
offLabelWidth = this._getDimension(offSpan, "width");
offLabelWidth += parseInt(offSpan.css('padding-right'), 10);
offLabelWidth += parseInt(offSpan.css("padding-right"), 10);
if (mode === "container") {
newWidth = onLabelWidth > offLabelWidth ? onLabelWidth : offLabelWidth;
newWidth += this._getDimension(this.handle, "width") + this.handleMargin;
@ -122,7 +127,7 @@
x = event.pageX || event.originalEvent.changedTouches[0].pageX;
iOSCheckbox.currentlyClicking = this.handle;
iOSCheckbox.dragStartPosition = x;
return iOSCheckbox.handleLeftOffset = parseInt(this.handle.css('left'), 10) || 0;
return iOSCheckbox.handleLeftOffset = parseInt(this.handle.css("left"), 10) || 0;
};
iOSCheckbox.prototype.onDragMove = function(event, x) {
@ -164,14 +169,14 @@
}
if (iOSCheckbox.dragging) {
p = (x - iOSCheckbox.dragStartPosition) / this.rightSide;
this.elem.prop('checked', p >= 0.5).change();
this.elem.prop("checked", p >= 0.5).change();
} else {
this.elem.prop('checked', !this.elem.prop('checked')).change();
this.elem.prop("checked", !this.elem.prop("checked")).change();
}
iOSCheckbox.currentlyClicking = null;
iOSCheckbox.dragging = null;
if (typeof this.onChange === "function") {
this.onChange(this.elem, this.elem.prop('checked'));
this.onChange(this.elem, this.elem.prop("checked"));
}
return this.didChange();
};
@ -181,7 +186,7 @@
};
iOSCheckbox.prototype.didChange = function() {
var new_left;
var newLeft;
if (this.isDisabled()) {
this.container.addClass(this.disabledClass);
@ -189,18 +194,18 @@
} else {
this.container.removeClass(this.disabledClass);
}
new_left = this.elem.prop('checked') ? this.rightSide + 2 : 0;
newLeft = this.elem.prop("checked") ? this.rightSide + 2 : 0;
this.handle.animate({
left: new_left
left: newLeft
}, this.duration);
this.onLabel.animate({
width: new_left + this.handleRadius
width: newLeft + this.handleRadius
}, this.duration);
this.offSpan.animate({
marginRight: -new_left
marginRight: - newLeft
}, this.duration);
return this.onSpan.animate({
marginLeft: new_left - this.rightSide
marginLeft: newLeft - this.rightSide
}, this.duration);
};
@ -213,16 +218,16 @@
};
localMouseUp = function(event) {
self.onGlobalUp.apply(self, arguments);
$(document).unbind('mousemove touchmove', localMouseMove);
return $(document).unbind('mouseup touchend', localMouseUp);
$(document).unbind("mousemove touchmove", localMouseMove);
return $(document).unbind("mouseup touchend", localMouseUp);
};
this.elem.change(function() {
return self.refresh();
});
return this.container.bind('mousedown touchstart', function(event) {
return this.container.bind("mousedown touchstart", function(event) {
self.onMouseDown.apply(self, arguments);
$(document).bind('mousemove touchmove', localMouseMove);
return $(document).bind('mouseup touchend', localMouseUp);
$(document).bind("mousemove touchmove", localMouseMove);
return $(document).bind("mouseup touchend", localMouseUp);
});
};
@ -241,7 +246,7 @@
offset -= 3;
}
this.rightSide = containerWidth - this._getDimension(this.handle, "width") - offset;
if (this.elem.is(':checked')) {
if (this.elem.is(":checked")) {
this.handle.css({
left: this.rightSide
});
@ -292,17 +297,17 @@
iOSCheckbox.defaults = {
duration: 200,
checkedLabel: 'ON',
uncheckedLabel: 'OFF',
checkedLabel: "ON",
uncheckedLabel: "OFF",
resizeHandle: true,
resizeContainer: true,
disabledClass: 'iPhoneCheckDisabled',
containerClass: 'iPhoneCheckContainer',
labelOnClass: 'iPhoneCheckLabelOn',
labelOffClass: 'iPhoneCheckLabelOff',
handleClass: 'iPhoneCheckHandle',
handleCenterClass: 'iPhoneCheckHandleCenter',
handleRightClass: 'iPhoneCheckHandleRight',
disabledClass: "iPhoneCheckDisabled",
containerClass: "iPhoneCheckContainer",
labelOnClass: "iPhoneCheckLabelOn",
labelOffClass: "iPhoneCheckLabelOff",
handleClass: "iPhoneCheckHandle",
handleCenterClass: "iPhoneCheckHandleCenter",
handleRightClass: "iPhoneCheckHandleRight",
dragThreshold: 5,
handleMargin: 15,
handleRadius: 4,
@ -322,7 +327,7 @@
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
dataName = (_ref = (_ref1 = args[0]) != null ? _ref1.dataName : void 0) != null ? _ref : iOSCheckbox.defaults.dataName;
_ref2 = this.filter(':checkbox');
_ref2 = this.filter(":checkbox");
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
checkbox = _ref2[_i];
existingControl = $(checkbox).data(dataName);
@ -346,14 +351,14 @@
}
opts = $.extend({}, options, {
resizeHandle: false,
disabledClass: 'iOSCheckDisabled',
containerClass: 'iOSCheckContainer',
labelOnClass: 'iOSCheckLabelOn',
labelOffClass: 'iOSCheckLabelOff',
handleClass: 'iOSCheckHandle',
handleCenterClass: 'iOSCheckHandleCenter',
handleRightClass: 'iOSCheckHandleRight',
dataName: 'iOSCheckbox'
disabledClass: "iOSCheckDisabled",
containerClass: "iOSCheckContainer",
labelOnClass: "iOSCheckLabelOn",
labelOffClass: "iOSCheckLabelOff",
handleClass: "iOSCheckHandle",
handleCenterClass: "iOSCheckHandleCenter",
handleRightClass: "iOSCheckHandleRight",
dataName: "iOSCheckbox"
});
return this.iphoneStyle(opts);
};


+ 292
- 236
code/html/custom.js
File diff suppressed because it is too large
View File


+ 3
- 3
code/ota.py View File

@ -19,7 +19,7 @@ from zeroconf import ServiceBrowser, ServiceStateChange, Zeroconf
try:
# noinspection PyUnresolvedReferences
input = raw_input # Python2
input = raw_input # Python2 *!! redefining build-in input.
except NameError:
pass # Python3
@ -56,7 +56,7 @@ def on_service_state_change(zeroconf, service_type, name, state_change):
devices.append(device)
def list():
def list_devices():
"""
Shows the list of discovered devices
"""
@ -241,7 +241,7 @@ if __name__ == '__main__':
devices = sorted(devices, key=lambda device: device.get(field, ''))
# List devices
list()
list_devices()
# Flash device
if args.flash > 0:


Loading…
Cancel
Save