Data formatting library

Hi All,
I am putting together an LCD screen using unusual hardware protocol.
Is there a library available to format the various data classes into printable text?
ie input = (x000A) gives ( "10") . etc.
Integer, real and hex into character would be good.
Thanks
Dave

The print methods support what you want to do. So if you implement something based on the print methods, you should be OK; only problem might be leading zeroes.

If that is not what you want, there is sprintf; for AVR based boards, it does not support floats but it will give you a text that you cans end to the display.

Welcome to the forum

Which Arduino board are you using ?

Thanks Sterretje, Will investigate print methods further...

Currently playing with el-cheapo Uno. Thx

I am assuming this is related to 'print method'. Will investigate this further. Thx

Hi,
What I am seeing is that I can create an object (if that is the correct term) called BMS for instance and then do the formatting using BMS.print(a,b);
Is this correct?
I am rather 'old-school' and find the documentation for this irritatingly vague.
Thanks
Dave

What might that protocol be? There may be an Arduino library to match, which forum members could recommend, given a link or some details.

Thanks Delta_G,
It is a standard LCD (4x20) legacy device I designed nearly 20 yrs ago. The unit is driven by a PIC 16f84 with something like 15kb machine code primatives and programme.
The hardware is 10 bit bit-banged to the screen board. 8b data + 1b Alarm LED +1b LCD Reg Select.
Also in the cable are +/- supply, 1b Shift reg clock, 1b LCD load clock and 1b button feed back to uP.

Fortunately, I did not need to write a machine code version of floating point to printable... The U-integer one was challenging enough to make quick.

As I designed the hardware for a specific application I did not even look for an existing library.

Woops.
Just replied to wrong sender...

Yes. I'll 'fess up' I learned programming when Commodore was still a MidShipman.
Done Fortran, Basic (PDP11 mubas and many others.) Machine code (both hand coded and assembler for 6502, 6800, PDP8, Z80, VAX, pic. Command line programming for minis through to windows / Unix boxes.

The legacy box I have is a battery state monitor accumulating Amp-hours, displaying remaining capacity % and able to alarm on low Ah, Volt out of spec on 3 battery banks. Designed for commercial boats with 'House supply', Port & Starboard Crank batteries or Engine & GenSet. 12V / 24V - AGM or Gel.
I must say it works a treat.
But. Moving forward upping to a modern processor would be sensible. Also I have a few of these screens sitting around which could be used on Uno projects...
It all turned to 'custard' when some (clot?) suggested object oriented code would be good...
They may be right if I can make a 'sender' and use Sender.print("Horray")
But, regarding the documentation, there is a significant gap between 'available functions' and 'documented functions'. Try Googling print method or .print, Also search the Arduino docs pages for what I can do and how to do it.
Sorry if I am boring you all.
It may be simpler to use LCD library and make a new hardware interface board.
Thanks for your support.
Dave

when you have defined a clean communication protocol to the PIC16F84 it shouldn't be a big issue to write a LCD class based on the common LCD API 1.0 which handles the LCD via the PIC16F84.

the LCD class can inherit from Print.h,
you add all supported functions from the LCD API 1.0
you need to implement the HW layer to interact with your PIC16F84.
you need to at the write() function to print one character. Rest of the implemenation comes from the Print.h (BIN, HEX, DEC, integers, floats, Strings, char strings ...)

See also

Arduino Playground - LCDAPI

Hi Noiasca,
Sounds promising. Found the source code for LiquidCrystal on GitHub. That may be easily modifyable to do the stuff.
Spent a couple of hours trying to break into API work. No success at all. Any (newbie) pointers?
Thanks
Dave

"No success at all" tells us nothing about your problem.

  1. Post the code you have,
  2. Post what you get under which condition,
  3. Post what you want to get instead.
  4. Post anything we need to get an understanding about your PIC16F84 driven display - including the protocol.
  5. and post a short, standalone - but working - demo sketch where you just send a "Hello World" to the display.

Hi Noiasca
The 4x20 LCD display box is purpose built to interface with a PIC computer I developed some time back.
The interface cable is 6 wires. +/-, 1 input to uP, serial clock, serial data, LCD enable (clock).
The serial data stream is 10bits (bit banged) 8 data, RS, alarm LED.
The PIC is the system engine.
The Q about API relates to your post " based on the common LCD API 1.0 which handles the LCD".
My search for LCD API has met a blank.
As yet I am in the software design phase and have not written any code.
It looks like I will modify liquidcrystal(cpp and h) and create a specialised library for the project.
Thanks
Dave

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.