SlideShare una empresa de Scribd logo
1 de 47
Handy-Programmierung mit Python Symbian S60 Andreas Schreiber < [email_address] > Tech Talk, DLR Köln-Porz, 15.07.2008
Smartphones ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Betriebssysteme für Smartphones ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Symbian OS und S60 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Quelle: S60 Platform: Introductory Guide. Nokia Corporation, 2007. http://www.s60.com/business/developers/documents  A schematic diagram of the S60 platform architecture.
Symbian Foundation Schaffung einer einheitlichen Software-Plattform ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Quellen: Nokia Press Release (June 24, 2008), http://www.nokia.com/A4136001?newsid=1230415 Nokia kauft Symbian (heise news, 24.06.2008), http://www.heise.de/newsticker/meldung/109873
S60 Platform Services Fundamental services ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
S60 Application Services Certain basic functionality for S60 applications  ,[object Object],[object Object],[object Object]
Python for S60 (PyS60) ,[object Object],[object Object],[object Object],[object Object],[object Object]
“ Hello World” import  appuifw appuifw.app.title = u „Hello World&quot; appuifw.note(u &quot;Hello   World!&quot; ,  'info' )
Start des Python-Interpreters
Ausführen von Python-Code (1) Skripte (“Run script”)
Ausführen von Python-Code (2) Interaktive Konsole
Ausführen von Python-Code (3) Bluetooth-Konsole
 
Python API Typen und Bibliotheken von PyS60 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Python S60-Module (1) Betriebssystem-Zugriff und -Information ,[object Object],[object Object],[object Object],[object Object]
Python S60-Module (2) Benutzerschnittstelle und Grafik (I) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Python S60-Module (3) Benutzerschnittstelle und Grafik (II) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Python S60-Module (4) Audio und Kommunikation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Python S60-Module (5) Datenmanagement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Struktur von Applikationen (1) Visuelles Layout ,[object Object],Title Navigation Tabs Body Menu Exit Dialog
Struktur von Applikationen (2) Source-Code-Template ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],import  appuifw import  e32 appuifw.app.screen =  'normal' def  item1(): print   &quot; item1 was selected.” appuifw.app.menu = [(u&quot;item 1&quot;, item1)] def  quit(): appuifw.app.set_exit() app.exit_key_handler=quit appuifw.app.title = u 'Simple   Application' app_lock = e32.Ao_lock() # starts scheduler -> event processing app_lock.wait() Ausführliches Template unter: http://www.mobilenin.com/pys60/resources/app_skeleton_with_mainloop.py
Graphical User Interface ( appuifw )  Basiselemente ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Graphical User Interface ( appuifw )  Screen Size ,[object Object],[object Object],normal large full
Beispiele
Beispiel „Versenden einer SMS“ (1) Source Code import  appuifw import  messaging data = appuifw.query(u &quot;what are you doing?&quot; ,  &quot;text&quot; ) receiver =  &quot;+49172940****&quot;   if  appuifw.query(u &quot;Send message?&quot; ,  &quot;query&quot; ) ==  True : messaging.sms_send(receiver, data) appuifw.note(u &quot;Message sent.&quot; ,  &quot;info&quot; ) else : appuifw.note( u&quot;Messages   not sent!&quot; ,  &quot;info&quot; ) s60test.send_sms.py
Beispiel „Versenden einer SMS“ (2) Ausführung
Beispiel „Versenden einer SMS“ (3) Erfolgskontrolle beim Empfänger
Beispiel „SMS-Empfang und Sound“ (1) Funktionen ,[object Object],[object Object]
Beispiel „SMS-Empfang und Sound“ (2) Source Code: Sound-Operationen class  SoundRecorder: filename =  'e:boo.wav'   # Drive E: is SD card mySound = None def  record(self): self.mySound = audio.Sound.open(self.filename) self.mySound.record() def  play(self): try : self.mySound = audio.Sound.open(self.filename) self.mySound.play() except : appuifw.note(u &quot;No sound recorded!&quot; ,  &quot;error&quot; ) def  stop(self): if  self.mySound:  self.mySound.stop() self.mySound.close() def  clear(self): self.stop() os.remove(self.filename)
Beispiel „SMS-Empfang und Sound“ (3) Source Code: SMS-Empfang recorder = SoundRecorder() def  message_received(msg_id): box = inbox.Inbox() sms_text = box.content(msg_id)  appuifw.note(u &quot;sms content: &quot;  + sms_text ,  &quot;info&quot; ) if  sms_text ==  &quot;play&quot; : recorder.play() elif  sms_text ==  &quot;record&quot; : recorder.record() elif  sms_text ==  &quot;stop&quot; : recorder.stop() elif  sms_text ==  &quot;clear&quot; : recorder.clear() app_lock.signal() box = inbox.Inbox() box.bind(message_received)
Beispiel „Kamera und File-Upload“ (1) Aufnahme von Bildern import  time import  appuifw import  camera filename = time.strftime( &quot;n95-%Y%m%d%H%M%S.jpg&quot; , time.gmtime()) image = camera.take_photo() image.save(filename) appuifw.note(u &quot;Photo   saved to %s&quot;  % filename,  'info' ) if  imageToURL(filename) == 200: appuifw.note(u &quot;Photo   uploaded successfully.&quot; ,  'info' ) else : appuifw.note(u &quot;Photo   upload failed!&quot; ,  'error' )
Kamera-Einstellungen Optionen von camera.take_photo() def  take_photo( mode= 'RGB16' , size=(640, 480), zoom=0, flash= 'none' , exposure= 'auto' , white_balance= 'auto' ):
Beispiel „Kamera und File-Upload“ (2) Hochladen auf Server mit httplib import  httplib, urllib, base64, os.path def  imageToURL(aPath): data = open(aPath,  'rb' ).read()  # read binary data of picture encodedData = base64.encodestring(data)  # encoded it to base64 headers = { &quot;Content-type&quot; :  &quot;application/x-www-form-urlencoded&quot; , &quot;Accept&quot; :  &quot;text/plain&quot; ,} params = urllib.urlencode({u 'fileName' :    os.path.split(aPath)[1], u 'data' :encodedData}) conn = httplib.HTTPConnection( &quot;www.onyame.de&quot; ) conn.request( &quot;POST&quot; ,  &quot;/image_uploader.php&quot; , params, headers) response = conn.getresponse() conn.close() return  response.status  Quelle: http://wiki.forum.nokia.com/index.php/How_to_upload_a_file_to_server_with_application/x-www-form-urlencoded
Beispiel „Kamera und File-Upload“ (3) Hochladen auf Server
Beispiel „Kamera und File-Upload“ (4) Erfolgskontrolle ,[object Object]
Beispiel „Mandelbrot-Menge“ (1) Rahmenprogramm import  e32 from  appuifw  import  * app.screen =  'full' app.body = canvas = Canvas() width, height = canvas.size xaxis = width/2 yaxis = height/1.5 scale = 60 iterations = 25 # <<iteration>> lock = e32.Ao_lock() app.exit_key_handler = lock.signal lock.wait()
Beispiel „Mandelbrot-Menge“ (2) Iterationsschleife for  y  in  range(height): for  x  in  range(width): magnitude = 0 z = 0+0j c = complex(float(y-yaxis)/scale,    float(x-xaxis)/scale) for  i  in  range(iterations): z = z**2+c if  abs(z) > 2: v = 765*i/iterations if  v > 510: color = (255, 255, v%255) elif  v > 255: color = (255, v%255, 0) else : color = (v%255, 0, 0) break else : color = (0, 0, 0) canvas.point((x, y), color) e32.ao_yield()
Beispiel „Kontakte-Datenbank“ import  contacts db = contacts.open() print u &quot;Searching contacts…&quot; found = db.find( 'guy' )  # search in name, email, etc. for  guy  in  found: firstname = guy.find( 'first_name' )[0].value company = guy.find( 'company_name' )[0].value email_address = guy.find( 'email_address' )[0].value print  u &quot;%s  %s  %s&quot;  %  (firstname, company, email_address)
Beispiel „Kalender“ ,[object Object],[object Object]
Beispiel „Bewegungssensor“ (1) Abfrage der Beschleunigungssensoren import  sensor sensors = sensor.sensors() # Does this device have Accelerator Sensor if  sensors.has_key( 'AccSensor' ): SENSOR_ACC = True sensor_data = sensors[ 'AccSensor' ] sensor_acc = sensor.Sensor(sensor_data[ 'id' ],  sensor_data[ 'category' ]) sensor_acc.connect(handle_sensor_raw) def  handle_sensor_raw(a_data): if  a_data.has_key( 'data_1' ): acc_data_1 = a_data[ 'data_1' ] acc_data_2 = a_data[ 'data_2' ] acc_data_3 = a_data[ 'data_3' ]
Beispiel „Bewegungssensor“ (2) Graphische Aufbereitung: „Sensor Analyzer“  ,[object Object]
Beispiel „Location Based Service“ Auswertung der GSM Cell ID ,[object Object],import  location HOME_CELL_ID = u&quot;98521779&quot; WIFE = u&quot;+49173247****“ entries = [u &quot;freu mich auf Dich!&quot; ,  u &quot;hab Hunger.&quot; ,  u &quot;hab schlechte Laune.&quot; ] listbox = appuifw.Listbox(entries, shout)  home = 0 while  home == 0: country, provider, lac, cell = location.gsm_location() if  (cell== HOME_CELL_ID): home = 1 message = u &quot;Bin gleich zuhause und %s&quot;  % mood  messaging.sms_send(WIFE, message)
Links ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Anlaufstellen für Hilfe ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Python für andere mobile Geräte ,[object Object],[object Object]
Literatur ,[object Object]

Más contenido relacionado

La actualidad más candente

Dallo schema corporeo al vissuto corporeo
Dallo schema corporeo al vissuto corporeo Dallo schema corporeo al vissuto corporeo
Dallo schema corporeo al vissuto corporeo
imartini
 
Breve introduzione alla grafica pubblicitaria
Breve introduzione alla grafica pubblicitariaBreve introduzione alla grafica pubblicitaria
Breve introduzione alla grafica pubblicitaria
Simone Terenziani
 
Significato del disegno infantile
Significato del disegno infantileSignificato del disegno infantile
Significato del disegno infantile
Azza
 
Analizat financiare
Analizat financiareAnalizat financiare
Analizat financiare
baron
 
La vita dell'universo
La vita dell'universoLa vita dell'universo
La vita dell'universo
imartini
 
Paraja dhe banka punim seminarik
Paraja dhe banka punim seminarikParaja dhe banka punim seminarik
Paraja dhe banka punim seminarik
Shpejtim Rudi
 
12 le emozioni
12    le emozioni12    le emozioni
12 le emozioni
imartini
 
Funzione del gioco
Funzione del giocoFunzione del gioco
Funzione del gioco
imartini
 
Corresponsabilità educativa tra scuola e famiglia
Corresponsabilità educativa tra scuola e famigliaCorresponsabilità educativa tra scuola e famiglia
Corresponsabilità educativa tra scuola e famiglia
Maria Filomia
 

La actualidad más candente (20)

Infanzia-inclusione e TIC
Infanzia-inclusione e TICInfanzia-inclusione e TIC
Infanzia-inclusione e TIC
 
Presentazione progetto di marketing (mercato valigeria)
Presentazione progetto di marketing (mercato valigeria)Presentazione progetto di marketing (mercato valigeria)
Presentazione progetto di marketing (mercato valigeria)
 
Dallo schema corporeo al vissuto corporeo
Dallo schema corporeo al vissuto corporeo Dallo schema corporeo al vissuto corporeo
Dallo schema corporeo al vissuto corporeo
 
Geshtaltizmi
GeshtaltizmiGeshtaltizmi
Geshtaltizmi
 
Programi Alpha Web
Programi Alpha WebProgrami Alpha Web
Programi Alpha Web
 
Breve introduzione alla grafica pubblicitaria
Breve introduzione alla grafica pubblicitariaBreve introduzione alla grafica pubblicitaria
Breve introduzione alla grafica pubblicitaria
 
Significato del disegno infantile
Significato del disegno infantileSignificato del disegno infantile
Significato del disegno infantile
 
Analizat financiare
Analizat financiareAnalizat financiare
Analizat financiare
 
PNSD, il punto sulle azioni avviate in attuazione del Piano Nazionale Scuola ...
PNSD, il punto sulle azioni avviate in attuazione del Piano Nazionale Scuola ...PNSD, il punto sulle azioni avviate in attuazione del Piano Nazionale Scuola ...
PNSD, il punto sulle azioni avviate in attuazione del Piano Nazionale Scuola ...
 
La metodologia Eas e il Lesson Planning
La metodologia Eas e il Lesson PlanningLa metodologia Eas e il Lesson Planning
La metodologia Eas e il Lesson Planning
 
La vita dell'universo
La vita dell'universoLa vita dell'universo
La vita dell'universo
 
Paraja dhe banka punim seminarik
Paraja dhe banka punim seminarikParaja dhe banka punim seminarik
Paraja dhe banka punim seminarik
 
Apprendimento letto scrittura _Fusi
Apprendimento letto scrittura _FusiApprendimento letto scrittura _Fusi
Apprendimento letto scrittura _Fusi
 
Amortizimi
AmortizimiAmortizimi
Amortizimi
 
12 le emozioni
12    le emozioni12    le emozioni
12 le emozioni
 
Checklists for an Effective Lead Generation Campaign
Checklists for an Effective Lead Generation CampaignChecklists for an Effective Lead Generation Campaign
Checklists for an Effective Lead Generation Campaign
 
Plan de transport 12/2020 2023 - Hainaut
Plan de transport 12/2020 2023 - HainautPlan de transport 12/2020 2023 - Hainaut
Plan de transport 12/2020 2023 - Hainaut
 
Analiza financiare
Analiza financiareAnaliza financiare
Analiza financiare
 
Funzione del gioco
Funzione del giocoFunzione del gioco
Funzione del gioco
 
Corresponsabilità educativa tra scuola e famiglia
Corresponsabilità educativa tra scuola e famigliaCorresponsabilità educativa tra scuola e famiglia
Corresponsabilità educativa tra scuola e famiglia
 

Similar a Handy-Programmierung mit Python

C3 Wichterich & Partner Mobile Solutions Blackberry Nokia Intellisync
C3 Wichterich & Partner Mobile Solutions Blackberry Nokia IntellisyncC3 Wichterich & Partner Mobile Solutions Blackberry Nokia Intellisync
C3 Wichterich & Partner Mobile Solutions Blackberry Nokia Intellisync
guest608dc7
 

Similar a Handy-Programmierung mit Python (20)

C3 Wichterich & Partner Mobile Solutions Blackberry Nokia Intellisync
C3 Wichterich & Partner Mobile Solutions Blackberry Nokia IntellisyncC3 Wichterich & Partner Mobile Solutions Blackberry Nokia Intellisync
C3 Wichterich & Partner Mobile Solutions Blackberry Nokia Intellisync
 
Top 10 Internet Trends 2008
Top 10 Internet Trends 2008Top 10 Internet Trends 2008
Top 10 Internet Trends 2008
 
CeBit 2001 Messebericht
CeBit 2001 MesseberichtCeBit 2001 Messebericht
CeBit 2001 Messebericht
 
Top 10 Internet Trends 2002
Top 10 Internet Trends 2002Top 10 Internet Trends 2002
Top 10 Internet Trends 2002
 
Top 10 Internet Trends 2006
Top 10 Internet Trends 2006Top 10 Internet Trends 2006
Top 10 Internet Trends 2006
 
Skype – Instant Messaging
Skype – Instant MessagingSkype – Instant Messaging
Skype – Instant Messaging
 
AWS Customer presentation - Voice Publishing
AWS Customer presentation - Voice PublishingAWS Customer presentation - Voice Publishing
AWS Customer presentation - Voice Publishing
 
Programmierung von Mobiltelefonen mit Python
Programmierung von Mobiltelefonen mit PythonProgrammierung von Mobiltelefonen mit Python
Programmierung von Mobiltelefonen mit Python
 
A3 MCA
A3 MCAA3 MCA
A3 MCA
 
Top 10 Internet Trends 2004
Top 10 Internet Trends 2004Top 10 Internet Trends 2004
Top 10 Internet Trends 2004
 
Ajax, Comet & Co.
Ajax, Comet & Co.Ajax, Comet & Co.
Ajax, Comet & Co.
 
iDTRONICs RFID Desktop Reader EVO HF 2.0: HID oder VCP – Einstellbare Datenau...
iDTRONICs RFID Desktop Reader EVO HF 2.0: HID oder VCP – Einstellbare Datenau...iDTRONICs RFID Desktop Reader EVO HF 2.0: HID oder VCP – Einstellbare Datenau...
iDTRONICs RFID Desktop Reader EVO HF 2.0: HID oder VCP – Einstellbare Datenau...
 
Zertifizierter projektmanager verfügbar
Zertifizierter projektmanager verfügbarZertifizierter projektmanager verfügbar
Zertifizierter projektmanager verfügbar
 
Csb Kundenforum 2007
Csb Kundenforum 2007Csb Kundenforum 2007
Csb Kundenforum 2007
 
Chatbots bauen mit dem Microsoft Bot Framework
Chatbots bauen mit dem Microsoft Bot FrameworkChatbots bauen mit dem Microsoft Bot Framework
Chatbots bauen mit dem Microsoft Bot Framework
 
Lotus Foundations Workshop Teil1
Lotus Foundations Workshop Teil1Lotus Foundations Workshop Teil1
Lotus Foundations Workshop Teil1
 
Webcast 12 09
Webcast 12 09Webcast 12 09
Webcast 12 09
 
App framework company messenger (Messaging-SDK)
App framework company messenger (Messaging-SDK)App framework company messenger (Messaging-SDK)
App framework company messenger (Messaging-SDK)
 
Microsoft Bot Framework (.NET Edition)
Microsoft Bot Framework (.NET Edition)Microsoft Bot Framework (.NET Edition)
Microsoft Bot Framework (.NET Edition)
 
DACHNUG50 MX_Workshop.pdf
DACHNUG50 MX_Workshop.pdfDACHNUG50 MX_Workshop.pdf
DACHNUG50 MX_Workshop.pdf
 

Más de Andreas Schreiber

Más de Andreas Schreiber (20)

Provenance-based Security Audits and its Application to COVID-19 Contact Trac...
Provenance-based Security Audits and its Application to COVID-19 Contact Trac...Provenance-based Security Audits and its Application to COVID-19 Contact Trac...
Provenance-based Security Audits and its Application to COVID-19 Contact Trac...
 
Visualization of Software Architectures in Virtual Reality and Augmented Reality
Visualization of Software Architectures in Virtual Reality and Augmented RealityVisualization of Software Architectures in Virtual Reality and Augmented Reality
Visualization of Software Architectures in Virtual Reality and Augmented Reality
 
Provenance as a building block for an open science infrastructure
Provenance as a building block for an open science infrastructureProvenance as a building block for an open science infrastructure
Provenance as a building block for an open science infrastructure
 
Raising Awareness about Open Source Licensing at the German Aerospace Center
Raising Awareness about Open Source Licensing at the German Aerospace CenterRaising Awareness about Open Source Licensing at the German Aerospace Center
Raising Awareness about Open Source Licensing at the German Aerospace Center
 
Open Source Licensing for Rocket Scientists
Open Source Licensing for Rocket ScientistsOpen Source Licensing for Rocket Scientists
Open Source Licensing for Rocket Scientists
 
Interactive Visualization of Software Components with Virtual Reality Headsets
Interactive Visualization of Software Components with Virtual Reality HeadsetsInteractive Visualization of Software Components with Virtual Reality Headsets
Interactive Visualization of Software Components with Virtual Reality Headsets
 
Provenance for Reproducible Data Science
Provenance for Reproducible Data ScienceProvenance for Reproducible Data Science
Provenance for Reproducible Data Science
 
Visualizing Provenance using Comics
Visualizing Provenance using ComicsVisualizing Provenance using Comics
Visualizing Provenance using Comics
 
Quantified Self Comics
Quantified Self ComicsQuantified Self Comics
Quantified Self Comics
 
Nachvollziehbarkeit mit Hinblick auf Privacy-Verletzungen
Nachvollziehbarkeit mit Hinblick auf Privacy-VerletzungenNachvollziehbarkeit mit Hinblick auf Privacy-Verletzungen
Nachvollziehbarkeit mit Hinblick auf Privacy-Verletzungen
 
Reproducible Science with Python
Reproducible Science with PythonReproducible Science with Python
Reproducible Science with Python
 
Python at Warp Speed
Python at Warp SpeedPython at Warp Speed
Python at Warp Speed
 
A Provenance Model for Quantified Self Data
A Provenance Model for Quantified Self DataA Provenance Model for Quantified Self Data
A Provenance Model for Quantified Self Data
 
Open Source im DLR
Open Source im DLROpen Source im DLR
Open Source im DLR
 
Tracking after Stroke: Doctors, Dogs and All The Rest
Tracking after Stroke: Doctors, Dogs and All The RestTracking after Stroke: Doctors, Dogs and All The Rest
Tracking after Stroke: Doctors, Dogs and All The Rest
 
High Throughput Processing of Space Debris Data
High Throughput Processing of Space Debris DataHigh Throughput Processing of Space Debris Data
High Throughput Processing of Space Debris Data
 
Bericht von der QS15 Conference & Exposition
Bericht von der QS15 Conference & ExpositionBericht von der QS15 Conference & Exposition
Bericht von der QS15 Conference & Exposition
 
Telemedizin: Gesundheit, messbar für jedermann
Telemedizin: Gesundheit, messbar für jedermannTelemedizin: Gesundheit, messbar für jedermann
Telemedizin: Gesundheit, messbar für jedermann
 
Big Python
Big PythonBig Python
Big Python
 
Quantified Self mit Wearable Devices und Smartphone-Sensoren
Quantified Self mit Wearable Devices und Smartphone-SensorenQuantified Self mit Wearable Devices und Smartphone-Sensoren
Quantified Self mit Wearable Devices und Smartphone-Sensoren
 

Handy-Programmierung mit Python

  • 1. Handy-Programmierung mit Python Symbian S60 Andreas Schreiber < [email_address] > Tech Talk, DLR Köln-Porz, 15.07.2008
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. “ Hello World” import appuifw appuifw.app.title = u „Hello World&quot; appuifw.note(u &quot;Hello World!&quot; , 'info' )
  • 11. Ausführen von Python-Code (1) Skripte (“Run script”)
  • 12. Ausführen von Python-Code (2) Interaktive Konsole
  • 13. Ausführen von Python-Code (3) Bluetooth-Konsole
  • 14.  
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 26. Beispiel „Versenden einer SMS“ (1) Source Code import appuifw import messaging data = appuifw.query(u &quot;what are you doing?&quot; , &quot;text&quot; ) receiver = &quot;+49172940****&quot; if appuifw.query(u &quot;Send message?&quot; , &quot;query&quot; ) == True : messaging.sms_send(receiver, data) appuifw.note(u &quot;Message sent.&quot; , &quot;info&quot; ) else : appuifw.note( u&quot;Messages not sent!&quot; , &quot;info&quot; ) s60test.send_sms.py
  • 27. Beispiel „Versenden einer SMS“ (2) Ausführung
  • 28. Beispiel „Versenden einer SMS“ (3) Erfolgskontrolle beim Empfänger
  • 29.
  • 30. Beispiel „SMS-Empfang und Sound“ (2) Source Code: Sound-Operationen class SoundRecorder: filename = 'e:boo.wav' # Drive E: is SD card mySound = None def record(self): self.mySound = audio.Sound.open(self.filename) self.mySound.record() def play(self): try : self.mySound = audio.Sound.open(self.filename) self.mySound.play() except : appuifw.note(u &quot;No sound recorded!&quot; , &quot;error&quot; ) def stop(self): if self.mySound: self.mySound.stop() self.mySound.close() def clear(self): self.stop() os.remove(self.filename)
  • 31. Beispiel „SMS-Empfang und Sound“ (3) Source Code: SMS-Empfang recorder = SoundRecorder() def message_received(msg_id): box = inbox.Inbox() sms_text = box.content(msg_id) appuifw.note(u &quot;sms content: &quot; + sms_text , &quot;info&quot; ) if sms_text == &quot;play&quot; : recorder.play() elif sms_text == &quot;record&quot; : recorder.record() elif sms_text == &quot;stop&quot; : recorder.stop() elif sms_text == &quot;clear&quot; : recorder.clear() app_lock.signal() box = inbox.Inbox() box.bind(message_received)
  • 32. Beispiel „Kamera und File-Upload“ (1) Aufnahme von Bildern import time import appuifw import camera filename = time.strftime( &quot;n95-%Y%m%d%H%M%S.jpg&quot; , time.gmtime()) image = camera.take_photo() image.save(filename) appuifw.note(u &quot;Photo saved to %s&quot; % filename, 'info' ) if imageToURL(filename) == 200: appuifw.note(u &quot;Photo uploaded successfully.&quot; , 'info' ) else : appuifw.note(u &quot;Photo upload failed!&quot; , 'error' )
  • 33. Kamera-Einstellungen Optionen von camera.take_photo() def take_photo( mode= 'RGB16' , size=(640, 480), zoom=0, flash= 'none' , exposure= 'auto' , white_balance= 'auto' ):
  • 34. Beispiel „Kamera und File-Upload“ (2) Hochladen auf Server mit httplib import httplib, urllib, base64, os.path def imageToURL(aPath): data = open(aPath, 'rb' ).read() # read binary data of picture encodedData = base64.encodestring(data) # encoded it to base64 headers = { &quot;Content-type&quot; : &quot;application/x-www-form-urlencoded&quot; , &quot;Accept&quot; : &quot;text/plain&quot; ,} params = urllib.urlencode({u 'fileName' : os.path.split(aPath)[1], u 'data' :encodedData}) conn = httplib.HTTPConnection( &quot;www.onyame.de&quot; ) conn.request( &quot;POST&quot; , &quot;/image_uploader.php&quot; , params, headers) response = conn.getresponse() conn.close() return response.status Quelle: http://wiki.forum.nokia.com/index.php/How_to_upload_a_file_to_server_with_application/x-www-form-urlencoded
  • 35. Beispiel „Kamera und File-Upload“ (3) Hochladen auf Server
  • 36.
  • 37. Beispiel „Mandelbrot-Menge“ (1) Rahmenprogramm import e32 from appuifw import * app.screen = 'full' app.body = canvas = Canvas() width, height = canvas.size xaxis = width/2 yaxis = height/1.5 scale = 60 iterations = 25 # <<iteration>> lock = e32.Ao_lock() app.exit_key_handler = lock.signal lock.wait()
  • 38. Beispiel „Mandelbrot-Menge“ (2) Iterationsschleife for y in range(height): for x in range(width): magnitude = 0 z = 0+0j c = complex(float(y-yaxis)/scale, float(x-xaxis)/scale) for i in range(iterations): z = z**2+c if abs(z) > 2: v = 765*i/iterations if v > 510: color = (255, 255, v%255) elif v > 255: color = (255, v%255, 0) else : color = (v%255, 0, 0) break else : color = (0, 0, 0) canvas.point((x, y), color) e32.ao_yield()
  • 39. Beispiel „Kontakte-Datenbank“ import contacts db = contacts.open() print u &quot;Searching contacts…&quot; found = db.find( 'guy' ) # search in name, email, etc. for guy in found: firstname = guy.find( 'first_name' )[0].value company = guy.find( 'company_name' )[0].value email_address = guy.find( 'email_address' )[0].value print u &quot;%s %s %s&quot; % (firstname, company, email_address)
  • 40.
  • 41. Beispiel „Bewegungssensor“ (1) Abfrage der Beschleunigungssensoren import sensor sensors = sensor.sensors() # Does this device have Accelerator Sensor if sensors.has_key( 'AccSensor' ): SENSOR_ACC = True sensor_data = sensors[ 'AccSensor' ] sensor_acc = sensor.Sensor(sensor_data[ 'id' ], sensor_data[ 'category' ]) sensor_acc.connect(handle_sensor_raw) def handle_sensor_raw(a_data): if a_data.has_key( 'data_1' ): acc_data_1 = a_data[ 'data_1' ] acc_data_2 = a_data[ 'data_2' ] acc_data_3 = a_data[ 'data_3' ]
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.