Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- BroTech 7 segment display clock
- function writeBundle(sSide, seg1, seg2)
- rs.setBundledOutput(sSide, 0)
- fOut = 0
- if seg1[1] == 1 then fOut = fOut + colors.brown end
- if seg1[2] == 1 then fOut = fOut + colors.purple end
- if seg1[3] == 1 then fOut = fOut + colors.yellow end
- if seg1[4] == 1 then fOut = fOut + colors.magenta end
- if seg1[5] == 1 then fOut = fOut + colors.orange end
- if seg1[6] == 1 then fOut = fOut + colors.cyan end
- if seg1[7] == 1 then fOut = fOut + colors.white end
- if seg1[8] == 1 then fOut = fOut + colors.lime end
- if seg2[1] == 1 then fOut = fOut + colors.red end
- if seg2[2] == 1 then fOut = fOut + colors.green end
- if seg2[3] == 1 then fOut = fOut + colors.pink end
- if seg2[4] == 1 then fOut = fOut + colors.gray end
- if seg2[5] == 1 then fOut = fOut + colors.lightBlue end
- if seg2[6] == 1 then fOut = fOut + colors.blue end
- if seg2[7] == 1 then fOut = fOut + colors.black end
- if seg2[8] == 1 then fOut = fOut + colors.lightGray end
- rs.setBundledOutput(sSide, fOut)
- end
- function writeInt(sSide, val)
- bytes = {0x30, 0x6D, 0x79, 0x72, 0x5B, 0x5F, 0x31, 0x7F, 0x73, 0x3F} -- Each element's index number corresponds to the number it writes.
- local digitTens = 0
- local digitOnes = 0
- if val > 99 then return 1 end
- if val < 0 then return 1 end
- digitTens = math.floor(val / 10)
- digitOnes = val - (digitTens * 10)
- if digitTens == 0 then digitTens = 10 end
- if digitOnes == 0 then digitOnes = 10 end
- -- print(bit.tobits(bytes[digitTens]))
- -- print(bit.tobits(bytes[digitOnes]))
- writeBundle(sSide, bit.tobits(bytes[digitTens]), bit.tobits(bytes[digitOnes]))
- end
- hours = "right"
- minutes = "left"
- while true do
- os.startTimer(1)
- local cTime = os.time()
- cTime = textutils.formatTime(cTime, true)
- _, _, cHours, cMinutes = string.find(cTime, "(%d+):(%d+)")
- writeInt(hours, tonumber(cHours))
- writeInt(minutes, tonumber(cMinutes))
- os.pullEvent()
- end
Add Comment
Please, Sign In to add comment