olikraus:
Indeed I guess, this will be the most simple solution. Just remove all other existing "_arduino" versions and use your own one.
Hey, Oliver, I got it working! Thanks for your guidance. Video.
Here is my constructor:
U8G2_KS0108_128X64_F u8g2(U8G2_R0, U8X8_PIN_NONE, U8X8_PIN_NONE, U8X8_PIN_NONE, U8X8_PIN_NONE,
U8X8_PIN_NONE, U8X8_PIN_NONE, U8X8_PIN_NONE, U8X8_PIN_NONE,
/*enable=*/ D0, /*dc=*/ U8X8_PIN_NONE, /*cs0=*/ U8X8_PIN_NONE,
/*cs1=*/ U8X8_PIN_NONE, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low!
And here is the relavent section I updated in U8x8lib.cpp:
...
#else
#define GCLD_CS0 5
#define GCLD_CS1 7
#define GCLD_DC 6
/* this function completly replaces u8x8_byte_ks0108*/
extern "C" uint8_t u8x8_byte_arduino_ks0108(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
uint8_t i, b;
uint8_t *data;
static uint8_t ks0108_control = 0;
switch(msg)
{
case U8X8_MSG_BYTE_SEND:
data = (uint8_t *)arg_ptr;
while( arg_int > 0 )
{
b = *data;
data++;
arg_int--;
SPI.transfer(ks0108_control);
SPI.transfer(b);
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 1);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->data_setup_time_ns);
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 0);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->write_pulse_width_ns);
delayMicroseconds(5);
}
break;
case U8X8_MSG_BYTE_INIT:
SPI.begin();
/* disable chipselect */
bitWrite(ks0108_control, GCLD_CS0, 0);
bitWrite(ks0108_control, GCLD_CS1, 0);
/* no wait required here */
/* ensure that the enable signal is low */
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 0);
break;
case U8X8_MSG_BYTE_SET_DC:
bitWrite(ks0108_control, GCLD_DC, arg_int);
break;
case U8X8_MSG_BYTE_START_TRANSFER:
SPI.beginTransaction(SPISettings(100000000UL, MSBFIRST, SPI_MODE0));
bitWrite(ks0108_control, GCLD_CS0, bitRead(arg_int, 0));
bitWrite(ks0108_control, GCLD_CS1, bitRead(arg_int, 1));
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->post_chip_enable_wait_ns, NULL);
break;
case U8X8_MSG_BYTE_END_TRANSFER:
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
bitWrite(ks0108_control, GCLD_CS0, bitRead(arg_int, 0));
bitWrite(ks0108_control, GCLD_CS1, bitRead(arg_int, 1));
SPI.endTransaction();
break;
default:
return 0;
}
return 1;
}
#endif
...
Any ideas for improvements?




