Rex Software Development
This document originated from a machine translation from Japanese to English of the DS2 SDK. It has subsequently been manually edited to make it Rex specific and some sections that are not relevant have been removed. The section numbering has been preserved to maintain correspondence to the original document.
In a number of areas a common sense approach has been applied to interpreting the translation. Not every aspect has therefore been explicitly tested and verified. If you discover any area that appears to be in error please advice via www.rexextras.net.
Myles Rix September 2001
3.1 Basic
hardware constitution
7.2 Limitations
of addin programs
10.1 Event
management function
10.1.2 The
processing of the key event
10.1.3 The
processing of the scroll bar
10.1.4 DsEventAdd
- the event is registered
10.1.5 DsEventDelete
- the event is deleted
10.1.6 DsEventEnable
- the event is made effective
10.1.7 DsEventDisable
- the event is made invalid
10.1.8 DsEventClear
- All registered events are cleared
10.1.9 DsDialogScrollThumbSet
- the thumb position of the scroll bar is set
10.1.10 DsDialogTextButton
– display a text button and assign it an event id
10.1.11 The
DsSetScrollSize - scroll size is set
10.1.12 DsDialogScrollBarDraw
- the scroll bar is displayed
10.1.13 Message
management functions
10.1.14 DsEventMessageGet
- the event is acquired
10.1.15 DsReadMessage
- supervision of event
10.2.1 DsBeepOn
- beep sound is sounded
10.3 Date
management functions
10.3.1 DsCalCurrentTime
- date time of home is acquired
10.3.2 DsTime24get
– returns where Rex set for 24 hour or 12 hour systems
10.4 Key
& Touch panel management functions
10.4.1 DsTouchDataGet
- the touch data is acquired
10.5 Graphic-related
management function
10.5.1 DsDisplayLine
- a straight line is drawn
10.5.2 DsDisplayBitmap
– Displays a bit map
10.5.3 DsDisplayPointGet
– returns the state of the point
10.5.4 DsDisplayPointSet
– draw or clear a single pixel
10.5.5 DsDisplayBlockClear
– clears a block of the display
10.5.6 DsDisplayBlockReverse
– reverses a block of the display
10.5.7 DsDisplayBlock
– displays a block
10.5.8 DsDisplayWaitIconDraw
– displays the egg-timer wait icon
10.5.9 DsClearScreen
– clears screen
10.5.10 DsPrintf
– displays a character string
10.5.13 DsVScrollArea
– vertically scroll screen area
10.6 Data
base management functions
10.6.1 Data
base API return values
10.6.3 Restrictions
on data size
10.6.4 Compilation
of data base and call of data
10.6.6 DbOpen
– Opens table for use
10.6.7 DbClose
– Closes a database table
10.6.8 DbInsertRecord
- a record is added
10.6.9 DbFindRecord
– find a record and sets the current record pointer to it
10.6.10 DbReadField
- the field where the record is appointed is read
10.6.11 DbDeleteRecord
- the current record is deleted
10.6.12 DbNextRecord
- makes the next record the current record
10.6.13 DbPreviousRecord
– make the previous record the current record
10.6.14 DbBeginTransaction|
Transaction is started
10.6.15 DbEndTransaction| Ends database transaction
10.6.16 DbGetRecordCount| Total number of records is obtained
10.6.17 DbCreate| A table is created
10.6.18 DbDestroy| a table is deleted
10.6.19 DbReadRecord
– current record is read
10.6.20 DbUpdateRecord| the current record is renewed
10.6.21 DbUpdateField| a field of the current record is updated
10.6.22 DbReadText| Read text fragment from designated position of specified field
10.6.23 DbInsertText|
It inserts the data in designated position of specified field
10.6.24 DbDeleteText|data
is deleted to designated position of field of the current record
10.6.25 DbFlush
- cache data is written to storage
10.6.26 DbGetFieldSize|
Size of field is acquired
10.7 Software
key management function
10.7.1 DsSoftwareKeyboard
- the software keyboard is started
10.7.2 DsSoftwareKeyboardSetInputMode
- starting setting of software keyboard
10.8 Addin
management functions
10.8.1 DsAddinTerminate
- it ends the addin software
10.9.1 DsSleep
– waits for designated time
10.9.2 DsVersionGet
- acquisition of version information
The development of an addins involves programming mainly with the C language. Development procedures, explanations and various settings are described below.
Supplied in the SDK are the various library, header files, and tools that are needed to develop addins. A compiler is also need. The DS2 SDK requires a separately purchased compiler made by IAR Corporation, however the rexDK uses a different and free compiler.
In general, the SDK provides the API that is needed for basic operation of the hardware. However, some knowledge of the hardware is needed at times, and in particular, when an application that retains data in the flash memory is developed, knowledge of the database may be necessary.
This document therefore includes the basic hardware constitution, workings of the OS and the API specification.
DataSlim2
CPU - Z80 core 8-bit CPU with Memory Management Unit (MMU)
Memory Access - Bank and Non_bank area Access
Display - 240 X 120 pixel, 2
Touch panel - analog resistive
Keyboard - 5key
Serial port - RS-23C2c
PCMCIA interface
Audio output - Beep
RAM - 32 Kbytes
ROM - 2mbytes with Flash type (Write/Erase support)
A single chip micro-computer which a Z80 core is adopted. The operational frequency is 4.3mHz, the smallest order effective speed is therefore 930nS.
See the API for details, but in summary when the DsMessageEventGet () API is called the CPU enters a HALT state. When an event occurs it returns from HALT state.
When the DsReadMessage () you use, the CPU becomes HALT state, the ά Plug. ????
As for reset of the system when connecting the electric battery or the reset switch pushing
It is every the time, the C The register in addition the terminal to be initialized in reset state, the C Lycee
It jumps to the address 0x0000 of bg interrupt vector.
The LCD dot constitution is 2 gradations of 240 X 120.
The real time clock is operated by the oscillation of the 32kHz. When the CPU enters Halt state, the clock continues to operate independently.
The DataSlim2 is formed with SRAM and Flash memory.
The touch pad resolution corresponds to 1 pixel of the LCD.
There are 5 keys. Home key also controls ON/OFF of power source .
The Operating System is unique to the DataSlim.
Donft access the hardware directly, use the device drivers via the SDK.
Removed as specific to compilation under DSK.
Data Type Bytes Range
Char 1 0 - 255
Signed char 1 -128` 127
Unsigned char 1 0` 255
Short int 2 -32768` 32767
Unsigned short
Unsigned int 2 0` 65535
Long 4 -2147483648` 2147483647
Unsigned long 4 0` 4294967295
Data pointer 2 0` 65535
Furthermore, the types below are defined in the gtype.h" file.
Typedef int SHORT;
Typedef int INT;
Typedef unsigned int UINT;
Typedef void VOID;
Typedef unsigned char UCHAR;
Typedef unsigned long ULONG;
Typedef unsigned char *PUCHAR;
Typedef unsigned int *PUINT;
Typedef long LONG;
Typedef unsigned short USHORT;
Typedef int BOOL;
Typedef char BYTE;
Typedef char CHAR;
Typedef short int WORD;
Typedef int ERROR;
The active memory size, including the stack territory, is 4kbyte. In order to manage the resources of the DataSlim2, malloc () should not (cannot?) be used.
Maximum of 8 addins each of up to 8kbyte.
The accessible memory space of 8bit CPU usually is 64kbytes.
Access of the memory which exceeds this is made possible by changing BANK in order to access the additional the space. Please note changing banks in addins program cannot be done. (NOTE WE CAN CHANGE BANKS DESPITE WHAT THE MANUAL SAYS).
Translation unclear
As for DataSlim2 data retention ^ When it reads, the data base
APIi DataSlim2 API reference j Through, to Flash memory the retention ^ of the data;
Reading is done.
Because of that to DataSlim2 data retention ^ When reading is done, the f
- There are times when the knowledge regarding the ^x[X is needed.
Guess: Defining an index enables faster searching, and sorting into ascending or descending orders.
Translation unclear
With DataSlim2 API data base API, at the time of data base compilation in
It is possible to define the fbNX. i Note F At the time of data base compilation
By all means the P The j which has the necessity to define the index;
By defining the index performance when searching improvement
It can do Ή ι thing.
In addition due to the flag of index presentation, appointing descending order and ascending order
It has become possible.
In addition as for the index plural it has become possible, to define, when searching I
It is possible to appoint the fbNX.
The system reserves IDs in the range 0` 29999 , hence user addins can use the range 30000 `
65535. There is a warning that if you use databases in the system range you might destroy some of the system data.
The DataSlim2 API explanation follows.
The following structures are defined in the header files and included when used.
Typedef struct {
UINT PointX;
UINT PointY; } POINT
/* rectangle *
Typedef struct {
UINT X;
UINT Y;
UINT CX;
UINT cy; } RECT
Typedef struct { INT message; / Message
CHAR
bCode; / Message extended byte data
INT
sCode; / Message extended word data
POINT
pt; / Touch panel coordinate data
}
MSG;
Typedef struct {
Unsigned charday; / Day (1-31)
Unsigned charmonth; / Month (1-12)
Unsigned short year; / Year (1990-2030)
} CDATE;
Typedef struct {
Unsigned charminute; / Minute (0-59)
Unsigned charhour; / Time (0-23)
} CTIME;
Code |
Name |
Description |
0x01 |
DS_MSG_PAINT |
Signals that a screen repaint is required. |
0x02 |
DS_MSG_CLOSE |
|
0x03 |
DS_MSG_COMMAND |
An event message (also the scroll bar) occurred. Examine the bCode element of the message structure for detail. |
0x04 |
DS_MSG_SHORTCUT |
|
0x10 |
DS_MSG_KEY_DOWN |
A key was pressed. Examine the sCode element for information as to which key. |
0x11 |
DS_MSG_KEY_UP |
|
0x12 |
DS_MSG_CHAR |
|
0x20 |
DS_MSG_TOUCH_DOWN |
|
0x21 |
DS_MSG_TOUCH_UP |
|
0x22 |
DS_MSG_TOUCH_MOVE |
|
0x23 |
DS_MSG_SCROLLUP_REPEAT |
|
0x24 |
DS_MSG_SCROLLDOWN_REPEAT |
|
0x25 |
DS_MSG_PAGEUP_REPEAT |
|
0x26 |
DS_MSG_PAGEDOWN_REPEAT |
|
0x27 |
DS_MSG_SCROLLUP_UP |
|
0x28 |
DS_MSG_SCROLLDOWN_UP |
|
0x29 |
DS_MSG_PAGEUP_UP |
|
0x2A |
DS_MSG_PAGEDOWN_UP |
|
0x30 |
DS_MSG_SCROLLUP |
|
0x31 |
DS_MSG_SCROLLDOWN |
|
0x32 |
DS_MSG_RIGHTSCROLL |
|
0x33 |
DS_MSG_LEFTSCROLL |
|
0x34 |
DS_MSG_PAGEUP |
|
0x35 |
DS_MSG_PAGEDOWN |
|
0x36 |
DS_MSG_SCROLL_THUMB |
|
0x37 |
DS_MSG_SCROLL_THUMB_DOWN |
|
0x40 |
DS_MSG_TIMER1 |
This event is generated with 1 second intervals |
0x41 |
DS_MSG_ALARM |
|
0x42 |
DS_MSG_POWERON |
|
0x43 |
DS_MSG_COMMAND_DOWN |
|
0x44 |
DS_MSG_COMMAND_REPEAT |
|
0x45 |
DS_MSG_COMMAND_UP |
|
0x46 |
DS_MSG_POWEROFF |
|
0x47 |
DS_MSG_AUTOPOWEROFF |
|
0x48 |
DS_MSG_BATTERY_DETECT |
|
Translation unclear
At the time of the MSG_DS_CLOSE / the synchronizer, the when starting with shortcut
bZ[W. With application to do picture elimination rapidly, the DsAddinTerminate
() It executes.
The event ID is an 8 bit value however the range of events available for addin development is restricted since some are reserved for system use. The range becomes as below:
The 0x50 - 0x7F without repeat mode the event
The 0x80 - 0xEF there is a repeat mode, the event
Events when there is no repeat mode are:
When touching MSG_DS_COMMAND_DOWN
Events when there is a repeat mode:
When touching MSG_DS_COMMAND_DOWN
When repeating MSG_DS_COMMAND_REPEAT
When raising MSG_DS_COMMAND_UP
Translation unclear
Concerning the return function from addin application
When it returns from addin application, addin application
Empty DsAddinTerminate API is executed.
As for DsAddinTerminate API, event IDF 0x80` Event to 0xcEf
Please do not do the use in message.
When a key is pressed the sCode element of the message structure contains both the key and the nature of the key press:
Home key : KEY_TOP_A to KEY_TOP_E
Back key : KEY_ BACK _A to KEY_ BACK _E
Enter Key : KEY_ ENTER _A to KEY_ ENTER _E
Up Key : KEY_ UP _A to KEY_ UP _E
Down key : KEY_ DOWN _A, KEY_ DOWN _E
The _A, _B, _C, _D and _E variation indicate:
_A: The key was touched
_B: The key was pressed and is still held after 1 second
_C: The key was pressed and released within 1 second.
_D: The key was pressed and held for more than 1 second;
_E: The key was pressed and released after 1 second.
After an event message is retrieved the message structure will be as follows:
The message element of the msg structure returns MSG_DS_COMMAND
The bCode element indicates the nature of the input that has taken place
The sCode element indicates the position of the thumb bar
When Thumb bar touched : MSG_DS_SCROLL_THUMB
When scroll up touched : MSG_DS_SCROLLUP
When repeating : MSG_DS_SCROLLUP_REPEAT
When raising : MSG_DS_SCROLLUP_UP
When scroll down touched : MSG_DS_SCROLLDOWN
When repeating : MSG_DS_SCROLLDOWN_REPEAT
When raising : MSG_DS_SCROLLDOWN_UP
When page up touched : MSG_DS_PAGEUP
When repeating : MSG_DS_PAGEUP_REPEAT
When raising : MSG_DS_PAGEUP_UP
When page down touched : MSG_DS_PAGEDOWN
When repeating : MSG_DS_PAGEDOWN_REPEAT
When raising : MSG_DS_PAGEDOWN_UP
Translation unclear
When the number of entire lines (value " -1 " being, to become in invalid and indicate the sum button )
Sample code
Sample code which does event acquisition is shown below.
/*** event acquisition example ***/
/* event ID is declared *
#define ID1 0x80
#define ID2 0x81
/* variables are defined *
MSG msg;
Int x1=10, x2 = 10, y1=0, y2 = 60;
Int w1=50, w2 = 50, h1=40, h2 = 40;
/* events are cleared *
DsEventClear ();
/*Register event *
DsEventAdd (x1, y1, w1, h1, ID1, enable);
DsEventAdd (x2, y2, w2, h2, ID2, enable);
/* scroll bar drawing *
DsDialogScrollBarDraw (220,0,120,100)
/* acquire events and decide response *
While (1)
{
/*
event message is acquired *
DsEventMessageGet
(&msg);
Switch (msg.message)
{
Case
MSG_DS_CLOSE:
/*
close message is acquired, ends application is done, *
Break;
Case
MSG_DS_PAINT:
/*
paint message, redrawing *
Break;
Case
MSG_DS_KEY_DOWN:
Switch (msg.sCode)
{
Case
KEY_TOP_C:
/*TOP
key unless there is a reading ά frame with
the _C, it cannot distinguish the power source On/Off, *
Break;
Case
KEY_BACK_A:
/*BACK
key was pushed, *
Break;
Case
KEY_ENTER_C:
The
i
where the /* ENTER key is pushed; P The j which is the depression within second; *
Break;
Case
KEY_UP_A:
Case
KEY_UP_D:
/*
UP key is pushed and released, or pushed and held *
Break;
Case
KEY_DOWN_A:
Case
KEY_DOWN_D:
*
DOWN key is pushed and released, or pushed and held
Break;
}
Break;
Case
MSG_DS_COMMAND:
Switch (msg.bCode)
{
Case
ID1:
/* the event ID=ID1 which is registered was selected *
Break;
Case
ID2:
/*
the event ID=ID2 which is registered was selected *
Break;
Case
MSG_DS_SCROLLUP:
/*
scroll bar up was selected *
Break;
Case
MSG_DS_SCROLLDOWN:
/*
scroll bar down was selected *
Break;
}
Break;
}
}
A touch panel event is registered. When that area is touched the eventid message occurs.
Syntax
type tEvent DsEventAdd (
Unsigned char X,
Unsigned char Y,
Unsigned char CX,
Unsigned char cy,
TEventId eventid,
TEventMode mode)
Arguments
X coordinate with respect to the left of argument event area 0 - 239
Y coordinate with respect to the left of event area 0 - 119
X width of event area 0 - 240
Y width of event area 0 - 120
Event ID:
Event Mode: Initial condition of event ?
1 F Validity (please make usually 1)
0 F Invalidity
Return value
Total number of events after the new event is registered
Explanation
The maximum number of the events that can be registered 42. If it exceeds this when trying to register the event, an error occurs.
If area are define that overlap the last event to register for that area takes priority.
Translation unclear
As for the event which ahead is done, is registered before the that at that area execution
The κ increase it is.
With the Mode event initial condition from as for the change to invalid validity being possible,
It does, but the € It is not possible from merited state to make invalid.
A touch panel event is deleted
Syntax
Type tEvent DsEventDelete (void)
Arguments
There is no argument
Explanation
Deletes the last event created?
Return value
Total number of remaining events after deletion?
Translation unclear
gThe event which remark lastly is registered is deleted. Therefore some event ν
Whether it is excluded, it cannot appoint. g
The touch panel event is enabled
Type boolean DsEventEnable (tEventId eventid)
Arguments
Event ID
Return value
Return value success (1) / failure (0)
Explanation
I think the bit below is saying that events are normally enabled by default once they are registered.
Translation unclear
When with remark usual use method registering the event, it has become effective.
The touch panel event is disabled
Type boolean DsEventDisable (tEventId eventid)
Arguments
Event ID
Return value
Return value success (1) / failure (0)
All registered events are cleared
Type boolean DsEventClear (void)
Arguments
There is no argument
Return value
Return value success (1) / failure (0)
Type int
DsDialogScrollThumbSet (int Line)
Arguments
The line value which indicates the argument sum button (the number of entire lines is set beforehand necessary
There is a main point)
Return value
Return value 1
Explanation
Sets the position of the scroll bar, eg set it to 15 with a bar of size 20 and the bar will be ¾ of the way through your scroll bar.
When the argument is zero, the bar moves to the top. With the number 0xFF or the total number of lines, the bar moves to the bottom.
/ ---------------- example -----------------
DsDialogScrollBarDraw (220, 0, 120, 100);
DsDialogScrollThumbSet (20);
This sets the thumb position to be 1/5 of the way through the scroll bar.
Type int DsDialogTextButton ( unsigned
int X,
Unsigned
int Y,
Unsigned
int CX,
Unsigned
int cy,
Unsigned
char eventid,
Char
*str)
Arguments
X coordinate with respect to the left
Y coordinate with respect to the top
X width of button
Y heigh of button
Eventid event ID
Str :text
Return value
Success (1) / failure (0)
Scrollbar size is set
Type BOOL DsSetScrollSize (int size)
Arguments
size: Size
Explanation
Changes the scale which the scroll bar represents. This isnft needed if a list of fixed size is used, because you defined the size with the draw function. If you have a list of items that can increase or decrease then use this function.
Return value
Return value TRUE = success FALSE = error
The scroll bar is displayed
Type int
DsDialogScrollBarDraw ( unsigned
int X,
unsigned int Y,
unsigned int height,
unsigned int size)
Arguments
X X coordinate
Y Y coordinate
Height height
Size size
Explanation
There isnft a handle hence only one at a time is allowed.
Return value
Return value 1
[ DsEventMessageGet ]
* Close message when connecting
* Touch panel-related event i Shortcut and scroll bar ) which it includes;
* Key event
* P Second message OR MSG_DS_PAINT
[ DsReadMessage ]
* Close message when connecting
* Touch panel-related event
* Key event
For the DsEventMessageGet the HALT function becomes effective. When the event occurs, the HALT is cancelled. For the DsReadMessage the HALT function does not work.
So, for an application where a user response needed before proceeding the DsEventMessageGet () is used, however, when we would like to acquire the key event inside the function which real-time processing is required (ie games) the DsReadMessage () can be used.
Type BOOL DsEventMessageGet (MSG *msg);
Arguments
msg message structure
Return value
TRUE is returned always
Explanation
The events are:
* Close event
* Key event
* Touch panel event
* Redrawing and request
* P Second timer
Until the above-mentioned event occurs, the kernel enters halt state.
Note that while in HALT state:
* Battery detection
* Automatic power off
* Alarm processing
care each automatically processed. (without issuing the event processing).
There is a MSG_DS_PAINT command which is executed when the REX powers back up. If you have no code here, nothing is redisplayed on the REX. Depending on what your application was doing when it was powered down, it should be doing when it powers up. You just may not realize without checking DsEventMessageGet() that you need to repaint the screen.
When is repeat mode and acquires the event, the Q Messages
MSG_DS_COMMAND_DOWN
MSG_DS_COMMAND_UP
Type BOOL DsReadMessage (MSG *msg, UINT mode);
Arguments
msg message structure
Mode 0= message is left in the buffer , 1= the message which is acquired is deleted.
Return value
There is a return value TRUE message, There is no FALSE message
Translation unclear
The remark below-mentioned event is issued.
* Close event
* Key event
* Touch panel event
This ` o h When the event which it should return at the point in time when it calls does not exist,
At all do, calling and returning to the origin, the DsEventMessageGet
DsEventMessageGet
* Battery detection
* Automatic power off
* Alarm processing
It does not process automatically. In addition, this ` o h In application
So to call with the region which needs turnaround time, discontinuing processing, the following processing
You use with supervisory purpose of the event when it moves.
Type int DsBeepOn (int mode)
Arguments
mode 0 = off 1 = easy 2 = strong -1 = present setting is sounded
Return value
Return value 1
Type int DsCalCurrentTime ( CDATE *date, CTIME *time)
Arguments
date date structure
time time structure
Return value
Success (1) / failure (0)
Type int DsTime24get (void)
Arguments
There is no argument
Return value
24 hour system (1) / AM/PM system (0)
The coordinate where the touch panel is pushed is acquired
Type BOOL DsTouchDataGet (POINT *point)
Arguments
Pointer to coordinate structure
Return value
Panel is touched (1) / Panel is not touched (0)
Type int DsDisplayLine ( int X,
Int Y,
Int Cx,
Int Cy,
Int mode);
Arguments
X: Starting point in X coordinate
Y: Starting point in Y coordinate
Cx: The width of X
Cy: The width of Y
Mode: Type of straight line
Return value
Return value 1
Remark * int X and the Y really are handled as the unsigned char.
i As for upper byte disregard j
Explanation
The mode value defines the behaviour of the line drawing:
The low byte defines a bit pattern. (eg x00 = white, xFF= black, x55= dotted)
The upper byte " 0 " F Normal drawing " 1 " FBitwise OR with each existing pixel
Example
DsDisplayLine (X, Y, Cx, Cy, 0x155);
Translation unclear
?Diagonal (slanted) lines are solid regardless of mode value.?
Type BOOL DsDisplayBitmap (INT X, INT Y, ULONG address, UINT mode);
Argument
X: The wCoordinate
Y: The xCoordinate
Address: Address of bitmap data
Mode: 0 = normality 1 = inverts
Return value
TRUE = success FALSE = entry territory error
Explanation
Explanation of Bitmap data
The bitmap is a byte array. The first byte specifies the width of the bitmap, the second byte specifies the height. The next bytes define the pixels to be displayed, each bit corresponds to a single pixel. A line of bitmap data always consists of a whole number of bytes. However, when drawing bitmaps with a width not equal to a multiple of 8, the additional bits which must be padded to the right of the line are ignored.
Example
Const char sample_bmp [ ] = { 30, 5,
0xFF,0xFF,0xFF,0xFC,
0x80,0x00,0x00,0x04,
0x80,0x00,0x00,0x04,
0x80,0x00,0x00,0x04,
0xFF,0xFF,0xFF,0xFC };
Type int DsDisplayPointGet (int X and int Y)
Argument
int X: X coordinate
Int Y: Y coordinate
Return value
Return value 1: The point is set, 0: the point is clear
Type int DsDisplayPointSet (int X, int Y and MODE mode)
Argument
int X F X coordinate
Int Y F Y coordinate
Mode F 1 draw pixel ,0 clear pixel
Return value
Return value 1
Type int DsDisplayBlockClear (int X, int Y, int CX and int cy)
Argument
int X F X coordinate
Int Y F Y coordinate
Int CX F Width of X direction
Int cy F Width of Y direction
Return value
Return value 1
Type int DsDisplayBlockReverse (int X,
int Y,
int Cx,
int cy,
MODE mode)
Argument
X F X coordinate
Y F Y coordinate
Cx F Width of X direction
Cy F Width of Y direction
Mode F 1 mesh indication, 0 reversing display
Return value
Return value 1
Type int DsDisplayBlock (int X, int Y, int Cx and int Cy, MODE mode)
Arguments
X F X coordinate
Y F Y coordinate
Cx F Width of X direction
Cy F Width of Y direction
Mode F 1 solid 0 outline
Return value
Return value 1
Type int DsDisplayWaitIconDraw (MODE mode)
Arguments
mode F 1 display 0 clear
Return value
Return value 1
Explanation
Note the function automatically saves and restores the area of the display over which the egg timer is displayed.
Type boolean DsClearScreen (void)
Arguments
There is no argument
Return value
Return value 0
Translation unclear
The remark event ID, figure everything is eliminated.
int RxPrintf( int x, int y, int style, char* text );
Arguments
X: X coordinate
Y: Y coordinate
Style: x00 = normal, x10=bold, x20=small. Add 1 to invert
Text: pointer to null terminated character string
Explanation
Note the function only changes the pixels covered by the text, the background is not changed. When printing inverted text, remember that to create a black background first.
The style combination bold and small is not valid.
Maximum sting length is 80, including the null-terminator.
The DsPrintf function for the Rex6000 is an extended system function:
SYSCALLEX( 0x0330, x, y, length, style, text, page );
The argument length is per default -1, which will print the string until a 0 character is found.
The argument page is always set the actual page of
the buffer if the buffer is located in the code area of the addin
(0x8000-0x9fff)
Return value
Return value 1
Translation unclear
Function the number of indicatory possible letters is calculated from the pixel which is appointed
Type int DsGetByPixel (char *str, int pixel)
Argument str character string
The number of pixel dots
The number of return value letters The place which transfers the remark const and the character string which is defined at double quart directly as argument Combination € Normal value is not returned. As for argument through the variable of char type, transferring, under Occasion.
Translation unclear
The number of pixels which bet on indication in the functional designated character string is calculated
Type int
DsGetPixelByByte (unsigned char *str, int N)
Argument str character string
The number of N letters
The number of return value pixels
The place which transfers the remark const and the character string which is defined at double quart directly as argument
Combination € Normal value is not returned. As for argument through the variable of char type, transferring, under Occasion.
Type int DsVScrollArea (INT X, INT Y, INT W, INT H and INT v);
Arguments
X: X Coordinate
Y:x Coordinate
W: Width
H: Height
V: Scroll amount in pixels (sign: Negative=down F Positive=up j
Return value
Return value 1
Explanation
Translation unclear
As for indication after the scroll n of picture state before the scroll; q The joining which it calculates The fruit is drawn. In addition, there is no virtual region in scroll function, indicatory territory
Because only the limits become the scroll object, with the scroll outside the indicatory territory object. With the picture image which becomes is turned off.
0 : Normal end
DB_ERR_SYS : System error
DB_STORAGE_FULL : Storage full
DB_CACHE_OVERFLOW : Cache overfollow
DB_OUT_OF_MEMORY : Failure of memory acquisition with the malloc
DB_REC_BUF_OVER : Over of record buffer
DB_INT8 F 8 bit integers
DB_INT16 F 16 bit integers
DB_INT32 F 32 bit integers
DB_FXDSTR F Fixed length character string
DB_FXDDAT F Fixed length data
DB_VARSTR F Varying character string
DB_VARDAT F Varying data
DB_RECID F Record ID
* Fixed length character string and the fixed length data : 255 bytes or less.
* Varying length character string and varying data : 65535 bytes or less.
Note that for DbInsertRecord, DbUpdateRecord and DbUpdateField the size of the varying character string is restricted 512 bytes or less.
Translation unclear
Because it increases, when it exceeds 512 bytes, once at 512 bytes or less the record
After the adding, please renew with the DbInsertText.
* Fixed length character string and fixed length data, as for varying character string and varying data inside
As for expression the i which is identical; The j where only interface differs;
* Record long i Total { of field length; Header j : 65535 bytes or less
In order to use a data base, using data base API, it is necessary to define the data base.
Example code – database creation
The code example below creates a new database. It creates a database by defining the database table id, the fields & their types and an index.
/* data base definition is done, *
#define ID_DBTBL 30000
#define OK 0
#define ERROR 1
Static tDbFieldDef dbFields [ ] = {
{ DB_RECID, 0 }, / Record ID
{ DB_INT32, 0 }, / Counter
{ DB_FXDSTR, 18 }, / myField1
{ DB_FXDDAT, 16 }, / myField2
{ 0 }
};
Static tDbIndexFieldDef dbIndex1_fields [ ] = {
{ 1, 0 }, / RecordKey index
{ 0 }
};
Static tDbIndexDef dbIndex [ ] = {
{ DbIndex1_fields },
{ 0 }
};
/* data base is drawn up *
Int db_create (void)
{
Int dbresult;
Dbresult=DbCreate (ID_DBTBL, dbFields , dbIndex);
If (dbresult == DB_DBID_USED)
/* processing when the data base existsal already*/
Return OK;
Else if (dbresult! = 0)
/* processing when error occurs */
Return ERROR;
Return OK;
}
Example code – record insertion
The data is retained in the /* data base *
Int db_insert (void)
{
Int dbh, dbresult;
Unsigned long dbRecordId = 1;
Unsigned char dbmyfield1 [ ] = " 12345678901234567 ";
Unsigned char dbmyfield2 [ ] = " 12345678901234
Dbh = DbOpen (ID_DBTBL);
If (! Dbh) { /*failure in opening*/
Return ERROR;
}
/*go to the first record*/
Dbresult=DbFindRecord (dbh , 1, 1, 0L);
If (! Dbresult)
{ If (DbInsertRecord (dbh , dbRecordId, (long) 0, dbmyfield1,
Dbmyfield2))
{/*processing when insert fails*/
DbClose (dbh);
Return ERROR;
}
}
DbClose (dbh);
Return OK;
}
Example code – record reading
Int db_readrecord (void)
{
Int dbh, dbresult;
Unsigned long dbRecordId, counter;
Unsigned char myField1 [ 18 ], myField2 [ 16 ];
/* opening, find, and read */
Dbh = DbOpen (ID_DBTBL);
If (dbh)
{
Dbresult=DbFindRecord (dbh , 1, 1, 0L);
If (dbresult == 1)
{Dbresult=DbReadRecord (dbh, &dbRecordId , &counter,
&myField1, &myField2);
DbClose (dbh);
Return OK;
}
Else
{
DbClose (dbh);
Return ERROR;
}
Return ERROR;
}
}
Example code – main
The following code uses the procedures that have been defined above.
Int db_main (void)
{
Int ret;
/*** Create database ***/
If (db_create ())
{
/* error handling */
...
}
/* transaction is started *
If (DbBeginTransaction ())
{
/* error handling */
...
}
/* Insert processing *
If (db_insert ())
{
/* error handling */
...
}
/* Ends transaction *
Ret = DbEndTransaction (1, NULL);
If (ret == ER_CANCEL || ret == ER_SYS)
{ /*processing for memory full */
...
}
Else if (ret <=0)
{
/* Processing for ER_EXIT, ER_CLOSE, and ER_PAINT
}
/*** db_readrecord ***/
If (db_readrecord ())
{
/* error handling *
}
}
Note that database renewal callsi DbInsert, DbDelete and DbUpdatejrenew only memory cache at the time when they are called.
The memory cache is processed into Flash RAM storage when DbClose is processed or when ae FLUSH is done
If renewal processing is continued once the cache memory is full it cause an error and that renewal processing as invalid. In order to be able to restore to the state before starting the renewal, transaction processing must be initialised before the renewal processing begins.
The API contains two functions for this purpose:
DbBeginTransaction ()
DbEndTransaction ()
Transaction processing is done before and after the functions which actually change the data.
Example code - transaction processing
Int SomeProcedure ()
{
Dbh = DbOpen (...);
If (! Dbh) {
Return ERROR;
}
If (DbInsertRecord (dbh...)
{
DbClose (dbh);
Return ERROR;
}
DbClose (dbh);
Return OK;
}
/* transaction start *
If (DbBeginTransaction ())
{
/* error handling *
...
}
/* DB Renewal processing *
Ret1 = SomeProcedure ();
/* transaction end *
Ret2 = DbEndTransaction (1, NULL);
If (ret2 == ER_CANCEL || ret2 == ER_SYS)
{
/* error processing
...
}
Else
if (ret2 <=0)
{
/* processing of ER_CLOSE, ER_EXIT and ER_PAINT *
...
}
/* Processing at time of normal end * /
...
tDbHandle DbOpen (unsigned short dbid)
dbid=databaseIc
Return value
Table handle ( or NULL if there is an error)
Explanation
Note multiple tables can be opened simultaneously, but sound fairly risky. The following didnft translate too clearly:
Translation unclear
However identical table Simultaneously Q When the time it opens, to add on one hand, the renewal i Insert and update And so on j When it does, as for the other current record the i which becomes invalid; The ` by the system As for the FbN being not to have gone, the j whose note is necessary; Furthermore, it returns, in judgement of value When the NULL is used, the include please do the stdio.h.
int DbClose (tDbHandle dbh)
Arguments
dbhtable : handle
Return value
0 = normality , other values = error
Type int DbInsertRecord (tDbHandle dbh...)
Arguments
dbh: Table handle
the data i which is written to field; one argument per field j
Because the number of arguments vary pay careful attention when coding.
Return value
0 = normality , other = error
Designated methodological F of remark data;
DB_INT8: A A: Unsigned char type variable
DB_INT16: B B: Short type integer
DB_INT32: C C: Long type integer
DB_FXDSTR: S S: Char* type character string
Length of field size amount as for business and rear is good necessary even with the NULL
DB_FXDDAT: D D: Unsigned char* type byte line
Length of field size amount necessary business
DB_VARSTR: S S: Char* type character string i NULL-terminatej
DB_VARAT: D, L
D: Unsigned char* type byte line
L: Byte several i Unsinged shortj
DB_RECID: C
C: Unsigned long type integer
When the 0L is appointed, it is formed automatically
Supplemental explanatory F
After executing, the record which is added becomes the current record.
the
The occasion where is.
Type int DbFindRecord (tDbHandle dbh,
unsigned char index_no,
unsigned Char mode...)
Arguments
Dbh : Table handle
Index_no : Index number i 1, 2... j
Mode : Search mode
When 0 = exact match or return an error
When 1 = where no match, return the record following the current
When 2 = where no match, return the record before the current
Searching key i Plural j
Designation method of the key refers to the DbInsertRecord
When searching from the first, to make mode = 1, as for value of the key like below
The F which it does;
Field F of integer; 0 or the smallest negative number
Field F in character string; " "
When from end searching in reverse, to make mode = 2, as for value of the key below
The F which is made the way;
Field F of integer; Maximum correct number
Field F in character string; " \xff "
Return value 1 = the record which is appointed exists
0 = the i where the record which is appointed does not exist; As for current record undefined j
Negative value = error
Remark
Type int DbReadField (tDbHandle dbh, int field_no, &result)
Arguments
Dbh : table handle
Field_no : field number
&result : Pointer to place to store the return data
Return value
0 = success , DB_NO_CURRENT_RECORD = current record does not exist
Other = error
Example:
int i,
dbhandle;
char str[10];
dbhandle = DbOpen(4000);
DbReadField(dbhandle, 1, &i);
itoa(str,i);
DsPrintf(10,10,16,str);
Type int DbClose (tDbHandle dbh)
Arguments
dbh table handle
Return value
0 = normality
DB_NO_CURRENT_RECORD = current record does not exist
other = error
Explanation
After the executing the function, the current record becomes undefined.
Type int DbNextRecord (tDbHandle dbh)
Arguments
dbh table handle
Return value
1 = success
DB_NO_MORE_RECORD = There is no following record
In addition = error
Explanation
When DB_NO_MORE_RECORD is returned, the current record does not change.
The record order which is followed is determined by the index which was last used by DbFindRecord.
Type int DbPreviousRecord (tDbHandle dbh)
Arguments
dbh : database handle
Return value
1 = success
DB_NO_MORE_RECORD = there is no previous record
Other = error
Explanation
When DB_NO_MORE_RECORD is returned, the current record does not change.
The record order which is followed is determined by the index which was last used by DbFindRecord.
Type int DbBeginTransaction (void)
Arguments
There is no argument
Return value
?
Type int DbEndTransaction (unsigned char alert, void *dummy)
Depending on whether previous transactions resulted in errors or not, either DbCommitTransaction or The DbRollbackTransaction is called.
Arguments
?
Type unsigned long DbGetRecordCount (tDbHandle dbh)
Arguments
Database handle
Return value
The number of records
Type int DbCreate ( unsigned short dbid,
tDbFieldDef *flddef,
tDbIndexDef
*inxdef)
Arguments
Dbid : data base ID
flddef : field format; ended with a field= 0j [CHECK]
Idef : Definition of index
Return value
0 = normality , or DB_DBID_USED if the dbid has been used already, other values= error
Translation unclear
When using the data base, first it calls. With the execution of this function the X
The data inside tray G is eliminated entirely.
Just a little note: If you're using the DbCreate function the definitions need to reside in static memory so you can't define them globally and initialize them during declaration. Instead you'll have to write some code to fill the fields.
Type int DbDestroy (int dbid)
Arguments
dbid : data base ID
Return value
0 = success
Translation unclear
After the remark table executing the DbClose, please delete.
Guess: Close the database before you attempt to delete it?
Type int DbReadRecord (tDbHandle dbh...)
Arguments
dbh : table handle
Pointer to location to store data of fields [CHECK]
Return value
0 = success
DB_NO_CURRENT_RECORD = no current record
Other= error
Type int DbUpdateRecord (tDbHandle dbh, fields...)
Arguments
dbh : table handle
Return value
0 = success
DB_NO_CURRENT_RECORD = no current record
Other = error
Explanation
When execution of this function succeeds, the current record does not change
Type int DbUpdateField (tDbHandle dbh, int field_no, field)
Arguments
dbh : table handle
field_no : field number to update
field : value
Return value
1 = success
DB_NO_CURRENT_RECORD = no current record
other = error
Type int DbReadText (tDbHandle dbh,
unsigned
short field_no,
Unsigned
short offset,
Unsigned
short len,
Unsigned
short *len_ret,
Unsigned
char *buf)
Arguments
dbh : table handle
Expand – lost in translator
Return value
0 = success , other = error
Type int DbInsertText (tDbHandle dbh,
Unsigned
short field_no,
Unsigned
short offset,
Unsigned
short len,
Unsigned
char *buf)
Arguments
dbh : table handle
field_no : field number
offset : start point to insert at
len: number of bytes
*buf : data to be written
Return value
0 = success , other = error
Type int DbDeleteText(tDbHandle dbh,
Unsigned short field_no,
unsigned short offset,
unsigned
short len);
Arguments
dbh : table handle
field_no : field number
len: number of bytes to delete
Return value
0 = success , other = error
Type int DbFlush (void)
Arguments
There is no argument
Return value
0 = success , other = error
Type int Unsigned short max_field) ???
Arguments
There is no argument
Return value 0 = success
type int DbChangeCurrentIndex(tDbHandle dbh, unsigned char
index_nr );
Arguments
The argument dbh indicates the table for which to select a different index.
Explanation
The DbChangeCurrentIndex function changes to a different
index. This affects the selection of other records using the DbNextRecord, DbPreviousRecord
and other record selection functions.
For example if using a calendar database one can switch to a
different index to move through events in date order rather than the order they
were entered into the database.
Type ERROR DsSoftwareKeyboard (char *buffer, int size)
Arguments
Buffer: Pointer to keyboard buffer
Size: buffer size
Return value
Return value 1 normal end, -3 error
Explanation
When the software keyboard is started, all existing registered events are cleared.
Example
Strcpy (tmpbuf, " hello.world!h);
DsSoftwareKeyboard (tmpbuf, 128-1);
Type int DsSoftwareKeyboardSetInputMode ( Char mode,
Char page,
Char zenhan)
Arguments
Mode: Determines the title that appearscsee here
Page page (1, 2) : 1=Lower case, 2=Upper case
Zenhan full size (1) / half angle (2)
Return value
Return value 0 normal end
Translation unclear
When argument 0 being, the input mode which has been used lastly that way use
The κ it increases
Type void DsAddinTerminate (void)
There is no argument
There is no return value
Translation unclear
DsAddinTerminate API, event IDF 0x80` Event to 0xcEf
Please do not do the use in message.
Type int DsSleep (unsigned int time)
Arguments
time: The quantity of time
Return value
Return value 1
Return value 1
Translation unclear
When we would like to appoint the second unit,
Time = N & TIME_CLOCKTICK_F (N second j
When we would like to appoint the msec unit,
Time = N / TIME_CLOCKTICK (N milli-second j [ Setting with approximation ]
Type int DsVersionGet (void)
There is no argument
Return value
Version information returned in 2 bytes
Each 4 bits represent one digit:
Example
S P O R | (Binary conversion) | 1 0000 0000 0111| 1.0.0.7
[DOCUMENT ENDS]