This is a "hello world" for the Timex m851 written in C.
I ported the official SDK to C, I wrote a brief article about it here.
I hope this can be a useful template for building your own WristApp!
You need wine, unshield and msitools.
Note that on fedora, you will need
wine.i686.
First, run buildenv.sh to download the toolchain and headers.
Note: It doesn't install anything, it just places them in the build directory.
You must create a .app file that describes where the code goes.
Here is a minimal example:
[WristApp]
Name=Hello World
Description=Test Application
Line1=
Line2=
Version Required=018
PAR=hello_par_018.bin
CODE=hello_code_018.bin
DB=
Password Support=Now you need to create a base file for each of your states, name them
state0.c, state1.c and so on.
The first function in each state?.c file should be your event handler.
You can place variables wherever you like.
#include <timex.h>
void banner_state_manager (void)
{
switch (CORECurrentEvent) {
case COREEVENT_STATEENTRY:
coreSetPopDownState(COREDEFAULTSTATE);
break;
default:
// Use the default handler for all other events.
coreCommonBannerStateHandler();
break;
}
return;
}Note: If you want your state to be written in assembly, you can do that too! Just call it
state3.asmand theMakefilewill understand.
Put your background event handler in common.c, this is also where you will
put any common code that all states need to access.
You will also need a param.asm file that contains the application control
block.
The simplest Makefile will just contain this:
include etc/rules.mkThis assumes you just have a few state?.c files and that's it!
If you want more .c files linked into a state, specify that you want them
compiled and linked in like this:
# Add any additional object dependencies here.
state1.out: banner.obj data.obj extra.objYou can also adjust toolchain flags, for example to disable warnings or enable debugging options:
C88FLAGS=-s -w123If you want to append commands to a target, just use double colons.
For example:
clean::
rm -f my_extra_fileIf you want to create a database, first add a DB= section to your .app file.
Create records called *.rec in the db directory.
You can call the records 00_foo.rec, 02_bar.rec, 03_baz.rec and so on.
They will be added to the database in filename order.
Note: Currently it will always be a random access, variable record size database.
Use code like this to access it:
dbOpenFile();
dbReadRecordRandomVar(&rec, num, sizeof(rec));
dbCloseFile();The c88 compiler is sometimes finicky. A recommended step is to pre-process
your files with the GNU C Pre-processor, this way you can use modern features
and workaround buggy macro syntax.
To enable this feature, just do this:
# You can optionally request that all your .c file be pre-processed with GNU
# cpp before being compiled with c88.
#
USE_GNU_CPP = 1Once your Makefile is complete, just type make!
You can upload your app to your watch using libdlusb.
If you are using Windows, copy the .app and .bin files to your
C:\Program Files (x86)\Timex\App directory.
Alternatively, just run bin/wristappdl.exe for a simple upload tool.
Note: I needed to run it with Administrator priviliges and in compatability mode.
This means the locator couldn't find a way to fit your code into the available space. You can try splitting your code into more states, or reducing the amount of code in your common section to free up space.
If you're accessing lots of static data (strings, tables, etc), try putting that data into a database instead, that will make more room for code.
There is an simulator with debugging support (breakpoints, disassembler, save states, etc).
It is Windows only, but very handy for development.


