Display: introduce font.h, paraphrase handling distinct fonts.
While this could also be done properly now, with a couple of additional fonts, this would require quite some time. However, it's more important to have at least one display working now, rather than having a ton of sophisticated eye-candy, which isn't even user-visible, because the upper layers are still missing.
This commit is contained in:
parent
cb696701f8
commit
5f95784c0b
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
/** \file
|
||||
|
||||
\brief Font broker.
|
||||
|
||||
Here we map generic font variables to the actually used font. This is done in
|
||||
a rather primitive way by having the same variable name in all font variants
|
||||
and wrapping each font in the corresponding #ifdef.
|
||||
*/
|
||||
|
||||
#include "font.h"
|
||||
|
||||
#define TEACUP_C_INCLUDE
|
||||
#include "font_8x4.c"
|
||||
//#include "font_ another.c"
|
||||
#undef TEACUP_C_INCLUDE
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
#ifndef _FONT_H
|
||||
#define _FONT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "arduino.h" // For PROGMEM.
|
||||
|
||||
/**
|
||||
So far we have only one font and no choice for fonts in Configtool,
|
||||
so just paraphrase handling of distinct fonts.
|
||||
*/
|
||||
|
||||
//#if defined DISPLAY_FONT_8X4
|
||||
|
||||
#define FONT_ROWS 8
|
||||
#define FONT_COLUMNS 4
|
||||
#define FONT_SYMBOL_SPACE 1
|
||||
#define FONT_IS_PROPORTIONAL
|
||||
|
||||
//#elif defined DISPLAY_FONT_...another font
|
||||
|
||||
// ... ...
|
||||
|
||||
//#endif
|
||||
|
||||
typedef struct {
|
||||
#ifdef FONT_IS_PROPORTIONAL
|
||||
uint8_t columns;
|
||||
#endif
|
||||
uint8_t data[FONT_COLUMNS];
|
||||
} symbol_t;
|
||||
|
||||
extern const symbol_t PROGMEM font[];
|
||||
|
||||
#endif /* _FONT_H */
|
||||
|
|
@ -8,9 +8,12 @@
|
|||
removed from font.
|
||||
*/
|
||||
|
||||
#include "font_8x4.h"
|
||||
// So far we have no #define DISPLAY_FONT_... in Configtool.
|
||||
#if defined TEACUP_C_INCLUDE /* && defined DISPLAY_FONT_8x4 */
|
||||
|
||||
const symbol_t PROGMEM font_8x4[] = {
|
||||
#include "font.h"
|
||||
|
||||
const symbol_t PROGMEM font[] = {
|
||||
{2, {0x00, 0x00, 0x00, 0x00}}, /* space */
|
||||
{3, {0x0C, 0x5E, 0x0C, 0x00}}, /* excl_mark */
|
||||
{3, {0x03, 0x00, 0x03, 0x00}}, /* quot_mark */
|
||||
|
|
@ -113,3 +116,5 @@ const symbol_t PROGMEM font_8x4[] = {
|
|||
{4, {0x02, 0x01, 0x02, 0x01}}, /* tilde */
|
||||
{4, {0x00, 0x00, 0x00, 0x00}} /* del */
|
||||
};
|
||||
|
||||
#endif /* TEACUP_C_INCLUDE && DISPLAY_FONT_8x4 */
|
||||
|
|
|
|||
19
font_8x4.h
19
font_8x4.h
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
#ifndef _FONT_8x4_H
|
||||
#define _FONT_8x4_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "arduino.h" // For PROGMEM.
|
||||
|
||||
#define FONT_ROWS 8
|
||||
#define FONT_COLUMNS 4
|
||||
#define FONT_SYMBOL_SPACE 1
|
||||
|
||||
typedef struct {
|
||||
uint8_t columns;
|
||||
uint8_t data[FONT_COLUMNS];
|
||||
} symbol_t;
|
||||
|
||||
extern const symbol_t PROGMEM font_8x4[];
|
||||
|
||||
#endif /* _FONT_8x4_H */
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
#include <string.h>
|
||||
#include "config_wrapper.h"
|
||||
#include "displaybus.h"
|
||||
#include "font_8x4.h"
|
||||
#include "font.h"
|
||||
|
||||
|
||||
#define DISPLAY_I2C_ADDRESS (0x3C << 1)
|
||||
|
|
@ -96,8 +96,8 @@ static void i2c_test(void) {
|
|||
uint8_t index = (uint8_t)*message - 0x20;
|
||||
|
||||
// Send the character bitmap.
|
||||
for (i = 0; i < pgm_read_byte(&font_8x4[index].columns); i++) {
|
||||
displaybus_write(pgm_read_byte(&font_8x4[index].data[i]), 0);
|
||||
for (i = 0; i < pgm_read_byte(&font[index].columns); i++) {
|
||||
displaybus_write(pgm_read_byte(&font[index].data[i]), 0);
|
||||
}
|
||||
// Send space between characters.
|
||||
for (i = 0; i < FONT_SYMBOL_SPACE; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue