*/
#define CONFIG_LCD_ADDRESS_FAST 1
+/**
+ * Number of columns in LCD display.
+ * $WIZ$ type = "enum"
+ * $WIZ$ value_list = "lcd_hd44_cols"
+ */
+#define CONFIG_LCD_COLS LCD_HD44_COLS_16
+
+/**
+ * Number of rows in LCD display.
+ * $WIZ$ type = "enum"
+ * $WIZ$ value_list = "lcd_hd44_rows"
+ */
+#define CONFIG_LCD_ROWS LCD_HD44_ROWS_2
+
#endif /* CFG_LCD_H */
0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8A, 0x8B,
0x8C, 0x8D, 0x8E, 0x8F,
-#if LCD_COLS > 16
+#if CONFIG_LCD_COLS > 16
0x90, 0x91, 0x92, 0x93,
#endif
0xC4, 0xC5, 0xC6, 0xC7,
0xC8, 0xC9, 0xCA, 0xCB,
0xCC, 0xCD, 0xCE, 0xCF,
-#if LCD_COLS > 16
+#if CONFIG_LCD_COLS > 16
0xD0, 0xD1, 0xD2, 0xD3,
#endif
-#if LCD_ROWS > 2
+#if CONFIG_LCD_ROWS > 2
/* row 2 */
0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9A, 0x9B,
0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3,
-#if LCD_COLS > 16
+#if CONFIG_LCD_COLS > 16
0xA4, 0xA5, 0xA6, 0xA7,
#endif
0xD8, 0xD9, 0xDA, 0xDB,
0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3,
-#if LCD_COLS > 16
+#if CONFIG_LCD_COLS > 16
0xE4, 0xE5, 0xE6, 0xE7,
#endif
-#endif /* LCD_ROWS > 2 */
+#endif /* CONFIG_LCD_ROWS > 2 */
};
-STATIC_ASSERT(countof(lcd_address) == LCD_ROWS * LCD_COLS);
+STATIC_ASSERT(countof(lcd_address) == CONFIG_LCD_ROWS * CONFIG_LCD_COLS);
#else /* CONFIG_LCD_ADDRESS_FAST == 0 */
static const uint8_t col_address[] =
{
0x80,
0xC0,
-#if LCD_ROWS > 2
+#if CONFIG_LCD_ROWS > 2
0x94,
0xD4
#endif
};
-STATIC_ASSERT(countof(col_address) == LCD_ROWS);
+STATIC_ASSERT(countof(col_address) == CONFIG_LCD_ROWS);
/**
* Addresses of LCD display character positions, calculated runtime to save RAM
*/
static uint8_t lcd_address(uint8_t addr)
{
- return col_address[addr / LCD_COLS] + addr % LCD_COLS;
+ return col_address[addr / CONFIG_LCD_COLS] + addr % CONFIG_LCD_COLS;
}
#endif /* CONFIG_LCD_ADDRESS_FAST */
lcd_current_addr = addr + 1;
/* If we are at end of display wrap the address to 0 */
- if (lcd_current_addr == LCD_COLS * LCD_ROWS)
+ if (lcd_current_addr == CONFIG_LCD_COLS * CONFIG_LCD_ROWS)
lcd_current_addr = 0;
/* If we are at the end of a row put the cursor at the beginning of the next */
- if (!(lcd_current_addr % LCD_COLS))
+ if (!(lcd_current_addr % CONFIG_LCD_COLS))
lcd_setReg(lcd_address(lcd_current_addr));
}
#include <cfg/compiler.h> /* For stdint types */
/**
- * \name Display dimensions (in chars)
- * \{
+ * \name Values for CONFIG_LCD_ROWS.
+ *
+ * Select the number of rows which are available
+ * on the HD44780 Display.
+ * $WIZ$ lcd_hd44_rows = "LCD_HD44_ROWS_2", "LCD_HD44_ROWS_4"
+ */
+#define LCD_HD44_ROWS_2 2
+#define LCD_HD44_ROWS_4 4
+
+/**
+ * \name Values for CONFIG_LCD_COLS.
+ *
+ * Select the number of columns which are available
+ * on the HD44780 Display.
+ * $WIZ$ lcd_hd44_cols = "LCD_HD44_COLS_16", "LCD_HD44_COLS_20"
*/
-#define LCD_ROWS 2
-#define LCD_COLS 16
-/* \} */
+#define LCD_HD44_COLS_16 16
+#define LCD_HD44_COLS_20 20
/**
* \name Hitachi HD44 commands.
void lcd_setAddr(Layer *layer, lcdpos_t addr)
{
/* Sanity check: wrap around to display limits */
- while (addr >= LCD_ROWS * LCD_COLS)
- addr -= LCD_ROWS * LCD_COLS;
+ while (addr >= CONFIG_LCD_ROWS * CONFIG_LCD_COLS)
+ addr -= CONFIG_LCD_ROWS * CONFIG_LCD_COLS;
layer->addr = addr;
}
layer->buf[addr] = c;
/* Move to next character */
- if (++layer->addr >= LCD_COLS * LCD_ROWS)
+ if (++layer->addr >= CONFIG_LCD_COLS * CONFIG_LCD_ROWS)
layer->addr = 0;
/* Do not write on LCD if layer is hidden. */
LOCK_LCD;
lcd_setAddr(layer, 0);
- for (i = 0; i < LCD_COLS * LCD_ROWS; i++)
+ for (i = 0; i < CONFIG_LCD_COLS * CONFIG_LCD_ROWS; i++)
lcd_putCharUnlocked(c, layer);
UNLOCK_LCD;
}
LOCK_LCD;
lcd_setAddr(layer, LCD_POS(0, y));
- for (i = 0; i < LCD_COLS; i++)
+ for (i = 0; i < CONFIG_LCD_COLS; i++)
lcd_putCharUnlocked(0, layer);
UNLOCK_LCD;
}
* NOTE: calculating the string lenght BEFORE it gets
* printf()-formatted. Real lenght may differ.
*/
- pad = (LCD_COLS - strlen(format)) / 2;
+ pad = (CONFIG_LCD_COLS - strlen(format)) / 2;
while (pad--)
lcd_putCharUnlocked(' ', layer);
}
len = _formatted_write(format, (void (*)(char, void *))lcd_putCharUnlocked, layer, ap);
if (mode & (LCD_FILL | LCD_CENTER))
- while (layer->addr % LCD_COLS)
+ while (layer->addr % CONFIG_LCD_COLS)
lcd_putCharUnlocked(' ', layer);
/*
layer = (Layer *)LIST_HEAD(&lcd_FreeLayers);
layer->addr = 0;
- memset(layer->buf, 0, LCD_ROWS * LCD_COLS);
+ memset(layer->buf, 0, CONFIG_LCD_ROWS * CONFIG_LCD_COLS);
lcd_enqueueLayer(layer, pri);
lcdpos_t addr;
Layer *l;
- for (addr = 0; addr < LCD_ROWS * LCD_COLS; ++addr)
+ for (addr = 0; addr < CONFIG_LCD_ROWS * CONFIG_LCD_COLS; ++addr)
{
FOREACH_NODE(l, &lcd_Layers)
{
lcdpos_t addr;
/* Repair damage on underlaying layers */
- for (addr = 0; addr < LCD_ROWS * LCD_COLS; ++addr)
+ for (addr = 0; addr < CONFIG_LCD_ROWS * CONFIG_LCD_COLS; ++addr)
{
/* If location was covered by us */
if (layer->buf[addr])
#define LAYER_HIDDEN -127
/* Compute LCD address from x/y coordinates */
-#define LCD_POS(x,y) ((lcdpos_t)((uint8_t)(x) + (uint8_t)(y) * (uint8_t)LCD_COLS))
-#define LCD_ROW0 (LCD_COLS * 0)
-#define LCD_ROW1 (LCD_COLS * 1)
-#define LCD_ROW2 (LCD_COLS * 2)
-#define LCD_ROW3 (LCD_COLS * 3)
+#define LCD_POS(x,y) ((lcdpos_t)((uint8_t)(x) + (uint8_t)(y) * (uint8_t)CONFIG_LCD_COLS))
+#define LCD_ROW0 (CONFIG_LCD_COLS * 0)
+#define LCD_ROW1 (CONFIG_LCD_COLS * 1)
+#define LCD_ROW2 (CONFIG_LCD_COLS * 2)
+#define LCD_ROW3 (CONFIG_LCD_COLS * 3)
/**
* Overwrapping layer context.
* Characters cells with value 0 are transparent with respect
* to other layers in the background.
*/
- char buf[LCD_COLS * LCD_ROWS];
+ char buf[CONFIG_LCD_COLS * CONFIG_LCD_ROWS];
} Layer;
{
int i;
- for (i = 0; i < LCD_ROWS * LCD_COLS; ++i)
+ for (i = 0; i < CONFIG_LCD_ROWS * CONFIG_LCD_COLS; ++i)
{
lcd_putCharUnlocked('0' + (i % 10), lcd_DefLayer);
timer_delay(100);
*/
static void blk_hack(void)
{
- static signed char blk_colstart[LCD_COLS];
+ static signed char blk_colstart[CONFIG_LCD_COLS];
UBYTE row, col;
if (rand()%3 == 0)
{
/* Modify one column */
- col = rand() % LCD_COLS;
+ col = rand() % CONFIG_LCD_COLS;
blk_colstart[col] += rand() % 12 - 5;
}
- for (col = 0; col < LCD_COLS; ++col)
+ for (col = 0; col < CONFIG_LCD_COLS; ++col)
{
if (blk_colstart[col] > 0)
{
--blk_colstart[col];
/* Scroll down */
- for(row = LCD_ROWS-1; row; --row)
+ for(row = CONFIG_LCD_ROWS-1; row; --row)
{
lcd_SetAddr(blk_layer, LCD_POS(col,row));
lcd_PutChar(blk_layer->Buf[LCD_POS(col,row-1)], blk_layer);
++blk_colstart[col];
/* Clear tail */
- for(row = 0; row < LCD_ROWS; ++row)
+ for(row = 0; row < CONFIG_LCD_ROWS; ++row)
{
if (blk_layer->Buf[LCD_POS(col,row)] != ' ')
{