Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to input commands after os.dupterm(scr) ? #1

Open
jd3096-mpy opened this issue May 9, 2023 · 4 comments
Open

How to input commands after os.dupterm(scr) ? #1

jd3096-mpy opened this issue May 9, 2023 · 4 comments

Comments

@jd3096-mpy
Copy link

How to input commands after os.dupterm(scr) ?
Just like the gif show in readme

Now I have a keyboard to input letters,how can I do to run the commands for keyboard input?

@boochow
Copy link
Owner

boochow commented May 10, 2023

FBConsole could only be used for output. You still need the serial port to input.

@jd3096-mpy
Copy link
Author

FBConsole could only be used for output. You still need the serial port to input.

Thanks,I use another esp32 to send uart commands,it works.
Is there a way to send uart0 commands by esp32 self?
I init uart1 to send commands to uart0,it only show strs,but don't run commands by add b'\r'

微信图片_20230510090642

@boochow
Copy link
Owner

boochow commented May 13, 2023

You can give your object for the input stream as the named parameter readobj of FBConsole() like this:

scr = FBConsole(oled, readobj=mykeyboard)

mykeyboard object must have readinto(self, buf, nbytes=0) method. (Actually, I have not tested this by myself :-)
Please refer to the manual page of dupterm() for details.
https://docs.micropython.org/en/latest/library/os.html#terminal-redirection-and-duplication

@jd3096-mpy
Copy link
Author

Yes,you have got what I mean to do.
I tried readinto method but not work.

def readinto(self, buf, nbytes=0):

I don't understand how to use 'buf' for input.

So if you have free time,can you give me an easy example?Like push a button to input letter 'a' to the repl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants