mirror of
https://github.com/Ekokumppanit/Bicyclesim.git
synced 2026-01-26 03:04:09 +00:00
Merge branch 'master' of github.com:Ekokumppanit/Bicyclesim
This commit is contained in:
14
README.md
14
README.md
@@ -16,13 +16,9 @@ a speed sensor.
|
|||||||
|
|
||||||
## Speed sensor
|
## Speed sensor
|
||||||
|
|
||||||
Most basic speed sensor would be "Keyboard" that sends a keypress whenever
|
Most basic speed sensor would be "Keyboard" that sends a keypress whenever the wheel has turned one revolution.
|
||||||
the wheel has turned one revolution.
|
~~This kind of sensor can be built from a old keyboard by soldering a reed switch to right conductors at keyboard circuit board. Some instructions here: http://www.instructables.com/id/Hacking-a-USB-Keyboard/.~~
|
||||||
This kind of sensor can be built from a old keyboard by soldering a reed switch
|
Doesn't work. The reed switch wont be closed long enough for the keyboard controller or computer to register wheel revolutions.
|
||||||
to right conductors at keyboard circuit board. Some instructions here:
|
|
||||||
http://www.instructables.com/id/Hacking-a-USB-Keyboard/.
|
|
||||||
|
|
||||||
It is also possible to built equivalent device from Arduino Uno:
|
It should be possible to build working device from Arduino Uno (http://mitchtech.net/arduino-usb-hid-keyboard/) or Arduino Due (http://www.i-programmer.info/news/91-hardware/4965-new-powerful-arduino-due-.html).
|
||||||
http://mitchtech.net/arduino-usb-hid-keyboard/.
|
Device should read the reed switch status every 1ms and send keypress maybe every 500ms (send 'a' if there was one wheel revolution since last keypress, send 'b' if two etc).
|
||||||
Or more easily with the new Arduino Due:
|
|
||||||
http://www.i-programmer.info/news/91-hardware/4965-new-powerful-arduino-due-.html.
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
<div class="fluid-row">
|
<div class="fluid-row">
|
||||||
<form>
|
<form>
|
||||||
<legend>Asetukset</legend>
|
<legend>Asetukset</legend>
|
||||||
<label>Liikekerroin. Vaikuttaa nopeuteen jolla reitillä liikutaan. Ei vaikuta nopeuslukemaan tai kuljettuun matkaan.</label>
|
<label>Liikekerroin. Vaikuttaa kuljettuun matkaan mutta ei nopeuslukemaan.</label>
|
||||||
<input type="text" value="{{settings.multiplier}}" id="settings_multiplier"/>
|
<input type="text" value="{{settings.multiplier}}" id="settings_multiplier"/>
|
||||||
<label>Renkaan koko, tuumia</label>
|
<label>Renkaan koko, tuumia</label>
|
||||||
<input type="text" value="{{settings.diameter}}" id="settings_diameter"/>
|
<input type="text" value="{{settings.diameter}}" id="settings_diameter"/>
|
||||||
@@ -182,6 +182,8 @@
|
|||||||
{{#if can_edit}}<a href="#" class="remove"><i class="icon-remove-sign"></i></a>{{/if}}
|
{{#if can_edit}}<a href="#" class="remove"><i class="icon-remove-sign"></i></a>{{/if}}
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#if can_edit}}<li class="new-point"><button type="button" class="btn"><i class="icon-plus-sign"></i></button></li>{{/if}}
|
{{#if can_edit}}
|
||||||
|
<li class="actions"><button type="button" class="btn new-point"><i class="icon-plus-sign"></i> Uusi</button> <button type="button" class="btn save{{#if saved}} btn-success{{else}} btn-warning{{/if}}"><i class="icon-save"></i> Tallenna</button></li>
|
||||||
|
{{/if}}
|
||||||
</ol>
|
</ol>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -156,16 +156,16 @@ a.thumbnail
|
|||||||
ol.points
|
ol.points
|
||||||
margin 0
|
margin 0
|
||||||
li
|
li
|
||||||
font-size 0.9em
|
font-size 0.85em
|
||||||
border-top 1px solid #ccc
|
border-top 1px solid #ccc
|
||||||
padding 2px 0px
|
padding 2px 0px
|
||||||
list-style-position inside
|
list-style-position inside
|
||||||
&:first-child, &.new-point
|
&:first-child, &.actions
|
||||||
border-top 0
|
border-top 0
|
||||||
&.new-point
|
&.actions
|
||||||
list-style none
|
list-style none
|
||||||
span.location
|
span.location
|
||||||
font-size 0.8em
|
font-size 0.85em
|
||||||
a.remove
|
a.remove
|
||||||
float right
|
float right
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ function new_point(latlng) {
|
|||||||
add_point(latlng, num, true);
|
add_point(latlng, num, true);
|
||||||
++num;
|
++num;
|
||||||
$('.sidebar').animate({scrollTop: $('.sidebar-inner').height()}, 'fast');
|
$('.sidebar').animate({scrollTop: $('.sidebar-inner').height()}, 'fast');
|
||||||
|
Session.set('saved', false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +93,10 @@ Template.points.can_edit = function () {
|
|||||||
return (route && Meteor.user() && route.owner === Meteor.user()._id);
|
return (route && Meteor.user() && route.owner === Meteor.user()._id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Template.points.saved = function () {
|
||||||
|
return Session.get('saved');
|
||||||
|
};
|
||||||
|
|
||||||
Template.points.helpers(helpers);
|
Template.points.helpers(helpers);
|
||||||
|
|
||||||
Template.points.events({
|
Template.points.events({
|
||||||
@@ -101,11 +106,17 @@ Template.points.events({
|
|||||||
'click a.remove': function () {
|
'click a.remove': function () {
|
||||||
Meteor.call('remove_point', this._id, function () {
|
Meteor.call('remove_point', this._id, function () {
|
||||||
full_clear_required = true;
|
full_clear_required = true;
|
||||||
|
Session.set('saved', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'click .new-point button': function () {
|
'click .new-point': function () {
|
||||||
new_point(maps.getLatLng());
|
new_point(maps.getLatLng());
|
||||||
},
|
},
|
||||||
|
'click .save': function () {
|
||||||
|
Meteor.call('update_route', Session.get('route'), function () {
|
||||||
|
Session.set('saved', true);
|
||||||
|
});
|
||||||
|
},
|
||||||
'change #points-autoadd': function (event) {
|
'change #points-autoadd': function (event) {
|
||||||
Session.set('points-autoadd', event.currentTarget.checked);
|
Session.set('points-autoadd', event.currentTarget.checked);
|
||||||
}
|
}
|
||||||
@@ -124,6 +135,7 @@ Meteor.autorun(function () {
|
|||||||
if (Session.equals('page', 'edit') && Session.get('route')) {
|
if (Session.equals('page', 'edit') && Session.get('route')) {
|
||||||
debug('sivu tai route vaihtui, route: ' + Session.get('route'));
|
debug('sivu tai route vaihtui, route: ' + Session.get('route'));
|
||||||
full_clear_required = true;
|
full_clear_required = true;
|
||||||
|
Session.set('saved', true);
|
||||||
|
|
||||||
Deps.nonreactive(function () {
|
Deps.nonreactive(function () {
|
||||||
var route = Routes.findOne({_id: Session.get('route')});
|
var route = Routes.findOne({_id: Session.get('route')});
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ Meteor.methods({
|
|||||||
var route = Routes.findOne({_id: route_id});
|
var route = Routes.findOne({_id: route_id});
|
||||||
if (!route) return;
|
if (!route) return;
|
||||||
|
|
||||||
var point_id = Points.insert({latlng: latlng, route: route_id, distance: 0, next: null});
|
var point_id = Points.insert({latlng: latlng, heading: 0, route: route_id, distance: 0, next: null});
|
||||||
|
|
||||||
// Add new point after last point.
|
// Add new point after last point.
|
||||||
Points.update({route: route_id, next: null, _id: {$ne: point_id}}, {$set: {next: point_id}});
|
Points.update({route: route_id, next: null, _id: {$ne: point_id}}, {$set: {next: point_id}});
|
||||||
@@ -49,7 +49,15 @@ Meteor.methods({
|
|||||||
// If route didn't have any point, update first point,
|
// If route didn't have any point, update first point,
|
||||||
Routes.update({_id: route_id, first: null}, {$set: {first: point_id}});
|
Routes.update({_id: route_id, first: null}, {$set: {first: point_id}});
|
||||||
|
|
||||||
update_route(route_id);
|
// Update distance and heading of previous point
|
||||||
|
var prev = Points.findOne({next: point_id});
|
||||||
|
if (prev) {
|
||||||
|
heading = computeFinalBearing(prev.latlng, latlng);
|
||||||
|
distance = computeDistance(prev.latlng, latlng);
|
||||||
|
Points.update({next: point_id}, {$set: {heading: heading, distance: distance}});
|
||||||
|
}
|
||||||
|
|
||||||
|
// update_route(route_id);
|
||||||
},
|
},
|
||||||
remove_point: function (point_id) {
|
remove_point: function (point_id) {
|
||||||
var point = Points.findOne({_id: point_id});
|
var point = Points.findOne({_id: point_id});
|
||||||
@@ -61,6 +69,9 @@ Meteor.methods({
|
|||||||
|
|
||||||
Points.remove({_id: point_id});
|
Points.remove({_id: point_id});
|
||||||
|
|
||||||
update_route(point.route);
|
// update_route(point.route);
|
||||||
|
},
|
||||||
|
update_route: function (route_id) {
|
||||||
|
update_route(route_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user