EaPaper Library for EM027BS013
Dependencies: EM027BS013 TFT_fonts
Fork of EaEpaper by
Diff: EaEpaper.cpp
- Revision:
- 4:672976335e80
- Parent:
- 0:fedcef5319f5
diff -r 1371614703cd -r 672976335e80 EaEpaper.cpp --- a/EaEpaper.cpp Wed Jun 25 17:43:32 2014 +0000 +++ b/EaEpaper.cpp Thu Apr 02 16:27:46 2015 +0000 @@ -6,30 +6,36 @@ #define LM75A_ADDRESS (0x92) // 0x49 << 1 #define LM75A_CMD_TEMP 0x00 -static uint8_t _oldImage[EA_IMG_BUF_SZ]; static uint8_t _newImage[EA_IMG_BUF_SZ]; -EaEpaper::EaEpaper(PinName p_on, PinName border, PinName discharge, PinName reset, PinName busy, PinName cs, - PinName pwm, - PinName mosi, PinName miso, PinName sck, - PinName sda, PinName scl, +EaEpaper::EaEpaper(PinName sec03_SpiSCK, + PinName sec04_SpiMOSI, + PinName sec05_SpiMISO, + PinName sec06_EpdCS, + PinName sec07_EpdBusy, + PinName sec08_EpdBorder, + PinName sec09_I2cSCL, + PinName sec10_I2cSDA, + PinName sec11_FlashCS, + PinName sec12_EpdReset, + PinName sec13_EpdPanelOn, + PinName sec14_EpdDischarge, const char* name): - epd_(EPD_2_7, - p_on, // panel_on_pin - border, // border_pin - discharge, // discharge_pin - pwm, // pwm_pin - reset, // reset_pin - busy, // busy_pin - cs, // chip_select_pin - mosi, // mosi - miso, // miso - sck), // sck - i2c_(sda, scl), + em_(sec03_SpiSCK, + sec04_SpiMOSI, + sec05_SpiMISO, + sec06_EpdCS, + sec07_EpdBusy, + sec08_EpdBorder, + sec09_I2cSCL, + sec10_I2cSDA, + sec11_FlashCS, + sec12_EpdReset, + sec13_EpdPanelOn, + sec14_EpdDischarge), // sck GraphicsDisplay(name) { draw_mode = NORMAL; - memset(_oldImage, 0, EA_IMG_BUF_SZ); memset(_newImage, 0, EA_IMG_BUF_SZ); } @@ -48,40 +54,16 @@ // erase pixel after power up void EaEpaper::clear() { - epd_.begin(); - epd_.setFactor(readTemperature()/100); - epd_.clear(); - epd_.end(); - - memset(_oldImage, 0, EA_IMG_BUF_SZ); - memset(_newImage, 0, EA_IMG_BUF_SZ); + memset(_newImage, 0xFF, EA_IMG_BUF_SZ); } // update screen _newImage -> _oldImage void EaEpaper::write_disp(void) { - epd_.begin(); - epd_.setFactor(readTemperature()/100); - epd_.image(_oldImage, _newImage); - epd_.end(); - - memcpy(_oldImage, _newImage, EA_IMG_BUF_SZ); + em_.drawImage(_newImage); } // read LM75A sensor on board to calculate display speed -int32_t EaEpaper::readTemperature() -{ - char buf[2]; - int32_t t = 0; - char reg = LM75A_CMD_TEMP; - - i2c_.write(LM75A_ADDRESS, ®, 1); - i2c_.read(LM75A_ADDRESS, buf, 2); - - t = ((buf[0] << 8) | (buf[1])); - - return ((t * 100) >> 8); -} // set one pixel in buffer _newImage @@ -92,19 +74,19 @@ if(draw_mode == NORMAL) { if(color == 0) - _newImage[(x / 8) + ((y-1) * 33)] &= ~(1 << (x%8)); // erase pixel + _newImage[(x / 8) + ((y-1) * 33)] &= ~(1 << (7-(x%8))); // erase pixel else - _newImage[(x / 8) + ((y-1) * 33)] |= (1 << (x%8)); // set pixel + _newImage[(x / 8) + ((y-1) * 33)] |= (1 << (7-(x%8))); // set pixel } else { // XOR mode if(color == 1) - _newImage[(x / 8) + ((y-1) * 33)] ^= (1 << (x%8)); // xor pixel + _newImage[(x / 8) + ((y-1) * 33)] ^= (1 << (7-(x%8))); // xor pixel } } // clear screen void EaEpaper::cls(void) { - memset(_newImage, 0, EA_IMG_BUF_SZ); // clear display buffer + memset(_newImage, 0xFF, EA_IMG_BUF_SZ); // clear display buffer } // print line