summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/decode.c
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2008-05-10 17:53:15 +0000
committerDominik Wenger <domonoky@googlemail.com>2008-05-10 17:53:15 +0000
commitacccee479a2e0ef1b373c7de85a70abb816682c3 (patch)
tree0f52f57d05188226721ff0b96850a1319df5a5ec /apps/plugins/mpegplayer/decode.c
parent251db062949edf0adb89ae609a53919d9a348e6e (diff)
downloadrockbox-acccee479a2e0ef1b373c7de85a70abb816682c3.zip
rockbox-acccee479a2e0ef1b373c7de85a70abb816682c3.tar.gz
rockbox-acccee479a2e0ef1b373c7de85a70abb816682c3.tar.bz2
rockbox-acccee479a2e0ef1b373c7de85a70abb816682c3.tar.xz
rbutil: Detect if Rockbox is already installed, and allow Backup bevor installing a new build.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17440 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mpegplayer/decode.c')
0 files changed, 0 insertions, 0 deletions
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
--[[
             __________               __   ___.
   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
                     \/            \/     \/    \/            \/
 $Id$

 Example Lua script

 Copyright (C) 2009 by Maurus Cuelenaere

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 KIND, either express or implied.

]]--

require("actions")   -- Contains rb.actions & rb.contexts
--require("buttons") -- Contains rb.buttons; not needed in this example

-- Example function which splashes a message for x seconds
function sayhello(seconds)
    local message = string.format("Hello world from LUA for %d seconds", seconds)
    rb.splash(seconds * rb.HZ, message)
end

-- Helper function which draws a (transparent) image at the center of the screen
function draw_image(img)
    local x, y = (rb.LCD_WIDTH - img:width()) / 2, (rb.LCD_HEIGHT - img:height()) / 2

    local func = rb.lcd_bitmap_transparent_part
              or rb.lcd_bitmap_part      -- Fallback version for grayscale targets
              or rb.lcd_mono_bitmap_part -- Fallback version for mono targets

    func(img, 0, 0, img:width(), x, y, img:width(), img:height())
    rb.lcd_update()
end

-- Helper function that acts like a normal printf() would do
local line = 0
function printf(...)
    local msg = string.format(...)
    local res, w, h = rb.font_getstringsize(msg, rb.FONT_UI)

    if(w >= rb.LCD_WIDTH) then
        rb.lcd_puts_scroll(0, line, msg)
    else
        rb.lcd_puts(0, line, msg)
    end
    rb.lcd_update()

    line = line + 1

    if(h * line >= rb.LCD_HEIGHT) then
        line = 0
    end
end

-- Helper function which reads the contents of a file
function file_get_contents(filename)
    local file = io.open(filename, "r")
    if not file then
        return nil
    end

    local contents = file:read("*all") -- See Lua manual for more information
    file:close() -- GC takes care of this if you would've forgotten it

    return contents
end

-- Helper function which saves contents to a file
function file_put_contents(filename, contents)
    local file = io.open(filename, "w+") -- See Lua manual for more information
    if not file then
        return false
    end

    local ret = file:write(contents) == true
    file:close() -- GC takes care of this if you would've forgotten it
    return ret
end

-- Clear the screen
rb.lcd_clear_display()

-- Draw an X on the screen
rb.lcd_drawline(0, 0, rb.LCD_WIDTH, rb.LCD_HEIGHT)
rb.lcd_drawline(rb.LCD_WIDTH, 0, 0, rb.LCD_HEIGHT)

if(rb.lcd_rgbpack ~= nil) then -- Only do this when we're on a color target, i.e. when LCD_RGBPACK is available
    local rectangle = rb.new_image(10, 15) -- Create a new image with width 10 and height 15
    for i=1, 10 do
        for j=1, 15 do