Giter VIP home page Giter VIP logo

Comments (6)

zerulin avatar zerulin commented on June 10, 2024

It seems that your codes are written for 2.13inch e-Paper (B). However, the 2.13inch e-Paper (B) doesn't support partial refresh.

from e-paper.

randohinn avatar randohinn commented on June 10, 2024

@zerulin Okay, tried implementing the full frame refresh method

#include "spi.h"
#include <util/delay.h>
#include <avr/pgmspace.h>


// Display resolution
#define EPDWIDTH      104
#define EPDHEIGHT     212

#define IF_INVERT_COLOR 0

// EPD2IN13B commands
#define PANEL_SETTING                               0x00
#define POWER_SETTING                               0x01
#define POWER_OFF                                   0x02
#define POWER_OFF_SEQUENCE_SETTING                  0x03
#define POWER_ON                                    0x04
#define POWER_ON_MEASURE                            0x05
#define BOOSTER_SOFT_START                          0x06
#define DEEP_SLEEP                                  0x07
#define DATA_START_TRANSMISSION_1                   0x10
#define DATA_STOP                                   0x11
#define DISPLAY_REFRESH                             0x12
#define DATA_START_TRANSMISSION_2                   0x13
#define VCOM_LUT                                    0x20
#define W2W_LUT                                     0x21
#define B2W_LUT                                     0x22
#define W2B_LUT                                     0x23
#define B2B_LUT                                     0x24
#define PLL_CONTROL                                 0x30
#define TEMPERATURE_SENSOR_CALIBRATION              0x40
#define TEMPERATURE_SENSOR_SELECTION                0x41
#define TEMPERATURE_SENSOR_WRITE                    0x42
#define TEMPERATURE_SENSOR_READ                     0x43
#define VCOM_AND_DATA_INTERVAL_SETTING              0x50
#define LOW_POWER_DETECTION                         0x51
#define TCON_SETTING                                0x60
#define RESOLUTION_SETTING                          0x61
#define GET_STATUS                                  0x71
#define AUTO_MEASURE_VCOM                           0x80
#define READ_VCOM_VALUE                             0x81
#define VCM_DC_SETTING                              0x82
#define PARTIAL_WINDOW                              0x90
#define PARTIAL_IN                                  0x91
#define PARTIAL_OUT                                 0x92
#define PROGRAM_MODE                                0xA0
#define ACTIVE_PROGRAM                              0xA1
#define READ_OTP_DATA                               0xA2
#define POWER_SAVING                                0xE3
/*
unsigned char epaper_get_image(int width) {
	return malloc(8*width);
}*/

void epaper_draw_absolute_pixel(unsigned char* image, int x, int y, int colored) {
	if (x < 0 || x >= EPDWIDTH || y < 0 || y >= EPDHEIGHT) {
        return;
    }
    if (IF_INVERT_COLOR) {
        if (colored) {
            image[(x + y * EPDWIDTH) / 8] |= 0x80 >> (x % 8);
        } else {
            image[(x + y * EPDWIDTH) / 8] &= ~(0x80 >> (x % 8));
        }
    } else {
        if (colored) {
            image[(x + y * EPDWIDTH) / 8] &= ~(0x80 >> (x % 8));
        } else {
            image[(x + y * EPDWIDTH) / 8] |= 0x80 >> (x % 8);
        }
    }
}

void send_command(unsigned char command) {
	PORTB &= ~(1 << PINB1);
	send_recieve_spi_byte(command);

}

void send_data(unsigned char data) {
	PORTB |= (1 << PINB1);
	send_recieve_spi_byte(data);

}

void epaper_clear(unsigned char* image) {
	for (int x = 0; x < EPDWIDTH; x++) {
        for (int y = 0; y < EPDHEIGHT; y++) {
            epaper_draw_absolute_pixel(image,x, y, 0);
        }
    }
}

void epaper_init() {
	DDRD &= ~(1 << DDD1);
	DDRB |= (1 << DDB1);
	send_command(BOOSTER_SOFT_START);
	send_data(0x17);
	send_data(0x17);
	send_data(0x17);
	send_command(POWER_ON);
	while(!(PIND &&(1<<PD1)));
    send_command(PANEL_SETTING);
	send_data(0x8F);
	send_data(0x8F);
    send_command(VCOM_AND_DATA_INTERVAL_SETTING);
    send_data(0x37);
    send_command(RESOLUTION_SETTING);
    send_data(0x68);
    send_data(0x00);
    send_data(0xD4);

}

void epaper_display() {
	send_command(DISPLAY_REFRESH);
	while(!(PIND &&(1<<PD1)));
}


void epaper_display_frame(unsigned char* frame_buffer_black, unsigned char* frame_buffer_red) {
    if (frame_buffer_black != NULL) {
        send_command(DATA_START_TRANSMISSION_1);
        _delay_ms(2);
        for (int i = 0; i < EPDWIDTH * EPDHEIGHT / 8; i++) {
            send_data(pgm_read_byte(&frame_buffer_black[i]));
        }
        _delay_ms(2);
    }
    if (frame_buffer_red != NULL) {
        send_command(DATA_START_TRANSMISSION_2);
        _delay_ms(2);
        for (int i = 0; i < EPDWIDTH* EPDHEIGHT / 8; i++) {
            send_data(pgm_read_byte(&frame_buffer_red[i]));
        }
        _delay_ms(2);
    }
}

and


	unsigned char image[2048];
epaper_init();
	epaper_clear(image);
	epaper_display_frame(image, image);
	epaper_display();

This seems like it should clear the whole display, no? Nothing happens for me, the display does not refresh :(

from e-paper.

randohinn avatar randohinn commented on June 10, 2024

Any ideas @zerulin? I'm also not exactly sure how big the image array should be? The code here seems to suggest 8*width?

from e-paper.

hnwangkg-ezio avatar hnwangkg-ezio commented on June 10, 2024

Please run the demo we provided directly, do not make any changes and try again.

from e-paper.

hnwangkg-ezio avatar hnwangkg-ezio commented on June 10, 2024

The image array size = (image width / 8) * image height

from e-paper.

randohinn avatar randohinn commented on June 10, 2024

The image array size = (image width / 8) * image height

That works! No longer does weird stuff, except if I try to epaper_display_frame, then it is mostly garbage, when setting the two partials separately, all works 😄

from e-paper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.