First of all, I should precise that I'm quite new to OC and Lua, but already used to programming in general.
What I'm trying to do :
I have a basic setup with a computer and a screen attached to it. Another screen (a larger one) is connected via a network cable. Both screens have a keyboard attached to them, and the computer have two graphic cards (one per screen), one is a Tier 3 card and the other a Tier 2.
I would like to be able to use the big screen for displaying informations about my power plant, and the smaller one to control the computer (ie. the terminal should live in the smaller screen). Unfortunately when booting, the terminal attaches to a random GPU and a random screen. Sometimes it's on the large screen, sometimes on the small one. That led me to create a startup script that would care of binding the correct screen to the correct GPU (the large screen with the T3 GPU), and make the terminal use the smaller screen.
Problem is that anything seems to apply. After having bound the screen and GPU to the terminal with term.bind(screen, gpu) , nothing changes. term.screen and term.gpu stay the same, and nothing actually happens to the terminal. It just stays on the screen it booted on.
Here's a screenshot of what is currently happening (the larger screen is referred as "Auxiliary screen" and the smaller as "Master screen")
As you can see, primary GPU, screen and keyboard components refers to the correct devices, but aren't used (the shell is still on the large screen). term.gpu/screen/keyboard returns the same adresses as before running the script.
The code I've written so far :
local component = require("component")local term = require("term")local gpus = component.list("gpu")local screens = component.list("screen")local mgpu, mscreen --Masterlocal sgpu, sscreen --Aux.--Finding the GPUsfor addr, type in gpus do
print("GPU found : @".. addr)local gpu = component.proxy(addr)local vx,vy = gpu.getViewport()
print(" Viewport : ".. vx ..",".. vy)if gpu.slot ==0then
print(" Master GPU (slot 0)")
mgpu = gpu
elseif gpu.slot ==1then
print(" Auxilliary GPU (slot 1)")
sgpu = gpu
endend--Finding the screenslocal maxScreenSize =0for addr, type in screens dolocal screen = component.proxy(addr)local w,h = screen.getAspectRatio()
print("Screen found : ".. w ..",".. h .." @".. screen.address)if(w*h)> maxScreenSize thenif mscreen then
sscreen = mscreen
end
maxScreenSize = w*h
mscreen = screen
else
sscreen = screen
endlocal keyboards = screen.getKeyboards()for i,addr in ipairs(keyboards)do
print(" Keyboard : @".. addr)endifnot keyboards[1]then
print("Warning : no keyboard found for this screen : ".. screen.address)endend
print("Master screen : @".. mscreen.address)
print("Aux. screen : @".. sscreen.address)
io.read()--used to prevent the screen to be cleared when switched without leaving time to read the above adresses--Bind the correct screens to the correct GPUs
mgpu.bind(mscreen.address,false)
sgpu.bind(sscreen.address,false)
mgpu.setResolution(155,45)
sgpu.setResolution(50,25)--Set the default components the terminal should use
component.setPrimary("gpu", sgpu.address)
os.sleep(0.05)
component.setPrimary("screen", sscreen.address)
os.sleep(0.05)
component.setPrimary("keyboard", component.invoke(sgpu.getScreen(),"getKeyboards")[1])
term.bind(sgpu, sscreen, component.invoke(sgpu.getScreen(),"getKeyboards")[1])
os.sleep(0.05)
print("Initialization complete !")--This should always be printed on the small screen (hint: it isn't. :( )
I'd be glad if someone could find a solution to that. Thnaks by advance for your answers
Greetings form France
Edit : fixed an error about term.gpu/screen/keyboard
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.
Hi everyone !
First of all, I should precise that I'm quite new to OC and Lua, but already used to programming in general.
What I'm trying to do :
I have a basic setup with a computer and a screen attached to it. Another screen (a larger one) is connected via a network cable. Both screens have a keyboard attached to them, and the computer have two graphic cards (one per screen), one is a Tier 3 card and the other a Tier 2.
I would like to be able to use the big screen for displaying informations about my power plant, and the smaller one to control the computer (ie. the terminal should live in the smaller screen). Unfortunately when booting, the terminal attaches to a random GPU and a random screen. Sometimes it's on the large screen, sometimes on the small one. That led me to create a startup script that would care of binding the correct screen to the correct GPU (the large screen with the T3 GPU), and make the terminal use the smaller screen.
Problem is that anything seems to apply. After having bound the screen and GPU to the terminal with term.bind(screen, gpu) , nothing changes. term.screen and term.gpu stay the same, and nothing actually happens to the terminal. It just stays on the screen it booted on.
Here's a screenshot of what is currently happening (the larger screen is referred as "Auxiliary screen" and the smaller as "Master screen")
As you can see, primary GPU, screen and keyboard components refers to the correct devices, but aren't used (the shell is still on the large screen). term.gpu/screen/keyboard returns the same adresses as before running the script.
The code I've written so far :
I'd be glad if someone could find a solution to that. Thnaks by advance for your answers
Greetings form France
Edit : fixed an error about term.gpu/screen/keyboard
Link to post
Share on other sites