peterhinch / micropython-micro-gui

A lightweight MicroPython GUI library for display drivers based on framebuf, allows input via pushbuttons. See also micropython-touch.
MIT License
270 stars 40 forks source link

Cannot install or add directories- need support with ssd1306 #13

Closed johnr1245 closed 1 year ago

johnr1245 commented 2 years ago

Hi there. I am an extreme beginner with python and programming generally and am trying to use a ssd1306 display with a tiny pico board and cannot for the life of me figure out how to install this as there are few visuals and I am getting extremely confused by the instructions.

I can open the hardware setup file and attempt to make it (depsite the fact I dont even know if it works as there are very few examples using the sdd1306 and doesnt really explain what the different lines of code mean) As well how is one supposed to get the gui and driver folders into the boards directory as from the IDE im using you cannot do that unless you open every .py file in each of those folders and indivually save each to the directory from within the IDE?

As well the $ mpremote mount . command does nothing for me when I try to use it in the command line after editing the hardware set up file and nothing in the REPL so I really just have no idea what is supposed to be using what, kinda just says to do it. Really great info in the rest of this but I could really use some clarification in how it is actually installed. Any help would be much appreicated and I can provide photos and what not of the pin lay out and code I have already. Thank you for all the work!

johnr1245 commented 2 years ago

So I changed some stuff around and got all the folders on the board. I have cleared most of the errors (I think) but am still left with this one which I cannot find any folders or files matching the name. Any idea what this error code means?

python

peterhinch commented 2 years ago

There is something wrong with your hardware_setup.py file. It's impossible for me to figure out what the problem is without seeing the code.

johnr1245 commented 2 years ago

My apologies very true lol, thank you very much for the reply, my apologies if my initial question was scattered.

Below is the code for the hardware_setup.py I currently have the navigation button's code omitted as I was sure how to add them to the example code for the ssd1306 but am not sure if that could be causing an issue as well? I have asked on other forums and they had suggested that I am importing ssd incorrectly and should be importing it from gui.core.ugui instead of hardware_setup.py, but I thought the hardware_setup is what defined the ssd value for all other files.

As well this code below is just the example supplied from the nano_gui example for the ssd1306 driver adjusted to the pins for my Tiny Pico, beyond that I have not edited it. Also just out of curiosity, why is there a letter Y before the IO pin number, I tried without and it seemed to have messed with the code so I assumed it to be necessary.

https://pastebin.com/LExTvSiT

peterhinch commented 2 years ago

OK. I had to rush off this morning so didn't have a chance to address this properly. The other people are right when running a full application. I suggest you look at the simple demo and use it as a template when you come to write your app.

However the code you cite is straight from the README and should work. I run this as a first step when checking any new hardware config. I'm baffled why the import is failing but I suspect an error is occurring which is not being displayed. This unseen error is preventing the ssd object being instantiated, so the later failure to import is occurring. What tool are you using to access the REPL?

Your setup file is for a Pyboard, which has pin numbers beginning X or Y. Pico pin numbers are just numbers. You will need to edit the pin numbers and I2C number to match the Pico and your wiring.

johnr1245 commented 2 years ago

No worries! And thank you I was actually just thinking about how I will be putting this all together in practice and this demos gonna help with the set up alot.

And strange. I also received this as an error which is different than the failure to find ssd i was seeing earlier. Cant remember exactly what I changed but might have been the ssd = None in line 19 of ugui.py. It said :

Traceback (most recent call last): File "<stdin>", line 2 SyntaxError: invalid syntax

So not sure if this might be the root of why ssd cant be written? As well for the REPL I am just using the shell tool in Thonny IDE, not sure if I am actually doing that correctly but it seemed to be working with some earlier code I was using just to test the oled. And I might try reimporting the example file in case I changed anything else in the file unknowingly earlier. As well not sure if it might be because I have the file directory misarranged or something,

And ahh I see I'll try removing the Ys on the pins. And what exactly is the I2C number and how would I go about changing that? Is that the 0x-- formatted addresses? Thank you so much for the help, really appreciated.

peterhinch commented 2 years ago

I think the IDE tools you are using may not be showing all the error messages. You might try using the official mpremote. In any support query it's best to cut and paste the full traceback and I don't think you're getting that at the moment. Your setup file will have thrown an exception when it hit the first pin number with an "X" or "Y" designation.

Hardware I2C buses have a number and are usually tied to specific pins. These vary between devices. Alternatively you can use SoftI2C which lets you choose the associated pins.

johnr1245 commented 2 years ago

Alright I'll look into using that to get more info hopefully. Any idea about the best way to go about that ? And have removed the Y and have still been getting the same error as before.

Also regarding mpremote. I didnt end up mounting the file directory with it as the $ mpremote mount . command was not doing anything for me so instead I think I either just uploaded the gui and driver folders or manually copy and pasted the folder which I think could have broken the file structure. Any idea why the $ mpremote mount . command wouldnt be working? I am just supposed to copy and paste that into the repl on my ide correct? Any values have to be added to it or just as is?

johnr1245 commented 2 years ago

Just tried mpremote mount and got something different this time that might be the tracebacks you needed to be. Looks pretty messed up. Should I just be wiping my microcontroller and starting again or using a different IDE? Here is a paste bin for traceback: https://pastebin.com/PRjABZFW

peterhinch commented 2 years ago

This seems to be a problem with Thonny. I've never used this, so can't help. If you move to the forum the developer of Thonny is available to help.

johnr1245 commented 2 years ago

Alright will try. Should I just try all the steps again on a different IDE like Pycharm or VScode? Seems like alot of the beginner IDEs have pretty poor error reporting.

peterhinch commented 2 years ago

In MicroPython I am a command-line guy - I use mpremote or rshell. For advice on IDE's please ask in the forum.

peterhinch commented 1 year ago

Closing due to inactivity.