Add mirroring to graphics module #435
unitythemaker
started this conversation in
Ideas
Replies: 2 comments
-
I think writing an image manipulation library is more appropriate than adding to the builtin graphics API. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I did what I wanted by editing SSD1306-i2c module's code and I'm sharing for the future comers. https://kaluma.io/@niklauslee/ssd1306-i2c/code/index.js (LN 79-107) /**
* Return a graphic context
* @return {GraphicContext}
*/
getContext() {
if (!this.context) {
this.context = new BufferedGraphicsContext(this.width, this.height, {
rotation: this.rotation,
bpp: 1,
display: (buffer) => {
var cmds = new Uint8Array([
0x22, // pages
0, (this.height >> 3) - 1,
0x21, // columns
0, this.width - 1
]);
this.sendCommands(cmds);
var WIRE_MAX = 128;
var chunk = new Uint8Array(WIRE_MAX + 1);
chunk[0] = 0x40;
+ var mirrored = new Uint8Array(buffer.byteLength);
for (var i = 0; i < mirrored.byteLength; i += WIRE_MAX) {
+ mirrored.set(buffer.subarray(i, i + this.width).reverse(), i, this.width);
chunk.set(new Uint8Array(mirrored.buffer, i, WIRE_MAX), 1);
this.i2c.write(chunk, this.address);
}
}
});
}
return this.context;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For some reason, I need to revert the image that'll be displaying to the oled. But not like rotating/flipping image more like mirroring. It'd awesome if it's added. Currently, I'm physically adding a mirror to make what I want and I'm trying to shrink it's size but I don't know C lang. Right now, I'm trying to add that functionality using JS with existing API features for graphics module.
Normal
Rotated/Flipped
Mirrored
https://note.nkmk.me/en/python-pillow-flip-mirror/
Beta Was this translation helpful? Give feedback.
All reactions