[openfirmware] [commit] r3776 - cpu/x86/pc/olpc/sstools
repository service
svn at openfirmware.info
Thu Jul 9 04:30:10 CEST 2015
Author: quozl
Date: Thu Jul 9 04:30:09 2015
New Revision: 3776
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3776
Log:
OLPC XO-4 - screenshot feature extensions, cache of shots
Modified:
cpu/x86/pc/olpc/sstools/bmp.fth
Modified: cpu/x86/pc/olpc/sstools/bmp.fth
==============================================================================
--- cpu/x86/pc/olpc/sstools/bmp.fth Wed Jul 1 07:55:06 2015 (r3775)
+++ cpu/x86/pc/olpc/sstools/bmp.fth Thu Jul 9 04:30:09 2015 (r3776)
@@ -1,4 +1,4 @@
-\ dump XO-1 frame buffer in BMP24 format
+\ dump XO-4 frame buffer in BMP24 format
dev /display
: fb-va ( -- fb ) frame-buffer-adr ;
@@ -14,19 +14,20 @@
h# 36 constant /bmp-hdr
/bmp-hdr buffer: bmp-hdr
+0 value fb-va-orig
0 value fb-va
: put-plane ( -- )
- " fb-va" screen-ih $call-method to fb-va
+ fb-va-orig to fb-va
bmp-height 0 do
bmp-width
0 ?do
- fb-va w@ ( rgb565 )
- 565>rgb ( r g b )
- ofd @ fputc
- ofd @ fputc
- ofd @ fputc
- fb-va wa1+ to fb-va
+ fb-va w@ ( rgb565 )
+ 565>rgb ( r g b )
+ ofd @ fputc
+ ofd @ fputc
+ ofd @ fputc
+ fb-va wa1+ to fb-va
loop
loop
;
@@ -58,6 +59,7 @@
writing
screen-wh to bmp-height to bmp-width
+ " fb-va" screen-ih $call-method to fb-va-orig
put-header
put-plane
ofd @ fclose
@@ -72,3 +74,94 @@
['] evaluate catch ?dup if nip nip .error then
screen-ih add-output
;
+
+\ special screenshots to cache, then later save
+
+: red-on ols-led-on ;
+: red-off ols-led-off ols-led-ec-control ;
+: red-blinks ( n -- ) 0 do red-on d# 50 ms red-off d# 200 ms loop ;
+: orange-on led-storage-gpio# gpio-set ols-led-on ols-assy-mode-on ;
+: orange-off led-storage-gpio# gpio-clr ols-led-off ols-assy-mode-off ;
+
+0 value cb-va \ base of cache
+0 value /cb-va \ size of image
+0 value #cb \ number of images in cache
+
+: .cb ( -- ) ." you have " #cb .d ." images in cache" cr ;
+
+: cb-wipe ( -- )
+ screen-wh to bmp-height to bmp-width
+ " fb-va" screen-ih $call-method to fb-va-orig
+ bmp-height bmp-width * 2* to /cb-va
+ load-base to cb-va
+ 0 to #cb
+ .cb
+;
+
+: >cb ( #cb -- cb-va' )
+ cb-va swap /cb-va * +
+;
+
+: cb-show ( -- )
+ fb-va-orig #cb >cb /cb-va move \ save screen beyond cache
+ #cb 0 ?do
+ i >cb fb-va-orig /cb-va move \ show an image
+ key drop \ wait for a key
+ loop
+ #cb >cb fb-va-orig /cb-va move \ restore screen
+ .cb
+;
+
+: saving ( #cb fn$ -- )
+ writing ( #cb )
+ >cb to fb-va-orig ( )
+ put-header
+ put-plane
+ ofd @ fclose
+;
+
+: cb-save ( -- )
+ #cb 0 ?do
+ i
+ ts$
+ " u:\"
+ " saving %s%s.bmp" sprintf
+ 2dup type cr
+ orange-on
+ ['] evaluate catch ?dup if nip nip .error then
+ orange-off
+ d# 1000 ms \ hack to enforce unique file name
+ loop
+ .cb
+;
+
+: ?cb-wait-key-up
+ red-on
+ begin gpio-rotate-button? 0= until
+ red-off d# 200 ms
+;
+
+: cb-key-down ( -- )
+ ?cb-wait-key-up \ wait for key release
+ #cb 1+ red-blinks \ blink red led to show cache size
+ fb-va-orig #cb >cb /cb-va move \ save image to cache
+ #cb 1+ to #cb \ increment image counter
+ red-off \ turn off the led
+;
+
+: cb-help
+ cr
+ ." XO-4 screenshot to cache utility 2015-06-19" cr
+ " commands" cr
+ cr
+ ." .cb show how many images are in cache" cr
+ ." cb-wipe empty the cache" cr
+ ." cb-show show the cache, one by one" cr
+ ." cb-save save the cache to USB drive" cr
+ cr
+;
+cb-help
+cb-wipe
+
+: cb-alarm ( -- ) gpio-rotate-button? if cb-key-down then ;
+' cb-alarm d# 100 alarm \ schedule regular asynchronous task
More information about the openfirmware
mailing list