mirror of
https://github.com/tjboldt/Apple2-IO-RPi.git
synced 2024-11-24 15:31:14 +00:00
Change server to test writing 4 KiB to II
This commit is contained in:
parent
44a1381b28
commit
60cf6d6b5a
@ -1,22 +0,0 @@
|
||||
var fs = require('fs');
|
||||
var gpio = require('onoff').Gpio;
|
||||
|
||||
var output = new gpio(4, 'high', {activeLow: true});
|
||||
var input = new gpio(6, 'in', 'both');
|
||||
|
||||
function onCleanUp() {
|
||||
output.unwatchAll();
|
||||
output.unexport();
|
||||
input.unexport();
|
||||
}
|
||||
|
||||
function onStatusChanged(err, value) {
|
||||
if (err) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
input.watch(onStatusChanged);
|
||||
|
||||
process.on('SIGINT', onCleanUp);
|
74
RaspberryPi/test.js
Normal file
74
RaspberryPi/test.js
Normal file
@ -0,0 +1,74 @@
|
||||
var fs = require('fs');
|
||||
var gpio = require('onoff').Gpio;
|
||||
|
||||
var out_write = new gpio(5, 'high', {activeLow: true});
|
||||
var out_read = new gpio(11, 'high', {activeLow: true});
|
||||
var out_command1 = new gpio(9, 'low', {activeLow: false});
|
||||
var out_command2 = new gpio(10, 'low', {activeLow: false});
|
||||
var out_bit3 = new gpio(22, 'low', {activeLow: false});
|
||||
var out_bit2 = new gpio(27, 'low', {activeLow: false});
|
||||
var out_bit1 = new gpio(17, 'low', {activeLow: false});
|
||||
var out_bit0 = new gpio(4, 'low', {activeLow: false});
|
||||
var in_write = new gpio(12, 'in', 'both');
|
||||
var in_read = new gpio(16, 'in', 'both');
|
||||
var in_command1 = new gpio(20, 'in');
|
||||
var in_command2 = new gpio(21, 'in');
|
||||
var in_bit3 = new gpio(26, 'in');
|
||||
var in_bit2 = new gpio(19, 'in');
|
||||
var in_bit1 = new gpio(13, 'in');
|
||||
var in_bit0 = new gpio(6, 'in');
|
||||
|
||||
function onCleanUp() {
|
||||
in_write.unwatchAll();
|
||||
in_write.unexport();
|
||||
}
|
||||
|
||||
function onWriteChanged(err, value) {
|
||||
if (err) {
|
||||
}
|
||||
else {
|
||||
//console.log(`value: ${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
number = 0;
|
||||
startTime = Date.now();
|
||||
|
||||
function onReadChanged(err, value) {
|
||||
if (err) {
|
||||
}
|
||||
else {
|
||||
if (value == 1) {
|
||||
//console.log("Nibble has been read");
|
||||
out_write.writeSync(0);
|
||||
}
|
||||
else {
|
||||
writeNibble(number++);
|
||||
if(number >= 4096) {
|
||||
seconds = Date.now() - startTime;
|
||||
console.log(`Sent 2 KiB in ${seconds} milliseconds.`);
|
||||
process.exit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
in_write.watch(onWriteChanged);
|
||||
in_read.watch(onReadChanged);
|
||||
|
||||
function writeNibble(nibble) {
|
||||
out_bit3.writeSync((nibble&8)>>3);
|
||||
out_bit2.writeSync((nibble&4)>>2);
|
||||
out_bit1.writeSync((nibble&2)>>1);
|
||||
out_bit0.writeSync(nibble&1);
|
||||
out_command1.writeSync(0);
|
||||
out_command2.writeSync(0);
|
||||
out_read.writeSync(0);
|
||||
out_write.writeSync(1);
|
||||
}
|
||||
|
||||
writeNibble(0);
|
||||
|
||||
process.on('SIGINT', onCleanUp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user