Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Subtixx

Segment Display

Question

Hey, I'm kind of confused. After I coded a little program for Integrated Circuits (A mod) to display Letters on a 7-Segment Display, I've discovered that project red has a SISD (Sixteen segment display). So I search and found this page:
 
http://ftb.gamepedia.com/Segment_Display
Which says:

Furthermore there is a compatibility to ComputerCraft and OpenComputers to easyly display specific characters on the Segment Display in SISD mode.

The 16 bars on the SISD-Segement Display allow 216 (65536) combination options. With the computers the player can send via Bundled Cable a self-chosen combination to the display, which then displays this combination. Furthermore, a generated restone signal from the cable can be read and the corresponding number can be found.

The following table shows the combination numbers of the Latin alphabet and Arabic numbers:


So I tried:

component.redstone.setBundledOutput(35023)
component.redstone.setBundledOutput(sides.right, 35023)
component.redstone.setBundledOutput(sides.right, colors.white, 35023)

which doesn't work. (1: Invalid side, 2: Invalid color, 3: Turns on the white cable).

 

My "old" code for the 7-segment display worked good. But this is giving me a headache right now..

 

So I started to look into the source of opencomputers and the integration of projectred, and found... Nothing. Just the integration of the screwdriver.

 

My question:

Is there an implementation for this or not?

Or does anybody have an idea how to "convert" a decimal like 800000 to unsigned short (1,2,4,8,16....), binary (0010), or any other usable form for Integrated Circuits 7-Segment Display or RedPowers SISD?

Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I imagine this:

35023 corresponds to 1000 1000 1100 1111 witch must mean every bit is a signal for each color. i never used the setBundledOutput method but i imagine, from your example that there is no combination in the method parameters that accepts bitwise data to write several colors at once. If that is the case you could make something like this:

 

function mySetBundledOutput(side, value)
   for n = 0, to 15 do
      component.redstone.setBundledOutput(side, n, bit32.band(bit32.rshift(value, n), 0x1));
   end
end

Just wrote the function here in the forum... didn't tested it, don't kow if it will work

In lua 5.3 you could use the bitwise operators that are better than using the bit32 lib

component.redstone.setBundledOutput(side, n, (value shr n) band 0x1);
Link to post
Share on other sites
  • 0

L3tLuin.png

 

Nope..

 

It doesn't even turn on the bundled cable (Individual colors).

 

Honestly I'm at a point where I have no clue anymore.

 

There's no possible (+ fast) solution to display an integer in the computer to a segment display.

With fast I mean ye sure. I could do something like 1 = blue on, red on, yellow off etc. but for a RF display (8.000.000 RF) that take ages to code, and ages to display.

The segmented display can display values up to 65535 (4 displays as slaves and 1 master). Where this is the logic behind it:

white = 1

orange = 2

magenta = 4

light blue = 8

etc.

 

And you can do something like:

white on + orange on = 3

 

But.. I don't seem to know a possible solution to do:

8000000 = light blue, orange, red etc.

Because tabling all possible values would be inefficient and dumb.

 

The easiest thing I imagine would be a BCD...

Link to post
Share on other sites
  • 0

i'm setting the value to 1 maybe thats too low...
from the docs:

"Note that for mods such as ProjectRed, low values (such as the vanilla maximum of 15) may not function as expected for simple on/off values (opening a door for example), because they have a larger value range. You may need to use a higher value, such as 255."

 

try this inside the function instead:
 

component.redstone.setBundledOutput(side, n, bit32.band(bit32.rshift(value, n), 0x1) * 255);

Sorry i dont have the game in this machine to test it

 

Link to post
Share on other sites
  • 0
  • Solution

i'm setting the value to 1 maybe thats too low...

from the docs:

"Note that for mods such as ProjectRed, low values (such as the vanilla maximum of 15) may not function as expected for simple on/off values (opening a door for example), because they have a larger value range. You may need to use a higher value, such as 255."[/size]

 

try this inside the function instead:

 

component.redstone.setBundledOutput(side, n, bit32.band(bit32.rshift(value, n), 0x1) * 255);
Sorry i dont have the game in this machine to test it
 

(I didn't thought about the 255 problem.. Thanks.)

Holy cow. xD It works! But.. Same as the tabling. It's so so so so so so so slow..... It takes ~3-4 seconds to display. And with a energy cell that is updating every tick.. It would hogg up displaying. Hmm I'll think about something! thanks

 

EDIT:

BLAZING FAST

http://i.imgur.com/MofzliT.gifv

component = require("component")
colors = require("colors")
sides = require("sides")

rs = component.redstone

local segments = {
  ["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 = {}
for n=0, 15 do
  nullCols[n] = 0
end
rs.setBundledOutput(sides.right, nullCols)

function displaySegment(side, value)
   local setCols = {}   
   for n = 0, 15, 1 do
      setCols[n] = bit32.band(bit32.rshift(value, n), 0x1) * 255
   end
   rs.setBundledOutput(side, setCols)
end

function splitSegment(str)
  if(type(str) == number) then
    str = tostring(str)
  end
  for i = 1, #str do
    rs.setBundledOutput(sides.right, nullCols)
    local c = str:sub(i,i)
    if(c ~= nil) then
      displaySegment(sides.right, segments[c])
    end
    os.sleep(0.5)
  end
end

os.sleep(2)
splitSegment("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.