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

Multiple screens in OpenOS

Question

Hi everyone. I'm new to OpenComputers but i have some programming skills. I would like to ask HOW to use multiple screens with OpenOS. I have two Tier III GPUs installed but still only one screen works. So how can i make two or more screens to work with one or even two GPUs installed?

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

(i might be 2 years late but who cares)
Normally on openos when you connect 2 screens it's not going to display content like how would you expect on a real computer
You have to make a program that will display stuff on the second screen
I have made a sample program here that it will search for all the screens make you choose one and it will draw a dark-blue background with Hello world text on top (works best on tier 3 gpu and screen but can also work on whatever tier you want) it requires only 1 gpu
Feel free to modify it to your liking like making a terminal a gui ect but just to let you know if you want to draw content on more than 1 screen simultaneously you have to use 2 gpus or more depending on how many screens you have as you can only bind 1 screen to each gpu at the time

require("term").clear()
print("Loading")
local component = require("component")
local gpu = component.gpu
local event = require("event")
print("Getting Screens...")

local screens = {}

for address, type in component.list("screen") do --find all screens connected to the computer and add them to the screens table
  table.insert(screens, 1, address)
end

print("Please select a screen to use")
local i = 1
while i <= #screens do
  print(i.. ") ".. screens[i])
  i = i + 1
end

--Messy keyboard input teaken from a random os i'm making and modified a bit cuz i'm too bored to make another code

function decimalToChar(decimal)
    local char = string.char(tonumber(decimal))  -- Convert decimal to character
    return char
end

function decimalToString(decimalStr)
    local result = {}
    for num in decimalStr:gmatch("%d+") do
        table.insert(result, decimalToChar(num))
    end
    return table.concat(result)
end

local tTXT = ""
local enter = true

while enter do
  local name, data, key = event.pull()
  if name == "key_down" then
    if key ~= 8 and key ~= 13 then
      tTXT = tTXT.. decimalToString(tostring(key))
    else
      if key == 8 then
        tTXT = string.sub(tTXT, 1, string.len(tTXT) - 1)
      elseif key == 13 then
        enter = false
      end
    end
    local etTXT = tTXT.. "_"
    if string.len(etTXT) < 25 then
      while string.len(etTXT) < 25 do
        etTXT = etTXT.. " "
      end
    end
    gpu.set(1, 13, etTXT)
  end
end

print("Drawing Image...")

local originalScreen = gpu.getScreen()
--setting up the screen
gpu.bind(screens[tTXT + 0])
local w, h = gpu.maxResolution()
gpu.setResolution(w, h)
--drawing the image
gpu.setBackground(0x000080)
gpu.fill(1, 1, w, h, " ")
gpu.set(1, 1, "Hello World!")
--return to the original screen
gpu.bind(originalScreen)

 

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.