QuickDraw for the Arduino

I did not see an introductory forum, so this is my first post. Please be gentle.

I have been enjoying the Arduino since I first learned of it a couple of months ago. I purchased a Seeed TFT 1.0 display on clearance for prototypes. I have been searching for graphics libraries and have downloaded a few. So far, they seem fairly basic, and some are specific to particular displays.

What I would like to find, or build if necessary, is something quite like the original QuickDraw for the Mac with color extensions. Perhaps about like QuickDraw was during the time of the color Mac II, though probably with a different color model. Since most TFTs are pretty much write-only, it would not need the fancier transfer logic. However, I'd like at least the following features:

  • Rectangular variable-sized pens for stroking lines, polygons, ovals, rects, and roundrects
  • Fill for polygons, ovals, rects, and roundrects
  • Patterns (8 * 8 or 16 * 16) for filling and possibly stroking
  • Regions for clipping
  • CopyBits/CopyPix, even without scaling (to the display, not necessarily back)

Fonts can be tacked onto CopyBits functionality. I've just listed the things I think have to be done together in a common architecture.

This is something that I can write. I know this because I've done it before, on the Zenith Z-100 computer around 1985. Though there might be some bottleneck in feeding the TFT, the Arduinos are, if anything, faster, and from the YouTube demos I've seen, scan line filling should be quite good enough.

However, if there is something out there, there isn't much point in doing it. (Regions I could probably do without, but I know how to do them, so I would if I wrote it.)

Does anyone have any suggestions?

I did not see an introductory forum,

That is odd because there is a how to use this forum sticky post in every section, why did you not see it?

What you are talking about is normally called a graphics libary. Yes you can write your own. Sometimes the vendor of the display will have one or at least the start of one.
However, there is a limited space to work with in an arduino so it can't be too big.

epepke:
What I would like to find, or build if necessary, is something quite like the original QuickDraw for the Mac with color extensions.

The Arduino Uno has 2K of RAM while the Mega boards has 8K. This should be a serious consideration in any implementation with something graphics related.

You might be looking more for a board based on a microprocessor instead of the Arduino's microcontroller.

Grumpy_Mike:

I did not see an introductory forum,

That is odd because there is a how to use this forum sticky post in every section, why did you not see it?

I saw a how to use this forum link, giving, I believe, 14 steps. I read through all of them. I even went to several fora and read those to see if there was any substantial difference. I saw no statement to the effect of "Go to the XXX forum and introduce yourself before your first post." It is possible that I missed one, and if so, I would be happy if you could point it out to me so that I could comply. However, I honestly did not see such a statement, whether you believe me or not.

[quote author=James C4S link=topic=165382.msg1234148#msg1234148 date=1368054226]

epepke:
What I would like to find, or build if necessary, is something quite like the original QuickDraw for the Mac with color extensions.

The Arduino Uno has 2K of RAM while the Mega boards has 8K. This should be a serious consideration in any implementation with something graphics related.

You might be looking more for a board based on a microprocessor instead of the Arduino's microcontroller[/quote]

Please accept my apologies, but I'm struggling to understand this as a caveat, if indeed it is.

I admit that I am new to TFTs, but as far as I can tell from the one I have, you set the XY and the direction of scan, and then you send pixel colors until you stop. These colors are laid down sequentially. Of course, there is raster memory, but that is in the TFT, and I don't have to worry about it, as I don't need transfer modes other than copy.

It's a simple scanline algorithm; the only complexity is in the weaving. Bresenham line-drawers, which I've seen in some of the libraries I've downloaded, require one Bresenham runner. With polygons (actually combinations of lines and elliptical curves, for which there is also a Bresenham algorithm) I require 2, and clipping to a clip path requires an extra set of 2. This is multiplied by the number of active extents, but this is always 1 for convex structures. Concave structures require more memory, sometimes, but I should note at this point that even Silicon Graphics didn't implement concave scanline conversion. Patterns are done while assembling the scan line, and if I limit it to original QuickDraw patterms, that means one 16-bit integer in memory. Furthermore, as I'll be using pointers, the memory in use during the scanline conversion will be smaller than expected compared to most line-drawing algorithms I've seen per vertex/runner. Fat lines do not significanly increase memory, though they require, say, a 6-sided polygon to represent a fat line using rectangular pens, or a 4-sided polygon for butt caps. However, the vertices can be generated on the fly, with only 3 in memory at once.

So I don't really see how 2K is any kind of serious limitation. It might be a limitation for someone wanting to use the graphics library if they want to do something hideously complex, but I figure they can either do on-the-fly generation or keep complex polygons in something like an SD card.

I do recall that the original QuickDraw had a 3K data structure, but 1) that was for some complex CopyBits operations that really aren't necessary, and 2) 3K was purely arbitrary and could easily be reduced.

As for the rest, I'm really not all that conscious of nomenclature. I'm 51, and I recall when the world's most powerful computers were nothing compared to an Arduino. So it isn't very important to me whether something is called a processor or a controller or a hoojimongle, and I get enough word-based thought from politics. I have been thinking about a Raspberry Pi for some time, and while I find it really impressive as a concept and implementation, I also find it somewhat baroque. The last time I was doing the microprocessor thing was about 1995, and the only stable platform I could find was the MC86HC11 (if memory serves), and it kind of sucked. When I was able to find a nice programmable chip with on-board persistent memory (I was even willing to put up with the UV window), and enough pins including on-board A-D conversion, I'd get an engineering sample and then be told by the manufacturer that they were going to stop production in a few months, which rather shell-shocked me. A small-time Joe such as I simply does not have the clout to entice a big manufacturer to keep making what I want.

When I saw the Arduino (accidentally, in a Radio Shack of all places), I said, "That's it." The capabilities and the price seemed to me about right. I ordered online a small Arduino with a break-out board for $10, a pittance, and the chip itself seems to be $3 in unit quantities. I got an Esplora and an Uno for prototyping. I noticed that functionally similar chips were made in different form factors, even by different manufacturers, and I figured that the Arduino community in general had enough clout to keep these things made for a while. So I remembered many things I had wanted to do decades ago but which were not feasible. I was genuinely excited. It reminded me of how, when I was a kid, we read Radio Electronics and Popular Electronics and ordered stuff from Poly Paks, Herbach and Rademan, and later Jameco and Digi-Key. It had depressed me that this kind of spirit seemed to have gone away for a couple of decades (except in just software for commodity computers), because I think it's an essentially healthy thing for the future. Seeing the Arduino tempered my cynicism, and I have been hopeful.

Addition, since I'm not supposed to modify except for tags. Yes, I did read the material.

I came to this forum hoping to be able to discuss such things, hoping to find at least some people with a similar spirit. If I was mistaken in thinking that this might be a place to do this, I sincerely apologize. It was an honest mistake, believe it or not.

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.

There's only one routine that would need to be customized for a particular display. This routine would need to be able to fill an extent on the screen with a series of colors. So I don't think that customizing for a particular display would be too difficult.

I think, however, that if the Arduino is semantically just a controller, there probably wouldn't be any touch TFTs at Radio shack. If it's designed to run a washing machine, maybe there should only be Arduino's on washing machines?

But I think I have my answer.

I came to this forum hoping to be able to discuss such things, hoping to find at least some people with a similar spirit.

That is fine, I was interested in to why you thought

I did not see an introductory forum,

When there is one on each forum section. One of our members Nick Gammon did a lot of work putting it together and people still do not seem to pay any attention to it. There is an ongoing discussion about it here:-

The point about quick time is that it is an attempt to provide a resolution free graphics library. It's main advantage was that coordinates were defined as being at the space between pixels not the pixels themselves. This did make things easier but quick time did occupy much more memory than the arduino has in total. It is possible to implement a limited graphics library and the LadyAda library for their OLED display is a good example. However, it does restrict the size of what other code you can have in the arduino. This was a problem I had with my latest project. I had to do all sorts of tricks to free up SRAM to make the code run correctly with this small library in.

I'm 51, and I recall .....

Well I am 61 and by no means the oldest member here. :slight_smile:

This is strange. I already explained. I saw the introductory message. I did not see, in any of those messages, though I checked in several fora, an introductory forum. That is, a forum where I could introduce myself. The words "message" and "forum" are different. It is possible to tell them apart with the naked eye. Am I speaking Swahili here, or is there something else going on?

Can you point me to a line in that message that tells me to introduce myself on a forum, or are you just being difficult and obstreperous?

In any event, I've gotten arbitrary regions working and drawing with patterns. It's very fast and isn't close to pushing the memory boundaries.

There isn't an "Introduce Yourself" type of subforum that I've seen either. I'm not sure where the misunderstanding came from, nor the seemingly derogatory tone of some of the replies(some people's parents, eh?). You were quite amicable and concise at the same time. To the best of my knowledge, this is also the correct forum for this message. I can assure you, you have landed in the right community, and welcome.

I also picked up a Seeed 2.8" Touch Shield v1.0 from Radio Shack a few months ago. I'm not familiar with QuickDraw for Mac, but if I understand correctly, you are looking for a library that can draw some primitives to the screen. If you haven't already seen it, maybe this library will help get you through some of the basics? Google Code Archive - Long-term storage for Google Code Project Hosting.

Perhaps Grumpy_Mike thinks "introductory forum" meant "introduction to forums". I don't know. It seems like hackles are rising to no good purpose.

Anyway.... on to the subject at hand.

epepke made a video of some graphic tests with his library. The whole drawing circles and squares thing reminds me of all those "Dhrystone" and "Whetstone" tests we all used to run on our computers around the time of the 80286, 386, and 486 chips. I remember running it on a 386@33MHz and 4MB of RAM, with a then-fairly-new "graphics accelerator" with 1MB of RAM in it, it seems comparable in speed.

Not bad for a microcontroller with only 2k of RAM, I think, but my programming language of choice has been solder until very recently, so perhaps I'm easily impressed.

Well, I wrote it anyway. Here's a video:

It's much better than QuickDraw. I had patterns, but I took them out, as it's so easy to use the Brush class to make patterns. A class inheriting from both Shape and Brush can also do images. I've been thinking about implementing PNG images, but I only have the Arduino Uno and no SDRAM, so there isn't much option to display a big image.

The demo doesn't have polyline, which I implemented after. These, again, are better than QuickDraw. End caps are square, and line joins use proper mitering. It neatly goes down to one-pixel line widths with speeds comparable to any single-pixel algorithm I've ever seen, so I don't need any special-casing, which is nice, because I can avoid extra code.

I've compressed the fonts significantly. The ASCII font with a few extra Unicode characters takes 850 bytes total for the font definition. I put in some extra Unicode characters I liked, which you can see here:

https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-ash3/1013022_10200826653301629_1651191896_n.jpg

Not everybody will want all glyphs, so I'm working on a mechanism to choose. The trick is that subsequent Unicode codes take up less space than simply picking and choosing. The glyph definitions are pretty compact, and there are several levels of compression.

I put in upper- and lower-case thorns, because I'm not too happy about my reception here, and I think y'all could use a thorn in your sides, since y'all have put up with and promoted a jerk culture. I've learned from some people that Grumpy Mike gets to flame people, but appropriate responses are stopped lest a Forum God be criticized. This is your decision and your responsibility, not mine.

I also did diacritics, ten of them. They are combining diacritics, and they work better than most fonts, because not only can they be combined with any other glyph, but they can stack correctly as per the Unicode standard. I can't find the picture I posted to Facebook. Getting rid of the dots on the "i" and "j" was somewhat tricky, but I did it. I might work on the aesthetics a bit, but it all basically works and looks reasonably good.

This is really very easy to adapt to any device. I adapted it to the Mac so that I could make documentation. The interface is minimal, only requiring the ability to set the X and Y and direction and blast pixels/colors. I have my eye on a $7 display, which I'll get when I start making money again. I think it will work fine. There is no limitation other than 16=bit coordinates, so it could work on some pretty big displays. The major speed limitation seems to be bit-blasting, which is hardware-dependent. The 2-D construction is very fast with kAnd, kOr, kMinus, and kXor. It works with everything. Only when it gets to trees of 30 or more entries does it seem to slow down noticeably. I might modify it to be completely neutral with regard to preferred pixel-blasting direction, but it doesn't affect my device.

I've taken to heart the admonitions that nobody would care. I had been used to supportive GPL communities, and it really isn't my problem that this isn't one. This is y'all's community, not mine. I was not welcomed. Y'all can have y'allses fun. I have no desire to affront anybody. Have a nice day.

Moderator edit: Insults deleted. (Nick Gammon)

epepke:
I came to this forum hoping to be able to discuss such things, hoping to find at least some people with a similar spirit. If I was mistaken in thinking that this might be a place to do this, I sincerely apologize. It was an honest mistake, believe it or not.

Give us a bloody break. This is a friendly forum. Your comments are not.

In your original post you said that the tft was write only. Actually you can read from the tft screen's GRAM you have (the seeedstudio tft v1.0) I also have that tft and reading is very simple.

epepke:
Well, I wrote it anyway.

That's sweet work; I'm impressed. Sorry that you felt like your reception here was poor! I'd bet that for every grouchy responder, a whole bunch of silent lurkers were appreciating your work as much as I do.

kelvin31415:
That's sweet work; I'm impressed. Sorry that you felt like your reception here was poor! I'd bet that for every grouchy responder, a whole bunch of silent lurkers were appreciating your work as much as I do.

I agree.

Hard to make a good second first impression.

That's sweet work; I'm impressed. Sorry that you felt like your reception here was poor! I'd bet that for every grouchy responder, a whole bunch of silent lurkers were appreciating your work as much as I do.

I also agree. How is it that this person, who is obviously very talented, be "turned away" from this forum by some people misreading what he said? He clearly says an introductory forum which in the online community is where people introduce themselves to the forum at large. In fact some forums insist on this before you can post anything in their forum. This forum does not have one of these, however it does have a comprehensive how to use this forum, which to my way of thinking is a totally different thing. Anyway what would I know XD

I've re-read the first few posts and I just don't see where this angst is coming from.

I saw a couple of warnings that the Arduino might not have enough RAM for an extensive graphics library. This was clearly intended to be helpful. Often we see people doing large arrays in their code, clearly unaware they only have 2 kB of RAM on a Uno.

But then things went downhill, sadly:

epepke:
I came to this forum hoping to be able to discuss such things, hoping to find at least some people with a similar spirit. If I was mistaken in thinking that this might be a place to do this, I sincerely apologize. It was an honest mistake, believe it or not.

epepke:
I've taken to heart the admonitions that nobody would care. I had been used to supportive GPL communities, and it really isn't my problem that this isn't one. This is y'all's community, not mine. I was not welcomed. Y'all can have y'allses fun.

I just don't understand it. I am interested in Quickdraw myself, as that was the graphics library on the original Mac. And I am interested in graphics libraries, having written one for a graphics LCD. I don't see anyone saying they don't care.

However I do get a bit defensive when someone with only a handful of posts to their name starts attacking the forum as uncaring, or unfriendly. I don't believe it is. I also don't believe there is anything in this thread that supports such a notion.