* the GNU General Public License.
*
* Copyright 2005 Develer S.r.l. (http://www.develer.com/)
- *
+ * All Rights Reserved.
* -->
*
* \brief Generic text LCD driver (impl.).
*
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Bernie Innocenti <bernie@codewiz.org>
* \author Stefano Fedrigo <aleph@develer.com>
*/
-/*#*
- *#* $Log$
- *#* Revision 1.4 2006/09/20 20:02:43 marco
- *#* Replaced ISLISTEMPTY with LIST_EMPTY
- *#*
- *#* Revision 1.3 2006/07/19 12:56:25 bernie
- *#* Convert to new Doxygen style.
- *#*
- *#* Revision 1.2 2006/02/24 00:27:14 bernie
- *#* Use new naming convention for list macros.
- *#*
- *#* Revision 1.1 2005/11/04 18:00:42 bernie
- *#* Import into DevLib.
- *#*
- *#* Revision 1.11 2005/06/14 14:43:43 bernie
- *#* Add DevLib headers.
- *#*
- *#* Revision 1.10 2005/06/06 17:41:57 batt
- *#* Add lcd_layerSet function.
- *#*
- *#* Revision 1.9 2005/06/01 16:40:07 batt
- *#* Remove debug string.
- *#*
- *#* Revision 1.8 2005/06/01 16:38:04 batt
- *#* Adapt to changes in mware/list.h.
- *#*
- *#* Revision 1.7 2005/06/01 10:45:22 batt
- *#* lcd_setAddr(): Bugfix boundary condition; Misc cleanup.
- *#*
- *#* Revision 1.6 2005/06/01 10:36:23 batt
- *#* Layer: Rename member variables and Doxygenize.
- *#*
- *#* Revision 1.5 2005/05/27 11:05:58 batt
- *#* Do not write on lcd if layer is hidden.
- *#*/
-
#include "lcd_text.h"
#include "lcd_hd44.h"
-#include <drv/timer.h> // timer_delay()
-#include <mware/formatwr.h> // _formatted_write()
-#include <mware/list.h> // LIST_EMPTY()
+
#include <cfg/macros.h> // BV()
#include <cfg/debug.h>
+#include <drv/timer.h> // timer_delay()
+
+#include <mware/formatwr.h> // _formatted_write()
+#include <struct/list.h> // LIST_EMPTY()
+
#include <string.h> // strlen()
/** Maximum number of layers. */
#define LCD_LAYERS 6
-#if CONFIG_KERNEL
+#if CONFIG_KERN
+ #include <kern/sem.h>
/** Semaphore to arbitrate access to the display. */
static struct Semaphore lcd_semaphore;
#define LOCK_LCD sem_obtain(&lcd_semaphore)
#define UNLOCK_LCD sem_release(&lcd_semaphore)
-#else /* !CONFIG_KERNEL */
+#else /* !CONFIG_KERN */
#define LOCK_LCD do {} while (0)
#define UNLOCK_LCD do {} while (0)
-#endif /* !CONFIG_KERNEL */
+#endif /* !CONFIG_KERN */
DECLARE_LIST_TYPE(Layer);
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;
}
-#if CONFIG_KERNEL
+#if CONFIG_KERN
void lcd_lock(void)
{
UNLOCK_LCD;
}
-#endif /* CONFIG_KERNEL */
+#endif /* CONFIG_KERN */
/**
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])
#include <cfg/debug.h>
void lcd_init(void)
{
+ #if CONFIG_KERN
+ sem_init(&lcd_semaphore);
+ #endif
+
int i;
LIST_INIT(&lcd_Layers);
lcd_setCursor(0);
}
-#if CONFIG_TEST
-void lcd_test(void)
-{
- int i;
-
- for (i = 0; i < LCD_ROWS * LCD_COLS; ++i)
- {
- lcd_putCharUnlocked('0' + (i % 10), lcd_DefLayer);
- timer_delay(100);
- }
-}
-#endif /* CONFIG_TEST */