Monthly Archives: April 2014

Macaw web design tool: not quite ready

If you have any interest in creating beautiful looking websites on a Mac or PC, you should check out Macaw, a new web tool that was just launched on March 31, 2014. I do not recall how I became aware of this tool a few weeks ago, but after watching a sneak preview video, it had my interest.

Macaw allows the easy creation of beautiful looking websites with very clean CSS, HTML and JavaScript code. As a Dreamweaver user (an older version), I have constantly been frustrated with how difficult it was to create a modern looking website. Apple’s iWeb made elegant sites with simple drag and drop, so why couldn’t a professional tool do the same? (iWeb made notoriously ugly code, and lacked the ability to customize templates or create library objects to use on multiple pages.)

Unfortunately, the 1.0 release of Macaw has a long way to go. While it does create beautiful code, there are so many bugs in the initial release that I have so-far found it practically unusable, spending hours trying to create a simple two page website. I have ran both the PC and Mac version, and each has its own quirks. (The PC version, for instance, can’t seem to remember my password and always launches with garbage characters in the login field. The Mac version has a nasty habit of going to a black screen and requiring a force-quit and restart.)

These bugs will no doubt be fixed in upcoming releases — it is version 1.0, after all.

But currently, the biggest issue is the complete lack of any kind of site templates. Every page you make is effectively an independent page. If you set up a page to be 800 pixels wide, and get it all perfect, then make a second page, that page is black and goes back to the default 1200 pixel width. (You can duplicate a page to work around this.)

If you create a perfect header and/or footer, then duplicate it on several other pages and decide you want to make a change to it (updating a copyright date or address), you have to manually go in and edit every page.

You can’t even make a simple list, numbered or otherwise.

There are currently huge items missing from Macaw that make it rather impractical for anything other than a very basic (but beautiful and elegantly coded) website. I might use it to replace all my one-off iWeb sites, but there is no way I can use it for anything large at this point.

My hope is I can use Macaw to create a beautiful single page, then open that page in Dreamweaver and convert it in to a template.

And if I can make that work, Macaw is going to be worth every penny.

Check out the trial. It has some mind blowing potential, but right now there are enough missing features that it’s not quite ready.

Porting from 32-bit systems: 16-bit constants

I recently ran in to an issue at my day job where I had to write some time functions for a project. My work system did not have <time.h> and related functions like gmtime(), which I needed.

Unfortunately, once I implemented my version of gmtime() routine (based on some code I found online), I found it did not work on my target system. Testing on a PC using GNU-C worked fine, so I expected it had something to do with the code not being written for systems with 16-bit “ints” — like the Arduino.

I narrowed down the problematic code, and used the Arduino to test it. Here is the sample:


#define SECS_DAY          (24*60*60)

void setup()
{
long           time;
unsigned long  dayclock;

Serial.begin(9600);

time =   1396342111;

dayclock = (unsigned long)time % SECS_DAY;

Serial.println(time);
Serial.println(dayclock);
}

void loop()
{
}

On the PC, dayclock would print as 31711. On an Arduino, it would print as 18911. Initially I just tried to cast things to “unsigned long” but that did nothing. When I realized my mistake, I felt rather dumb since I learned this long ago.

Numeric constants, like that #define, are treated as “int” values meaning that on the PC (where int is 32-bits) they were different than on my target system (where int is 16-bit).

When dealing with long constants, you add “L” to the number like this:


#define THISISANINT 123456
#define THISISALONG 123456L

To fix my problem, all I did was throw in the Ls:


#define SECS_DAY          (24L*60L*60L)

The code I used as reference was written by someone who probably only considered it running on machines with 32-bit ints. Most desktop (PC/Mac/etc.) programmers tend to code this way.

Maybe this reminder will help someone else as they try to port code to an Arduino project.

Side note: Rather than use “int” and “long”, if you use a new enough compiler (C99 standard), include and use the actual type you want, such as uint8_t, uint16_t, or uint32_t. As you can see, “int” on the PC would be 32-bits, and “int” on Arduino (or MSP430, or…) would be 16-bits. It’s not portable code that way, and the C standard has finally solved this challenge.

Here’s another example for you to try… It should print out 86400 (24*60*60), which it does on a PC/32-bit system, but not on a system where ints are 16-bits. Have fun!


// This will fail (ints, 16-bit)
#define SECS_DAY  (24*60*60)

// This works (longs, 32-bit)
//#define SECS_DAY  (24L*60L*60L)

void setup()
{
Serial.begin(9600);

Serial.println(SECS_DAY);
}

void loop()
{
}