element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum How to convert code for Driver IC IL0373 to Driver ID SSD1680
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 7 replies
  • Subscribers 388 subscribers
  • Views 1756 views
  • Users 0 members are here
  • driver
  • epaper
  • adafruit feather
  • nrf
  • segger embedded studio
Related

How to convert code for Driver IC IL0373 to Driver ID SSD1680

KKaushik
KKaushik over 2 years ago

I'm working on epaper display (based on SSD1680) with the nRF52840DK board.

I have a code sample from this link, but this code uses paper based on IL0373 IC.

Below is the code for paper.c 

#include "paper.h"

#include <string.h>

#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "nrf_drv_spi.h"

#define PAPER_RST_PIN 13
#define PAPER_DC_PIN  14

#define PAPER_SPI_INSTANCE 0
#define PAPER_SPI_SS_PIN   29
#define PAPER_SPI_MOSI_PIN 4
#define PAPER_SPI_SCK_PIN  3

#define PAPER_BYTE_WIDTH ((PAPER_PIXEL_WIDTH % 8 == 0) ? PAPER_PIXEL_WIDTH / 8 : PAPER_PIXEL_WIDTH / 8 + 1)
#define PAPER_BYTE_HEIGHT PAPER_PIXEL_HEIGHT
#define PAPER_BUFLEN PAPER_BYTE_WIDTH * PAPER_BYTE_HEIGHT

#define PAPER_CMD_PWR  0x01
#define PAPER_CMD_BTST 0x06
#define PAPER_CMD_PON  0x04
#define PAPER_CMD_PSR  0x00
#define PAPER_CMD_PLL  0x30
#define PAPER_CMD_TRES 0x61
#define PAPER_CMD_VDCD 0x82
#define PAPER_CMD_VCOM 0x50
#define PAPER_CMD_LUT_VCDC 0x20
#define PAPER_CMD_LUT_WW 0x21
#define PAPER_CMD_LUT_BW 0x22
#define PAPER_CMD_LUT_WB 0x23
#define PAPER_CMD_LUT_BB 0x24
#define PAPER_CMD_DISP 0x12

static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(PAPER_SPI_INSTANCE);

static uint8_t paper_cmd_pwr[] = {
  PAPER_CMD_PWR,
  0x03, 0x00, 0x2b, 0x2b, 0x03,
};

static uint8_t paper_cmd_btst[] = {
  PAPER_CMD_BTST,
  0x17, 0x17, 0x17,
};

static uint8_t paper_cmd_pon[] = {
  PAPER_CMD_PON,
};

static uint8_t paper_cmd_psr[] = {
  PAPER_CMD_PSR,
  0xbf, 0x0d,
};

static uint8_t paper_cmd_pll[] = {
  PAPER_CMD_PLL,
  0x3a,
};

static uint8_t paper_cmd_tres[] = {
  PAPER_CMD_TRES,
  PAPER_PIXEL_WIDTH,
  (PAPER_PIXEL_HEIGHT >> 8) & 0xff,
  PAPER_PIXEL_HEIGHT & 0xff,
};

static uint8_t paper_cmd_vdcd[] = {
  PAPER_CMD_VDCD,
  0x28,
};

static uint8_t paper_cmd_vcom[] = {
  PAPER_CMD_VCOM,
  0x97
};

static uint8_t paper_cmd_lut_vcdc[] = {
  PAPER_CMD_LUT_VCDC,
  0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
  0x60, 0x28, 0x28, 0x00, 0x00, 0x01,
  0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
  0x00, 0x12, 0x12, 0x00, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00,
};

static uint8_t paper_cmd_lut_ww[] = {
  PAPER_CMD_LUT_WW,
  0x40, 0x08, 0x00, 0x00, 0x00, 0x02,
  0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  0x40, 0x14, 0x00, 0x00, 0x00, 0x01,
  0xA0, 0x12, 0x12, 0x00, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

static uint8_t paper_cmd_lut_bw[] = {
  PAPER_CMD_LUT_BW,
  0x40, 0x17, 0x00, 0x00, 0x00, 0x02,
  0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03,
  0x40, 0x0A, 0x01, 0x00, 0x00, 0x01,
  0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

static uint8_t paper_cmd_lut_wb[] = {
  PAPER_CMD_LUT_WB,
  0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
  0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
  0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

static uint8_t paper_cmd_lut_bb[] = {
  PAPER_CMD_LUT_BB,
  0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
  0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
  0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

static uint8_t paper_cmd_disp[] = {
  PAPER_CMD_DISP,
};

static uint8_t paper_buffer[PAPER_BUFLEN];
static uint8_t paper_prev_buffer[PAPER_BUFLEN];

static void paper_begin_command(void) {
  nrf_gpio_pin_clear(PAPER_DC_PIN);
}

static void paper_begin_data(void) {
  nrf_gpio_pin_set(PAPER_DC_PIN);
}

static ret_code_t paper_tx_cmd(uint8_t *cmd, uint8_t length) {
  ret_code_t ret;

  paper_begin_command();
  ret = nrf_drv_spi_transfer(&spi, cmd, 1, NULL, 0);
  if (ret != NRF_SUCCESS) return ret;

  if (length - 1 > 0) {
    paper_begin_data();
    ret = nrf_drv_spi_transfer(&spi, cmd + 1, length - 1, NULL, 0);
    if (ret != NRF_SUCCESS) return ret;
  }

  return ret;
}

static void paper_reset(void) {
  nrf_gpio_pin_clear(PAPER_RST_PIN);
  nrf_delay_ms(200);
  nrf_gpio_pin_set(PAPER_RST_PIN);
  nrf_delay_ms(200);
}

static ret_code_t paper_tx_lut(void) {
  ret_code_t ret;

  ret = paper_tx_cmd(paper_cmd_vcom, sizeof(paper_cmd_vcom));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_vcdc, sizeof(paper_cmd_lut_vcdc));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_ww, sizeof(paper_cmd_lut_ww));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_bw, sizeof(paper_cmd_lut_bw));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_wb, sizeof(paper_cmd_lut_wb));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_bb, sizeof(paper_cmd_lut_bb));
  if (ret != NRF_SUCCESS) return ret;

  return ret;
}

static ret_code_t _paper_display(void) {
  ret_code_t ret;

  /*
   * TODO transfer chunks of 256 bytes rather than calling nrf_drv_spi_transfer
   * for each byte.
   */

  uint8_t command[1];

  command[0] = 0x10;
  ret = paper_tx_cmd(command, 1);
  if (ret != NRF_SUCCESS) return ret;

  paper_begin_data();
  for (int i = 0; i < PAPER_BUFLEN; i++) {
    ret = nrf_drv_spi_transfer(&spi, paper_prev_buffer + i, 1, NULL, 0);
    if (ret != NRF_SUCCESS) return ret;
  }

  nrf_delay_ms(10);

  /*
   * TODO i'm not yet sure about the purpose of sending the previous buffer too.
   * just sending 0x00s works pretty good. when sending the actual previous
   * image buffer, it looks like sections that have not changed become kinda
   * dirty / greyish (which could be useful because one can use three colors).
   */

  // memcpy(paper_prev_buffer, paper_buffer, PAPER_BUFLEN);

  command[0] = 0x13;
  ret = paper_tx_cmd(command, 1);
  if (ret != NRF_SUCCESS) return ret;

  paper_begin_data();
  for (int i = 0; i < PAPER_BUFLEN; i++) {
    ret = nrf_drv_spi_transfer(&spi, paper_buffer + i, 1, NULL, 0);
    if (ret != NRF_SUCCESS) return ret;
  }

  nrf_delay_ms(10);

  ret = paper_tx_lut();
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_disp, sizeof(paper_cmd_disp));
  if (ret != NRF_SUCCESS) return ret;

  nrf_delay_ms(100); // TODO use busy pin rather than arbitrary delays

  return ret;
}

ret_code_t paper_init(void) {
  ret_code_t ret;

  nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
  spi_config.ss_pin   = PAPER_SPI_SS_PIN;
  spi_config.mosi_pin = PAPER_SPI_MOSI_PIN;
  spi_config.sck_pin  = PAPER_SPI_SCK_PIN;

  ret = nrf_drv_spi_init(&spi, &spi_config, NULL, NULL);
  if (ret != NRF_SUCCESS) return ret;

  nrf_gpio_cfg_output(PAPER_RST_PIN);
  nrf_gpio_cfg_output(PAPER_DC_PIN);

  paper_reset();

  ret = paper_tx_cmd(paper_cmd_pwr, sizeof(paper_cmd_pwr));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_btst, sizeof(paper_cmd_btst));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_pon, sizeof(paper_cmd_pon));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_psr, sizeof(paper_cmd_psr));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_pll, sizeof(paper_cmd_pll));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_tres, sizeof(paper_cmd_tres));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_vdcd, sizeof(paper_cmd_vdcd));
  if (ret != NRF_SUCCESS) return ret;

  memset(paper_buffer, 0xff, PAPER_BUFLEN);
  memset(paper_prev_buffer, 0x00, PAPER_BUFLEN);

  return ret;
}

void paper_uninit(void) {
  // TODO uninit spi and free buffers
}

void paper_pixel_draw(uint16_t x, uint16_t y, uint32_t color) {
  ASSERT(x < PAPER_PIXEL_WIDTH);
  ASSERT(y < PAPER_PIXEL_HEIGHT);

  int bitn = y * PAPER_PIXEL_WIDTH + x;
  int byten = bitn / 8;
  bitn = 8 - bitn % 8 - 1;

  if (color == 0) paper_buffer[byten] |= 1UL << (bitn);
  else paper_buffer[byten] &= ~(1UL << (bitn));
}

void paper_rect_draw(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color) {
  ASSERT(x + width < PAPER_PIXEL_WIDTH);
  ASSERT(y + height < PAPER_PIXEL_HEIGHT);

  for (uint16_t _x = x; _x < x + width; _x++)
    for (uint16_t _y = y; _y < y + height; _y++)
      paper_pixel_draw(_x, _y, color);
}

void paper_display(void) {
  APP_ERROR_CHECK(_paper_display());
}

void paper_rotation_set(nrf_lcd_rotation_t rotation) {
  UNUSED_PARAMETER(rotation);

  // TODO
}

void paper_display_invert(bool invert) {
  UNUSED_PARAMETER(invert);

  // TODO
}

I have used adafruit library from this link and successfully worked using SSD1680

I want to know how can I convert the paper.c code to use SSD1680 from the adafruit library instead of IL0373 driver

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz over 2 years ago +3
    Hi, I think you wish to use an Adafruit library on a non-Adafruit board, is that correct? If so, the approach that you mention (converting the paper.c driver) is not needed. Adafruit libraries are already…
  • shabaz
    shabaz over 2 years ago in reply to KKaushik +1
    Hi Kaushik, Replying here because others may be able to help if they can see it: Regarding the message: Hello, I have been following your given code, for the paper display. I have changed only…
  • shabaz
    shabaz over 2 years ago in reply to KKaushik +1
    Hi, The code definitely works (it was confirmed by several people in the comments at Experimenting with E-Paper Displays: Building a Clock! ) so if it is not functioning for you, it may be one of these…
  • shabaz
    shabaz over 2 years ago

    Hi,

    I think you wish to use an Adafruit library on a non-Adafruit board, is that correct? If so, the approach that you mention (converting the paper.c driver) is not needed. Adafruit libraries are already C code, that can be used with any microcontroller (pretty much). You don't need the paper.c code at all (well, you could use the line or rectangle drawing routines from it if desired, but nothing much else).

    If you wish to use as much of the Adafruit code as possible, then the thing that needs to be done is to _port_ the Adafruit library, rather than try to convert the driver for a completely different chip (i.e. your paper.c file is effectively a driver of sorts, just visually examining it). There's no special technique however. The Adafruit code will need to be manually inspected, and modified to suit your new microcontroller environment. 

    Personally, if it were me (I have done this for a different e-paper display, so I know it is feasible), I'd take the constant arrays from the known working code (i.e. the Adafruit code), and then just write the rest of the code from scratch, following both the datasheet (if available) as well as the Adafruit code. There's not a lot of code to write, since the controllers inside these displays do not expect much communication. They do however expect the correct initializing data, hence the need to use the constant arrays from the known working code.

    Finally, one other approach is to simply google around for a driver that will suit your microcontroller. For example, my code might work for you:  Experimenting with E-Paper Displays: Building a Clock! 

    I believe it is for a display that uses the same chip, i.e. SSD1680 (but I'm only 90% sure). It was specifically written in C (not C++) without any reliance on other libraries, so that it would be easy to port to any microcontroller. However it is a 6-year-old blog post, so I can't recall much.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • KKaushik
    KKaushik over 2 years ago in reply to shabaz

    Thanks a lot for your reply, I'll try the code you have given. But one more thing I wanted to confirm

    shabaz said:
    Adafruit libraries are already C code, that can be used with any microcontroller (pretty much). You don't need the paper.c code at all

    When I checked the libraries used in SSD1680.c, I ended up with Arduino.h and SPI.h. So I thought those are related to Arduino-compatible boards.

    And SPI.h is used in SSD1680.c are related to Arduino too not the nRF52840DK board.

    Adafruit_SSD1680.c  > Adafruit_EPD.h > Adafruit_GFX.h > Arduino.h

    So I am not sure if I can use Arduino.h to nRF52840Dk Projects, as I going to need to include all these sub-libraries to include the folder of the project.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to KKaushik

    This is part of the porting exercise, i.e. visually inspecting any included files content (doesn't matter if it is called Arduino.h or not, you still need to inspect what gets included from it). Otherwise, you could try to use code (e.g. the code I wrote) that isn't dependent on other libraries or header files, if you have difficulty porting the Arduino version.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to KKaushik

    Hi Kaushik,

    Replying here because others may be able to help if they can see it:

    Regarding the message:

    Hello,

    I have been following your given code, for the paper display.

    I have changed only the pin definition:

    //main.cpp

    #define led LED3
    #define bset p11
    #define bdown p12
    #define bup p24


    //ep29.h

    #define DC D1
    #define RST D2
    #define BUSY D3
    #define CS D0

    #define MISO D9
    #define MOSI p17
    #define CLK p19


    Thou the LED is blinking right but no response on the e-paper display.

    Could you suggest me something?

    I'm not sure of the issue. I believe that should work, since you say that the LED is blinking, then that suggests that the GPIO is perhaps functioning, although you should double-check that, and also share your code, so that people familiar with your nRF board etc may spot anything.

    However, there is also a strong chance that these values in main.cpp might need changing:

    image

    These values are specific to the E-paper glass, and not to the SSD1680. I think each batch (or at the very least each manufacturer) will have different settings. They need to be obtained from the manufacturer of the E-paper. In my case, since I bought the E-paper from Waveshare, I used the values that were in their code.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • KKaushik
    KKaushik over 2 years ago in reply to shabaz

    Here is the code I compiled in "mbed Studio"

    main.cpp

    #include "mbed.h"
    #include "ep29.h"
    
    // Wiring connections
    // Blue - MOSI - PTD2
    // Yellow - SCK - PTD1
    // Orange - CS - PTD7
    // Green - DC Data/Command - PTD6
    // White - RST - PTA17
    // Purple - BUSY - PTA16
    // Black - GND
    // Red - 3.3V
    
    //definitions
    #define LED_ON 0
    #define LED_OFF 1
    #define FOREVER 1
    #define MODE_TIMEDISPLAY 1
    #define MODE_TIMESET 2
    #define BTN_SET_PRESSED btn_set.read()==0
    #define BTN_SET_RELEASED btn_set.read()==1
    #define BTN_DOWN_PRESSED btn_down.read()==0
    #define BTN_DOWN_RELEASED btn_down.read()==1
    #define BTN_UP_PRESSED btn_up.read()==0
    #define BTN_UP_RELEASED btn_up.read()==1
    #define SET_NULL 0
    #define SET_HOUR 1
    #define SET_MIN 2
    #define SET_YEAR 3
    #define SET_MONTH 4
    #define SET_DATE 5
    
    // Constants
    
    // look-up tables, provided by Waveshare
    const unsigned char full_mode[] = {
            0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69, 
            0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00,
            0xf8, 0xb4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00 };
    const unsigned char partial_mode[] = {
            0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x13, 0x14, 0x44, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    
    
    // Global Variables
    DigitalOut myled(LED1); // in-built LED
    time_t unixtime;
    Ticker sec_ticker;
    Ticker debounce_ticker;
    char screen_update_ctr;
    char do_screen_update;
    DigitalIn btn_set(BUTTON1);
    DigitalIn btn_down(BUTTON2);
    DigitalIn btn_up(BUTTON3);
    char button_inhibit;
    unsigned char fbuf[EP_FRAMEMEMSIZE];
    char led_state=0;
    
    void
    sec_handler(void)
    {
        unixtime++;
        screen_update_ctr++;
        if (screen_update_ctr>=60)
        {
          do_screen_update=1;
          screen_update_ctr=0;
        }
        led_state=led_state^1;
        myled=led_state;
    }
    
    void
    debounce_handler(void)
    {
        button_inhibit=0;
        debounce_ticker.detach();
    }
    
    int
    main(void)
    {
        char timebuf[6]; // used to store HH:MM time, e.g. 19:20
        char calbuf[32]; // used to store the date, e.g. Fri 29 Dec 2017
        char textbuf[10];
        unsigned int dx, dy;
        char mode=MODE_TIMEDISPLAY;
        char setting=SET_NULL;
        struct tm tset;
        int val;
        int toadd;
        
        btn_set.mode(PullUp);
        btn_down.mode(PullUp);
        btn_up.mode(PullUp);
        
        button_inhibit=0;
        screen_update_ctr=0;
        do_screen_update=1;
        myled = LED_OFF;  
     
        ep_spi_init();
        ep_init((unsigned char*)full_mode);
        
        ep_setbg(fbuf, ALL_WHITE); 
        // any buttons pressed on startup?
        if (BTN_DOWN_PRESSED)
        {
            ep_setframe(fbuf, 0,0, EP_WIDTH, EP_HEIGHT);
            ep_displayframe();
            ep_setframe(fbuf, 0,0, EP_WIDTH, EP_HEIGHT);
            ep_displayframe();
            while(FOREVER)
            {
                wait_us(200);
                myled=LED_ON;
                wait_us(200);
                myled=LED_OFF;
            }
        }
        if (BTN_UP_PRESSED)
        {
            ep_write_text(fbuf, "E-Paper Clock", 10,50, COL_BLACK, 2.0, 1.0, NULL, PEN_MED);
            ep_setframe(fbuf, 0,0, EP_WIDTH, EP_HEIGHT);
            ep_displayframe();
            while(FOREVER)
            {
                wait_us(200);
                myled=LED_ON;
                wait_us(200);
                myled=LED_OFF;
            }
        }
        
        unixtime=1514583436;  // Set RTC time to some initial value
        sec_ticker.attach(sec_handler, 1.0);
        
        while(FOREVER)
        {
            toadd=0;
            if ((BTN_UP_PRESSED) && (button_inhibit==0))
                toadd=1;
            if ((BTN_DOWN_PRESSED) && (button_inhibit==0))
                toadd=-1;
            if (toadd!=0)
            {
                sec_ticker.detach();
                screen_update_ctr=59;
                sec_ticker.attach(sec_handler, 1.0);
                button_inhibit=1;
                debounce_ticker.attach(debounce_handler, 0.3);
                if (mode==MODE_TIMESET)
                {
                    switch(setting)
                    {
                        case SET_HOUR:
                            if ((toadd>0) && (tset.tm_hour<23))
                                tset.tm_hour+=1;
                            else if ((toadd<0) && (tset.tm_hour>0))
                                tset.tm_hour-=1;
                            break;
                        case SET_MIN:
                            if ((toadd>0) && (tset.tm_min<59))
                                tset.tm_min+=1;
                            else if ((toadd<0) && (tset.tm_min>0))
                                tset.tm_min-=1;
                            break;
                        case SET_YEAR:
                            if ((toadd>0) && (tset.tm_year<199)) // allow up to 2099
                                tset.tm_year+=1;
                            else if ((toadd<0) && (tset.tm_year>0)) // allow down to 1900
                                tset.tm_year-=1;
                            break;
                        case SET_MONTH:
                            if ((toadd>0) && (tset.tm_mon<11))
                                tset.tm_mon+=1;
                            else if ((toadd<0) && (tset.tm_mon>0))
                                tset.tm_mon-=1;
                            break;
                        case SET_DATE:
                            if ((toadd>0) && (tset.tm_mday<31))
                                tset.tm_mday+=1;
                            else if ((toadd<0) && (tset.tm_mday>1))
                                tset.tm_mday-=1;
                            break;
                        default:
                            break;
                    }
                }   
            }
            
            if ((BTN_SET_PRESSED) && (button_inhibit==0))
            {
                if (mode==MODE_TIMEDISPLAY)
                {
                    mode=MODE_TIMESET;
                    strftime(timebuf, 6, "%H", localtime(&unixtime));
                    sscanf(timebuf, "%d", &val);
                    tset.tm_hour=val;
                    strftime(timebuf, 6, "%M", localtime(&unixtime));
                    sscanf(timebuf, "%d", &val);
                    tset.tm_min=val;
                    strftime(timebuf, 6, "%Y", localtime(&unixtime));
                    sscanf(timebuf, "%d", &val);
                    tset.tm_year=val-1900;
                    strftime(timebuf, 6, "%m", localtime(&unixtime));
                    sscanf(timebuf, "%d", &val);
                    tset.tm_mon=val-1;
                    strftime(timebuf, 6, "%d", localtime(&unixtime));
                    sscanf(timebuf, "%d", &val);
                    tset.tm_mday=val;
                    tset.tm_sec=screen_update_ctr;
                    
                    setting=SET_HOUR;
                    screen_update_ctr=0;
                    do_screen_update=1;
                    button_inhibit=1;
                    debounce_ticker.attach(debounce_handler, 1.0);
                }
                else if (mode==MODE_TIMESET)
                {
                    switch(setting)
                    {
                        case SET_HOUR:
                            setting=SET_MIN;
                            break;
                        case SET_MIN:
                            setting=SET_YEAR;
                            break;
                        case SET_YEAR:
                            setting=SET_MONTH;
                            break;
                        case SET_MONTH:
                            setting=SET_DATE;
                            break;
                        case SET_DATE:
                            setting=SET_NULL;
                            unixtime = mktime(&tset);
                            mode=MODE_TIMEDISPLAY;
                            break;
                        default:
                            break;
                    }
                    screen_update_ctr=0;
                    do_screen_update=1;
                    button_inhibit=1;
                    debounce_ticker.attach(debounce_handler, 1.0);
                }
            }
            if (do_screen_update)
            {
                do_screen_update=0;
                ep_setbg(fbuf, ALL_WHITE);
                switch(mode)
                {
                    case MODE_TIMEDISPLAY:
                        //unixtime=time(NULL);
                        strftime(timebuf, 6, "%H:%M", localtime(&unixtime));
                        strftime(calbuf, 32, "%a %e %b %Y", localtime(&unixtime));
                        ep_write_text(fbuf, calbuf, 0,103, COL_BLACK, 1.0, 1.0, NULL, PEN_MED);
                        dx=ep_write_text(fbuf, timebuf, 0,5, COL_BLACK, 3.0, 4.0, NULL, PEN_THICK);
                        break;
                    case MODE_TIMESET:
                        switch(setting)
                        {
                            case SET_HOUR:
                                ep_write_text(fbuf, "Set Hour:", 0,103, COL_BLACK, 1.0, 1.0, NULL, PEN_MED);
                                sprintf(textbuf, "%02d", tset.tm_hour);
                                ep_write_text(fbuf, textbuf, 0,5, COL_BLACK, 3.0, 4.0, NULL, PEN_THICK);
                                break;
                            case SET_MIN:
                                ep_write_text(fbuf, "Set Min:", 0,103, COL_BLACK, 1.0, 1.0, NULL, PEN_MED);
                                sprintf(textbuf, "%02d", tset.tm_min);
                                ep_write_text(fbuf, textbuf, 0,5, COL_BLACK, 3.0, 4.0, NULL, PEN_THICK);
                                break;
                            case SET_YEAR:
                                ep_write_text(fbuf, "Set Year:", 0,103, COL_BLACK, 1.0, 1.0, NULL, PEN_MED);
                                sprintf(textbuf, "%d", 1900+tset.tm_year);
                                ep_write_text(fbuf, textbuf, 0,5, COL_BLACK, 3.0, 4.0, NULL, PEN_THICK);
                                break;
                            case SET_MONTH:
                                ep_write_text(fbuf, "Set Month:", 0,103, COL_BLACK, 1.0, 1.0, NULL, PEN_MED);
                                sprintf(textbuf, "%d", 1+tset.tm_mon);
                                ep_write_text(fbuf, textbuf, 0,5, COL_BLACK, 3.0, 4.0, NULL, PEN_THICK);
                                break;
                            case SET_DATE:
                                ep_write_text(fbuf, "Set Date:", 0,103, COL_BLACK, 1.0, 1.0, NULL, PEN_MED);
                                sprintf(textbuf, "%d", tset.tm_mday);
                                ep_write_text(fbuf, textbuf, 0,5, COL_BLACK, 3.0, 4.0, NULL, PEN_THICK);
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
                ep_setframe(fbuf, 0,0, EP_WIDTH, EP_HEIGHT);
                ep_displayframe();
            }
            wait_us(100); // small sleep
        } // end while(FOREVER)
        
    }

    ep29.cpp

    /***********************************************
     * ep29.cpp
     * 2.9 inch E-Paper Driver
     * rev 1 - shabaz - December 2017
     * free for all non-commercial use
     *
     ***********************************************/
    
    #include "mbed.h"
    #include "ep29.h"
    
    // Definitions
    
    // these constants are taken from Waveshare source code:
    #define DRIVER_OUT_CTRL                    0x01
    #define BOOST_SOFT_START_CTRL              0x0c
    #define GATE_SCAN_START_POS                0x0f
    #define DEEP_SLEEP                         0x10
    #define DATA_ENTRY_MODE_SET                0x11
    #define SW_RESET                           0x12
    #define TEMP_SENSOR_CTRL                   0x1a
    #define MASTER_ACTIVATION                  0x20
    #define DISPLAY_UPDATE_CTRL_1              0x21
    #define DISPLAY_UPDATE_CTRL_2              0x22
    #define WRITE_RAM                          0x24
    #define WRITE_VCOM_REG                     0x2c
    #define WRITE_LUT_REG                      0x32
    #define SET_DUMMY_LINE_PERIOD              0x3a
    #define SET_GATE_TIME                      0x3b
    #define BORDER_WAVEFORM_CTRL               0x3c
    #define SET_RAM_X_ADDRESS_START_END_POS    0x44
    #define SET_RAM_Y_ADDRESS_START_END_POS    0x45
    #define SET_RAM_X_ADDRESS_CTR              0x4e
    #define SET_RAM_Y_ADDRESS_CTR              0x4f
    #define TERM_FRAME_READ_WRITE              0xff
    
    #define EP_RST_LOW ep_rst=0
    #define EP_RST_HIGH ep_rst=1
    #define EP_DC_LOW ep_dc=0
    #define EP_DC_HIGH ep_dc=1
    #define EP_DC_CMD ep_dc=0
    #define EP_DC_DATA ep_dc=1
    #define EP_CS_LOW ep_cs=0
    #define EP_CS_HIGH ep_cs=1
    #define EP_BUSY (ep_busy.read()==1)
    #define EP_NOT_BUSY (ep_busy.read()==0)
    
    // Constants
    // The array here is taken from http://paulbourke.net/dataformats/hershey/
    
    const int8_t simplex[95][112] = {
        0,16, /* Ascii 32 */
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,10, /* Ascii 33 */
        5,21, 5, 7,-1,-1, 5, 2, 4, 1, 5, 0, 6, 1, 5, 2,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,16, /* Ascii 34 */
        4,21, 4,14,-1,-1,12,21,12,14,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,21, /* Ascii 35 */
       11,25, 4,-7,-1,-1,17,25,10,-7,-1,-1, 4,12,18,12,-1,-1, 3, 6,17, 6,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       26,20, /* Ascii 36 */
        8,25, 8,-4,-1,-1,12,25,12,-4,-1,-1,17,18,15,20,12,21, 8,21, 5,20, 3,
       18, 3,16, 4,14, 5,13, 7,12,13,10,15, 9,16, 8,17, 6,17, 3,15, 1,12, 0,
        8, 0, 5, 1, 3, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       31,24, /* Ascii 37 */
       21,21, 3, 0,-1,-1, 8,21,10,19,10,17, 9,15, 7,14, 5,14, 3,16, 3,18, 4,
       20, 6,21, 8,21,10,20,13,19,16,19,19,20,21,21,-1,-1,17, 7,15, 6,14, 4,
       14, 2,16, 0,18, 0,20, 1,21, 3,21, 5,19, 7,17, 7,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       34,26, /* Ascii 38 */
       23,12,23,13,22,14,21,14,20,13,19,11,17, 6,15, 3,13, 1,11, 0, 7, 0, 5,
        1, 4, 2, 3, 4, 3, 6, 4, 8, 5, 9,12,13,13,14,14,16,14,18,13,20,11,21,
        9,20, 8,18, 8,16, 9,13,11,10,16, 3,18, 1,20, 0,22, 0,23, 1,23, 2,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        7,10, /* Ascii 39 */
        5,19, 4,20, 5,21, 6,20, 6,18, 5,16, 4,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       10,14, /* Ascii 40 */
       11,25, 9,23, 7,20, 5,16, 4,11, 4, 7, 5, 2, 7,-2, 9,-5,11,-7,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       10,14, /* Ascii 41 */
        3,25, 5,23, 7,20, 9,16,10,11,10, 7, 9, 2, 7,-2, 5,-5, 3,-7,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,16, /* Ascii 42 */
        8,21, 8, 9,-1,-1, 3,18,13,12,-1,-1,13,18, 3,12,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,26, /* Ascii 43 */
       13,18,13, 0,-1,-1, 4, 9,22, 9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,10, /* Ascii 44 */
        6, 1, 5, 0, 4, 1, 5, 2, 6, 1, 6,-1, 5,-3, 4,-4,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        2,26, /* Ascii 45 */
        4, 9,22, 9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,10, /* Ascii 46 */
        5, 2, 4, 1, 5, 0, 6, 1, 5, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        2,22, /* Ascii 47 */
       20,25, 2,-7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,20, /* Ascii 48 */
        9,21, 6,20, 4,17, 3,12, 3, 9, 4, 4, 6, 1, 9, 0,11, 0,14, 1,16, 4,17,
        9,17,12,16,17,14,20,11,21, 9,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        4,20, /* Ascii 49 */
        6,17, 8,18,11,21,11, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       14,20, /* Ascii 50 */
        4,16, 4,17, 5,19, 6,20, 8,21,12,21,14,20,15,19,16,17,16,15,15,13,13,
       10, 3, 0,17, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       15,20, /* Ascii 51 */
        5,21,16,21,10,13,13,13,15,12,16,11,17, 8,17, 6,16, 3,14, 1,11, 0, 8,
        0, 5, 1, 4, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        6,20, /* Ascii 52 */
       13,21, 3, 7,18, 7,-1,-1,13,21,13, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,20, /* Ascii 53 */
       15,21, 5,21, 4,12, 5,13, 8,14,11,14,14,13,16,11,17, 8,17, 6,16, 3,14,
        1,11, 0, 8, 0, 5, 1, 4, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       23,20, /* Ascii 54 */
       16,18,15,20,12,21,10,21, 7,20, 5,17, 4,12, 4, 7, 5, 3, 7, 1,10, 0,11,
        0,14, 1,16, 3,17, 6,17, 7,16,10,14,12,11,13,10,13, 7,12, 5,10, 4, 7,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,20, /* Ascii 55 */
       17,21, 7, 0,-1,-1, 3,21,17,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       29,20, /* Ascii 56 */
        8,21, 5,20, 4,18, 4,16, 5,14, 7,13,11,12,14,11,16, 9,17, 7,17, 4,16,
        2,15, 1,12, 0, 8, 0, 5, 1, 4, 2, 3, 4, 3, 7, 4, 9, 6,11, 9,12,13,13,
       15,14,16,16,16,18,15,20,12,21, 8,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       23,20, /* Ascii 57 */
       16,14,15,11,13, 9,10, 8, 9, 8, 6, 9, 4,11, 3,14, 3,15, 4,18, 6,20, 9,
       21,10,21,13,20,15,18,16,14,16, 9,15, 4,13, 1,10, 0, 8, 0, 5, 1, 4, 3,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,10, /* Ascii 58 */
        5,14, 4,13, 5,12, 6,13, 5,14,-1,-1, 5, 2, 4, 1, 5, 0, 6, 1, 5, 2,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       14,10, /* Ascii 59 */
        5,14, 4,13, 5,12, 6,13, 5,14,-1,-1, 6, 1, 5, 0, 4, 1, 5, 2, 6, 1, 6,
       -1, 5,-3, 4,-4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        3,24, /* Ascii 60 */
       20,18, 4, 9,20, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,26, /* Ascii 61 */
        4,12,22,12,-1,-1, 4, 6,22, 6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        3,24, /* Ascii 62 */
        4,18,20, 9, 4, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       20,18, /* Ascii 63 */
        3,16, 3,17, 4,19, 5,20, 7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,
       12, 9,10, 9, 7,-1,-1, 9, 2, 8, 1, 9, 0,10, 1, 9, 2,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       55,27, /* Ascii 64 */
       18,13,17,15,15,16,12,16,10,15, 9,14, 8,11, 8, 8, 9, 6,11, 5,14, 5,16,
        6,17, 8,-1,-1,12,16,10,14, 9,11, 9, 8,10, 6,11, 5,-1,-1,18,16,17, 8,
       17, 6,19, 5,21, 5,23, 7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,
       21, 9,20, 7,19, 5,17, 4,15, 3,12, 3, 9, 4, 6, 5, 4, 7, 2, 9, 1,12, 0,
       15, 0,18, 1,20, 2,21, 3,-1,-1,19,16,18, 8,18, 6,19, 5,
        8,18, /* Ascii 65 */
        9,21, 1, 0,-1,-1, 9,21,17, 0,-1,-1, 4, 7,14, 7,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       23,21, /* Ascii 66 */
        4,21, 4, 0,-1,-1, 4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,
       11,-1,-1, 4,11,13,11,16,10,17, 9,18, 7,18, 4,17, 2,16, 1,13, 0, 4, 0,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       18,21, /* Ascii 67 */
       18,16,17,18,15,20,13,21, 9,21, 7,20, 5,18, 4,16, 3,13, 3, 8, 4, 5, 5,
        3, 7, 1, 9, 0,13, 0,15, 1,17, 3,18, 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       15,21, /* Ascii 68 */
        4,21, 4, 0,-1,-1, 4,21,11,21,14,20,16,18,17,16,18,13,18, 8,17, 5,16,
        3,14, 1,11, 0, 4, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,19, /* Ascii 69 */
        4,21, 4, 0,-1,-1, 4,21,17,21,-1,-1, 4,11,12,11,-1,-1, 4, 0,17, 0,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,18, /* Ascii 70 */
        4,21, 4, 0,-1,-1, 4,21,17,21,-1,-1, 4,11,12,11,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       22,21, /* Ascii 71 */
       18,16,17,18,15,20,13,21, 9,21, 7,20, 5,18, 4,16, 3,13, 3, 8, 4, 5, 5,
        3, 7, 1, 9, 0,13, 0,15, 1,17, 3,18, 5,18, 8,-1,-1,13, 8,18, 8,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,22, /* Ascii 72 */
        4,21, 4, 0,-1,-1,18,21,18, 0,-1,-1, 4,11,18,11,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        2, 8, /* Ascii 73 */
        4,21, 4, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       10,16, /* Ascii 74 */
       12,21,12, 5,11, 2,10, 1, 8, 0, 6, 0, 4, 1, 3, 2, 2, 5, 2, 7,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,21, /* Ascii 75 */
        4,21, 4, 0,-1,-1,18,21, 4, 7,-1,-1, 9,12,18, 0,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,17, /* Ascii 76 */
        4,21, 4, 0,-1,-1, 4, 0,16, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,24, /* Ascii 77 */
        4,21, 4, 0,-1,-1, 4,21,12, 0,-1,-1,20,21,12, 0,-1,-1,20,21,20, 0,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,22, /* Ascii 78 */
        4,21, 4, 0,-1,-1, 4,21,18, 0,-1,-1,18,21,18, 0,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       21,22, /* Ascii 79 */
        9,21, 7,20, 5,18, 4,16, 3,13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0,13, 0,15,
        1,17, 3,18, 5,19, 8,19,13,18,16,17,18,15,20,13,21, 9,21,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       13,21, /* Ascii 80 */
        4,21, 4, 0,-1,-1, 4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,
       10, 4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       24,22, /* Ascii 81 */
        9,21, 7,20, 5,18, 4,16, 3,13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0,13, 0,15,
        1,17, 3,18, 5,19, 8,19,13,18,16,17,18,15,20,13,21, 9,21,-1,-1,12, 4,
       18,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       16,21, /* Ascii 82 */
        4,21, 4, 0,-1,-1, 4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,
       11, 4,11,-1,-1,11,11,18, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       20,20, /* Ascii 83 */
       17,18,15,20,12,21, 8,21, 5,20, 3,18, 3,16, 4,14, 5,13, 7,12,13,10,15,
        9,16, 8,17, 6,17, 3,15, 1,12, 0, 8, 0, 5, 1, 3, 3,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,16, /* Ascii 84 */
        8,21, 8, 0,-1,-1, 1,21,15,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       10,22, /* Ascii 85 */
        4,21, 4, 6, 5, 3, 7, 1,10, 0,12, 0,15, 1,17, 3,18, 6,18,21,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,18, /* Ascii 86 */
        1,21, 9, 0,-1,-1,17,21, 9, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,24, /* Ascii 87 */
        2,21, 7, 0,-1,-1,12,21, 7, 0,-1,-1,12,21,17, 0,-1,-1,22,21,17, 0,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,20, /* Ascii 88 */
        3,21,17, 0,-1,-1,17,21, 3, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        6,18, /* Ascii 89 */
        1,21, 9,11, 9, 0,-1,-1,17,21, 9,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,20, /* Ascii 90 */
       17,21, 3, 0,-1,-1, 3,21,17,21,-1,-1, 3, 0,17, 0,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,14, /* Ascii 91 */
        4,25, 4,-7,-1,-1, 5,25, 5,-7,-1,-1, 4,25,11,25,-1,-1, 4,-7,11,-7,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        2,14, /* Ascii 92 */
        0,21,14,-3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,14, /* Ascii 93 */
        9,25, 9,-7,-1,-1,10,25,10,-7,-1,-1, 3,25,10,25,-1,-1, 3,-7,10,-7,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       10,16, /* Ascii 94 */
        6,15, 8,18,10,15,-1,-1, 3,12, 8,17,13,12,-1,-1, 8,17, 8, 0,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        2,16, /* Ascii 95 */
        0,-2,16,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        7,10, /* Ascii 96 */
        6,21, 5,20, 4,18, 4,16, 5,15, 6,16, 5,17,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,19, /* Ascii 97 */
       15,14,15, 0,-1,-1,15,11,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4,
        3, 6, 1, 8, 0,11, 0,13, 1,15, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,19, /* Ascii 98 */
        4,21, 4, 0,-1,-1, 4,11, 6,13, 8,14,11,14,13,13,15,11,16, 8,16, 6,15,
        3,13, 1,11, 0, 8, 0, 6, 1, 4, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       14,18, /* Ascii 99 */
       15,11,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0,11,
        0,13, 1,15, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,19, /* Ascii 100 */
       15,21,15, 0,-1,-1,15,11,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4,
        3, 6, 1, 8, 0,11, 0,13, 1,15, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,18, /* Ascii 101 */
        3, 8,15, 8,15,10,14,12,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4,
        3, 6, 1, 8, 0,11, 0,13, 1,15, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,12, /* Ascii 102 */
       10,21, 8,21, 6,20, 5,17, 5, 0,-1,-1, 2,14, 9,14,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       22,19, /* Ascii 103 */
       15,14,15,-2,14,-5,13,-6,11,-7, 8,-7, 6,-6,-1,-1,15,11,13,13,11,14, 8,
       14, 6,13, 4,11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0,11, 0,13, 1,15, 3,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       10,19, /* Ascii 104 */
        4,21, 4, 0,-1,-1, 4,10, 7,13, 9,14,12,14,14,13,15,10,15, 0,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8, 8, /* Ascii 105 */
        3,21, 4,20, 5,21, 4,22, 3,21,-1,-1, 4,14, 4, 0,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,10, /* Ascii 106 */
        5,21, 6,20, 7,21, 6,22, 5,21,-1,-1, 6,14, 6,-3, 5,-6, 3,-7, 1,-7,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,17, /* Ascii 107 */
        4,21, 4, 0,-1,-1,14,14, 4, 4,-1,-1, 8, 8,15, 0,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        2, 8, /* Ascii 108 */
        4,21, 4, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       18,30, /* Ascii 109 */
        4,14, 4, 0,-1,-1, 4,10, 7,13, 9,14,12,14,14,13,15,10,15, 0,-1,-1,15,
       10,18,13,20,14,23,14,25,13,26,10,26, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       10,19, /* Ascii 110 */
        4,14, 4, 0,-1,-1, 4,10, 7,13, 9,14,12,14,14,13,15,10,15, 0,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,19, /* Ascii 111 */
        8,14, 6,13, 4,11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0,11, 0,13, 1,15, 3,16,
        6,16, 8,15,11,13,13,11,14, 8,14,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,19, /* Ascii 112 */
        4,14, 4,-7,-1,-1, 4,11, 6,13, 8,14,11,14,13,13,15,11,16, 8,16, 6,15,
        3,13, 1,11, 0, 8, 0, 6, 1, 4, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,19, /* Ascii 113 */
       15,14,15,-7,-1,-1,15,11,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4,
        3, 6, 1, 8, 0,11, 0,13, 1,15, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,13, /* Ascii 114 */
        4,14, 4, 0,-1,-1, 4, 8, 5,11, 7,13, 9,14,12,14,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       17,17, /* Ascii 115 */
       14,11,13,13,10,14, 7,14, 4,13, 3,11, 4, 9, 6, 8,11, 7,13, 6,14, 4,14,
        3,13, 1,10, 0, 7, 0, 4, 1, 3, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,12, /* Ascii 116 */
        5,21, 5, 4, 6, 1, 8, 0,10, 0,-1,-1, 2,14, 9,14,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       10,19, /* Ascii 117 */
        4,14, 4, 4, 5, 1, 7, 0,10, 0,12, 1,15, 4,-1,-1,15,14,15, 0,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,16, /* Ascii 118 */
        2,14, 8, 0,-1,-1,14,14, 8, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       11,22, /* Ascii 119 */
        3,14, 7, 0,-1,-1,11,14, 7, 0,-1,-1,11,14,15, 0,-1,-1,19,14,15, 0,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        5,17, /* Ascii 120 */
        3,14,14, 0,-1,-1,14,14, 3, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        9,16, /* Ascii 121 */
        2,14, 8, 0,-1,-1,14,14, 8, 0, 6,-4, 4,-6, 2,-7, 1,-7,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        8,17, /* Ascii 122 */
       14,14, 3, 0,-1,-1, 3,14,14,14,-1,-1, 3, 0,14, 0,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       39,14, /* Ascii 123 */
        9,25, 7,24, 6,23, 5,21, 5,19, 6,17, 7,16, 8,14, 8,12, 6,10,-1,-1, 7,
       24, 6,22, 6,20, 7,18, 8,17, 9,15, 9,13, 8,11, 4, 9, 8, 7, 9, 5, 9, 3,
        8, 1, 7, 0, 6,-2, 6,-4, 7,-6,-1,-1, 6, 8, 8, 6, 8, 4, 7, 2, 6, 1, 5,
       -1, 5,-3, 6,-5, 7,-6, 9,-7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        2, 8, /* Ascii 124 */
        4,25, 4,-7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       39,14, /* Ascii 125 */
        5,25, 7,24, 8,23, 9,21, 9,19, 8,17, 7,16, 6,14, 6,12, 8,10,-1,-1, 7,
       24, 8,22, 8,20, 7,18, 6,17, 5,15, 5,13, 6,11,10, 9, 6, 7, 5, 5, 5, 3,
        6, 1, 7, 0, 8,-2, 8,-4, 7,-6,-1,-1, 8, 8, 6, 6, 6, 4, 7, 2, 8, 1, 9,
       -1, 9,-3, 8,-5, 7,-6, 5,-7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       23,24, /* Ascii 126 */
        3, 6, 3, 8, 4,11, 6,12, 8,12,10,11,14, 8,16, 7,18, 7,20, 8,21,10,-1,
       -1, 3, 8, 4,10, 6,11, 8,11,10,10,14, 7,16, 6,18, 6,20, 7,21,10,21,12,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
       -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
    };
    
    
    
    // Extern variables
    
    // Global variables
    // Hardware Input/Output
    SPI ep_spi(p24, p23, p25); // mosi, miso, sclk
    DigitalOut ep_cs(p27);
    DigitalOut ep_dc(p6);
    DigitalOut ep_rst(p7);
    DigitalIn ep_busy(p8);
    
    // Function prototypes
    void ep_blob(unsigned char* frame, int x, int y, unsigned char col);
    
    // Functions
    void ep_spi_init(void)
    {
        EP_RST_HIGH;
        EP_CS_HIGH;
        ep_spi.format(8,0);
    }
    
    void ep_reset(void)
    {
        EP_RST_LOW;
        wait_us(200);
        EP_RST_HIGH;
        wait_us(200);
    }
    
    void ep_cmd(unsigned char cmd)
    {
        EP_DC_CMD;
        EP_CS_LOW;
        ep_spi.write(cmd);
        EP_CS_HIGH;
    }
    
    void ep_data(unsigned char data)
    {
        EP_DC_DATA;
        EP_CS_LOW;
        ep_spi.write(data);
        EP_CS_HIGH;
    }
    
    void ep_wait(void)
    {
        while(EP_BUSY);
        wait_us(100);
    }
    
    void ep_sleep(void)
    {
        ep_cmd(DEEP_SLEEP);
        ep_wait();
    }
    
    void
    ep_init(unsigned char* lut)
    {
        int i;
        unsigned char* lutptr=(unsigned char*)lut;
        ep_reset();
        ep_cmd(DRIVER_OUT_CTRL);
        ep_data((EP_HEIGHT-1)&0xff);
        ep_data(((EP_HEIGHT-1)>>8)&0xff);
        ep_data(0x00);
        ep_cmd(BOOST_SOFT_START_CTRL);
        ep_data(0xd7);
        ep_data(0xd6);
        ep_data(0x9d);
        ep_cmd(WRITE_VCOM_REG);
        ep_data(0xa8);
        ep_cmd(SET_DUMMY_LINE_PERIOD);
        ep_data(0x1a);
        ep_cmd(SET_GATE_TIME);
        ep_data(0x08);
        ep_cmd(DATA_ENTRY_MODE_SET);
        ep_data(0x03);
        ep_cmd(WRITE_LUT_REG);
        for (i=0; i<30; i++)
        {
            ep_data(*lutptr);
            lutptr++;   
        }
    }
    
    void
    ep_memptr(int x, int y)
    {
        ep_cmd(SET_RAM_X_ADDRESS_CTR);
        ep_data((x>>3) & 0xff);
        ep_cmd(SET_RAM_Y_ADDRESS_CTR);
        ep_data(y & 0xff);
        ep_data((y>>8) & 0xff);
        ep_wait();
    }
    
    void
    ep_memarea(int xs, int ys, int xf, int yf)
    {
        ep_cmd(SET_RAM_X_ADDRESS_START_END_POS);
        ep_data((xs>>3) & 0xff);
        ep_data((xf>>3) & 0xff);
        ep_cmd(SET_RAM_Y_ADDRESS_START_END_POS);
        ep_data(ys & 0xff);
        ep_data((ys>>8) & 0xff);
        ep_data(yf & 0xff);
        ep_data((yf>>8) & 0xff);
    }
    
    void
    ep_displayframe(void)
    {
        ep_cmd(DISPLAY_UPDATE_CTRL_2);
        ep_data(0xc4);
        ep_cmd(MASTER_ACTIVATION);
        ep_cmd(TERM_FRAME_READ_WRITE);
        ep_wait();
    }
    
    void
    ep_clearframe(unsigned char col8=ALL_WHITE)
    {
        int i;
        ep_memarea(0,0, EP_WIDTH-1, EP_HEIGHT-1);
        ep_memptr(0,0);
        ep_cmd(WRITE_RAM);
        for (i=0; i<EP_FRAMEMEMSIZE; i++)
        {
            ep_data(col8);
        }
    }
    
    void
    ep_setframe(unsigned char* frame, int x, int y, int width, int height)
    {
        int xf, yf;
        int xx, yy;
        int width8;
        
        x=x & 0xf8;
        width=width & 0xf8;
        width8=width/8;
        xf=x+width-1;
        yf=y+height-1;
        ep_memarea(x,y, xf,yf);
        ep_memptr(x,y);
        ep_cmd(WRITE_RAM);
        for (yy=0; yy<height; yy++)
        {
            for (xx=0; xx<width8; xx++)
            {
                ep_data(frame[xx+yy*width8]);
            }
        } 
        
    }
    
    void
    ep_plot_raw(unsigned char* frame, int x, int y, unsigned char col)
    {  
        if ((x<0) || (x>=EP_WIDTH) || (y<0) || (y>=EP_HEIGHT))
            return;
        switch(col)
        {
            case COL_WHITE:
                frame[(x+y*EP_WIDTH)/8] |= (0x80 >> (x%8));
                break;
            case COL_BLACK:
                frame[(x+y*EP_WIDTH)/8] &= ~(0x80 >> (x%8));
                break;
            default:
                break;
        }
    }
    
    void
    ep_plot(unsigned char* frame, int x, int y, unsigned char col)
    {  
        int tx, ty;
        tx=y;
        ty=x;
        
        if ((x<0) || (x>=EP_HEIGHT) || (y<0) || (y>=EP_WIDTH))
            return;
        switch(col)
        {
            case COL_WHITE:
                frame[(tx+ty*EP_WIDTH)/8] |= (0x80 >> (tx%8));
                break;
            case COL_BLACK:
                frame[(tx+ty*EP_WIDTH)/8] &= ~(0x80 >> (tx%8));
                break;
            default:
                break;
        }
    }
    
    void
    ep_setbg(unsigned char* frame, unsigned char col8)
    {
        int i;
        unsigned char* fptr;
        fptr=frame;
        for (i=0; i<EP_WIDTH8*EP_HEIGHT; i++)
        {
            *fptr=col8;
            fptr++;
        }
    }
    
    void
    ep_line(unsigned char* frame, int x, int y, int x2, int y2, unsigned char col, char weight)
    {
        int dx, dy;
        int sx, sy, err, e2;
        
        if (x>x2)
            dx=x-x2;
        else
            dx=x2-x;
        if (y>y2)
            dy=y-y2;
        else
            dy=y2-y;
    
        if (x<x2)
            sx=1;
        else
            sx=-1;
      
        if (y<y2)
            sy=1;
        else
            sy=-1;
            
        err=dx-dy;
     
        while(1)
        {
            ep_plot(frame, x, y, col);
            switch(weight)
            {
                case PEN_THIN:
                    break;
                case PEN_MED:
                    if (EP_HEIGHT-1>=x+1)
                        ep_plot(frame, x+1, y, col);
                    if (0<=x-1)
                        ep_plot(frame, x-1, y, col);
                    if (EP_WIDTH-1>=y+1)
                        ep_plot(frame, x, y+1, col);
                    if (0<=y-1)
                        ep_plot(frame, x, y-1, col);
                    break;
                case PEN_THICK:
                    ep_blob(frame, x, y, col);
                    break;
                default:
                    break;
            }
            if ((x==x2) && (y==y2))
                break;
            e2=2*err;
            if (e2>-dy)
            {
                err=err-dy;
                x=x+/*(unsigned char)*/sx;
            }
            if ((x==x2) && (y==y2))
            { 
                ep_plot(frame, x, y, col);
                switch(weight)
                {
                    case PEN_THIN:
                        break;
                    case PEN_MED:
                        if (EP_HEIGHT-1>=x+1)
                            ep_plot(frame, x+1, y, col);
                        if (0<=x-1)
                            ep_plot(frame, x-1, y, col);
                        if (EP_WIDTH-1>=y+1)
                            ep_plot(frame, x, y+1, col);
                        if (0<=y-1)
                            ep_plot(frame, x, y-1, col);
                        break;
                    case PEN_THICK:
                        ep_blob(frame, x, y, col);
                        break;
                    default:
                        break;
                }
                break;
            }
            if (e2<dx)
            { 
                err=err+dx;
                y=y+/*(unsigned char)*/sy; 
            }
        } // end while(1)
        
    }
    
    void
    ep_blob(unsigned char* frame, int x, int y, unsigned char col)
    {
        ep_line(frame, x-1,y+2,  x+1,y+2, col);
        ep_line(frame, x-2,y+1,  x+2,y+1, col);
        ep_line(frame, x-2,y,  x+2,y, col);
        ep_line(frame, x-2,y-1,  x+2,y-1, col);
        ep_line(frame, x-1,y-2,  x+1,y-2, col);
    }
    
    int
    ep_write_text(unsigned char* frame, char* text, int x, int y, unsigned char col,
                    double xscale, double yscale, unsigned int* dy, char weight)
    {
        int xx, mdy;
        int wt;
        int i, im;
        int ci=0;
        unsigned char c;
        int nv;
        int /*int8_t*/ w;
        int ipx, ipy;
        int px, py;
        int ox, oy;
        int old=0;
        int do_scale=0;
        int not_finished=1;
        mdy=0;
        
        ox=0; oy=0;
        wt=0;
        
        if ((xscale>1.01) || (xscale<1.01) || (yscale>1.01) || (yscale<1.01))
            do_scale=1;
        
        xx=x;
        while(not_finished)
        {
            c=text[ci];
            ci++;
            if (c=='\0')
                break;
            if ((c>126) || (c<32))
                continue;
            c=c-32;
            nv=simplex[c][0];
            w=simplex[c][1];
            if (w<0)
                w=0-w;
            if (nv==0)
            {
                xx=xx+w;
                wt=wt+w;
                continue;
            }
            im=2+(nv*2);
            old=0;
            for (i=2; i<im; i=i+2)
            {
                ipx=simplex[c][i];
                ipy=simplex[c][i+1];
                if (ipx>=0)
                {
                    px=ipx;
                }
                else
                {
                    px=0-ipx;
                }
                if (ipy>=0)
                {
                    py=ipy;
                }
                else
                {
                    if (py==-1)
                    {
                        py=32767;
                    }
                    else
                    {
                        py=0-ipy;
                    }
                }
                
                if (do_scale)
                {
                    //px=(unsigned int)(((double)ipx)*xscale);
                    //py=(unsigned int)(((double)ipy)*yscale);
                    px=((double)px)*xscale;
                    py=((double)py)*yscale;
                }
                if ((py!=32767) && (py>mdy))
                    mdy=py+1;
                if ((ipx==-1) && (ipy==-1)) // pen up
                {
                    old=0;
                }
                else
                {
                    if (old) // a previous point is stored in ox, oy
                    {
                        if (((ox+xx)>(EP_HEIGHT-1)) || ((px+xx)>(EP_HEIGHT-1)))
                        {
                            not_finished=0;
                            break;
                        }
                        ep_line(frame, ox+xx, oy+y, px+xx, py+y, col, weight);
                        ox=px; oy=py;
                    }
                    else
                    {
                        ox=px; oy=py;
                        old=1;
                    }
                }
            }
            if (do_scale)
            {
                xx=xx+(unsigned int)(((double)w)*xscale);
                wt=wt+(unsigned int)(((double)w)*xscale);
            }
            else
            {
                xx=xx+w;
                wt=wt+w;
            }
        }
    
        if (dy!=NULL)
            *dy=mdy;
        return(wt+1);
    }
    
    

    ep29.h

    // ep29.h.h
    // ep29 header file
    // rev 1 - December 2017- Shabaz
    
    #ifndef _EP29_H_
    #define _EP29_H_
    
    // Definitions
    #define EP_WIDTH 128
    #define EP_HEIGHT 296
    // EP_WIDTH8 is width/8
    #define EP_WIDTH8 16
    // EP_FRAMEMEMSIZE is (width/8) * height;
    #define EP_FRAMEMEMSIZE 4736
    #define ALL_WHITE 0xff
    #define ALL_BLACK 0x00
    #define COL_WHITE 1
    #define COL_BLACK 0
    #define PEN_THIN 0
    #define PEN_MED 1
    #define PEN_THICK 2
    
    // Functions
    void ep_spi_init(void);
    void ep_sleep(void);
    void ep_init(unsigned char* lut);
    
    void ep_setbg(unsigned char* frame, unsigned char col8);
    void ep_line(unsigned char* frame, int x, int y, int x2, int y2, unsigned char col, char weight=PEN_THIN);
    int ep_write_text(unsigned char* frame, char* text, int x, int y, unsigned char col,
                    double xscale, double yscale, unsigned int* dy, char weight=PEN_THIN);
    
    void ep_clearframe(unsigned char col8);
    void ep_setframe(unsigned char* frame, int x, int y, int width, int height);
    void ep_displayframe(void);
    
    
    #endif // _EP29_H_

    Points I have changed from the code link you mentioned earlier (here) are

    wait_us(200); //from  wait(0.2);
     

    Used these pins

    // Hardware Input/Output
    SPI ep_spi(p24, p23, p25); // mosi, miso, sclk
    DigitalOut ep_cs(p27);
    DigitalOut ep_dc(p6);
    DigitalOut ep_rst(p7);
    DigitalIn ep_busy(p8);

    After compiling, I flashed the .hex file from nRF Programmer. The onboard LED blinks but no response on the e-paper display.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to KKaushik

    Hi,

    The code definitely works (it was confirmed by several people in the comments at  Experimenting with E-Paper Displays: Building a Clock! ) so if it is not functioning for you, it may be one of these things:

    (1) The driver chip for the Waveshare display that I used, and the driver chip for the display you are using, may be different. I don't know how to confirm.

    (2) The E-paper glass in your display module is different from the one I used. If it is different, then the arrays called full_mode[] and partial_mode[] need changing. The values in the arrays come from the manufacturer (or the supplier you obtain the display from)

    (3) Some porting error, but I cannot see any issue there. I have not used the nRF board however so I can't be sure.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • KKaushik
    KKaushik over 2 years ago in reply to shabaz

    Thanks a lot for your replies, I'll try to get in contact with the manufacturer for this and get those array values. I'll update it here in case I get to work this around.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube