Commit fc639ed1 authored by Jake Read's avatar Jake Read

probably just about to break everything

parent db873c86
......@@ -239,6 +239,7 @@ t6.outputs.packet.attach(bridge.inputs.F)
bridge.outputs.F.attach(t6.inputs.packet)
//bridge.state.rF = '0'
*/
t7.outputs.packet.attach(bridge.inputs.G)
bridge.outputs.G.attach(t7.inputs.packet)
......
// boilerplate atkapi header
const InOut = require('../../lib/inout.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const PCKT = require('../../lib/packets.js')
// a constructor, a fn, a javascript mess
function ATKBreadBoardServo(port) {
var atkbbs = {
// descriptions are used in UI
description: {
name: 'Breadboard Servo Signal Generator',
alt: 'servo',
isHardware: true
}
}
atkbbs.state = State()
// alias !
var state = atkbbs.state
state.button = Button('SEND')
state.onChange('button', onButtonPress)
state.servoVal = 0 // 0->100 does 1 -> 2ms duty on 20ms period
state.onChange('servoVal', onButtonPress)
atkbbs.inputs = {
packet: Input('headless packet', onPacketReturn) // makes anything into '1' event
}
atkbbs.outputs = {
packet: Output('number')
}
function onButtonPress(evt) {
var pwm = state.servoVal
if(pwm > 100){
pwm = 100
} else if (pwm < 0){
pwm = 0
}
var microval = Math.round(7.5 * pwm)
console.log('pwm on line', microval)
var pwmpack = PCKT.pack32(microval)
pwmpack.unshift(141)
atkbbs.outputs.packet.emit(pwmpack)
}
function onPacketReturn(evt) {
}
return atkbbs
}
// exports
module.exports = ATKBreadBoardServo
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment