Show Posts
Pages: [1] 2 3
1  Using Arduino / Displays / Re: Font generation for bitmaps on: May 09, 2013, 01:34:24 pm
But like I said you then you have to worry about pixel data format.
In your case it looks like you are using 8 bit pixel data
encoded horizontally msb to lsb and stored in the array top to bottom.

The fonts you have appear to be fixed width and only 8 pixels wide.

A combination. The small font is 8 pixels wide, but the large data (encoded in an int) is 12 bit wide.

They are not actually fixed width but because it is only 0-9, at the time it didn't matter.

Things get much trickier/complicated when the fonts are no longer
8 pixels wide, particularly wider than 8 pixels as it now the pixel data has to span a byte.
Or when the font is not a fixed width font or fixed height font.
The pixel rendering code for your display will be more complicated if you
start to use variable width fonts or something like BDF format
since  you won't be able to do something as simple as grab the byte
and use it as "pixels" for the display.

That isn't a problem. My function for placing characters has an X/Y position, so it currently has to span bytes.
With the BDF format, it is pretty handy as I can also encode the width so I can do a 'displayString' function and have a better quality display.

Fixed width looks pretty poor when your characters are that large.

2  Using Arduino / Programming Questions / Re: Compile errors with Progmem on: May 09, 2013, 11:14:52 am
Try it the other way round:

prog_uint32_t  PROGMEM crc_table[16] = {
3  Using Arduino / Programming Questions / Re: Changing variable in loop on: May 09, 2013, 09:17:49 am
It would appear that your time never goes past your cutout time although as per previous post, how do you know it never gets reset? you never use it again

4  Using Arduino / Programming Questions / Re: [SOLVED] A sketch from several files on: May 09, 2013, 09:15:28 am
Well, of course they are global so they can be used anywhere, but generally speaking not every bit of code uses them.

So in my current sketch, all the functions that use the screen directly are all in one file (also when I first used it I realised I couldn't access the global variable outside that file). As all those functions work correctly, and there is no reason for anything else to access the screen variable, it is in that file.

So when I am editing other files, I really don't need to know about it.
5  Using Arduino / Programming Questions / Re: [SOLVED] A sketch from several files on: May 09, 2013, 08:22:49 am
I tend to tuck away the global variables with the functions that use them, so in my current LED display driver, I have a buffer which holds the screen, it is just defined within the functions that work on the screens and not accessed anywhere else. I find that works away for holding things that are not needed everywhere and making it clearer.
6  Using Arduino / Displays / Re: QuickDraw for the Arduino on: May 09, 2013, 04:19:16 am
I have not seen any full scale graphics libraries out there, as any such library would need to be quite big and for the majority of Arduino use wouldn't be that much use.
The major difference for the mac is that it was a consumer system designed for other people to write graphics applications in, targeting one style memory mapped screen  ( for the time - even the original mac had 24k of graphics memory) whereas the arduino is an embedded system designed to run (effectively) a single program, so the graphics would be very customized to your application and whatever display you had - the vast majority of running arduinos in the wild have no graphics.

I wouldn't imagine that a graphics library would have much use for most people, as their screens are so different. I am sure if you did, the first thing that would happen is that someone would come along complaining that it was missing some of the copybits modes!

 However, as you said there wouldn't be too much difficulty in writing such a thing.

I have a series of generic graphics tools I write, but they are very custom on the layout of my screen, as I am using led grid display. When I start using a graphic LCD, I will have something else.

Depending on what it is you are trying to achieve, maybe the Raspberry Pi would be better, as it does have a full graphics library and hardware accelerated graphics.
When someone refers to the difference between a microcontroller and a general purpose microprocessor I would take that to mean that a controller is something that is designed primarily for IO control systems, such as robot control, weather stations, washing machine controllers etc, rather than user based graphics, or at least that is how I would have always understood it (and I am pretty well the same age as you - as far as I know it has always been the same).

Unlike in politics, I think that it really is quite important naming in science based fields to ensure people are talking about the same things.

7  Using Arduino / Displays / Re: Font generation for bitmaps on: May 09, 2013, 03:56:37 am
I wanted a hex dump of the bits of a font in an ideal world!

Currently, my font looks like this:

// 8 bit font
prog_uchar PROGMEM midNumbers[12][11] = {
{ 0x38, 0x44, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x44, 0x38 }, //  character 0
{ 0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, //  character 1
{ 0x3C, 0x42, 0x02, 0x02, 0x04, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7E }, //  character 2
{ 0x3C, 0x42, 0x02, 0x02, 0x04, 0x18, 0x04, 0x02, 0x02, 0x42, 0x3C }, //  character 3
{ 0x04, 0x0C, 0x14, 0x24, 0x24, 0x44, 0x84, 0xFE, 0x04, 0x04, 0x04 }, //  character 4
{ 0x7C, 0x40, 0x40, 0x78, 0x44, 0x02, 0x02, 0x02, 0x02, 0x44, 0x38 }, //  character 5
.. etc

prog_uint16_t PROGMEM largeNumbers[12][16] = {
{ 0x0F80, 0x1FC0, 0x38E0, 0x3060, 0x6030, 0x6030, 0x6030, 0x6030,
  0x6030, 0x6030, 0x6030, 0x6030, 0x3060, 0x38E0, 0x1FC0, 0x0F80 }, //  character 0
{ 0x0300, 0x0300, 0x1F00, 0x1F00, 0x0300, 0x0300, 0x0300, 0x0300,
  0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x1FE0, 0x1FE0 },//  character 1
{ 0x1F80, 0x3FC0, 0x20E0, 0x0060, 0x0060, 0x0060, 0x0060, 0x00C0,
  0x0180, 0x0380, 0x0700, 0x0E00, 0x1C00, 0x3800, 0x3FF0, 0x3FF0}, //  character 2
{ 0x1F80, 0x3FC0, 0x20E0, 0x0060, 0x0060, 0x00C0, 0x0780, 0x0780,
.. etc

If they were still as they originally were in binary, you would see the pattern, so originally they were:


prog_uchar PROGMEM midNumbers[12][11] = {
{ // 0
},{ ...

where you can see the outline of a zero.

Anyway, turns out that I had missed a trick in fontforge, I couldn't get it to export bitmap data before, but that is because you need to go to Element->Bitmap strikes available before it will export bitmap data. Then you can select Generate Fonts and export BDF as olikraus said, which is perfect for the job, as it exports a hex dump of the font. Each letter looks a bit like this:

STARTCHAR ampersand
SWIDTH 666 0
BBX 6 8 0 0

So it would be fairly trivial to take that as an input to some python script and pump out a header file in the format I need for a sketch.

I guess that is why there weren't so many other tools as fontforge does it, if just a little tricky to find out how to use.

Thanks all.
8  Using Arduino / Displays / Re: Font generation for bitmaps on: May 09, 2013, 02:01:39 am
Thanks for the info I will check it out and see what I find.

Bill: what i have is a font which only covers 0-9 and . and : in two fonts, and what I wanted was the whole character set.
9  Using Arduino / Displays / Re: Font generation for bitmaps on: May 08, 2013, 06:13:00 pm
Regardless to the format of a font at source, open type, true type, postscript etc, ultimately they all have to be bitmapped by the time they get to the screen, so it is not hard to get it to that point - the fonts I have done so far have been copying them from the bitmapped versions from fontforge.

Unfortunately most of the tools I have found save into odd formats (or specific game formats) and although there are a few expensive tools that do it,  I assume there isn't much call for it in open source or free apps.

I guess I will finish off this app and stick it on the net somewhere.
10  Using Arduino / Displays / Font generation for bitmaps on: May 08, 2013, 03:20:21 pm
I have a 64 x 16 display from Embedded adventures which I have been playing around with and have now got display nicely and flicker free.

I have made 2 fonts for it for digits, one which was 16 high and 12 wide (5 characters on the display) and a second one with is 11 high and 8 wide (8 on the display). Trouble is I did those fonts by hand bit by bit copying an existing font, which is a bit laborious.
I started knocking up a mac app to generate bitmaps for making fonts but was wondering if there was anything already existing that could take a font and squirt out a binary representation at the end?

11  Using Arduino / Interfacing w/ Software on the Computer / Re: Need an example C++ program that can transmit/receive to/from Serial on: May 08, 2013, 03:31:09 am
Code from 10 years ago should work fine as nothing has changed with the serial port handling in that time, you still open a serial port with:


const WCHAR portName[] = {L"COM1"} ;

HANDLE port = CreateFile(portName,           
                       GENERIC_READ | GENERIC_WRITE,

    SetupComm(port, inBufferSize, outBufferSize);
    serialSetTimeouts(port, MAXDWORD, 0, 0, 0, 0);
    ..couldn't open the port

There is nothing new in 7/8 that would prevent that working (although there are plenty of things that do stop ports working!).

If you have code that works like you posted, it would be easier to fix the crash. What causes it to crash?
12  Using Arduino / Microcontrollers / Re: Speeding up the compiler on: May 07, 2013, 09:04:26 am
Although the 'Get a faster computer' was probably tongue in cheek, it does sound like there is something wrong with your computer.

If I load up a basic sketch (blink without delay), and hit verify, it takes a shade over 2 seconds to build it (and that probably includes saving). Admittedly this is a fast macbook with a fair bit of RAM, but does indicate that maybe there is something wrong with your computer?
13  Using Arduino / Programming Questions / Re: Incrementation of number on: May 02, 2013, 03:55:19 pm
Well, as pas is fixed and held at 1, and freq starts at 10, first time through the loop, freq is:

freq = 10 + (1 * 1);   so it will be 11.
freq = 11 + (2 * 1);  so now  13
freq = 13 + (3 * 1);  so now 16
freq = 16 + (4 * 1);  so now 20
freq = 20 + (5 * 1);  so now 25

so now, you hit the bit where freq is over 20, so i is set back to 1, so the next time through

freq = 25 + (1 * 1); so now 26 (freq is over 20 still so i set back to 1)
freq = 26 + (1 * 1); so now 27 (freq is over 20 still so i set back to 1)

add infinitum, adding 1 until you get bored and switch it off.
14  Using Arduino / Programming Questions / Re: Incrementation of number on: May 02, 2013, 03:31:31 pm
Assuming that the variable 'pas' is a positive number, 'freq' can never go down , because whatever happens, when freq gets to 20, you change the value of the number you are adding to it, but you still carry on adding something to it. However, as you set i to 1, you never leave the loop as it never gets past 11.
15  Using Arduino / Sensors / Re: Small signal and high voltage on: May 01, 2013, 03:33:28 am
I would have thought if there was no overlap of the signals and you are in control of the signal generation (ie, you also have a low voltage version of it), it would be fairly easy to provide an 'off' period for the sensor. Once you have removed the DC component and low pass filtered the input, it should be fairly manageable to get into an op-amp to clean it up and make it into pulses for the arduino
Pages: [1] 2 3