Imon driver: Add bignum support (Y. Scheglyuk)

This commit is contained in:
mmdolze
2011-03-28 19:09:58 +00:00
parent c9c3272eba
commit 5fbc384be5
4 changed files with 85 additions and 33 deletions
+1
View File
@@ -29,6 +29,7 @@ v.0.5dev (ongoing development)
* convert i2500vfd and mdm166a driver to use 8 byte bitmap custom character
* ula200: convert custom characters to 8 byte bitmap
* Build system: Fix trying to install svga driver twice
+ imon: Add bignum support (Y. Scheglyuk)
v0.5.4
* Update driver includes and LDFLAGS (fixed glk and bayrad binding error)
+2 -2
View File
@@ -47,7 +47,7 @@ glk_LDADD = libbignum.a
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 @@ hd44780_SOURCES = lcd.h lcd_lib.h hd44780.h hd44780.c hd44780-drivers.h hd447
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
+65 -14
View File
@@ -44,6 +44,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
@@ -93,6 +94,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 {
@@ -123,7 +126,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];
@@ -210,7 +214,8 @@ MODULE_EXPORT int imon_init (Driver *drvthis)
* 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;
@@ -233,7 +238,8 @@ MODULE_EXPORT void imon_close (Driver *drvthis)
* \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;
@@ -246,7 +252,8 @@ MODULE_EXPORT const char * imon_get_info (Driver *drvthis)
* 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;
@@ -258,7 +265,8 @@ MODULE_EXPORT void imon_clear (Driver *drvthis)
* 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;
@@ -274,7 +282,8 @@ MODULE_EXPORT void imon_flush (Driver *drvthis)
* \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;
@@ -291,7 +300,8 @@ MODULE_EXPORT void imon_string (Driver *drvthis, int x, int y, const char string
* \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;
@@ -313,7 +323,8 @@ MODULE_EXPORT void imon_chr (Driver *drvthis, int x, int y, char c)
* \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:
@@ -390,7 +401,8 @@ MODULE_EXPORT int imon_icon (Driver *drvthis, int x, int y, int icon)
* \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;
@@ -409,7 +421,8 @@ MODULE_EXPORT void imon_vbar (Driver *drvthis, int x, int y, int len, int promil
* \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;
@@ -457,12 +470,47 @@ MODULE_EXPORT void imon_hbar (Driver *drvthis, int x, int y, int len, int promil
}
/**
* 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;
@@ -475,7 +523,8 @@ MODULE_EXPORT int imon_width (Driver *drvthis)
* \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;
@@ -488,7 +537,8 @@ MODULE_EXPORT int imon_height (Driver *drvthis)
* \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;
@@ -501,7 +551,8 @@ MODULE_EXPORT int imon_cellwidth (Driver *drvthis)
* \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;
+17 -17
View File
@@ -26,27 +26,27 @@
#ifndef IMON_H
#define IMON_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);