Subtixx 5 Posted December 23, 2015 Share Posted December 23, 2015 Easy to expand! You can create "modules" of segmented displays: This is an "API/Library/Program" to display multiple characters on multiple SISD (sixteen-segment display) Setup pictures: Marquee text:http://i.imgur.com/VlEbn4L.gifv Bugs / ToDo: Convert it to an actual library / API Displaying a marqueed "HELLO" text on 9 segmented display causes to display "LLO HE " Marquee text? (scrolling text) Placing more characters than redstone addresses causes the program to "crash" Implement a function / method to use up all 5 sides of the redstone I/O (5 because 6 sides - the side for the cable)2.1 Easier ability to change sides (Related to 2) Adding non-alphanumeric character will ?(I assume) crash? the program. Changelog: v1.2:- Optimizations- Added "Marquee" Text function- Fixed "Specified Side is invalid" trying to use sides[]v1.1:- Added new special chars: +, -, *- Fixed non-alphanumeric characters- Added the ability to use more than 1 side of a redstone I/O- Fixed more than one character displayv1.0:- First release Code: --################################################################### --################# ProjectRed SISD Display v1.2 #################### --################# (c) 2015 GigaToni #################### --################# DO NOT REDISTRIBUTE! #################### --################################################################### component = require("component") sides = require("sides") local redstoneAddresses = { { ["address"] = "3fbde23c-9b52-45ec-b957-3c5cc516c7ba", ["validSides"] = { sides.north, sides.west, sides.south } }, { ["address"] = "1f49d174-6cd4-4eca-b246-60ed886053c4", ["validSides"] = { sides.north, sides.west, sides.south } }, { ["address"] = "47889542-98ef-42ea-916f-96d3898e44b2", ["validSides"] = { sides.north, sides.west, sides.south } } } local segments = { ["*"] = 65280, ["+"] = 43520, ["-"] = 34816, ["0"] = 17663, ["1"] = 12, ["2"] = 34935, ["3"] = 34879, ["4"] = 34956, ["5"] = 37043, ["6"] = 35067, ["7"] = 15, ["8"] = 35071, ["9"] = 35007, ["A"] = 35023, ["B"] = 10815, ["C"] = 243, ["D"] = 8767, ["E"] = 35059, ["F"] = 35011, ["G"] = 2299, ["H"] = 35020, ["I"] = 8755, ["J"] = 124, ["K"] = 38080, ["L"] = 240, ["M"] = 1484, ["N"] = 4556, ["O"] = 255, ["P"] = 35015, ["Q"] = 4351, ["R"] = 39111, ["S"] = 35003, ["T"] = 8707, ["U"] = 252, ["V"] = 17600, ["W"] = 20684, ["X"] = 21760, ["Y"] = 43140, ["Z"] = 17459, } local nullCols = { [0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0, [10] = 0, [11] = 0, [12] = 0, [13] = 0, [14] = 0, [15] = 0, } function resetDisplay() for k,v in pairs(redstoneAddresses) do if(#v["validSides"] > 5) then print("Address " .. v["address"] .. " Error: You may only have 5 sides!") end if(component.list(v["address"]) == nil) then print("Address " .. v["address"] .. " Error: Address is not available!") end for key, side in pairs(v["validSides"]) do if(sides[side] == nil) then print("Side (".. key ..") " .. side .. " Error: The specified side is invalid!") else print("Clearing ("..v["address"]..") Side: " .. sides[side] .. "") component.invoke(v["address"], "setBundledOutput", side, nullCols) end end end end function displaySegment(address, side, value) local setCols = {} for n = 0, 15, 1 do setCols[n] = bit32.band(bit32.rshift(value, n), 0x1) * 255 end if(address == nil) then print("No address given!") return end if(component.list(address) == nil) then print("Unavailable address found: " .. address) return end component.invoke(address, "setBundledOutput", side, setCols) end function splitSegment(str) if(type(str) == number) then str = tostring(str) end local sID = 1 for _, add in pairs(redstoneAddresses) do for _, side in pairs(add["validSides"]) do local c = str:sub(sID, sID) if(c ~= nil and c ~= "" and c ~= " ") then if(segments[c] ~= nil) then displaySegment(add["address"], side, segments[c]) else print(add["address"] .. " (" .. sides[side] .. ") received unknown character '" .. c .. "'") end elseif(c == " ") then -- skip whitespace else return end sID = sID + 1 end end end function marqueeDisplay(str) str = str .. " " splitSegment(str) os.sleep(1) while true do resetDisplay() local c = str:sub(1, 1) str = str:sub(2, #str) .. c splitSegment(str) os.sleep(1) end end ------------------------------------------------------------------------------------- ------------------------------------ Program start ---------------------------------- ------------------------------------------------------------------------------------- resetDisplay() ----- Examples: --splitSegment("ABCDEFGHI") --marqueeDisplay("HELLO") [Thanks to @_CURSOR_ for the bit shifting part!] Quote Link to post Share on other sites
jhagrid77 4 Posted December 24, 2015 Share Posted December 24, 2015 I would recommend uploading the code to pastebin or something so that you can just use wget http//:webpage.com/script That's an example by the way. Quote Link to post Share on other sites
Subtixx 5 Posted December 24, 2015 Author Share Posted December 24, 2015 I know . Sorry. But I was to excited that it worked. Quote Link to post Share on other sites
jhagrid77 4 Posted December 28, 2015 Share Posted December 28, 2015 It's alright, I would be too. Quote Link to post Share on other sites
Daraketh 2 Posted January 7, 2016 Share Posted January 7, 2016 I'm a tad confused, I have RedLogic but I can't find these segmented displays? EDIT: Oh, is this Project:Red? Quote Link to post Share on other sites