Comments (4)
Well you can access the buffer directly. See https://github.com/daschr/pico-ssd1306/blob/main/ssd1306.c#L143 to get an idea how to access a pixel. The buffer is horizontally line by line encoded where (0,0)
is the upper left corner.
Also, one byte encodes 8 pixels where the most significant bit represents the bigger y.
F.e: pixel (8,56)
is encoded at byte=buffer[8 + (56/8)]
and then (byte>>(y%8))&1
.
You could use something like this:
uint8_t ssd1306_get_pixel(ssd1306_t *p, uint32_t x, uint32_t y){
const uint8_t p = (p->buffer[x+p->width*(y>>3)]>>(y&0x7))&1;
return p;
}
from pico-ssd1306.
Hey, sorry for the late reply, so if I understand it correctly, you store the pixels in an array of uint8_t, where each 1 or 0 is a pixel except the most significant digit, which stores the y value?
from pico-ssd1306.
Do you like reserve the most significant nibble for all 64 lines of y ?
from pico-ssd1306.
I think my explanation was a bad.
The RAM stores the display data in pages of 128 x 1byte. Each bytes encodes the 8 vertically neighbouring pixels.
See https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf page 25.
So if you want to access the pixel at (x,y), you first calculate the page (y/8, since each byte encodes 8 vertically pixels) and multiplicate it by 128 (size of a page). Then you add x to for getting the position of the byte in the array. Now, you have to access the y%8 bit of the byte, which encodes the pixel.
from pico-ssd1306.
Related Issues (12)
- SSD1306 dimensions HOT 4
- Any tools or tips to create more (and bigger) fonts?
- Small documentation error in font description HOT 1
- fix sign-compare and maybe-unitialized issues HOT 1
- Displaying bitmap HOT 2
- Character spacing uses height rather than width HOT 3
- Conversion from BMP to image.h format HOT 1
- Initialisation sometimes ends up with everything on top line HOT 1
- Question: ssd1306_deinit not included in header file HOT 1
- Display shows static HOT 4
- Naming error on ssd13606_draw_empty_square procedure HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pico-ssd1306.