Skip to content

Commit

Permalink
ESP8266 implementation works.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlohr committed Aug 10, 2020
1 parent d7c1288 commit 27db708
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
28 changes: 17 additions & 11 deletions esp8266/user/squeepaper.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int ICACHE_FLASH_ATTR SQUEEPAPER_Poll( int milliseconds )
case SC_BUSYHI: //Busy_high
case SC_BUSYLO: //Busy_low
//If the busy matches, we're good
if( !!(SQUEEPAPER_BUSY) == s ) { popoff = 3; break; }
if( !(SQUEEPAPER_BUSY) == s ) { popoff = 3; break; }
case SC_WAIT:
//Otherwise timeout.
squee_elapsed_on_command += milliseconds;
Expand Down Expand Up @@ -132,7 +132,7 @@ static void SQUEEPAPER_BusyLow( uint16_t timeout )// If BUSYN=1 then waiting

static void SQUEEPAPER_Wait( int timeout )
{
while( squee_free() < 3 ) { printf( "SQUEEFREE: %d\n", squee_free() ); SQUEEPAPER_Poll(1); SQUEEPAPER_DELAY_MS(1); }
while( squee_free() < 3 ) { SQUEEPAPER_Poll(1); SQUEEPAPER_DELAY_MS(1); }
squee_tack( SC_WAIT );
squee_tack( timeout & 0xff );
squee_tack( timeout >> 8 );
Expand Down Expand Up @@ -280,7 +280,7 @@ void SQUEEPAPER_FinishData()
#elif( defined ( SKU14144 ) || defined( SKU13379 ) )
SQUEEPAPER_SendCommand(0x12); // DISPLAY_REFRESH
SQUEEPAPER_Wait(100);
SQUEEPAPER_BusyHigh(35000);
SQUEEPAPER_BusyHigh(20000);
#endif

}
Expand All @@ -289,21 +289,24 @@ void SQUEEPAPER_TestPattern()
{
int x, y;
#ifdef SKU13379
SQUEEPAPER_BeginData();

SQUEEPAPER_BeginData2();
for( y = 0; y < SQUEEPAPER_HEIGHT; y++ )
for( x = 0; x < SQUEEPAPER_WIDTHD/8; x++ )
{
SQUEEPAPER_SendData( (x>SQUEEPAPER_WIDTHD/16)?0xff:0x00 );
SQUEEPAPER_SendData( (y>SQUEEPAPER_HEIGHT/2)?0xff:0x00 );
}
SQUEEPAPER_FinishData();
SQUEEPAPER_BeginData2();

SQUEEPAPER_BeginData();
for( y = 0; y < SQUEEPAPER_HEIGHT; y++ )
for( x = 0; x < SQUEEPAPER_WIDTHD/8; x++ )
{
SQUEEPAPER_SendData( (y>SQUEEPAPER_HEIGHT/2)?0xff:0x00 );
SQUEEPAPER_SendData( (x>SQUEEPAPER_WIDTHD/16)?0xff:0x00 );
}
SQUEEPAPER_FinishData();


#else
SQUEEPAPER_BeginData();
for( y = 0; y < SQUEEPAPER_HEIGHT; y++ )
Expand All @@ -323,21 +326,24 @@ void SQUEEPAPER_Clear(uint8_t color)
int i;
int j;
#ifdef SKU13379
SQUEEPAPER_BeginData();
uint8_t cs = (color & 1)?0xff:0x00;
uint8_t cs;

SQUEEPAPER_BeginData2();
cs = (color / 2)?0x00:0xff;
for(i=0; i<SQUEEPAPER_WIDTHD/8; i++) {
for(j=0; j<height; j++)
SQUEEPAPER_SendData(cs );
}
SQUEEPAPER_FinishData();

SQUEEPAPER_BeginData2();
cs = (color / 2)?0x00:0xff;
SQUEEPAPER_BeginData();
cs = (color & 1)?0xff:0x00;
for(i=0; i<SQUEEPAPER_WIDTHD/8; i++) {
for(j=0; j<height; j++)
SQUEEPAPER_SendData(cs );
}
SQUEEPAPER_FinishData();

#else
SQUEEPAPER_BeginData();
for(i=0; i<width/2; i++) {
Expand Down
2 changes: 1 addition & 1 deletion esp8266/user/squeepaper.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
#define SQUEEPAPER_CLK0 { PIN_OUT_CLEAR = 1<<SQUEEPAPER_SCLK; }
#define SQUEEPAPER_DIN1 { PIN_OUT_SET = 1<<SQUEEPAPER_DIN; }
#define SQUEEPAPER_DIN0 { PIN_OUT_CLEAR = 1<<SQUEEPAPER_DIN; }
#define SQUEEPAPER_DELAY { int i; for( i = 0; i < 5; i++ ) { asm volatile( "nop" ); } }
#define SQUEEPAPER_DELAY { int i; for( i = 0; i < 15; i++ ) { asm volatile( "nop" ); } }
#define SQUEEPAPER_DELAY_MS(x) { ets_delay_us( ((x) * 1000) ); }

#define SQUEEPAPER_GPIO_SETUP { \
Expand Down
14 changes: 5 additions & 9 deletions esp8266/user/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ static void ICACHE_FLASH_ATTR timer100ms(void *arg)

do
{
r = SQUEEPAPER_Poll(100);
r = SQUEEPAPER_Poll(1);
opsct++;
if( r == 1 ) return;
if( opsct == 2000 ) break;
} while( r > 1 );

Expand All @@ -133,36 +134,31 @@ static void ICACHE_FLASH_ATTR timer100ms(void *arg)
{
if( state == 0 )
{
printf( "SD0X\r\n" );
SQUEEPAPER_BeginData();
state++;
}
else if( state < 76 )
{
printf( "SD0\r\n" );
int i;
for( i = 0; i < 200; i++ )
SQUEEPAPER_SendData( i );
SQUEEPAPER_SendData( (state < 36)?0xff:0x00 );
state++;
}
else if( state == 76 )
{
printf( "SD1\r\n" );
SQUEEPAPER_FinishData();
SQUEEPAPER_BeginData2();
state++;
}
else if( state < 152 )
{
printf( "SD2\r\n" );
int i;
for( i = 0; i < 200; i++ )
SQUEEPAPER_SendData( 0xaa );
SQUEEPAPER_SendData( ((i/25)%2)?0xff:0x00 );
state++;
}
else if( state == 152 )
{
printf( "SD3\r\n" );
SQUEEPAPER_FinishData();
state++;
}
Expand Down Expand Up @@ -258,7 +254,7 @@ void ICACHE_FLASH_ATTR user_init(void)
// Set timer100ms to be called every 100ms
os_timer_disarm(&some_timer);
os_timer_setfn(&some_timer, (os_timer_func_t *)timer100ms, NULL);
os_timer_arm(&some_timer, 100, 1);
os_timer_arm(&some_timer, 1, 1);

// Set the wifi sleep type
wifi_set_sleep_type(LIGHT_SLEEP_T);
Expand Down

0 comments on commit 27db708

Please sign in to comment.