PDA

View Full Version : sleep(1, 0) - does not work


korda
12-14-2008, 12:51 PM
I have been waiting on solution to minimize power consumption for 2xAA battery operated remote control.
Previous problem was reported in "wakeup pin" thread. No answers so far.
I have tried to call sleep (1, 0) from a different sub, than timer100ms hook.
This is all the same, engine does not sleep. I verified by using Fluke to measure mA.
Here is my latest transmitter script, pasted below:

def startup():
global countdown
global receiverAddress
receiverAddress = "\x00\x2f\x48"


# set button pins to INPUT
setPinDir (1, False)
setPinDir (2, False)
setPinDir (5, False)
setPinDir (6, False)

# monitor button pins
monitorPin(1, True)
monitorPin(2, True)
monitorPin(5, True)
monitorPin(6, True)

wakeupOn(1, True, True)
wakeupOn(2, True, True)
wakeupOn(5, True, True)
wakeupOn(6, True, True)

sleep(1, 0)


def buttonPress(port, state):
global countdown
rpc(receiverAddress, 'receiveState', port, state)
countdown = 1000
while countdown > 0: #time delay to TX message and then sleep
countdown -=1
sleep(1, 0)


################################################## ##############
def wakeupOn(pin, isEnabled, polarity): # default to enabling, falling edge
"""Controls "wakeup" feature for the specified GPIO (11,12,13,14)"""
canSetPolarity = True # default to the most common case
if pin==11:
mask = 0x01
# canSetPolarity = False
elif pin==12:
mask = 0x02
# canSetPolarity = False
elif pin==13:
mask = 0x04
elif pin==14:
mask = 0x10
else:
return # only pins 11-14 can do this trick

if canSetPolarity: # only pins 11-14 can do this trick
if polarity:
poke(0x16, peek(0x16) | mask) # 0x16 is KBI1SC
else:
poke(0x16, peek(0x16) & ~mask)

if isEnabled:
poke(0x17, peek(0x17) | mask) # 0x17 is KBI1PE
else:
poke(0x17, peek(0x17) & ~mask)


# Event Handlers
snappyGen.setHook(SnapConstants.HOOK_STARTUP, startup)
snappyGen.setHook(SnapConstants.HOOK_GPIN, buttonPress)

kbanks
12-15-2008, 08:38 AM
look on the "reminder" thread...