pyb vs machine

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

We don’t really write code for either but just provide both modules.

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. :slight_smile: