Кажется, к MidletPascal таки можно подключать java библиотеки...
/*
* Lib_siemens.java
*
*/
/**
* Lib_siemens for MIDletPascal.
* To compile this class, you also need MIDP 1.0 and Siemens extension APIs.
* And to use, of course, MIDletPascal (http://www.midletpascal.com)
*
* The listed functions are available on all java-able Siemens phones.
*
* web:
http://inf.nyme.hu/~kusicsk/ * e-mail: znos@freemail.hu
*
* @author Krisztian Kusics (a. ZnOS)
*/
public class Lib_siemens {
//==========================================================================
// Vibrator
//==========================================================================
/**
* Activates vibrator.
*/
public static void startvibrator() {
com.siemens.mp.game.Vibrator.startVibrator();
}
/**
* Deactivates vibrator.
*/
public static void stopvibrator() {
com.siemens.mp.game.Vibrator.stopVibrator();
}
/**
* Activates the vibrator for a given time in milliseconds.
* @param duration duration of the vibrator activation period, in milliseconds.
*/
public static void triggervibrator(int duration) {
com.siemens.mp.game.Vibrator.triggerVibrator(duration);
}
//==========================================================================
// Sound
//==========================================================================
/**
* Plays a tone.
* @param tone_freq the frequency of this tone [Hz]
* @param tone_time the duration of this tone [ms]
*/
public static void playtone(int tone_freq, int tone_time) {
com.siemens.mp.game.Sound.playTone(tone_freq, tone_time);
}
/**
* Play back a tone as specified by a note and its duration. A note is given
* in the range of 0 to 127. The frequency of the note can be calculated from
* the following formula:
*
* SEMITONE_CONST = 17.31234049066755 = 1/(ln(2^(1/12)))
* note = ln(freq/8.176)*SEMITONE_CONST
*
* The musical note A = MIDI note 69 (0x45) = 440 Hz.
*
* This call is a non-blocking call. Notice that this method may utilize CPU
* resources significantly on devices that don't have hardware support for
* tone generation.
* @param note Defines the tone of the note as specified by the above formula.
* @param duration The duration of the tone in milli-seconds. Duration must
* be non-negative.
* @param volume Audio volume range from 0 to 100. 100 represents the maximum
* volume at the current hardware level. Setting the volume to a value less
* than 0 will set the volume to 0. Setting the volume to greater than 100
* will set the volume to 100.
*/
public static void playmiditone(int note, int duration, int volume) {
try {
com.siemens.mp.media.Manager.playTone(note, duration, volume);
} catch(IllegalArgumentException iae) {
// if the given note or duration is out of range.
} catch(com.siemens.mp.media.MediaException me) {
// if the tone cannot be played due to a device-related problem.
}
}
//==========================================================================
// LCD backlight
//==========================================================================
/**
* Activates the LCD backlight.
*/
public static void setlighton() {
com.siemens.mp.game.Light.setLightOn();
}
/**
* Deactivates LCD backlight.
*/
public static void setlightoff() {
com.siemens.mp.game.Light.setLightOff();
}
//==========================================================================
// Making an outgoing call
//==========================================================================
/**
* Starts a phone call.
* IMPORTANT NOTE: The java application will terminate upon performing this method call.
* @param number a phone number to dial. (International format)
*/
public static void dial(String number) {
try {
com.siemens.mp.gsm.Call.start(number);
} catch(IllegalArgumentException iae) {
// if a phone number is entered in the wrong format or is missing in method call
} catch(com.siemens.mp.NotAllowedException nae) {
// if the call is not allowed (by the user)
}
}
//==========================================================================
// Sending SMS
//==========================================================================
/**
* Sends an sms to the specified number. The user will be prompted whether
* an SMS is allowed to be send each time the method is called.
* For further information regarding the mapping of Unicode into standard GSM char
* (7 bit) see the <A href="http://unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT">
* ETSI mapping specifications</A>.
* @param number phone number to send SMS to. (International format)
* @param data SMS text
* @return number of characters actually send
*/
public static int sendsms(String number, String data) {
int numOfCharsSent = 0;
try {
numOfCharsSent = com.siemens.mp.gsm.SMS.send(number, data);
} catch(IllegalArgumentException iae) {
// the phone number or the text message is missing in method call, or format of the number is incorrect
} catch(com.siemens.mp.NotAllowedException nae) {
// if the transfer is not allowed.
} catch(java.io.IOException ioe) {
// if the network is not available
}
return numOfCharsSent;
}
----------------
Code:
{
This example shows how to use the Lib_siemens MP library.
The available Siemens-specific functions are:
* startvibrator;
* stopvibrator;
* triggervibrator(duration : integer);
* playtone(tone_freq, tone_time : integer);
* playmiditone(note, duration, volume : integer);
* setlighton;
* setlightoff;
(Both setlighton/off methods are overridden by the phone settings,
which means that they has effect only if the backlight is off initially)
* dial(number string);
* sendsms(number, text: string) : integer;
--------
Lib_siemens issues, forum at
http://www.midletpascal.com}
program siemens_example;
uses siemens;
var
numOfCharsSent : integer;
begin
siemens.startvibrator;
delay(2000);
siemens.stopvibrator;
delay(2000);
siemens.triggervibrator(500);
delay(2000);
siemens.playtone(400, 500);
delay(2000);
siemens.playmiditone(69, 500, 50);
delay(2000);
siemens.setlightoff;
delay(2000);
siemens.setlighton;
delay(2000);
siemens.dial('+36301234567');
delay(2000);
numOfCharsSent := siemens.sendsms('+36301234567', 'This is a sms.');
drawText('Hello world!', 0, 0);
repaint;
delay(2000);
end.
источник:
http://www.midletpascal.com/forum/viewtopic.php?t=258