Page 1 of 1

pyb vs machine

Posted: Thu Jun 07, 2018 7:10 pm
by OutoftheBOTS
This is just some food for though about future direction.

pyb module in MicoPython has been replaced by the machine module. Only a few years ago there was only 1 board that ran Micro-Python and it was called the pyboard that ran on a STM32 chip. The pyb module was methods for controlling hardware on the pyboard.

Since then many new ports of Micro-python for a number of new chips: ESP8266, ESP32, SAMD(adafruit circuit-python)

One of the big ideas of MicroPython is to have code portable from 1 chip to the next i.e my micropython script will run on all ports of micropython on all chips without needing editing. For this reason pyb module was replaced by machine module to make it consistent across all platforms of micropython.

Both pyb and machine are included in official MicroPython port so that it is backward compatible but I do believe to is planned to phase out pyb. ESP8266, ESP32 and circuit-python ports have already removed the pyb module from their builds.

I would suggest all new code is written around machine module rather than pyb module

Re: pyb vs machine

Posted: Thu Jun 07, 2018 8:10 pm
by kwagyeman
We don't really write code for either but just provide both modules.

Re: pyb vs machine

Posted: Thu Jun 07, 2018 9:46 pm
by OutoftheBOTS
Ok I was juts following your examples and they all use the pyb module and I didn't realize that the machine module was available so I changed my ESP32 screen script to pyb but now I have just tried my original script with machine and it works fine. :)