This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
BigSHinyToys's profile picture

Redstone signal tester

Started by BigSHinyToys, 09 June 2012 - 12:44 AM
BigSHinyToys #1
Posted 09 June 2012 - 02:44 AM
this program is designed to allow for quick testing of redstone Input/Output and display of Output status.How to useInstall in a computer run it from the CC console. press the keys 1 to 6 to switch the Output status of each side. pressing "q" will Quit the program.Pictures
Spoiler
ver 0.3
Spoiler
--[[	    By Big Shiny Toys	    9 june 2012 ver 0.3	    NO right's reserved	    use as you see fit no credit required]]--local sList = rs.getSides() -- this is a list of names "left" "right" ect...local function draw()    term.clear()    term.setCursorPos(1,1)    for i = 1,6 do	    term.setCursorPos(1,i)	    write(i.."| "..sList[i])	    term.setCursorPos(11,i)	    write(tostring(rs.getOutput(sList[i])))	    term.setCursorPos(16,i)	    print(" input: "..tostring(rs.getInput(sList[i])))    endendfor i = 1,6 do -- remove if you dont want all outputs set to off on program startup    rs.setOutput(sList[i],false) -- remove if you dont want all outputs set to off on program startupend -- remove if you dont want all outputs set to off on program startupdraw()while true do -- start a loop    e,e1,e2,e3,e4,e5 = os.pullEvent() -- wait here for an event then make e = to the event name eg "key" or "cahr" or "rednet_message"    if e == "char" then	    if e1 == "q" then error() end	    e1 = tonumber(e1) -- converts string to number (integra)	    if e1 <= 6 and e1 >= 1 then -- checks if the numver is between 1 and 6		    if rs.getOutput(sList[e1]) then -- checkes if it is already on			    rs.setOutput(sList[e1],false) -- turns it off if it was on		    else			    rs.setOutput(sList[e1],true) -- turns it on if it was off		    end	    end	    draw()    end    if e == "redstone" then	    draw()    end    term.setCursorPos(1,7)    term.clearLine()    print(tostring(e).." "..tostring(e1).." "..tostring(e2).." "..tostring(e3).." "..tostring(e4).." "..tostring(e5))end
PixelToast #2
Posted 13 June 2012 - 05:29 AM
i have one for bundled cables but it dosent output
mine was designed to test the io expander from rpc
Spoiler

side="bottom"
local xS,yS = term.getSize()
xOSet=math.ceil(xS/3)-5
yOSet=math.ceil(yS/3)
local function Scur(x,y,text,tf)
lastX=x
lastY=y
term.setCursorPos(xOSet+lastX,yOSet+lastY)
if tf==nil then print(text) else write(text) end
end
local function Scur1(text)
Scur(1,lastY+1,text)
end
local function Scur2(text)
Scur(2,lastY,text,1)
end
starfeild={}
for l1=1,xS do
starfeild[l1]={}
for l2=1,yS do
  starfeild[l1][l2]=math.random(1,15)
end
end
last=-1
while true do
decimal=rs.getBundledInput(side)
tBinary=bit.tobits(decimal)
binary=""
for l1=1,#tBinary do
  binary=tBinary[l1]..binary
end
if decimal==0 then binary=0 end
shell.run("clear")
for l1=1,xS do
  for l2=1,yS do
   term.setCursorPos(l1,l2)
   if starfeild[l1][l2]==1 then
    write("-")
   elseif starfeild[l1][l2]==2 then
    write("+")
   end
  end
end
dec=decimal
    local base,K,hex,iter,D=16,"0123456789ABCDEF","",0
    while dec>0 do
	    iter=iter+1
	    dec,D=math.floor(dec/base),math.fmod(dec,base)+1
	    hex=string.sub(K,D,D)..hex
    end
Scur(1,1,"o------------------------o")
Scur1("|   -=CABLE DEBUGGER=-   |")
Scur1("|					    |")
Scur1("|					    |")
Scur2("Binary: "..binary)
Scur1("|					    |")
Scur2("Hexadecimal: "..hex)
Scur1("|					    |")
Scur2("Decimal: "..decimal)
Scur1("o------------------------o")
last=binary
os.pullEventRaw()
end
it has a nice little starfeild background and is centered
it does binary, decimal, and hex
BigSHinyToys #3
Posted 13 June 2012 - 09:02 AM
I have a basic ver of that too not very user friendly or well coded but you might find something useful in it. I have implemented a system for turning on or off all available bundle outs.
Spoiler

--[[
  Hard Commander
  Manipulation of Hardware
  Redstone , Peripherals , RP2 Bundle Cable
  By Big Shiny Toys
 
  Notes:
  65536
]]--
-- vars
ver = 0.1
local tSides = redstone.getSides()
local tColors = {
white = 1,orange = 2,magenta = 4,lightBlue = 8,
yellow = 16,lime = 32,pink = 64,gray = 128,
lightGray = 256,cyan = 512,purple = 1024,blue = 2048,
brown = 4096,green = 8192,red = 16384,black = 32768}
local tNumber = {
white,orange,magenta,lightBlue,
yellow,lime,pink,gray,
lightGray,cyan,purple,blue,
brown,green,red,black}
local curX,curY = 1,1
-- end vars
local function expand(iInput)
local tOutput = {}
local check = 32768
for i = 1,16 do
  if iInput >= check then
   tOutput[i] = 1
   iInput = iInput - check
  else
   tOutput[i] = 0
  end
  check = check/2
end
return tOutput
end
local function compact(tInput)
local iOutput = 0
local check = 1
for i = 16,1,-1 do
  if tInput[i] == 1 then
   iOutput = iOutput + check
  end
  check = check*2
end
return iOutput
end
--[[
local this = expand()
for i = 1,16 do
write(this[i])
end
print("")
]]--
while true do
local e,e1,e2,e3,e4,e5,e6 = os.pullEvent()
term.clear()
term.setCursorPos(1,1)
if e == "key" then
  if e1 == 200 then -- up key
   curY = curY -1
  end
  if e1 == 208 then -- down key
   curY = curY +1
  end
  if e1 == 203 then -- left key
   curX = curX -1
  end
  if e1 == 205 then -- right key
   curX = curX +1
  end
  if curY > 6 then curY = 1 end
  if curY < 1 then curY = 6 end
  if curX > 16 then curX = 1 end
  if curX < 1 then curX = 16 end
  if e1 == 28 then
   local total = expand(rs.getBundledOutput(tSides[curY]))
   if total[curX] == 1 then
    total[curX] = 0
   else
    total[curX] = 1
   end
   rs.setBundledOutput(tSides[curY],compact(total))
  end
end
term.setCursorPos(25+curX,(3+curY)*2)
write("^")
for i = 1,6 do
  local a = rs.getBundledInput(tSides[i])
  local val = expand(a)
  term.setCursorPos(1,i*2+5)
  for o = 1, 16 do
   write(val[o])
  end
  write(" "..a)
 
  a = rs.getBundledOutput(tSides[i])
  val = expand(a)
  term.setCursorPos(26,i*2+5)
  for o = 1, 16 do
   write(val[o])
  end
  write(" "..a)
end
end