Search found 145 matches

by liudr
Mon Aug 20, 2018 4:49 pm
Forum: General Discussion and Questions
Topic: Need some help how to distribute features between main.py and scripts on sd card
Replies: 13
Views: 1529

Re: Need some help how to distribute features between main.py and scripts on sd card

No. Have the module with the logging function run import os This forum is to support MicroPython: users assume a knowledge of Python. Your queries are elementary ones about the Python language. I would advise you to learn the language using Python on a PC with a book or online course. That was the ...
by liudr
Sun Aug 19, 2018 9:45 pm
Forum: General Discussion and Questions
Topic: Need some help how to distribute features between main.py and scripts on sd card
Replies: 13
Views: 1529

Re: Need some help how to distribute features between main.py and scripts on sd card

...Since you don’t have great control over when a module runs (at first import), it typically shouldn’t do anything else than define functions and classes, and possibly initialize some things. Any code that needs to run at a determined time should be inside those functions and classes. I got it now...
by liudr
Sun Aug 19, 2018 9:43 pm
Forum: General Discussion and Questions
Topic: Need some help how to distribute features between main.py and scripts on sd card
Replies: 13
Views: 1529

Re: Duck Typing

Python uses Duck Typing . It is normal to do things like: import machine i2c = machine.I2C(1) import my_module my_module.run(i2c) my_module only needs to import machine if "machine" appears in its sourcecode. The module can feely call I2C methods against the passed I2C instance: Python determines t...
by liudr
Sun Aug 19, 2018 5:05 pm
Forum: General Discussion and Questions
Topic: Need some help how to distribute features between main.py and scripts on sd card
Replies: 13
Views: 1529

Re: Need some help how to distribute features between main.py and scripts on sd card

I am mainly using MP on ESP32 with Loboris port so I do all my editing via a FTP server. I setup in filezilla that it will open *.py with my selected IDE (note++ ha ha) then I just edit it and click save and filezilla will auto update it over FTP then I just swap to my puTTY terminal window(either ...
by liudr
Sat Aug 18, 2018 3:36 am
Forum: General Discussion and Questions
Topic: Need some help how to distribute features between main.py and scripts on sd card
Replies: 13
Views: 1529

Re: Need some help how to distribute features between main.py and scripts on sd card

OK, I am coming up with an idea. Currently my logger script has both functions and code. If I turn it entirely to functions, and call the logging function after I import the logger script, then there is no need to let the code know the namespace of main while import runs the code. I will let main ha...
by liudr
Sat Aug 18, 2018 12:48 am
Forum: General Discussion and Questions
Topic: Need some help how to distribute features between main.py and scripts on sd card
Replies: 13
Views: 1529

Need some help how to distribute features between main.py and scripts on sd card

I am trying to find a sensible way to distribute features between main.py and other scripts on sd card. My application is data logger. In doing so, I need a few things. Here is what I came up with: Flash • boot.py (don't plan on adding anything here in case it gets messed up) • main.py (decide which...
by liudr
Sat Aug 18, 2018 12:37 am
Forum: ESP32 boards
Topic: Sparkfun ESP32 board
Replies: 9
Views: 1175

Re: Sparkfun ESP32 board

Thanks. I'll try and learn more scripting (maybe more docs to write about how to do scripting so I can read about it when I forget). It's really hard to remember things the way I used to.
by liudr
Thu Aug 16, 2018 4:53 pm
Forum: ESP32 boards
Topic: Sparkfun ESP32 board
Replies: 9
Views: 1175

Re: Sparkfun ESP32 board

You never posted what flashing command you used that caused your dev board to crash though. I bet the crashes were caused by the command. One needn't to do wild guesses. I have done a dozen or two flashes and everything it went correctly. I keep the command in a document. It's a good idea to log wha...
by liudr
Thu Aug 16, 2018 3:53 pm
Forum: General Discussion and Questions
Topic: [SOLVED] UART.readline() not using timeout
Replies: 8
Views: 1146

Re: UART.readline() not using timeout

pythoncoder wrote:
Thu Aug 16, 2018 8:26 am
If you spot an error in the documentation why not submit a GitHub pull request to fix it?
Peter,

Thanks for the suggestion. I opened an issue on github. Another potential place to improve is to define some alias for time.sleep() as time.sleep_s() since there are already _ms and _us counterparts.
by liudr
Wed Aug 15, 2018 11:14 am
Forum: General Discussion and Questions
Topic: [SOLVED] UART.readline() not using timeout
Replies: 8
Views: 1146

Re: UART.readline() not using timeout

As he's using loboris port, I'm not sure the official docs apply to this. There is only esp8266 official doc: http://docs.micropython.org/en/latest/esp8266/library/machine.UART.html Units are not mentioned. Here is wipy port doc. Same thing: http://docs.micropython.org/en/latest/wipy/library/machin...