Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void update_display_bw_part(const FrameBufferType& frame_buffer,gfx::rect16 bounds,bool dithering) {
- //Serial.printf("(%d,%d)-(%d,%d)\r\n",bounds.x1,bounds.y1,bounds.x2,bounds.y2);
- // i've checked these constants over and over again. they're right:
- bus_driver::send_command(0x91);
- bus_driver::send_command(0x90);
- int x1=bounds.x1&0xF8;
- int x2=bounds.x2|0x7;
- bus_driver::send_data8(x1 >> 8);
- bus_driver::send_data8(x1 & 0xff); // x should be the multiple of 8, the last 3 bit will always be ignored
- bus_driver::send_data8(x2 >> 8);
- bus_driver::send_data8(x2 & 0xff);
- bus_driver::send_data8(bounds.y1 >> 8);
- bus_driver::send_data8(bounds.y1 & 0xff);
- bus_driver::send_data8(bounds.y2 >> 8);
- bus_driver::send_data8(bounds.y2 & 0xff);
- bus_driver::send_data8(0x01); // Gates scan both inside and outside of the partial window. (default)
- delay(2);
- bus_driver::send_command(0x13);
- if(dithering) {
- for(int y = bounds.y1;y<=bounds.y2;++y) {
- int row = y&15;
- for(int x=x1;x<=x2;x+=8) {
- uint8_t b = 0;
- for(int bx=0;bx<8;++bx) {
- int xx = (bx+x);
- int col = xx & 15;
- typename FrameBufferType::pixel_type px;
- frame_buffer.point(gfx::point16(xx,y),&px);
- b|=(1<<(7-bx))*
- !!(255.0 * px.template channelr<
- gfx::channel_name::L>() >
- gfx::helpers::dither::bayer_16[col +
- row * 16]);
- }
- bus_driver::send_data8(b);
- }
- }
- } else {
- // this is the one getting called
- // everything about this loop has been tested
- // in the update_display_bw() routine which contains
- // the same code
- for(int y = bounds.y1;y<=bounds.y2;++y) {
- for(int x=x1;x<=x2;x+=8) {
- uint8_t b = 0;
- for(int bx=0;bx<8;++bx) {
- typename FrameBufferType::pixel_type px;
- frame_buffer.point(gfx::point16(bx+x,y),&px);
- b|=(1<<(7-bx))*!!px.native_value;
- }
- bus_driver::send_data8(b);
- }
- }
- }
- delay(2);
- bus_driver::send_command(0x92);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement