How can I switch RGB565 to GRAYSCALE when receiving some information from UART?

How can I switch RGB565 to GRAYSCALE when receiving some information from UART?
Can OpenMV do this?

Yes, just change the sensor pixformat.

sensor.set_pixformat(sensor.RGB565)

To:

sensor.set_pixformat(sensor.GRAYSCALE)