u8x8 constructor list replacement

This commit is contained in:
olikraus 2015-12-23 18:44:00 +01:00
parent 30c1788681
commit a5fa4a96c3
5 changed files with 73 additions and 8 deletions

View File

@ -101,6 +101,14 @@ class U8X8 : public Print
};
class U8X8_SSD1306_128X64_4W_SW_SPI : public U8X8 {
public: U8X8_SSD1306_128X64_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_ssd1306_128x64_noname, u8x8_cad_001, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
}
// constructor list start
class U8X8_SSD1306_128X64_4W_SW_SPI : public U8X8 {
public: U8X8_SSD1306_128X64_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {

View File

@ -271,6 +271,11 @@ extern const u8g2_cb_t u8g2_cb_r1;
extern const u8g2_cb_t u8g2_cb_r2;
extern const u8g2_cb_t u8g2_cb_r3;
#define U8G2_R0 (&u8g2_cb_r0)
#define U8G2_R1 (&u8g2_cb_r1)
#define U8G2_R2 (&u8g2_cb_r2)
#define U8G2_R3 (&u8g2_cb_r3)
void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, const u8g2_cb_t *u8g2_cb);
/*==========================================*/

View File

@ -24,10 +24,10 @@ void setup(void)
digitalWrite(10, 0); // default output in I2C mode for the SSD1306 test shield
//u8x8_Setup_3Wire_SW_SPI(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 10, 8);
u8x8_Setup_4Wire_SW_SPI(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 10, 9, 8);
//u8x8_Setup_4Wire_SW_SPI(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 10, 9, 8);
//u8x8_Setup_4Wire_HW_SPI(&u8x8, u8x8_d_ssd1306_128x64_noname, 10, 9, 8);
//u8x8_Setup_SSD13xx_SW_I2C(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 8);
u8x8_Setup_SSD13xx_SW_I2C(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 8);
//u8x8_Setup_8Bit_6800(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
//u8x8_Setup_8Bit_8080(&u8x8, u8x8_d_ssd1306_128x64_noname, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);

View File

@ -3,16 +3,19 @@
#include <U8g2lib.h>
U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(&u8g2_cb_r0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(&u8g2_cb_r0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(&u8g2_cb_r0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(&u8g2_cb_r0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(&u8g2_cb_r0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(&u8g2_cb_r0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R3, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
void setup(void) {
pinMode(9, OUTPUT);
digitalWrite(9, 0); // default output in I2C mode for the SSD1306 test shield: set the i2c adr to 0
u8g2.begin();
}

View File

@ -249,6 +249,7 @@ FILE *buf_header_fp;
FILE *setup_code_fp;
FILE *setup_header_fp;
FILE *u8g2_cpp_header_fp;
FILE *u8x8_cpp_header_fp;
void do_setup_prototype(FILE *fp, int controller_idx, int display_idx, const char *postfix)
@ -260,6 +261,44 @@ void do_setup_prototype(FILE *fp, int controller_idx, int display_idx, const cha
}
/*===========================================*/
/*
class U8X8_SSD1306_128X64_4W_SW_SPI : public U8X8 {
public: U8X8_SSD1306_128X64_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_ssd1306_128x64_noname, u8x8_cad_001, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
}
*/
void do_u8x8_header(int controller_idx, int display_idx, int interface_idx)
{
FILE *fp = u8x8_cpp_header_fp;
fprintf(fp, "class U8X8_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, " : public U8X8 {\n");
fprintf(fp, " public: ");
fprintf(fp, "U8X8_");
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].name));
fprintf(fp, "%s_", struppercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s", struppercase(interface_list[interface_idx].interface_name));
fprintf(fp, "(%s) : U8X8() {\n", interface_list[interface_idx].pins_with_type);
fprintf(fp, " ");
fprintf(fp, "u8x8_Setup(getU8x8(), u8x8_d_");
fprintf(fp, "%s_", strlowercase(controller_list[controller_idx].name));
fprintf(fp, "%s, ", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(fp, "%s, ", strlowercase(controller_list[controller_idx].cad));
fprintf(fp, "%s, ", interface_list[interface_idx].arduino_com_procedure);
fprintf(fp, "%s);\n", interface_list[interface_idx].arduino_gpio_procedure);
fprintf(fp, " ");
fprintf(fp, "%s(getU8x8(), ", interface_list[interface_idx].setpin_function);
fprintf(fp, "%s);\n", interface_list[interface_idx].pins_plain);
fprintf(fp, " }\n");
fprintf(fp, "};\n");
}
/*
class U8G2_SSD1306_128x64_NONAME_1_SW_SPI : public U8G2
{
@ -272,6 +311,7 @@ class U8G2_SSD1306_128x64_NONAME_1_SW_SPI : public U8G2
};
*/
void do_display_interface(int controller_idx, int display_idx, const char *postfix, int interface_idx)
{
FILE *fp = u8g2_cpp_header_fp;
@ -304,9 +344,13 @@ void do_display_interface(int controller_idx, int display_idx, const char *postf
fprintf(fp, " }\n");
fprintf(fp, "};\n");
if ( strcmp(postfix, "1") == 0 )
do_u8x8_header(controller_idx, display_idx, interface_idx);
}
/*===========================================*/
void do_display(int controller_idx, int display_idx, const char *postfix)
@ -421,6 +465,9 @@ int main(void)
u8g2_cpp_header_fp = fopen("U8g2lib.h", "w");
fprintf(u8g2_cpp_header_fp, "/* generated code (codebuild), u8g2 project */\n");
u8x8_cpp_header_fp = fopen("U8x8lib.h", "w");
fprintf(u8x8_cpp_header_fp, "/* generated code (codebuild), u8g2 project */\n");
do_controller_list();
@ -438,6 +485,8 @@ int main(void)
fclose(u8g2_cpp_header_fp);
fclose(u8x8_cpp_header_fp);
system("cp u8g2_d_memory.c ../../csrc/.");
system("cp u8g2_d_setup.c ../../csrc/.");