Skip to content

Commit

Permalink
sw i2c restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Feb 29, 2016
1 parent 69f61ca commit 3480b87
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cppsrc/U8g2lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,19 @@ class U8G2_SSD1306_128X64_NONAME_F_8080 : public U8G2 {
};
class U8G2_SSD1306_128X64_NONAME_1_SW_I2C : public U8G2 {
public: U8G2_SSD1306_128X64_NONAME_1_SW_I2C(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ssd1306_i2c_128x64_noname_1(&u8g2, rotation, u8x8_byte_ssd13xx_sw_i2c, u8x8_gpio_and_delay_arduino);
u8g2_Setup_ssd1306_i2c_128x64_noname_1(&u8g2, rotation, u8x8_byte_sw_i2c, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_SSD13xx_SW_I2C(getU8x8(), clock, data, reset);
}
};
class U8G2_SSD1306_128X64_NONAME_2_SW_I2C : public U8G2 {
public: U8G2_SSD1306_128X64_NONAME_2_SW_I2C(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ssd1306_i2c_128x64_noname_2(&u8g2, rotation, u8x8_byte_ssd13xx_sw_i2c, u8x8_gpio_and_delay_arduino);
u8g2_Setup_ssd1306_i2c_128x64_noname_2(&u8g2, rotation, u8x8_byte_sw_i2c, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_SSD13xx_SW_I2C(getU8x8(), clock, data, reset);
}
};
class U8G2_SSD1306_128X64_NONAME_F_SW_I2C : public U8G2 {
public: U8G2_SSD1306_128X64_NONAME_F_SW_I2C(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_ssd1306_i2c_128x64_noname_f(&u8g2, rotation, u8x8_byte_ssd13xx_sw_i2c, u8x8_gpio_and_delay_arduino);
u8g2_Setup_ssd1306_i2c_128x64_noname_f(&u8g2, rotation, u8x8_byte_sw_i2c, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_SSD13xx_SW_I2C(getU8x8(), clock, data, reset);
}
};
Expand Down
2 changes: 1 addition & 1 deletion cppsrc/U8x8lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class U8X8_SSD1306_128X64_NONAME_8080 : public U8X8 {
};
class U8X8_SSD1306_128X64_NONAME_SW_I2C : public U8X8 {
public: U8X8_SSD1306_128X64_NONAME_SW_I2C(uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_ssd1306_128x64_noname, u8x8_cad_001, u8x8_byte_ssd13xx_sw_i2c, u8x8_gpio_and_delay_arduino);
u8x8_Setup(getU8x8(), u8x8_d_ssd1306_128x64_noname, u8x8_cad_ssd13xx_i2c, u8x8_byte_sw_i2c, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_SSD13xx_SW_I2C(getU8x8(), clock, data, reset);
}
};
Expand Down
6 changes: 3 additions & 3 deletions csrc/u8g2_d_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void u8g2_Setup_ssd1306_i2c_128x64_noname_1(u8g2_t *u8g2, const u8g2_cb_t *rotat
{
uint8_t tile_buf_height;
uint8_t *buf;
u8g2_SetupDisplay(u8g2, u8x8_d_ssd1306_128x64_noname, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
u8g2_SetupDisplay(u8g2, u8x8_d_ssd1306_128x64_noname, u8x8_cad_ssd13xx_i2c, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_ssd1306_16_1(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
Expand All @@ -46,7 +46,7 @@ void u8g2_Setup_ssd1306_i2c_128x64_noname_2(u8g2_t *u8g2, const u8g2_cb_t *rotat
{
uint8_t tile_buf_height;
uint8_t *buf;
u8g2_SetupDisplay(u8g2, u8x8_d_ssd1306_128x64_noname, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
u8g2_SetupDisplay(u8g2, u8x8_d_ssd1306_128x64_noname, u8x8_cad_ssd13xx_i2c, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_ssd1306_16_2(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
Expand All @@ -55,7 +55,7 @@ void u8g2_Setup_ssd1306_i2c_128x64_noname_f(u8g2_t *u8g2, const u8g2_cb_t *rotat
{
uint8_t tile_buf_height;
uint8_t *buf;
u8g2_SetupDisplay(u8g2, u8x8_d_ssd1306_128x64_noname, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
u8g2_SetupDisplay(u8g2, u8x8_d_ssd1306_128x64_noname, u8x8_cad_ssd13xx_i2c, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_ssd1306_16_f(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
Expand Down
1 change: 1 addition & 0 deletions csrc/u8x8.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ void u8x8_cad_SendSequence(u8x8_t *u8x8, uint8_t const *data);
uint8_t u8x8_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_001(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_st7920_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);


/*==========================================*/
Expand Down
1 change: 1 addition & 0 deletions csrc/u8x8_byte.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ uint8_t u8x8_byte_sw_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_p
case U8X8_MSG_BYTE_START_TRANSFER:
i2c_start(u8x8);
i2c_write_byte(u8x8, u8x8_GetI2CAddress(u8x8));
//i2c_write_byte(u8x8, 0x078);
break;
case U8X8_MSG_BYTE_END_TRANSFER:
i2c_stop(u8x8);
Expand Down
6 changes: 3 additions & 3 deletions csrc/u8x8_cad.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,16 @@ uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
case U8X8_MSG_CAD_SEND_CMD:
case U8X8_MSG_CAD_SEND_ARG:
//u8x8_byte_SetDC(u8x8, 0);
u8x8_byte_StartTransfer(u8x8);
u8x8_byte_SendByte(u8x8, u8x8_GetI2CAddress(u8x8));
u8x8_byte_StartTransfer(u8x8);
//u8x8_byte_SendByte(u8x8, u8x8_GetI2CAddress(u8x8));
u8x8_byte_SendByte(u8x8, 0x000);
u8x8_byte_SendByte(u8x8, arg_int);
u8x8_byte_EndTransfer(u8x8);
break;
case U8X8_MSG_CAD_SEND_DATA:
//u8x8_byte_SetDC(u8x8, 1);
u8x8_byte_StartTransfer(u8x8);
u8x8_byte_SendByte(u8x8, u8x8_GetI2CAddress(u8x8));
//u8x8_byte_SendByte(u8x8, u8x8_GetI2CAddress(u8x8));
u8x8_byte_SendByte(u8x8, 0x040);
u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
u8x8_byte_EndTransfer(u8x8);
Expand Down
4 changes: 3 additions & 1 deletion sys/arduino/u8g2_page_buffer/HelloWorld/HelloWorld.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11,


void setup(void) {
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(9, 0); // default output in I2C mode for the SSD1306 test shield: set the i2c adr to 0
pinMode(16, OUTPUT);
Expand All @@ -79,6 +81,6 @@ void loop(void) {
u8g2.setFont(u8g2_font_ncenB14_tr);
u8g2.drawStr(0,24,"Hello World!");
} while ( u8g2.nextPage() );
delay(1000);
//delay(1000);
}

7 changes: 4 additions & 3 deletions tools/codebuild/codebuild.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ struct controller controller_list[] =
}
},
{
"ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "i2c", COM_SSDI2C,
/* "ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "i2c", COM_SSDI2C, */
"ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_SSDI2C,
{
{ "128x64_noname" },
{ NULL }
Expand Down Expand Up @@ -177,12 +178,12 @@ struct interface interface_list[] =
{
"SW_I2C",
"u8x8_SetPin_SSD13xx_SW_I2C",
"u8x8_byte_ssd13xx_sw_i2c",
"u8x8_byte_sw_i2c" /* "u8x8_byte_ssd13xx_sw_i2c" */,
"u8x8_gpio_and_delay_arduino",
"uint8_t clock, uint8_t data, uint8_t reset = U8X8_PIN_NONE",
"clock, data, reset",
"clock, data [, reset]",
"u8x8_byte_ssd13xx_sw_i2c"
"u8x8_byte_sw_i2c" /* "u8x8_byte_ssd13xx_sw_i2c" */
},
/* 7 */
{
Expand Down

0 comments on commit 3480b87

Please sign in to comment.