From 12dc74fe62e17603f02ef58ce3a4f8901cd40424 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Wed, 18 May 2016 18:21:55 +0200 Subject: [PATCH] Display: finally get rid of i2c_test.c. Not without dubbing its remaining functionality in form of a display_greeting(), of course. --- display.h | 1 + display_ssd1306.c | 27 +++++++++++++++++++++++++-- i2c_test.c | 32 -------------------------------- mendel.c | 10 +--------- 4 files changed, 27 insertions(+), 43 deletions(-) delete mode 100644 i2c_test.c diff --git a/display.h b/display.h index 25b5951..a1aed94 100644 --- a/display.h +++ b/display.h @@ -39,6 +39,7 @@ void display_init(void); void display_tick(void); void display_clear(void); +void display_greeting(void); void display_clock(void); void display_set_cursor(uint8_t line, uint8_t column); void display_writechar(uint8_t data); diff --git a/display_ssd1306.c b/display_ssd1306.c index 32d0466..93f8a7a 100644 --- a/display_ssd1306.c +++ b/display_ssd1306.c @@ -53,8 +53,6 @@ logo, like "Welcome to Teacup" as a greeting screen, like writing numbers to readable places and so on. - - Get rid of i2c_test.c. - - Allow different fonts. Already paraphrased in font.h and font.c. Needs a selection menu in Configtool, of course, the same way one can select display types. @@ -84,6 +82,7 @@ #include "displaybus.h" #include "font.h" #include "sendf.h" +#include "delay.h" #include "dda.h" @@ -176,6 +175,30 @@ void display_set_cursor(uint8_t line, uint8_t column) { displaybus_write(0x10 | ((column >> 4) & 0x0F), 1); } +/** + Show a nice greeting. Pure eye candy. +*/ +void display_greeting(void) { + + display_clear(); + + /** + "Welcome to Teacup" is 64 pixel columns wide, entire display is + 128 columns, so we offset by 32 columns to get it to the center. + */ + display_set_cursor(1, 32); + + display_writestr_P(PSTR("Welcome to Teacup")); + + // Forward this to the display immediately. + while (buf_canread(display)) { + display_tick(); + } + + // Allow the user to worship our work for a moment :-) + delay_ms(5000); +} + /** Regular update of the display. Typically called once a second from clock.c. */ diff --git a/i2c_test.c b/i2c_test.c deleted file mode 100644 index 1cbd143..0000000 --- a/i2c_test.c +++ /dev/null @@ -1,32 +0,0 @@ - -/** - Quick test for sending some visible data to a SSD1306 display connected - via I2C. This means not to test the display, but the I2C implementation. - - To run this test, add this line to board or printer config.h: - - #define I2C - - With this done, a welcome message should appear on the display. Without - these additions, the binary size should be as small as the commit before. -*/ - -#ifdef I2C_TEST - -#include -#include "config_wrapper.h" -#include "display.h" -#include "font.h" -#include "sendf.h" - - -static void i2c_test(void) { - /** - "Welcome to Teacup" is 64 pixel columns wide, entire display is - 128 columns, so we offset by 32 columns to get it to the center. - */ - display_set_cursor(1, 32); - sendf_P(display_writechar, PSTR("Welcome to Teacup")); -} - -#endif /* I2C_TEST */ diff --git a/mendel.c b/mendel.c index 35b1f0d..6e3cc7c 100644 --- a/mendel.c +++ b/mendel.c @@ -30,13 +30,6 @@ #endif #include "config_wrapper.h" -#ifdef I2C - // This is temporary, until display code is completed. - // It includes static i2c_test(), which is called in init(): - #define I2C_TEST - #include "i2c_test.c" - #undef I2C_TEST -#endif #include "cpu.h" #include "serial.h" #include "dda_queue.h" @@ -125,8 +118,7 @@ void init(void) { #ifdef DISPLAY display_init(); - display_clear(); - i2c_test(); + display_greeting(); #endif // say hi to host