SparkFun Forums 

Where electronics enthusiasts find answers.

Hardware or product specific questions are best asked here.
#217006
I am trying to connect a Waveshare 4.3 inch (not to be confused with 4.3 inch display) and an Artemis blackboard nano.
I am confused as to which pins to use.
Waveshare and various tutorials on the web indicate:

VCC
GND
Din (data in pin) RX on microcontroller
Do (data out pin) TX on microcontroller
Wake up pin D2 on microcontroller

For starters, which pin on the Artemis blackboard nano corresponds with D2 on the arduino uno? I have connected the display to the RX and TX pins of the Artemis blackboard nano but without connectin the Wake up pin. The display shows power and has gone blank indicating some sort of connection.

Regards
#217041
Yes I can. Waveshare 4.3 inch UART ePaper display wiki URL https://www.waveshare.com/wiki/4.3inch_e-Paper

Waveshare provided the following code demo. I have attached as files the required epd.cpp and epd.h files as well. Thank you for your help.
Code: Select all
/*********************************************************************************************************
*
* File                : Arduino-epd
* Hardware Environment: 
* Build Environment   : Arduino
* Version             : V1.6.1
* By                  : WaveShare
*
*                                  (c) Copyright 2005-2015, WaveShare
*                                       http://www.waveshare.net
*                                       http://www.waveshare.com
*                                          All Rights Reserved
*
*********************************************************************************************************/
//#include <epd.h>
#include "epd.h"


const int led = 13;                           //user led


/*******************************************************************************
* Function Name  : void base_draw(void)
* Description    :
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void base_draw(void)
{
  int i, j;

  /*
  draw pixel
  */
  epd_clear();
  for (j = 0; j < 600; j += 50)
  {
    for (i = 0; i < 800; i += 50)
    {
      epd_draw_pixel(i, j);
      epd_draw_pixel(i, j + 1);
      epd_draw_pixel(i + 1, j);
      epd_draw_pixel(i + 1, j + 1);
    }
  }
  epd_udpate();
  delay(3000);

  /*
  draw line
  */
  epd_clear();
  for (i = 0; i < 800; i += 100)
  {
    epd_draw_line(0, 0, i, 599);
    epd_draw_line(799, 0, i, 599);
  }
  epd_udpate();
  delay(3000);

  /*
  fill rect
  */
  epd_clear();
  epd_set_color(BLACK, WHITE);
  epd_fill_rect(10, 10, 100, 100);

  epd_set_color(DARK_GRAY, WHITE);
  epd_fill_rect(110, 10, 200, 100);

  epd_set_color(GRAY, WHITE);
  epd_fill_rect(210, 10, 300, 100);

  epd_udpate();
  delay(3000);

  /*
  draw circle
  */
  epd_set_color(BLACK, WHITE);
  epd_clear();
  for (i = 0; i < 300; i += 40)
  {
    epd_draw_circle(399, 299, i);
  }
  epd_udpate();
  delay(3000);

  /*
  fill circle
  */
  epd_clear();
  for (j = 0; j < 6; j++)
  {
    for (i = 0; i < 8; i++)
    {
      epd_fill_circle(50 + i * 100, 50 + j * 100, 50);
    }
  }
  epd_udpate();
  delay(3000);

  /*
  draw triangle
  */
  epd_clear();
  for (i = 1; i < 5; i++)
  {
    epd_draw_triangle(399, 249 - i * 50, 349 - i * 50, 349 + i * 50, 449 + i * 50, 349 + i * 50);
  }
  epd_udpate();
  delay(3000);
}



void draw_text_demo(void)
{
  char buff[] = {'G', 'B', 'K', '3', '2', ':', ' ', 0xc4, 0xe3, 0xba, 0xc3, 0xca, 0xc0, 0xbd, 0xe7, 0};
  epd_set_color(BLACK, WHITE);
  epd_clear();
  epd_set_ch_font(GBK32);
  epd_set_en_font(ASCII32);
  epd_disp_string(buff, 0, 50);
  epd_disp_string("ASCII32: Hello, World!", 0, 300);

  epd_set_ch_font(GBK48);
  epd_set_en_font(ASCII48);
  buff[3] = '4';
  buff[4] = '8';
  epd_disp_string(buff, 0, 100);
  epd_disp_string("ASCII48: Hello, World!", 0, 350);

  epd_set_ch_font(GBK64);
  epd_set_en_font(ASCII64);
  buff[3] = '6';
  buff[4] = '4';
  epd_disp_string(buff, 0, 160);
  epd_disp_string("ASCII64: Hello, World!", 0, 450);


  epd_udpate();
  delay(3000);
}

void draw_bitmap_demo(void)
{
  epd_clear();
  epd_disp_bitmap("PIC4.BMP", 0, 0);
  epd_udpate();
  delay(5000);

  epd_clear();
  epd_disp_bitmap("PIC2.BMP", 0, 100);
  epd_disp_bitmap("PIC3.BMP", 400, 100);
  epd_udpate();
  delay(5000);

  epd_clear();
  epd_disp_bitmap("PIC7.BMP", 0, 0);
  epd_udpate();
}




void setup(void)
{
  /*
  user led init
  */
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  
  epd_init();
  epd_wakeup();
  epd_set_memory(MEM_NAND);
}

void loop(void)
{
  char flag = 0;
  
  base_draw();

  /*
  Draw text demo
  */
  draw_text_demo();

  /*
  Draw bitmap
  */
  draw_bitmap_demo();

  epd_enter_stopmode();
  while (1)
  {
    if(flag)
    {
      flag = 0;
      digitalWrite(led, LOW);
    }
    else
    {
      flag = 1;
      digitalWrite(led, HIGH);
    }
    delay(500);
  }
}
#217048
I didn't see the attached files show up so here they are again. I hope. Drats, it appears that the forum attached file rules do not allow for such attachment types. I will post these within code tags in this email.

epd.cpp
Code: Select all
/*********************************************************************************************************
*
* File                : epd.c
* Hardware Environment: 
* Build Environment   : RealView MDK-ARM  Version: 4.74
* Version             : V1.0
* By                  : V
*
*                                  (c) Copyright 2005-2014, WaveShare
*                                       http://www.waveshare.net
*                                          All Rights Reserved
*
*********************************************************************************************************/
#include "epd.h"
#include <Arduino.h>



const int wake_up = 2;
const int reset = 3;


/*
command define
*/
static const unsigned char _cmd_handshake[8] = {0xA5, 0x00, 0x09, CMD_HANDSHAKE, 0xCC, 0x33, 0xC3, 0x3C};        //CMD_HANDSHAKE
static const unsigned char _cmd_read_baud[8] = {0xA5, 0x00, 0x09, CMD_READ_BAUD, 0xCC, 0x33, 0xC3, 0x3C};       //CMD_READ_BAUD
static const unsigned char _cmd_stopmode[8] = {0xA5, 0x00, 0x09, CMD_STOPMODE, 0xCC, 0x33, 0xC3, 0x3C};         //CMD_STOPMODE
static const unsigned char _cmd_update[8] = {0xA5, 0x00, 0x09, CMD_UPDATE, 0xCC, 0x33, 0xC3, 0x3C};           //CMD_UPDATE
static const unsigned char _cmd_load_font[8] = {0xA5, 0x00, 0x09, CMD_LOAD_FONT, 0xCC, 0x33, 0xC3, 0x3C};       //CMD_LOAD_FONT
static const unsigned char _cmd_load_pic[8] = {0xA5, 0x00, 0x09, CMD_LOAD_PIC, 0xCC, 0x33, 0xC3, 0x3C};         //CMD_LOAD_PIC




static unsigned char _cmd_buff[CMD_SIZE];



/*
private function
*/
static void _putchars(const unsigned char * ptr, int n);
static unsigned char _verify(const void * ptr, int n);



/*******************************************************************************
* Function Name  : static void _putchars(const unsigned char * ptr, int n)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
static void _putchars(const unsigned char * ptr, int n)
{
  int i, x;
  
  for(i = 0; i < n; i++)
  {
      x = ptr[i];
    Serial.write(x);
  }
}
/*******************************************************************************
* Function Name  : static unsigned char _verify(const void * ptr, int n)
* Description    : 
* Input          : ptr      
                   n        
* Output         : None
* Return         : 
*******************************************************************************/
static unsigned char _verify(const void * ptr, int n)
{
  int i;
  unsigned char * p = (unsigned char *)ptr;
  unsigned char result;
  
  for(i = 0, result = 0; i < n; i++)
  {
    result ^= p[i];
  }
  
  return result;
}




/*******************************************************************************
* Function Name  : void epd_init(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_init(void)
{
  Serial1.begin(115200);
  pinMode(wake_up, HIGH);
  pinMode(reset, HIGH);
}
/*******************************************************************************
* Function Name  : void epd_reset(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_reset(void)
{
  digitalWrite(reset, LOW);
  delayMicroseconds(10);
  digitalWrite(reset, HIGH);
  delayMicroseconds(500);
  digitalWrite(reset, LOW);
  delay(3000);
}
/*******************************************************************************
* Function Name  : void epd_init(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_wakeup(void)
{
  digitalWrite(wake_up, LOW);
  delayMicroseconds(10);
  digitalWrite(wake_up, HIGH);
  delayMicroseconds(500);
  digitalWrite(wake_up, LOW);
  delay(10);
}

/*******************************************************************************
* Function Name  : void epd_handshake(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_handshake(void)
{
  memcpy(_cmd_buff, _cmd_handshake, 8);
  _cmd_buff[8] = _verify(_cmd_buff, 8);
  
  _putchars(_cmd_buff, 9);
}
/*******************************************************************************
* Function Name  : void epd_set_baud(long baud)
* Description    : set uart baud
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_set_baud(long baud)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0D;  
  
  _cmd_buff[3] = CMD_SET_BAUD;  
  
  _cmd_buff[4] = (baud >> 24) & 0xFF;
  _cmd_buff[5] = (baud >> 16) & 0xFF;
  _cmd_buff[6] = (baud >> 8) & 0xFF;
  _cmd_buff[7] = baud & 0xFF;
  
  _cmd_buff[8] = FRAME_E0;
  _cmd_buff[9] = FRAME_E1;
  _cmd_buff[10] = FRAME_E2;
  _cmd_buff[11] = FRAME_E3; 
  _cmd_buff[12] = _verify(_cmd_buff, 12);
  
  _putchars(_cmd_buff, 13); 
  
  delay(10);  
  Serial.begin(baud);
}
/*******************************************************************************
* Function Name  : void epd_read_baud(void)
* Description    : read uart baud
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_read_baud(void)
{
  memcpy(_cmd_buff, _cmd_read_baud, 8);
  _cmd_buff[8] = _verify(_cmd_buff, 8);
  
  _putchars(_cmd_buff, 9);
}
/*******************************************************************************
* Function Name  : void epd_set_memory(unsigned char mode)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_set_memory(unsigned char mode)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0A;  
  
  _cmd_buff[3] = CMD_MEMORYMODE;
  
  _cmd_buff[4] = mode;
  
  _cmd_buff[5] = FRAME_E0;
  _cmd_buff[6] = FRAME_E1;
  _cmd_buff[7] = FRAME_E2;
  _cmd_buff[8] = FRAME_E3;  
  _cmd_buff[9] = _verify(_cmd_buff, 9);
  
  _putchars(_cmd_buff, 10);   
}

/*******************************************************************************
* Function Name  : void epd_enter_stopmode(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_enter_stopmode(void)
{
  memcpy(_cmd_buff, _cmd_stopmode, 8);
  _cmd_buff[8] = _verify(_cmd_buff, 8);
  
  _putchars(_cmd_buff, 9);
}
/*******************************************************************************
* Function Name  : void epd_udpate(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_udpate(void)
{
  memcpy(_cmd_buff, _cmd_update, 8);
  _cmd_buff[8] = _verify(_cmd_buff, 8);
  
  _putchars(_cmd_buff, 9);
}
/*******************************************************************************
* Function Name  : void epd_screen_rotation(unsigned char mode)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_screen_rotation(unsigned char mode)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0A;  
  
  _cmd_buff[3] = CMD_SCREEN_ROTATION;
  
  _cmd_buff[4] = mode;
  
  _cmd_buff[5] = FRAME_E0;
  _cmd_buff[6] = FRAME_E1;
  _cmd_buff[7] = FRAME_E2;
  _cmd_buff[8] = FRAME_E3;  
  _cmd_buff[9] = _verify(_cmd_buff, 9);
  
  _putchars(_cmd_buff, 10); 
}
/*******************************************************************************
* Function Name  : void epd_load_font(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_load_font(void)
{
  memcpy(_cmd_buff, _cmd_load_font, 8);
  _cmd_buff[8] = _verify(_cmd_buff, 8);
  
  _putchars(_cmd_buff, 9);  
}
/*******************************************************************************
* Function Name  : void epd_load_pic(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_load_pic(void)
{
  memcpy(_cmd_buff, _cmd_load_pic, 8);
  _cmd_buff[8] = _verify(_cmd_buff, 8);
  
  _putchars(_cmd_buff, 9);
}
/*******************************************************************************
* Function Name  : void epd_set_color(unsigned char color, unsigned char bkcolor)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_set_color(unsigned char color, unsigned char bkcolor)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0B;
  
  _cmd_buff[3] = CMD_SET_COLOR;
  
  _cmd_buff[4] = color;
  _cmd_buff[5] = bkcolor;
  
  _cmd_buff[6] = FRAME_E0;
  _cmd_buff[7] = FRAME_E1;
  _cmd_buff[8] = FRAME_E2;
  _cmd_buff[9] = FRAME_E3;
  _cmd_buff[10] = _verify(_cmd_buff, 10);
  
  _putchars(_cmd_buff, 11);
}
/*******************************************************************************
* Function Name  : void epd_set_en_font(unsigned char font)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_set_en_font(unsigned char font)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0A;  
  
  _cmd_buff[3] = CMD_SET_EN_FONT;
  
  _cmd_buff[4] = font;
  
  _cmd_buff[5] = FRAME_E0;
  _cmd_buff[6] = FRAME_E1;
  _cmd_buff[7] = FRAME_E2;
  _cmd_buff[8] = FRAME_E3;  
  _cmd_buff[9] = _verify(_cmd_buff, 9);
  
  _putchars(_cmd_buff, 10); 
}
/*******************************************************************************
* Function Name  : void epd_set_ch_font(unsigned char font)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_set_ch_font(unsigned char font)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0A;  
  
  _cmd_buff[3] = CMD_SET_CH_FONT;
  
  _cmd_buff[4] = font;
  
  _cmd_buff[5] = FRAME_E0;
  _cmd_buff[6] = FRAME_E1;
  _cmd_buff[7] = FRAME_E2;
  _cmd_buff[8] = FRAME_E3;  
  _cmd_buff[9] = _verify(_cmd_buff, 9);
  
  _putchars(_cmd_buff, 10);
}
/*******************************************************************************
* Function Name  : void epd_draw_pixel(int x0, int y0)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_draw_pixel(int x0, int y0)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0D;  
  
  _cmd_buff[3] = CMD_DRAW_PIXEL;  
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  
  _cmd_buff[8] = FRAME_E0;
  _cmd_buff[9] = FRAME_E1;
  _cmd_buff[10] = FRAME_E2;
  _cmd_buff[11] = FRAME_E3; 
  _cmd_buff[12] = _verify(_cmd_buff, 12);
  
  _putchars(_cmd_buff, 13);
}
/*******************************************************************************
* Function Name  : void epd_draw_line(int x0, int y0, int x1, int y1)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_draw_line(int x0, int y0, int x1, int y1)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x11;  
  
  _cmd_buff[3] = CMD_DRAW_LINE; 
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  _cmd_buff[8] = (x1 >> 8) & 0xFF;
  _cmd_buff[9] = x1 & 0xFF;
  _cmd_buff[10] = (y1 >> 8) & 0xFF;
  _cmd_buff[11] = y1 & 0xFF;  
  
  _cmd_buff[12] = FRAME_E0;
  _cmd_buff[13] = FRAME_E1;
  _cmd_buff[14] = FRAME_E2;
  _cmd_buff[15] = FRAME_E3; 
  _cmd_buff[16] = _verify(_cmd_buff, 16);
  
  _putchars(_cmd_buff, 17); 
}
/*******************************************************************************
* Function Name  : void epd_fill_rect(int x0, int y0, int x1, int y1)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_fill_rect(int x0, int y0, int x1, int y1)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x11;  
  
  _cmd_buff[3] = CMD_FILL_RECT; 
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  _cmd_buff[8] = (x1 >> 8) & 0xFF;
  _cmd_buff[9] = x1 & 0xFF;
  _cmd_buff[10] = (y1 >> 8) & 0xFF;
  _cmd_buff[11] = y1 & 0xFF;  
  
  _cmd_buff[12] = FRAME_E0;
  _cmd_buff[13] = FRAME_E1;
  _cmd_buff[14] = FRAME_E2;
  _cmd_buff[15] = FRAME_E3; 
  _cmd_buff[16] = _verify(_cmd_buff, 16);
  
  _putchars(_cmd_buff, 17);   
}
/*******************************************************************************
* Function Name  : void epd_draw_circle(int x0, int y0, int r)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_draw_circle(int x0, int y0, int r)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0F;  
  
  _cmd_buff[3] = CMD_DRAW_CIRCLE; 
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  _cmd_buff[8] = (r >> 8) & 0xFF;
  _cmd_buff[9] = r & 0xFF;
  
  
  _cmd_buff[10] = FRAME_E0;
  _cmd_buff[11] = FRAME_E1;
  _cmd_buff[12] = FRAME_E2;
  _cmd_buff[13] = FRAME_E3; 
  _cmd_buff[14] = _verify(_cmd_buff, 14);
  
  _putchars(_cmd_buff, 15);
}
/*******************************************************************************
* Function Name  : void epd_fill_circle(int x0, int y0, int r)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_fill_circle(int x0, int y0, int r)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x0F;  
  
  _cmd_buff[3] = CMD_FILL_CIRCLE; 
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  _cmd_buff[8] = (r >> 8) & 0xFF;
  _cmd_buff[9] = r & 0xFF;
  
  
  _cmd_buff[10] = FRAME_E0;
  _cmd_buff[11] = FRAME_E1;
  _cmd_buff[12] = FRAME_E2;
  _cmd_buff[13] = FRAME_E3; 
  _cmd_buff[14] = _verify(_cmd_buff, 14);
  
  _putchars(_cmd_buff, 15); 
}
/*******************************************************************************
* Function Name  : void epd_draw_triangle(int x0, int y0, int x1, int y1, int x2, int y2)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_draw_triangle(int x0, int y0, int x1, int y1, int x2, int y2)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x15;  
  
  _cmd_buff[3] = CMD_DRAW_TRIANGLE; 
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  _cmd_buff[8] = (x1 >> 8) & 0xFF;
  _cmd_buff[9] = x1 & 0xFF;
  _cmd_buff[10] = (y1 >> 8) & 0xFF;
  _cmd_buff[11] = y1 & 0xFF;  
  _cmd_buff[12] = (x2 >> 8) & 0xFF;
  _cmd_buff[13] = x2 & 0xFF;
  _cmd_buff[14] = (y2 >> 8) & 0xFF;
  _cmd_buff[15] = y2 & 0xFF;
  
  _cmd_buff[16] = FRAME_E0;
  _cmd_buff[17] = FRAME_E1;
  _cmd_buff[18] = FRAME_E2;
  _cmd_buff[19] = FRAME_E3; 
  _cmd_buff[20] = _verify(_cmd_buff, 20);
  
  _putchars(_cmd_buff, 21);   
}
/*******************************************************************************
* Function Name  : void epd_fill_triangle(int x0, int y0, int x1, int y1, int x2, int y2)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_fill_triangle(int x0, int y0, int x1, int y1, int x2, int y2)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x15;  
  
  _cmd_buff[3] = CMD_FILL_TRIANGLE; 
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  _cmd_buff[8] = (x1 >> 8) & 0xFF;
  _cmd_buff[9] = x1 & 0xFF;
  _cmd_buff[10] = (y1 >> 8) & 0xFF;
  _cmd_buff[11] = y1 & 0xFF;  
  _cmd_buff[12] = (x2 >> 8) & 0xFF;
  _cmd_buff[13] = x2 & 0xFF;
  _cmd_buff[14] = (y2 >> 8) & 0xFF;
  _cmd_buff[15] = y2 & 0xFF;
  
  _cmd_buff[16] = FRAME_E0;
  _cmd_buff[17] = FRAME_E1;
  _cmd_buff[18] = FRAME_E2;
  _cmd_buff[19] = FRAME_E3; 
  _cmd_buff[20] = _verify(_cmd_buff, 20);
  
  _putchars(_cmd_buff, 21); 
}
/*******************************************************************************
* Function Name  : void epd_clear(void)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_clear(void)
{
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = 0x00;
  _cmd_buff[2] = 0x09;  
  
  _cmd_buff[3] = CMD_CLEAR;
  
  _cmd_buff[4] = FRAME_E0;
  _cmd_buff[5] = FRAME_E1;
  _cmd_buff[6] = FRAME_E2;
  _cmd_buff[7] = FRAME_E3;  
  _cmd_buff[8] = _verify(_cmd_buff, 8);
  
  _putchars(_cmd_buff, 9);  
}

/*******************************************************************************
* Function Name  : void epd_disp_char(unsigned char ch, int x0, int y0);
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_disp_char(unsigned char ch, int x0, int y0)
{
  unsigned char buff[2];
  
  buff[0] = ch;
  buff[1] = 0;
  
  epd_disp_string(buff, x0, y0);
}
/*******************************************************************************
* Function Name  : void epd_disp_string(const void * p, int x0, int y0)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_disp_string(const void * p, int x0, int y0)
{
  int string_size;
  unsigned char * ptr = (unsigned char *)p;
  
  
  string_size = strlen((const char *)ptr);
  string_size += 14;
  
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = (string_size >> 8) & 0xFF;
  _cmd_buff[2] = string_size & 0xFF;
  
  _cmd_buff[3] = CMD_DRAW_STRING;
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  
  strcpy((char *)(&_cmd_buff[8]), (const char *)ptr);
  
  string_size -= 5;
  
  _cmd_buff[string_size] = FRAME_E0;
  _cmd_buff[string_size + 1] = FRAME_E1;
  _cmd_buff[string_size + 2] = FRAME_E2;
  _cmd_buff[string_size + 3] = FRAME_E3;
  _cmd_buff[string_size + 4] = _verify(_cmd_buff, string_size + 4);
  
  _putchars(_cmd_buff, string_size + 5);
}
/*******************************************************************************
* Function Name  : void epd_disp_bitmap(const void * p, int x0, int y0)
* Description    : 
* Input          : 
* Output         : None
* Return         : 
* Attention      : None
*******************************************************************************/
void epd_disp_bitmap(const void * p, int x0, int y0)
{
  int string_size;
  unsigned char * ptr = (unsigned char *)p;
  
  string_size = strlen((const char *)ptr);
  string_size += 14;
  
  _cmd_buff[0] = FRAME_B;
  
  _cmd_buff[1] = (string_size >> 8) & 0xFF;
  _cmd_buff[2] = string_size & 0xFF;
  
  _cmd_buff[3] = CMD_DRAW_BITMAP;
  
  _cmd_buff[4] = (x0 >> 8) & 0xFF;
  _cmd_buff[5] = x0 & 0xFF;
  _cmd_buff[6] = (y0 >> 8) & 0xFF;
  _cmd_buff[7] = y0 & 0xFF;
  
  strcpy((char *)(&_cmd_buff[8]), (const char *)ptr);
  
  string_size -= 5;
  
  _cmd_buff[string_size] = FRAME_E0;
  _cmd_buff[string_size + 1] = FRAME_E1;
  _cmd_buff[string_size + 2] = FRAME_E2;
  _cmd_buff[string_size + 3] = FRAME_E3;
  _cmd_buff[string_size + 4] = _verify(_cmd_buff, string_size + 4);
  
  _putchars(_cmd_buff, string_size + 5);  
}
epd.h
Code: Select all
/*********************************************************************************************************
*
* File                : epd.h
* Hardware Environment: 
* Build Environment   : RealView MDK-ARM  Version: 4.74
* Version             : V1.0
* By                  : V
*
*                                  (c) Copyright 2005-2015, WaveShare
*                                       http://www.waveshare.net
*                                          All Rights Reserved
*
*********************************************************************************************************/
#ifndef    EPD_H
  #define  EPD_H
  

#define    CMD_SIZE                           512 

/*
frame format
*/
#define    FRAME_B                            0xA5
#define    FRAME_E0                           0xCC
#define    FRAME_E1                           0x33
#define    FRAME_E2                           0xC3
#define    FRAME_E3                           0x3C


/*
color define
*/
#define    WHITE                              0x03
#define    GRAY                               0x02
#define    DARK_GRAY                          0x01
#define    BLACK                              0x00

/*
command define
*/
#define    CMD_HANDSHAKE                      0x00                                                     //handshake
#define    CMD_SET_BAUD                       0x01                                                     //set baud
#define    CMD_READ_BAUD                      0x02                                                     //read baud
#define    CMD_MEMORYMODE                     0x07                                                     //set memory mode
#define    CMD_STOPMODE                       0x08                                                     //enter stop mode 
#define    CMD_UPDATE                         0x0A                                                     //update
#define    CMD_SCREEN_ROTATION                0x0D                                                     //set screen rotation
#define    CMD_LOAD_FONT                      0x0E                                                     //load font
#define    CMD_LOAD_PIC                       0x0F                                                     //load picture

#define    CMD_SET_COLOR                      0x10                                                     //set color
#define    CMD_SET_EN_FONT                    0x1E                                                     //set english font
#define    CMD_SET_CH_FONT                    0x1F                                                     //set chinese font

#define    CMD_DRAW_PIXEL                     0x20                                                     //set pixel
#define    CMD_DRAW_LINE                      0x22                                                     //draw line
#define    CMD_FILL_RECT                      0x24                                                     //fill rectangle
#define    CMD_DRAW_CIRCLE                    0x26                                                     //draw circle
#define    CMD_FILL_CIRCLE                    0x27                                                     //fill circle
#define    CMD_DRAW_TRIANGLE                  0x28                                                     //draw triangle
#define    CMD_FILL_TRIANGLE                  0x29                                                     //fill triangle
#define    CMD_CLEAR                          0x2E                                                     //clear screen use back color

#define    CMD_DRAW_STRING                    0x30                                                     //draw string

#define    CMD_DRAW_BITMAP                    0x70                                                     //draw bitmap


/*
FONT
*/
#define    GBK32                              0x01
#define    GBK48                              0x02
#define    GBK64                              0x03
  
#define    ASCII32                            0x01
#define    ASCII48                            0x02
#define    ASCII64                            0x03



/*
Memory Mode
*/
#define    MEM_NAND                           0
#define    MEM_TF                             1

/*
set screen rotation
*/
#define    EPD_NORMAL                         0                                                        //screen normal
#define    EPD_INVERSION                      1                                                        //screen inversion      


void epd_init(void);
void epd_reset(void);
void epd_wakeup(void);

void epd_handshake(void);
void epd_set_memory(unsigned char mode);
void epd_enter_stopmode(void);
void epd_udpate(void);
void epd_screen_rotation(unsigned char mode);
void epd_load_font(void);
void epd_load_pic(void);


void epd_set_color(unsigned char color, unsigned char bkcolor);
void epd_set_en_font(unsigned char font);
void epd_set_ch_font(unsigned char font);

void epd_draw_pixel(int x0, int y0);
void epd_draw_line(int x0, int y0, int x1, int y1);
void epd_fill_rect(int x0, int y0, int x1, int y1);
void epd_draw_circle(int x0, int y0, int r);
void epd_fill_circle(int x0, int y0, int r);
void epd_draw_triangle(int x0, int y0, int x1, int y1, int x2, int y2);
void epd_fill_triangle(int x0, int y0, int x1, int y1, int x2, int y2);
void epd_clear(void);

void epd_disp_char(unsigned char ch, int x0, int y0);
void epd_disp_string(const void * p, int x0, int y0);

void epd_disp_bitmap(const void * p, int x0, int y0);


  
#endif
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]