Skip to content

Commit

Permalink
ks0108... almost working olikraus#88
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Dec 6, 2016
1 parent 7f85179 commit e74aa7f
Show file tree
Hide file tree
Showing 3 changed files with 352 additions and 9 deletions.
70 changes: 61 additions & 9 deletions csrc/u8x8_d_ks0108.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@ static const uint8_t u8x8_d_ks0108_powersave1_seq[] = {
};


static void u8x8_ks0108_out(u8x8_t *u8x8, uint8_t *x, uint8_t *c, uint8_t **ptr, uint8_t *arg_int, void *arg_ptr)
{
u8x8_cad_SendCmd(u8x8, 0x040 | ((*x) & 63) );
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));

while( *arg_int > 0 )
{

u8x8_cad_SendData(u8x8, 8, *ptr); /* note: SendData can not handle more than 255 bytes */
(*ptr) += 8;
(*x)+= 8;
(*c)--;
if ( *c == 0 )
{
*ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
*c = ((u8x8_tile_t *)arg_ptr)->cnt;
(*arg_int)--;
}
if ( ((*x) & 63) == 0 )
break;

}

}


static const u8x8_display_info_t u8x8_ks0108_128x64_display_info =
{
Expand Down Expand Up @@ -102,6 +127,7 @@ uint8_t u8x8_d_ks0108_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
break;
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:

if ( arg_int == 0 )
{
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
Expand Down Expand Up @@ -132,24 +158,50 @@ uint8_t u8x8_d_ks0108_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
// break;
case U8X8_MSG_DISPLAY_DRAW_TILE:

u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);


x = ((u8x8_tile_t *)arg_ptr)->x_pos;
x *= 8;
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
c = ((u8x8_tile_t *)arg_ptr)->cnt;

if ( x < 64 )
{
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
u8x8_ks0108_out(u8x8, &x, &c, &ptr, &arg_int, arg_ptr);
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
}
if ( x < 128 )
{
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
u8x8_ks0108_out(u8x8, &x, &c, &ptr, &arg_int, arg_ptr);
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
}
//if ( x < 192 )
//{
//u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 4, NULL);
//u8x8_ks0108_out(u8x8, &x, &c, &ptr, &arg_int, arg_ptr);
//u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
//}

#ifdef old
u8x8_cad_SendCmd(u8x8, 0x040 | (x) );
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));

c = ((u8x8_tile_t *)arg_ptr)->cnt;
c *= 8;
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
do
{
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
c = ((u8x8_tile_t *)arg_ptr)->cnt;
while( c > 0 )
{
u8x8_cad_SendData(u8x8, 8, ptr); /* note: SendData can not handle more than 255 bytes */
ptr += 8;
x+= 8;
c--;
}
arg_int--;
} while( arg_int > 0 );

u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
#endif

break;
default:
return 0;
Expand Down
5 changes: 5 additions & 0 deletions sys/arduino/u8x8/GraphicsTest/GraphicsTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@
//U8X8_UC1611_EA_DOGM240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board
//U8X8_UC1611_EA_DOGXL240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board
//U8X8_UC1611_EA_DOGXL240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board
U8X8_KS0108_128X64 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low!


// End of constructor list


void setup(void)
{
/* U8g2 Project: KS0108 Test Board */
pinMode(16, OUTPUT);
digitalWrite(16, 0);

u8x8.begin();
}

Expand Down
Loading

0 comments on commit e74aa7f

Please sign in to comment.