Hello world example
From OpenTom
TomTom has released an example that starts with a short text "hello world example" followed by a touch screen example. A modified version of this program can be obtained at http://ghotidigital.sourceforge.net/
The code has a few functions that handle some basic i/o. The program results in an endless loop; to recover you need to reset the unit. Here are some of the functions used:
Contents |
The framebuffer functions
void FbRender_BlitCharacter(int x, int y, char character)
this funcion renders a charanter starting in col x, line y with the char character characters should be ASCII between 0x20 and 0x126 the characters itself are defined in an array; they are user definable.
void FbRender_BlitText(int x, int y, char *str)
this funcion renders a text starting in col x, line y with the text *str characters should be ASCII between 0x20 and 0x126 the characters itself are defined in an array; they are user definable.
void FbRender_Clear(int aFromY, int aNrLines, unsigned short aColor)
clear part of the screen starting at position aFromY, with aNrLines with color aColor
void FbRender_Close()
closes the fb device /dev/fb
void FbRender_Flush()
flushes the fb device /dev/fb (something like fflush(stdout) ?)
void FbRender_Open()
opens the fb device /dev/fb
void FbRender_Scroll(int target_y, int source_y, int height)
FbRender_Bpp()
this function returns the number of bits per pixel
int FbRender_ScreenWidth()
this function returns the x-res of the screen (width)
FbRender_ScreenHeight()
this function returns the y-res of the screen (height).
The drawing functions
void DrawHorizontalLine(int X, int Y, int width, unsigned short color)
draws an horizontal line, starting from X, to Y, width and the color set by color the function clips on the margins of the screen
void FillCircle (int cx, int cy, int aRad, unsigned short color)
void PutLinePoint(int x, int y, unsigned short color, int width)
The Touch Screen functions
void TsScreen_Exit()
this function closes the touch screen device /dev/ts
void TsScreen_Init()
this function opens the touch screen device /dev/ts
int TsScreen_pen(int &x,int &y,int &pen)
this function seems to detect that the screen is touched.
How to get the HelloWorld example working on the TomTom One
It seems that the display on the TomTom One is 320x240 instead of 240x320 on the TomTom Go. So on the TomTom One, the HelloWorld example does not work right out of the box. I had to correct a few things:
replace any '240' by '320' and any '320' by '240':
in the function FbRender_BlitCharacter: replace the line
register unsigned short *endp = ptr+7*240;
by the line
register unsigned short *endp = ptr+7*320;
and the line
ptr+=240-5;
by the line
ptr+=320-5;
in the function TsScreen_pen: replace the lines
x = new_event.y; y = new_event.x;
by the lines
x = new_event.x; y = new_event.y;
in the function DrawHorizontalLine: replace the line
#define iClipBottom 320
by the line
#define iClipBottom 240
and the line
#define iClipMax 240
by the line
#define iClipMax 320
there might be other places that I forgot...

