Author: wmb Date: 2007-09-20 00:22:01 +0200 (Thu, 20 Sep 2007) New Revision: 632
Modified: cpu/x86/pc/olpc/fw.bth dev/olpc/dcon/dcon.fth dev/pckbd.fth Log: OLPC - made it possible to control screen brightness and startup sound volume from the keyboard.
Modified: cpu/x86/pc/olpc/fw.bth =================================================================== --- cpu/x86/pc/olpc/fw.bth 2007-09-19 22:21:09 UTC (rev 631) +++ cpu/x86/pc/olpc/fw.bth 2007-09-19 22:22:01 UTC (rev 632) @@ -347,6 +347,39 @@ ' olpc-power-off to power-off [then]
+: dimmer ( -- ) screen-ih if " dimmer" screen-ih $call-method then ; +: brighter ( -- ) screen-ih if " brighter" screen-ih $call-method then ; + +dev /8042/keyboard +0 value waiting-up? +: olpc-check-abort ( scan-code -- abort? ) \ Square pressed? + last-scan over to last-scan ( scan-code old-scan-code ) + h# e0 <> if drop false exit then ( scan-code ) + + check-abort? 0= if drop false exit then ( scan-code ) + + dup h# 7f and h# 5d <> if drop false exit then ( scan-code ) + + h# 80 and if \ Up + false to waiting-up? + false ( abort? ) + else + secure? if false else waiting-up? 0= then ( abort? ) + true to waiting-up? + then +; +patch olpc-check-abort check-abort get-scan + +: handle-volume? ( scan-code -- scan-code flag ) + dup h# 43 = if dimmer true exit then + dup h# 44 = if brighter true exit then + dup h# 57 = if softer true exit then + dup h# 58 = if louder true exit then + false +; +' handle-volume? to scan-handled? +dend + \ Eliminate 4 second delay in install console for the case where \ there is no keyboard. The delay is unnecessary because the screen \ does not go blank when the device is closed. @@ -477,14 +510,6 @@ ?usb-keyboard ;
-: start-sound ( -- ) - playback-volume >r d# -9 to playback-volume - ['] load-started behavior >r - ['] noop to load-started - " rom:splash" ['] $play-wav catch if 2drop then - r> to load-started - r> to playback-volume -; : go-hook-freeze [ ' go-hook behavior compile, ] 0 " set-source" $call-screen @@ -492,11 +517,11 @@ : freeze ( -- ) ['] go-hook-freeze to go-hook ; : unfreeze ( -- ) ['] usb-quiet to go-hook ;
-: ?start-sound ( -- ) - game-key-mask h# 40 and 0= if start-sound then +: ?sound ( -- ) + game-key-mask h# 40 and 0= if sound then ; : ?freeze ( -- ) - game-key-mask h# 10 and 0= if freeze then + game-key-mask h# 40 and 0= if freeze then ; : ?games ( -- ) game-key-mask h# 20 and if @@ -517,7 +542,8 @@ fast-boot? if stdout off probe-pci - ?start-sound + ?sound + open-keyboard ?freeze ['] false to interrupt-auto-boot? probe-usb @@ -528,12 +554,11 @@ [then] auto-boot screen-ih stdout ! - open-keyboard ?usb-keyboard else banner probe-pci - ?start-sound + ?sound open-keyboard ?games ?freeze
Modified: dev/olpc/dcon/dcon.fth =================================================================== --- dev/olpc/dcon/dcon.fth 2007-09-19 22:21:09 UTC (rev 631) +++ dev/olpc/dcon/dcon.fth 2007-09-19 22:22:01 UTC (rev 632) @@ -117,6 +117,9 @@ : timeout! ( to -- ) 8 dcon! ; \ def: h# ffff : scanint! ( si -- ) 9 dcon! ; \ def: h# 0000 : bright! ( level -- ) d# 10 dcon! ; \ def: h# xxxF +: bright@ ( -- level ) d# 10 dcon@ ; +: brighter ( -- ) bright@ 1+ h# f min bright! ; +: dimmer ( -- ) bright@ 1- 0 max bright! ;
\ Colour swizzle, AA, no passthrough, backlight : set-color ( color? -- )
Modified: dev/pckbd.fth =================================================================== --- dev/pckbd.fth 2007-09-19 22:21:09 UTC (rev 631) +++ dev/pckbd.fth 2007-09-19 22:22:01 UTC (rev 632) @@ -386,6 +386,8 @@ init-data kbd-reset 0= to keyboard-present? ; +defer scan-handled? +' false to scan-handled? headerless : check-abort ( scan-code -- flag ) \ Ctrl-break pressed? check-abort? if @@ -409,12 +411,11 @@ begin get-data? while ( scan-code ) - dup enque ( scan-code ) - \ In the following code, we must be careful to unlock the \ queue before calling user-abort, because a timer interrupt \ can occur at any time after user-abort is executed. - check-abort if + dup check-abort if ( scan-code ) + drop unlock user-abort \ Wait here for long enough to ensure that an alarm timer tick \ will happen if it is going to happen. This is the safest @@ -430,7 +431,8 @@ \ if the alarm tick is turned off. d# 20 ms exit - then + then ( scan-code ) + scan-handled? if drop else enque then ( ) repeat unlock ;