From cec45a2fec5943b6dd43c9725ce742c816573bf1 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Mon, 25 Apr 2016 00:22:38 +0200 Subject: [PATCH] Display: create infrastructure for distinct displays. Dropped all the funtions for specific messages because plans on how to handle this have changed. --- display.c | 16 ++++++++++++++ display.h | 39 +++++++++++++++++++++++++++++++++ display_ssd1306.c | 6 ++--- display_ssd1306.h | 56 ----------------------------------------------- i2c_test.c | 2 +- mendel.c | 2 +- 6 files changed, 60 insertions(+), 61 deletions(-) create mode 100644 display.c create mode 100644 display.h delete mode 100644 display_ssd1306.h diff --git a/display.c b/display.c new file mode 100644 index 0000000..e32ab19 --- /dev/null +++ b/display.c @@ -0,0 +1,16 @@ + +/** \file + + \brief Display broker. + + Here we map generic display calls to calls to the actually used display and + also define functions common to all displays. +*/ + +#include "display.h" + +#define TEACUP_C_INCLUDE + #include "display_ssd1306.c" +#undef TEACUP_C_INCLUDE + +/* No common code so far. */ diff --git a/display.h b/display.h new file mode 100644 index 0000000..786ea2d --- /dev/null +++ b/display.h @@ -0,0 +1,39 @@ + +/** \file + + \brief Display broker. + + Here we map generic display calls to calls to the actually used display. +*/ + +#ifndef _DISPLAY_H +#define _DISPLAY_H + +#include +#include "config_wrapper.h" +#include "displaybus.h" + +#ifdef DISPLAY_BUS + + #if defined DISPLAY_TYPE_SSD1306 + + #define DISPLAY_I2C_ADDRESS 0x78 + #define DISPLAY_LINES 4 + #define DISPLAY_SYMBOLS_PER_LINE 32 + + #define DISPLAY + + #elif defined DISPLAY_TYPE_LCD1302 + + #error Display type LCD1302 not yet supported. + + #endif /* DISPLAY_TYPE_... */ + +#endif /* DISPLAY_BUS */ + + +void display_init(void); +void display_clear(void); +void display_text_P(uint8_t line, uint8_t column, PGM_P message_P); + +#endif /* _DISPLAY_H */ diff --git a/display_ssd1306.c b/display_ssd1306.c index 8a9ff35..e52e1b0 100644 --- a/display_ssd1306.c +++ b/display_ssd1306.c @@ -4,9 +4,9 @@ \brief Code specific to the SSD1306 display. */ -#include "display_ssd1306.h" +#include "display.h" -#ifdef DISPLAY_TYPE_SSD1306 +#if defined TEACUP_C_INCLUDE && defined DISPLAY_TYPE_SSD1306 #include "displaybus.h" #include "font.h" @@ -115,4 +115,4 @@ void display_text_P(uint8_t line, uint8_t column, PGM_P message) { displaybus_write(0x00, 1); } -#endif /* DISPLAY_TYPE_SSD1306 */ +#endif /* TEACUP_C_INCLUDE && DISPLAY_TYPE_SSD1306 */ diff --git a/display_ssd1306.h b/display_ssd1306.h deleted file mode 100644 index 26368e6..0000000 --- a/display_ssd1306.h +++ /dev/null @@ -1,56 +0,0 @@ - -#ifndef _DISPLAY_SSD1306_H -#define _DISPLAY_SSD1306_H - -#include "config_wrapper.h" - - -#ifdef DISPLAY_TYPE_SSD1306 - -#define DISPLAY -#define DISPLAY_I2C_ADDRESS (0x3C << 1) - - -#define DISPLAY_LINES 4 -#define DISPLAY_SYMBOLS_PER_LINE 16 -#define HOTENDS_COUNT 1 -#define HOTBED_ZONES 1 - -#define DISPLAY_PLACE_HOTEND 0, 0, 8 -#define DISPLAY_PLACE_HOTBED 0, 8, 8 -#define DISPLAY_PLACE_X 1, 0, 5 -#define DISPLAY_PLACE_Y 1, 5, 5 -#define DISPLAY_PLACE_Z 1, 10, 5 -#define DISPLAY_PLACE_FEEDRATE 2, 0, 5 -#define DISPLAY_PLACE_PROGRESS 2, 5, 5 -#define DISPLAY_PLACE_TIMER 2, 10, 6 -#define DISPLAY_PLACE_STATUS 3, 0, 16 - -typedef struct { - uint16_t hotend_temp[HOTENDS_COUNT]; - uint16_t hotbed_temp[HOTBED_ZONES]; - uint16_t x; - uint16_t y; - uint16_t z; - uint16_t feedrate; - uint8_t progress; // in percents - uint32_t timer; // in seconds -} DISPLAY_T; - - -void display_init(void); -void display_on(void); -void display_hotend(uint8_t index); -void display_hotbed(uint8_t index); -void display_point(uint16_t x, uint16_t y, uint16_t z); -void display_feedrate(uint16_t value); -void display_progress(uint8_t value); -void display_timer(uint32_t value); -void display_off(void); - -void display_clear(void); -void display_text_P(uint8_t line, uint8_t column, PGM_P message_P); - -#endif /* DISPLAY_TYPE_SSD1306 */ - -#endif /* _DISPLAY_SSD1306_H */ diff --git a/i2c_test.c b/i2c_test.c index fa95ab6..48527e3 100644 --- a/i2c_test.c +++ b/i2c_test.c @@ -15,7 +15,7 @@ #include #include "config_wrapper.h" -#include "display_ssd1306.h" +#include "display.h" #include "font.h" diff --git a/mendel.c b/mendel.c index 26ccbce..35b1f0d 100644 --- a/mendel.c +++ b/mendel.c @@ -52,7 +52,7 @@ #include "intercom.h" #include "spi.h" #include "sd.h" -#include "display_ssd1306.h" +#include "display.h" #include "simulator.h" #ifdef SIMINFO