Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Get mobile cpu speed

import miso
print miso.get_hal_attr(11)  # 104000 for my 6600

Keep light on using thread

Copy-paste version
import e32, miso, thread
running = 1
def lighton():
  while running:
    miso.reset_inactivity_time()
    e32.ao_sleep(5)

thread.start_new_thread(lighton, ())
# end by set running = 0


2 functions (lighton, lightoff) version.
import e32
import miso
import thread

flag = 1
def _lighton():
    while flag:
        miso.reset_inactivity_time()
        e32.ao_sleep(5)

def lighton():
    thread.start_new_thread(_lighton, ())

def lightoff():
    global flag
    flag = 0

Keeping the screen light on

Miso library provides a feature to turn your phone's screen light on.
import miso
miso.reset_inactivity_time()

Read the documentation and download miso from here.

To make it always on. You can put the call into a loop
with ao_sleep.
def light_on():
    import miso, e32
    miso.reset_inactivity_time()
    e32.ao_sleep(10, light_on)  # forever loop
light_on()      # always keep light on

Make a phone vibrating periodically

Some of my friends who practise mindfulness meditation
use an alarm device that vibrate every 2 minutes and
he will become mindful then.
Danny O'Brien of Life Hacks fame asked me about this too.
So, here's a short example (without parameter setting GUI)
that does exactly this.

You need to have miso library install. Only Series 60
2nd Ed FP2 device (Nokia 6630, Nokia 6680) can be used.
See vibrate(...) in miso documentation
http://pdis.hiit.fi/pdis/download/miso/miso-1.40-api.html
import appuifw, miso, e32

# run-and-break type of app
running = 1
def set_exit():
    global running
    running = 0
appuifw.app.exit_key_handler= set_exit

# main loop
while running:
    miso.vibrate(500, 100)  # vibrate for 500 millisec, at full speed
    e32.ao_sleep(10)   # vibrate every 10 seconds

I don't have a FP2 phone to test this. Though the code is
pretty straight forward, please report if there is a problem.
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS