I'm developing a shunting program for our model railway. For years it ran on a PC / laptop but when I heard about Arduino's I had the idea to use those instead. Instant on and a separate display for each operator. The only downer is that on the PC we had plenty of width to display the full wagon name and other stuff such and colour, style etc.
Using Arduino Megas and ks0108 / GLCD and SystemFont5x7 I can get 21 characters and 8 rows. However that leads wagon names abbreviated / truncated, so I hacked at SystemFont5x7 to create Iain5x7 which is proportional (see below). This allows me to create more meaningful descriptions but I can't be sure that the text won't spill over the edge of the display. Since I need all 8 rows to display the list of wagons, any auto wrapping would ruin the display.
One of the displays also incorporates a matrix display to indicate the selected route be used in the goods yard. That display needs to be refreshed every 390us to avoid flicker, so I need to write each character to GLCD in less than 390us (preferably less since I also have to update the matrix as well in that 390us). From my tests, some characters take longer to write than others. From your previous post I believe this is related to the font definition
#include <fonts/Iain5x7.h>
#include <fonts/SystemFont5x7.h>
#include <glcd.h>
void setup()
{
uint32_t start, stop;
Serial.begin(115200);
GLCD.Init(NON_INVERTED);
GLCD.ClearScreen();
GLCD.SelectFont(Iain5x7);
//GLCD.SelectFont(SystemFont5x7);
for (uint8_t i = 0; i < 95; i++)
{
char ch = i + 33;
GLCD.CursorToXY(0, 0); // Ensure each character doesn't wrap.
start = micros();
GLCD.write(ch);
stop = micros();
Serial.write(ch);
Serial.print("(");
Serial.print(ch);
Serial.print("): ");
Serial.print(stop - start);
Serial.println("us");
delay(100);
}
}
void loop(
void)
{
}
and here's my font (Iain5x7.h)
#ifndef IAIN5X7_H_INCLUDED
#define IAIN5X7_H_INCLUDED
/*
*
* Iain5x7
*
* created with FontCreator
* written by F. Maximilian Thiele
*
* http://www.apetech.de/fontCreator
* me@apetech.de
*
* File Name : Iain5x7.h
* Date : 28.12.2010
* Font size in bytes : 2461
* Font width : 5
* Font height : 7
* Font first char : 32
* Font last char : 128
* Font used chars : 96
*
* The font data are defined as
*
* struct _FONT_ {
* uint16_t font_Size_in_Bytes_over_all_included_Size_it_self;
* uint8_t font_Width_in_Pixel_for_fixed_drawing;
* uint8_t font_Height_in_Pixel_for_all_characters;
* unit8_t font_First_Char;
* uint8_t font_Char_Count;
*
* uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1];
* // for each character the separate width in pixels,
* // characters < 128 have an implicit virtual right empty row
*
* uint8_t font_data[];
* // bit field of all characters
*/
#include <inttypes.h>
#include <avr/pgmspace.h>
// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
#ifdef PROGMEM
#undef PROGMEM
#define PROGMEM __attribute__((section(".progmem.data")))
#endif
#define IAIN5X7_WIDTH 5
#define IAIN5X7_HEIGHT 7
static uint8_t Iain5x7[] PROGMEM = {
0x09, 0x9D, // size
0x05, // width
0x07, // height
0x20, // first char
0x60, // char count
// char widths
0x01, 0x01, 0x03, 0x05, 0x05, 0x05, 0x05, 0x01, 0x02, 0x02,
0x05, 0x03, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x01, 0x01, 0x03, 0x03,
0x03, 0x04, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x03, 0x04, 0x05, 0x03, 0x05, 0x05, 0x05, 0x04, 0x05,
0x04, 0x04, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x02,
0x03, 0x02, 0x03, 0x03, 0x01, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x01, 0x03, 0x04, 0x01, 0x05, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x05, 0x03, 0x04,
0x04, 0x03, 0x01, 0x03, 0x05, 0x00,
// font data
0x00, // 32
0xBE, // 33
0x0E, 0x00, 0x0E, // 34
0x28, 0xFE, 0x28, 0xFE, 0x28, // 35
0x48, 0x54, 0xFE, 0x54, 0x24, // 36
0x46, 0x26, 0x10, 0xC8, 0xC4, // 37
0x6C, 0x92, 0xAA, 0x44, 0xA0, // 38
0x06, // 39
0x3C, 0x42, // 40
0x42, 0x3C, // 41
0x00, 0x54, 0x38, 0x54, 0x00, // 42
0x10, 0x38, 0x10, // 43
0xC0, // 44
0x10, 0x10, // 45
0x40, // 46
0xC0, 0x38, 0x06, // 47
0x7C, 0x82, 0x82, 0x7C, // 48
0x04, 0xFE, // 49
0xC4, 0xA2, 0x92, 0x8C, // 50
0x82, 0x92, 0x92, 0x6C, // 51
0x30, 0x28, 0x24, 0xFE, // 52
0x4E, 0x92, 0x92, 0x72, // 53
0x78, 0x94, 0x92, 0x60, // 54
0x02, 0xE2, 0x12, 0x0E, // 55
0x6C, 0x92, 0x92, 0x6C, // 56
0x0C, 0x92, 0x52, 0x3C, // 57
0x6C, // 58
0x6C, // 59
0x10, 0x28, 0x44, // 60
0x28, 0x28, 0x28, // 61
0x44, 0x28, 0x10, // 62
0x04, 0xA2, 0x12, 0x0C, // 63
0x64, 0x92, 0xF2, 0x82, 0x7C, // 64
0xFC, 0x22, 0x22, 0xFC, // 65
0xFE, 0x92, 0x92, 0x6C, // 66
0x7C, 0x82, 0x82, 0x44, // 67
0xFE, 0x82, 0x82, 0x7C, // 68
0xFE, 0x92, 0x92, 0x82, // 69
0xFE, 0x12, 0x12, 0x02, // 70
0x7C, 0x82, 0xA2, 0x64, // 71
0xFE, 0x10, 0x10, 0xFE, // 72
0x82, 0xFE, 0x82, // 73
0x40, 0x80, 0x80, 0x7E, // 74
0xFE, 0x10, 0x28, 0x44, 0x82, // 75
0xFE, 0x80, 0x80, // 76
0xFE, 0x04, 0x08, 0x04, 0xFE, // 77
0xFE, 0x08, 0x10, 0x20, 0xFE, // 78
0x7C, 0x82, 0x82, 0x82, 0x7C, // 79
0xFE, 0x12, 0x12, 0x0C, // 80
0x7C, 0x82, 0xA2, 0x42, 0xBC, // 81
0xFE, 0x32, 0x52, 0x8C, // 82
0x4C, 0x92, 0x92, 0x64, // 83
0x02, 0xFE, 0x02, // 84
0x7E, 0x80, 0x80, 0x7E, // 85
0x3E, 0x40, 0x80, 0x40, 0x3E, // 86
0xFE, 0x40, 0x30, 0x40, 0xFE, // 87
0xC6, 0x28, 0x10, 0x28, 0xC6, // 88
0x06, 0x08, 0xF0, 0x08, 0x06, // 89
0xC2, 0xA2, 0x92, 0x8A, 0x86, // 90
0xFE, 0x82, // 91
0x06, 0x38, 0xC0, // 92
0x82, 0xFE, // 93
0x04, 0x02, 0x04, // 94
0x80, 0x80, 0x80, // 95
0x06, // 96
0x40, 0xA8, 0xA8, 0x70, // 97
0x7E, 0x90, 0x88, 0x70, // 98
0x70, 0x88, 0x88, 0x50, // 99
0x70, 0x88, 0x90, 0x7E, // 100
0x70, 0xA8, 0xA8, 0x30, // 101
0x10, 0xFC, 0x12, 0x04, // 102
0x10, 0xA8, 0xA8, 0x78, // 103
0xFE, 0x10, 0x08, 0xF0, // 104
0xFA, // 105
0x40, 0x80, 0x7A, // 106
0xFE, 0x20, 0x50, 0x88, // 107
0xFE, // 108
0xF8, 0x08, 0x30, 0x08, 0xF0, // 109
0xF8, 0x10, 0x08, 0xF0, // 110
0x70, 0x88, 0x88, 0x70, // 111
0xF8, 0x28, 0x28, 0x10, // 112
0x10, 0x28, 0x28, 0xF8, // 113
0xF8, 0x10, 0x08, 0x10, // 114
0x90, 0xA8, 0xA8, 0x48, // 115
0x08, 0x7E, 0x88, 0x40, // 116
0x78, 0x80, 0x40, 0xF8, // 117
0x78, 0x80, 0x78, // 118
0x78, 0x80, 0x60, 0x80, 0x78, // 119
0xD8, 0x20, 0xD8, // 120
0x18, 0xA0, 0xA0, 0x78, // 121
0xC8, 0xA8, 0xA8, 0x98, // 122
0x10, 0x6C, 0x82, // 123
0xEE, // 124
0x82, 0x6C, 0x10, // 125
0x10, 0x08, 0x10, 0x20, 0x10, // 126
};
#endif
You might be interested in this bit that I added to stop the warnings:
// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
#ifdef PROGMEM
#undef PROGMEM
#define PROGMEM __attribute__((section(".progmem.data")))
#endif
I think the Arduino team need to do the same thing to Tone.cpp in the library.
If you run the test you'll see that some of the letters are taking a bit too long to display but I'm pretty sure we won't have a ~ in our wagon names (but you never know...).
Iain