Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jake Read
rndmc
Commits
15571dff
Commit
15571dff
authored
Nov 14, 2018
by
Jake Read
Browse files
ongoing
parent
d9325673
Changes
7
Hide whitespace changes
Inline
Side-by-side
lib/atkroute.js
View file @
15571dff
...
...
@@ -25,6 +25,7 @@ function ATKRoute(route, calls) {
atkroute
.
onMessage
=
function
(
msg
){
// one key at a time, for now
var
key
=
msg
[
0
].
toString
()
// *could* slice the key out at this point, but nah
if
(
this
.
calls
[
key
]
!=
null
){
this
.
calls
[
key
](
msg
)
}
...
...
lib/atkunit.js
View file @
15571dff
...
...
@@ -22,6 +22,8 @@ function Hardware(){
hardware
.
state
=
State
()
var
state
=
hardware
.
state
state
.
reset
=
Button
(
'
reset hardware
'
,
onReset
)
state
.
test
=
Button
(
'
test network
'
,
onNetworkTest
)
state
.
message
=
'
click above to test network
'
state
.
route
=
'
0,0
'
// default
...
...
@@ -30,6 +32,13 @@ function Hardware(){
hardware
.
route
.
route
=
state
.
route
})
function
onReset
(){
var
rstpck
=
new
Array
()
rstpck
.
push
(
128
)
state
.
message
=
'
reset command issued
'
hardware
.
route
.
send
(
rstpck
)
}
function
onNetworkTest
(){
var
tstpck
=
new
Array
()
tstpck
.
push
(
127
)
...
...
lib/packets.js
View file @
15571dff
...
...
@@ -13,7 +13,7 @@ function unPack32(arr){
var
unPacked
=
arr
[
0
]
<<
24
|
arr
[
1
]
<<
16
|
arr
[
2
]
<<
8
|
arr
[
3
]
return
unPacked
}
else
{
console
.
log
(
"
ERR: arr > 4 at unPack32
"
)
console
.
log
(
"
ERR: arr > 4 at unPack32
"
,
arr
)
}
}
...
...
main.js
View file @
15571dff
...
...
@@ -29,11 +29,12 @@ const Programs = require('./programs.js')
var
program
=
Programs
.
new
(
'
new program
'
)
var
step
=
Programs
.
loadModuleFromSource
(
program
,
'
./modules/hardware/atkstepper.js
'
)
// UI
const
View
=
require
(
'
./views.js
'
)
View
.
startHttp
()
View
.
startWs
()
Programs
.
assignSocket
(
View
.
uiSocket
)
View
.
assignProgram
(
program
)
View
.
assignProgram
(
program
)
\ No newline at end of file
modules/hardware/atkseriallink.js
View file @
15571dff
...
...
@@ -191,6 +191,7 @@ function ATKSerialLink() {
if
(
returnRoute
.
toString
()
===
atkSerialLink
.
routes
[
key
].
route
.
toString
())
{
// strip header and return message
var
msg
=
pckt
.
slice
(
pckt
.
indexOf
(
255
)
+
1
)
// this slices down to the keys ... doesn't take the keys away
match
=
true
atkSerialLink
.
routes
[
key
].
onMessage
(
msg
)
}
...
...
modules/hardware/atkstepper.js
View file @
15571dff
...
...
@@ -20,17 +20,30 @@ function Stepper() {
stepper
.
description
.
alt
=
'
software representation of stepper motor
'
stepper
.
inputs
=
{
move
:
Input
(
'
move instruction
'
,
onNewInstruction
),
trapezoid
:
Input
(
'
move instruction
'
,
onNewInstruction
),
accel
:
Input
(
'
number
'
,
onAccelCommand
),
rmtrig
:
Input
(
'
event
'
,
onRawMove
)
}
stepper
.
outputs
=
{
ack
:
Output
(
'
move acknowledgement
'
),
position
:
Output
(
'
number
'
)
}
//
alias
to state (from Hardware() beginnings)
//
ptr
to state (from Hardware() beginnings)
var
state
=
stepper
.
state
// for acceleration moves, in steps/s/s
state
.
rate
=
2000
state
.
onChange
(
'
rate
'
,
()
=>
{
if
(
state
.
rate
>
2000
){
state
.
rate
=
2000
}
else
if
(
state
.
rate
<
100
){
state
.
rate
=
100
}
})
state
.
axis
=
'
X
'
state
.
spu
=
200
// steps per unit
state
.
rawMove
=
-
10
...
...
@@ -55,6 +68,10 @@ function Stepper() {
sendToHardware
(
testMove
)
}
function
onAccelCommand
(
num
){
// 1 or 0 for start or stop accelerating
}
function
onNewInstruction
(
move
)
{
// console.log('move to stepper', stepper.state.axis, move)
// pick out axis (check if it's a wait move)
...
...
@@ -200,15 +217,16 @@ function Stepper() {
stepper
.
route
.
subscribe
(
131
,
onHardwareStepsComplete
)
function
onHardwareStepsComplete
(
pckt
)
{
var
stepsMade
=
PCKT
.
unPack32
(
pckt
)
var
stepsMade
=
PCKT
.
unPack32
(
pckt
.
slice
(
1
)
)
state
.
position
+=
stepsMade
var
unitsMade
=
stepsMade
/
state
.
spu
var
ack
=
{
axis
:
state
.
axis
,
increment
:
unitsMade
}
console
.
log
(
"
STEPPER ACK MOVE
"
,
state
.
axis
)
console
.
log
(
"
STEPPER ACK MOVE
"
,
state
.
axis
,
stepsMade
)
stepper
.
outputs
.
ack
.
emit
(
ack
)
stepper
.
outputs
.
position
.
emit
(
state
.
position
)
}
stepper
.
route
.
subscribe
(
132
,
onHardwareWaitComplete
)
...
...
views.js
View file @
15571dff
...
...
@@ -34,7 +34,7 @@ function startHttp() {
// through this window
http
.
listen
(
8080
,
()
=>
{
console
.
log
(
'
listening on
8080 for static files
'
)
console
.
log
(
'
RNDMC is
listening on
localhost:8080
'
)
})
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment