-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add module octoliner #72
Conversation
modules/@amperka/octoliner.js
Outdated
if (binaryLine[i]) { | ||
sum += binaryLine[i]; | ||
avg += binaryLine[i] * weight[i]; | ||
console.log(sum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱 forgotten console.log
modules/@amperka/octoliner.js
Outdated
var avg = 0; | ||
var weight = [4, 3, 2, 1, -1, -2, -3, -4]; | ||
if (Array.isArray(binaryLine)) { | ||
console.log(binaryLine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙀 forgotten console.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Документация на вики наследует от экспандера неактуальные примеры кода.
Чтто такое «чувствительность датчиков линии»?
modules/@amperka/octoliner.js
Outdated
if (sum != 0) { | ||
return avg / sum / 4.0; | ||
} | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
отступ
@@ -0,0 +1,83 @@ | |||
var Octoliner = function(opts) { | |||
opts = opts || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хорошо бы задать дефолтный i2c или ошибку, если он не задан.
modules/@amperka/octoliner.js
Outdated
return result; | ||
}; | ||
|
||
Octoliner.prototype.mapLine = function(binaryLine) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут не binaryLine надо, а просто line, т.к. этот алгоритм работает и на дробных числах.
modules/@amperka/octoliner.js
Outdated
var weight = [4, 3, 2, 1, -1, -2, -3, -4]; | ||
if (Array.isArray(binaryLine)) { | ||
for (var i = 0; i < 8; i++) { | ||
if (binaryLine[i]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и без проверки здесь
LGTM |
описание http://wiki.amperka.ru/js:octoliner
@igor89
@igrztv
@acosinwork