Topic: Read bend sensor in widget (Chumby One)
I'm trying to read the bend sensor (top button) on my Chumby One, in order to get an easy-to-use snooze button in Duane's custom alarm ring screen from this thread: http://forum.chumby.com/viewtopic.php?id=4570
Here's the ActionScript that I'm using (the this.x.onRelease bits are Duane's code, the bend sensor-related stuff was shamelessly stolen from this thread: http://forum.chumby.com/viewtopic.php?id=4128)
_bent = _global.ASnative(5,25);
var getbend:Number;
var lastbend:Number;
var changestate:Boolean = true;
this.snoozeButton.onRelease = function() {
this._parent._chumby_alarm.snoozeAlarm();
}
this.offButton.onRelease = function() {
this._parent._chumby_alarm.stopAlarm();
}
this.offWithMusicButton.onRelease = function() {
this._parent._chumby_alarm.stopAlarmWithMusic();
}
this.clearBackupButton.onRelease = function() {
this._parent._chumby_alarm.resetBackupAlarm();
}
this.onEnterFrame = function() {
getbend = _bent();
if (getbend != lastbend) {
changestate = true;
}
if ((getbend == 0) && changestate) {
changestate = false;
}
if ((getbend == 1) && changestate) {
this._parent._chumby_alarm.snoozeAlarm();
changestate = false;
}
lastbend = _bent();
}
All of Duane's on-screen buttons work right (of course!) but the top button doesn't do anything on either press or release.
I'm targeting FlashLite 3/ActionScript 2 in Adobe Flash CS4 (v10). Any hints on what I'm doing wrong? I don't know a ton of Flash (as you might guess from my cargo-cult programming technique!), but I do write field-programmable gate array firmware code in VHDL for a living, and this looks like it should do what I want (i.e. track changes in the state of the bend sensor, and when it is depressed, snooze the alarm). Do I need to include a library or something? Or is there just a bug in my code that I don't see? I have the frame rate set to 12 fps, btw.
Thanks for any help anybody can give me.