[PATCH] imon driver bignum support
Yura Scheglyuk <[email protected]>
| Newsgroups | gmane.comp.sysutils.lcdproc |
|---|---|
| Message-ID | <[email protected]> |
Hi! I made patch for imon driver bignum support. This is the simple patch. NUM_CCs = 0, do_init = 0 and ccmode does not needed because imon can't define a custom character. BigClock in lcdproc working now. Also this patch contains cosmetic changes to conform to the LCDproc function declarations style. -- Best regards, Yura Scheglyuk. _______________________________________________ LCDproc mailing list [email protected] http://lists.omnipotent.net/mailman/listinfo/lcdproc
imon.bignum.patch
(text/plain, 10.4 KB)
--- server/drivers/Makefile.am.orig 2011-02-27 20:02:58.000000000 +0600
+++ server/drivers/Makefile.am 2011-03-22 16:14:04.031408122 +0600
@@ -47,7 +47,7 @@
hd44780_LDADD = libLCD.a @HD44780_DRIVERS@ @LIBUSB_LIBS@ @LIBFTDI_LIBS@ libbignum.a
hd44780_DEPENDENCIES = @HD44780_DRIVERS@
i2500vfd_LDADD = @LIBFTDI_LIBS@
-imon_LDADD = libLCD.a
+imon_LDADD = libLCD.a libbignum.a
imonlcd_LDADD = libLCD.a
IOWarrior_LDADD = @LIBUSB_LIBS@ libLCD.a libbignum.a
irman_LDADD = @LIBIRMAN@
@@ -92,7 +92,7 @@
EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-usbtiny.c hd44780-usbtiny.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h hd44780-ftdi.c hd44780-ftdi.h hd44780-ethlcd.c hd44780-ethlcd.h hd44780-uss720.c hd44780-uss720.h hd44780-usblcd.c hd44780-usblcd.h port.h lpt-port.h timing.h
i2500vfd_SOURCES = lcd.h i2500vfd.c i2500vfd.h i2500vfdfm.c i2500vfdfm.h report.h
icp_a106_SOURCES = lcd.h lcd_lib.h icp_a106.c icp_a106.h report.h
-imon_SOURCES = lcd.h lcd_lib.h imon.h imon.c report.h
+imon_SOURCES = lcd.h lcd_lib.h hd44780-charmap.h imon.h imon.c report.h adv_bignum.h
imonlcd_SOURCES = lcd.h lcd_lib.h imonlcd.h imonlcd_font.h imonlcd.c report.h
IOWarrior_SOURCES = lcd.h lcd_lib.h hd44780-charmap.h IOWarrior.c IOWarrior.h report.h adv_bignum.h
irman_SOURCES = lcd.h irmanin.c irmanin.h report.h
--- server/drivers/imon.h.orig 2007-04-03 05:29:54.000000000 +0800
+++ server/drivers/imon.h 2011-03-26 23:36:22.464450742 +0600
@@ -28,27 +28,27 @@
#include "lcd.h"
-MODULE_EXPORT int imon_init (Driver *drvthis);
-MODULE_EXPORT void imon_close (Driver *drvthis);
-MODULE_EXPORT int imon_width (Driver *drvthis);
-MODULE_EXPORT int imon_height (Driver *drvthis);
-MODULE_EXPORT int imon_cellwidth (Driver *drvthis);
-MODULE_EXPORT int imon_cellheight (Driver *drvthis);
-MODULE_EXPORT void imon_clear (Driver *drvthis);
-MODULE_EXPORT void imon_flush (Driver *drvthis);
-MODULE_EXPORT void imon_string (Driver *drvthis, int x, int y, const char string[]);
-MODULE_EXPORT void imon_chr (Driver *drvthis, int x, int y, char c);
-MODULE_EXPORT int imon_icon (Driver *drvthis, int x, int y, int icon);
-MODULE_EXPORT const char *imon_get_info (Driver *drvthis);
-MODULE_EXPORT void imon_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
-MODULE_EXPORT void imon_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
+MODULE_EXPORT int imon_init(Driver *drvthis);
+MODULE_EXPORT void imon_close(Driver *drvthis);
+MODULE_EXPORT int imon_width(Driver *drvthis);
+MODULE_EXPORT int imon_height(Driver *drvthis);
+MODULE_EXPORT int imon_cellwidth(Driver *drvthis);
+MODULE_EXPORT int imon_cellheight(Driver *drvthis);
+MODULE_EXPORT void imon_clear(Driver *drvthis);
+MODULE_EXPORT void imon_flush(Driver *drvthis);
+MODULE_EXPORT void imon_string(Driver *drvthis, int x, int y, const char string[]);
+MODULE_EXPORT void imon_chr(Driver *drvthis, int x, int y, char c);
+MODULE_EXPORT int imon_icon(Driver *drvthis, int x, int y, int icon);
+MODULE_EXPORT const char *imon_get_info(Driver *drvthis);
+MODULE_EXPORT void imon_vbar(Driver *drvthis, int x, int y, int len, int promille, int options);
+MODULE_EXPORT void imon_hbar(Driver *drvthis, int x, int y, int len, int promille, int options);
+MODULE_EXPORT int imon_get_free_chars(Driver *drvthis);
+MODULE_EXPORT void imon_num(Driver *drvthis, int x, int num);
/**
* these are not (yet?) supported by the iMON IR/VFD kernel module
*/
-//MODULE_EXPORT int imon_get_free_chars (Driver *drvthis);
-//MODULE_EXPORT void imon_set_char (Driver *drvthis, int n, char *dat);
-//MODULE_EXPORT void imon_num (Driver *drvthis, int x, int num);
+//MODULE_EXPORT void imon_set_char(Driver *drvthis, int n, char *dat);
//MODULE_EXPORT int imon_get_brightness(Driver *drvthis, int state);
//MODULE_EXPORT void imon_set_brightness(Driver *drvthis, int state, int promille);
//MODULE_EXPORT void imon_backlight(Driver *drvthis, int on);
--- server/drivers/imon.c.orig 2011-02-11 05:07:04.000000000 +0600
+++ server/drivers/imon.c 2011-03-26 23:29:02.836882000 +0600
@@ -45,6 +45,7 @@
#include "report.h"
#include "imon.h"
#include "hd44780-charmap.h"
+#include "adv_bignum.h"
// iMon reserves the first 8 locations for the
// special bargraph characters
@@ -94,6 +95,8 @@ MODULE_EXPORT int stay_in_foreground = 0
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "imon_";
+/* Constants for userdefchar_mode */
+#define NUM_CCs 0 /* imon can't define a custom character */
/** private data for the \c imon driver */
typedef struct imon_private_data {
@@ -124,7 +127,8 @@ static char * imon_charmaps[] = {
* \retval 0 Success.
* \retval <0 Error.
*/
-MODULE_EXPORT int imon_init (Driver *drvthis)
+MODULE_EXPORT int
+imon_init(Driver *drvthis)
{
PrivateData *p = NULL;
char buf[256];
@@ -211,7 +215,8 @@ MODULE_EXPORT int imon_init (Driver *drv
* Close the driver (do necessary clean-up).
* \param drvthis Pointer to driver structure.
*/
-MODULE_EXPORT void imon_close (Driver *drvthis)
+MODULE_EXPORT void
+imon_close(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -234,7 +239,8 @@ MODULE_EXPORT void imon_close (Driver *d
* \param drvthis Pointer to driver structure.
* \return Constant string with information.
*/
-MODULE_EXPORT const char * imon_get_info (Driver *drvthis)
+MODULE_EXPORT const char *
+imon_get_info(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -247,7 +253,8 @@ MODULE_EXPORT const char * imon_get_info
* Clear the screen.
* \param drvthis Pointer to driver structure.
*/
-MODULE_EXPORT void imon_clear (Driver *drvthis)
+MODULE_EXPORT void
+imon_clear(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -259,7 +266,8 @@ MODULE_EXPORT void imon_clear (Driver *d
* Flush data on screen to the LCD.
* \param drvthis Pointer to driver structure.
*/
-MODULE_EXPORT void imon_flush (Driver *drvthis)
+MODULE_EXPORT void
+imon_flush(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -275,7 +283,8 @@ MODULE_EXPORT void imon_flush (Driver *d
* \param y Vertical character position (row).
* \param string String that gets written.
*/
-MODULE_EXPORT void imon_string (Driver *drvthis, int x, int y, const char string[])
+MODULE_EXPORT void
+imon_string(Driver *drvthis, int x, int y, const char string[])
{
int i;
@@ -292,7 +301,8 @@ MODULE_EXPORT void imon_string (Driver *
* \param y Vertical character position (row).
* \param c Character that gets written.
*/
-MODULE_EXPORT void imon_chr (Driver *drvthis, int x, int y, char c)
+MODULE_EXPORT void
+imon_chr(Driver *drvthis, int x, int y, char c)
{
PrivateData *p = drvthis->private_data;
@@ -314,7 +324,8 @@ MODULE_EXPORT void imon_chr (Driver *drv
* \retval 0 Icon has been successfully defined/written.
* \retval <0 Server core shall define/write the icon.
*/
-MODULE_EXPORT int imon_icon (Driver *drvthis, int x, int y, int icon)
+MODULE_EXPORT int
+imon_icon(Driver *drvthis, int x, int y, int icon)
{
switch (icon) {
case ICON_BLOCK_FILLED:
@@ -391,7 +402,8 @@ MODULE_EXPORT int imon_icon (Driver *drv
* \param promille Current height level of the bar in promille.
* \param options Options (currently unused).
*/
-MODULE_EXPORT void imon_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
+MODULE_EXPORT void
+imon_vbar(Driver *drvthis, int x, int y, int len, int promille, int options)
{
PrivateData *p = drvthis->private_data;
@@ -410,7 +422,8 @@ MODULE_EXPORT void imon_vbar (Driver *dr
* \param promille Current length level of the bar in promille.
* \param options Options (currently unused).
*/
-MODULE_EXPORT void imon_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
+MODULE_EXPORT void
+imon_hbar(Driver *drvthis, int x, int y, int len, int promille, int options)
{
PrivateData *p = drvthis->private_data;
int pixels = ((long) 2 * len * p->cellwidth) * promille / 2000;
@@ -459,11 +472,46 @@ MODULE_EXPORT void imon_hbar (Driver *dr
/**
+ * Write a big number to the screen.
+ * \param drvthis Pointer to driver structure.
+ * \param x Horizontal character position (column).
+ * \param num Character to write (0 - 10 with 10 representing ':')
+ */
+MODULE_EXPORT void
+imon_num(Driver *drvthis, int x, int num)
+{
+ int do_init = 0;
+ /* do_init = 0 because imon can't define a custom character */
+ /* ccmode does not need because imon can't define a custom character */
+
+ if ((num < 0) || (num > 10))
+ return;
+
+ /* Lib_adv_bignum does everything needed to show the bignumbers. */
+ lib_adv_bignum(drvthis, x, num, 0, do_init);
+}
+
+
+/**
+ * Get total number of custom characters available.
+ * \param drvthis Pointer to driver structure.
+ * \return Number of custom characters (always NUM_CCs).
+ */
+
+MODULE_EXPORT int
+imon_get_free_chars(Driver *drvthis)
+{
+ return NUM_CCs;
+}
+
+
+/**
* Return the display width in characters.
* \param drvthis Pointer to driver structure.
* \return Number of characters the display is wide.
*/
-MODULE_EXPORT int imon_width (Driver *drvthis)
+MODULE_EXPORT int
+imon_width(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -476,7 +524,8 @@ MODULE_EXPORT int imon_width (Driver *dr
* \param drvthis Pointer to driver structure.
* \return Number of characters the display is high.
*/
-MODULE_EXPORT int imon_height (Driver *drvthis)
+MODULE_EXPORT int
+imon_height(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -489,7 +538,8 @@ MODULE_EXPORT int imon_height (Driver *
* \param drvthis Pointer to driver structure.
* \return Number of pixel columns a character cell is wide.
*/
-MODULE_EXPORT int imon_cellwidth (Driver *drvthis)
+MODULE_EXPORT int
+imon_cellwidth(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
@@ -502,7 +552,8 @@ MODULE_EXPORT int imon_cellwidth (Driver
* \param drvthis Pointer to driver structure.
* \return Number of pixel lines a character cell is high.
*/
-MODULE_EXPORT int imon_cellheight (Driver *drvthis)
+MODULE_EXPORT int
+imon_cellheight(Driver *drvthis)
{
PrivateData *p = drvthis->private_data;