10.3.4 Set the buffer color mode

RPiSpark v1.1 default the color mode of the display is "1" and the color mode of the buffer is also "1", which can only display black and white. So the Canvas plot function can only be set to 0 or 1 color values. For example, we draw a black filled, white-sided rectangle:

self.RPiSpark.Screen.Canvas.rectangle( (0, 0, 63, 127), 0, 1 )

If you want to draw RGB color graphics, you need to call RPiSpark.Screen.changeBufferColorMode("RGB") to reset the buffer color mode to RGB. For example, we draw a rectangle with a black fill and a gray border:

self.RPiSpark.Screen.Canvas.rectangle( (0, 0, 63, 127), (0,0,0), (180,180,180) )

Use RPiSpark.Screen.changeBufferColorMode() to change the color mode definition of the buffer. Two optional color mode values: "1", "RGB" When you set the buffer color mode to "RGB", the RPiSpark will perform the conversion process from the color mode "RGB" to the color mode "1" before the refresh. This will display an "RGB" mode image in a monochrome OLED ( Monochrome image dithering ).


Was this article helpful?

YES     |     NO


Enjoying the project? Spotted a mistake? Any opinions on the website? Let us know!