NRCPythonSeminar
From NRCwikis
Contents |
Prerequisites
- Phone: Nokia N93
- Python for S60: version 1.3.17
- Download the current release of Python for S60 from sourceforge: PyS60 1.3.15
- For N93 (and other 3rd edition phones) download and install on the phone the following files:
- PythonForS60_1_3_15_3rdEd_selfsigned.SIS
- PythonScriptShell_1_3_15_3rdEd_selfsigned.SIS
- Python for PC: version 2.4 or 2.5
- Download and install Python on your PC: Download Python Software
- Bluetooth Drivers: If you are using IBM ThinkPad, make sure you have Broadcom (formerly Widcomm) BT drivers installed
- You can download Broadcom (formerly Widcomm) BT drivers for IBM ThinkPads from Bluetooth with Enhanced Data Rate for Windows XP(This works for T60 and T43, others probably too.) Follow the installation instructions listed on the web page.
- If you are not sure if you have Broadcom drivers intalled, double click on "My Bluetooth Places" icon on your desktop, go to "Help->About My Bluetooth Places" to check. (If you do not have "My Bluetooth Places" icon on your desktop, you probably don't have the right drivers. Check, to be sure, by going to "Control Panel->Bluetooth Configuration".
Sample Code
Introduction to Python Programming
- Camera Example: Introducing basic functionality of: appuifw, camera, graphics
- Move camera.py to the Python directory on the phone
- Run the script, use select key to save a photo
- Exercise 1: Make the following modifications to camera.py
- change KeyboardHandler() to sense 'left arrow' key pressed
- capture image using videoconf. camera (position=1)
- decrease size of the image displayed to the canvas
- change the color of the rectangle around the image
- resize the photo to size=(256,256)
- save the result into E:\\Images\\icon.jpg
- Bluetooth File Transfer: more appuifw functionality; introducing socket functionality for setting up BT connections
- Move bt_send_file.py= to the Python directory on the phone
- Run the script, check if the the file called <tt>image.jpg is in your Bluetooth Exchange Folder
- If the file is not there, change settings to allow file transfer for "PIM Item Transfer" service from your Bluetooth settings (check under "Local Services")
- Filebrowser Example: python classes, and exception handling; introducing basic functionality of os and e32; use of listboxes
- Move filebrowser.py to the Python directory on the phone and run the script
- Navigate to E:\\Python, select one of the Python scripts, choose execfile() from the menu
- Navigate to =E:\\Images=, select one of the JPG images, choose *Open* from the menu
- Exercise 2: Make the following modifications to filebrowser.py
- Add "BT Send File" as one of the menu options when a file is selected
- Initiate BT file transfer to PC if user selects "BT Send File" from the menu
Advanced Python Programming
- OpenGL ES programming in Python:
- use of GLcanvas, basic rules for writing GLES code
- Move texture.py to the Python directory on the phone
- Move nasa_hubble.jpg and ogles.jpg to (E:\\Images)
- Run the script, use arrow keys to change cube orientation
- In the script, replace ogles.jpg with icon.jpg
- Push the script to the phone and rerun it
- Comparison with Carbide.c++ code
- Compare the code in texture_src directory with the Python script
- use of GLcanvas, basic rules for writing GLES code
- Capturing GPS Track
- Move gps_capture_track.py to the Python directory on the phone
- Run the script, select "Holux GPSlim236" when prompted for device (pairing code: 0000)
- Select "Options->New Log File", start a new track with current date in the name
- Uploading GPS Track to PC
- Move gps_upload_track.py to the Python directory on the phone
- From the listbox choose GPS track just created
- Change format to GPX, choose "Menu->Upload"
- On the PC open Google Maps GPX Viewer, browse to the location where the track was uploaded, and click "select" button on the web site
