전자종이를 TWELITE에 연결해 주세요.
https://qiita.com/nanbuwks/items/1a4d58fc7f74ab8c8d85
그럼 ESP 32는 WAVERSHARE의 e-Paper를 사용했지만, 이걸 TWELITE에 이식해 보세요.
"TWELITE로 SPI 테스트하기".
https://qiita.com/nanbuwks/items/e3e8c66ad67624cd8639
그러면 SPI로 AD 변환기 IC MCP 3008에 액세스하지만, 이 SPI 액세스 프로그램에는 e-Paper 코드가 적용됩니다.
컨디션
TWELITE DIP 기판 플러그 번호
TWELITE DIP 기판의 실크 태그
TWELITE CHIP 패드 번호
TWELITE IO 이름
WAVERSHARE-Paper 신호 이름
WAVERS 케이블 색상
SPI 신호 이름
(4)
(5)
(7)
(DIO5)
BUSY
자주색
(9)
(4)
(6)
(DIO4)
RST
백색
(11)
(8)
(10)
(DIO8)
DC
초록색
8
19
4
DIO19
CS
오렌지
CS
6
C
1
DO0
CLK
노랑, 황색
SCLK
5
18
3
DIO18
DIN
청색
MOSI
GND
GND
GND
GND
GND
검정색
28
VCC
VCC
VCC
VCC
빨강
TWELITE의 SPI 포트는 고정되지만 SPI 전용 이외의 RST와 BUSY 등은 적당한 GPIO에 맞춘다.테이블에는 괄호로 표시됩니다.
WAVERSHARE의 e-Paper 모듈은 SPI의 MISO 신호선을 사용하지 않습니다.대신 DC 신호선을 사용하여 Data/Command 및 Write/읽기(기본 4-Wire SPI 모드, 3-Wire SPI 모드의 경우 DC 신호선 대신 제어 비트를 MOSI 신호에 첨부합니다.)
이에 따라 애초 사용하지 않던 MISO 신호선이 DC 신호선에 할당됐다.하지만 잘 돌아가지 않아서 리스트처럼 움직였어요.
코드
e-Paper 모듈에만 테스트 모드가 표시됩니다.
"TWELITE로 SPI 테스트하기".
https://qiita.com/nanbuwks/items/e3e8c66ad67624cd8639
에는 무선통신이 없고 MCP 3008을 시작하기 위한 코드일 뿐이지만 역시 무선통신이 없다.
#include <AppHardwareApi.h>
#include "utils.h"
#include "ToCoNet.h"
#include "ToCoNet_mod_prototype.h"
#include "serial.h"
#include "fprintf.h"
#define LED 12
#define RST_PIN 4
#define DC_PIN 8
// #define CS_PIN 19 // fix by TWELITE
#define BUSY_PIN 5
#define EPD_WIDTH 128
#define EPD_HEIGHT 296
const unsigned char EPD_2IN9D_lut_vcomDC[] = {
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,
};
const unsigned char EPD_2IN9D_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,
};
const unsigned char EPD_2IN9D_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,
};
const unsigned char EPD_2IN9D_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,
};
const unsigned char EPD_2IN9D_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,
};
tsFILE sSerial0Stream;
static tsSerialPortSetup sSerial0;
void SendCommand( int32_t command)
{
vPortSetLo(DC_PIN);
vAHI_SpiSelect(1); // SPISEL0 スタート
vAHI_SpiStartTransfer8( command );
int i;
for ( i=0; bAHI_SpiPollBusy(); i++) // timeout 付 Busy チェック
{
if ( 1000 < i )
{
vfPrintf(&sSerial0Stream, "error! SPI timeout\n\r");
break;
}
vWait(1);
}
}
void SendData(char data)
{
vPortSetHi(DC_PIN);
vAHI_SpiSelect(1); // SPISEL0 スタート
vAHI_SpiStartTransfer8( data );
int i;
for ( i=0; bAHI_SpiPollBusy(); i++) // timeout 付 Busy チェック
{
if ( 1000 < i )
{
vfPrintf(&sSerial0Stream, "error! SPI timeout\n\r");
break;
}
vWait(1);
}
}
void WaitUntilIdle(void)
{
bool_t busy;
do {
SendCommand(0x71); // Command Get Status (FLG)
busy = bPortRead(BUSY_PIN); // busy is low active ( TWILITE low means 1 )
vWait(300); // 100uS
} while( busy );
vWait(600000); // 200mS
}
void SetFullReg(void)
{
SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
SendData(0xb7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
unsigned int count;
SendCommand(0x20);
for(count=0; count<44; count++) {
SendData(EPD_2IN9D_lut_vcomDC[count]);
}
SendCommand(0x21);
for(count=0; count<42; count++) {
SendData(EPD_2IN9D_lut_ww[count]);
}
SendCommand(0x22);
for(count=0; count<42; count++) {
SendData(EPD_2IN9D_lut_bw[count]);
}
SendCommand(0x23);
for(count=0; count<42; count++) {
SendData(EPD_2IN9D_lut_wb[count]);
}
SendCommand(0x24);
for(count=0; count<42; count++) {
SendData(EPD_2IN9D_lut_bb[count]);
}
}
void TurnOnDisplay(void)
{
SendCommand(0x12); //DISPLAY REFRESH
vWait(30000); // 100mS //!!!The delay here is necessary, 200uS at least!!!
WaitUntilIdle();
}
static void vProcessEvCore(tsEvent *pEv, teEvent eEvent, uint32 u32evarg)
{
bool_t inputdata;
static int counter=0;
static int counter2=0;
if (eEvent == E_EVENT_TICK_TIMER) { // 4ms timer
counter++;
if ( 0 == counter % 1000 ) {
counter2++;
vPortSetHi(LED);
vfPrintf(&sSerial0Stream, "%d : LED Hi\n\r",counter2);
vPortSetHi( DC_PIN);
}
if ( 250 == counter % 1000 ) {
vPortSetLo(LED);
vfPrintf(&sSerial0Stream, "%d : LED Lo\n\r",counter2);
vPortSetLo( DC_PIN);
}
}
}
void cbAppColdStart(bool_t bStart)
{
if (!bStart) {
} else {
vPortAsOutput(LED); // GPIO set
// vPortAsOutput(CS_PIN);
vPortSetLo( RST_PIN);
vPortAsOutput(RST_PIN);
vPortSetLo( DC_PIN);
vPortAsOutput(DC_PIN);
vPortAsInput(BUSY_PIN); // with pullup
ToCoNet_Event_Register_State_Machine(vProcessEvCore); // add Event handler
// serial init
static uint8 au8SerialBuffTx[32];
static uint8 au8SerialBuffRx[16];
sSerial0.pu8SerialRxQueueBuffer = au8SerialBuffRx;
sSerial0.pu8SerialTxQueueBuffer = au8SerialBuffTx;
sSerial0.u32BaudRate = 115200;
sSerial0.u16AHI_UART_RTS_LOW = 0xffff;
sSerial0.u16AHI_UART_RTS_HIGH = 0xffff;
sSerial0.u16SerialRxQueueSize = sizeof(au8SerialBuffRx);
sSerial0.u16SerialTxQueueSize = sizeof(au8SerialBuffTx);
sSerial0.u8SerialPort = E_AHI_UART_0;
sSerial0.u8RX_FIFO_LEVEL = E_AHI_UART_FIFO_LEVEL_1;
SERIAL_vInit(&sSerial0);
sSerial0Stream.bPutChar = SERIAL_bTxChar;
sSerial0Stream.u8Device = E_AHI_UART_0;
vfPrintf(&sSerial0Stream, "Hello World!\n\r");
vPortSetHi(RST_PIN);
vWait(600000); // 200mS
vPortSetLo(RST_PIN); // module reset
vWait(30000); // 10mS
vPortSetHi(RST_PIN);
vWait(600000); // 200mS
// digitalWrite(CS_PIN, LOW);
// SPI リソース初期化
vAHI_SpiConfigure(0, // use SPISEL0
FALSE, // MSB FIRST
FALSE, // SPI mode 0
FALSE, // SPI mode 0
4, // 16 / (num * 2 ) MHz clock
FALSE, // no use interrupt SPI transfer end
FALSE); // CSEL control by vAHI_SpiSelect
vAHI_SpiSelect(1); // SPISEL0 スタート
vPortSetLo( DC_PIN);
vPortAsOutput(DC_PIN);
//POWER SETTING
SendCommand(0x01);
SendData(0x03);
SendData(0x00);
SendData(0x2b);
SendData(0x2b);
SendData(0x03);
SendCommand(0x06); //boost soft start
SendData(0x17); //A
SendData(0x17); //B
SendData(0x17); //C
SendCommand(0x04); // power on
WaitUntilIdle(); // check BUSY pin
SendCommand(0x00); //panel setting
SendData(0xbf); //LUT from OTP,128x296
SendData(0x0e); //VCOM to 0V fast
SendCommand(0x30); //PLL setting
SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
SendCommand(0x61); //resolution setting
SendData(EPD_WIDTH);
SendData((EPD_HEIGHT >> 8) & 0xff);
SendData(EPD_HEIGHT & 0xff);
SendCommand(0x82); //vcom_DC setting
SendData(0x28);
vfPrintf(&sSerial0Stream, "e-Paper initialized.\n\r");
int w, h,i,j;
w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
h = EPD_HEIGHT;
SendCommand(0x10); // Display Transmission1 B/W Pixel Data
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
SendData(0x00);
}
}
// SendCommand(0x13);
// for (int j = 0; j < h; j++) {
// for (int i = 0; i < w; i++) {
// SendData(0xFF);
// }
// }
SendCommand(0x13); // Display Transmission2 Red Pixel Data
for ( j = 0; j < h; j++) {
for ( i = 0; i < w; i++) {
if ( 0 == ( j / 8 ) % 2 ){
SendData(0x00);
SendData(0xFF);
} else {
SendData(0xFF);
SendData(0x00);
}
}
j++;
}
vfPrintf(&sSerial0Stream, "e-Paper cleared\n\r");
SetFullReg();
TurnOnDisplay();
SendCommand(0X50);
SendData(0xf7);
SendCommand(0X02); //power off
WaitUntilIdle();
SendCommand(0X07); //deep sleep
SendData(0xA5);
vPortSetLo(RST_PIN);
} // if (!bStart) block end
}
void cbAppWarmStart(bool_t bStart) { return; }
void cbToCoNet_vRxEvent(tsRxDataApp *psRx) { return; }
void cbToCoNet_vTxEvent(uint8 u8CbId, uint8 bStatus) { return; }
void cbToCoNet_vNwkEvent(teEvent eEvent, uint32 u32arg) { return; }
void cbToCoNet_vHwEvent(uint32 u32DeviceId, uint32 u32ItemBitmap) { return; }
uint8 cbToCoNet_u8HwInt(uint32 u32DeviceId, uint32 u32ItemBitmap) { return FALSE; }
void cbToCoNet_vMain(void) { return; }
결실"ESP 32 및 Arduino 개발 환경에서 전자 용지를 사용하는 세 번째"
https://qiita.com/nanbuwks/items/1a4d58fc7f74ab8c8d85
마찬가지로 격자가 표시됩니다.
Reference
이 문제에 관하여(전자종이를 TWELITE에 연결해 주세요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/nanbuwks/items/be4f8125b686079e74d6텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)