12 hour display mode:
24 hour display mode
Wiring
Connection View
Spoiler
hourOut = "right" minuteOut = "left" twelveHour = true function clear() term.clear() term.setCursorPos(1,1) end function formatTime(nTime) local nHour = math.floor(nTime) local nMinute = math.floor((nTime - nHour)*60) if twelveHour == true and nHour >= 13 then pmDot = true nHour = nHour-12 else pmDot = false end return string.format( "%02d:%02d", nHour, nMinute ) end function readTime() clear() write "'q' to quit" while true do event, param = os.pullEvent() if event == "redstone" then encodeTime() elseif event == "char" and param == "q" then clear() rs.setBundledOutput(hourOut, 0) rs.setBundledOutput(minuteOut, 0) break end end end function encodeTime() gameTime = os.time() eTime = formatTime(gameTime) hour1 = string.sub(eTime, 1, 1) eHour1 = tonumber(hour1) hour2 = string.sub(eTime, 2, 2) eHour2 = tonumber(hour2) minute1 = string.sub(eTime, 4, 4) eMinute1 = tonumber(minute1) minute2 = string.sub(eTime, 5, 5) eMinute2 = tonumber(minute2) term.setCursorPos(8,6) write (gameTime) term.setCursorPos(8,7) write (eTime) cableSet() end function lowRegister() if input == 0 then lowValue = 63 elseif input == 1 then lowValue = 3 elseif input == 2 then lowValue = 109 elseif input == 3 then lowValue = 103 elseif input == 4 then lowValue = 83 elseif input == 5 then lowValue = 118 elseif input == 6 then lowValue = 126 elseif input == 7 then lowValue = 35 elseif input == 8 then lowValue = 127 elseif input == 9 then lowValue = 115 else end end function highRegister() if input == 0 then highValue = 8064 elseif input == 1 then highValue = 384 elseif input == 2 then highValue = 13952 elseif input == 3 then highValue = 13184 elseif input == 4 then highValue = 10624 elseif input == 5 then highValue = 15104 elseif input == 6 then highValue = 16128 elseif input == 7 then highValue = 4480 elseif input == 8 then highValue = 16256 elseif input == 9 then highValue = 14720 else end end function cableSet() input = eHour1 highRegister() input = eHour2 lowRegister() rs.setBundledOutput(hourOut, highValue + lowValue + 32768) input = eMinute1 highRegister() input = eMinute2 lowRegister() if pmDot == true then rs.setBundledOutput(minuteOut, highValue + lowValue + 32768) else rs.setBundledOutput(minuteOut, highValue + lowValue) end end readTime()
Silly code snippit tool makes my indentation all wonky.
Anyway, colon is fed power from the hour cable. the PM dot is fed power from the minute cable if 12 hour mode is true.