Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsding committed May 16, 2021
0 parents commit 7ccd44a
Show file tree
Hide file tree
Showing 26 changed files with 303 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.kra
17 changes: 17 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rockbox-theme-podamp
====================

This is a WPS (While Playing screen) for iPod minis running Rockbox that looks
like the Winamp(r) main window.

It comes in two variants, one with a light background, and one with a dark one.


License
-------

This work is licensed under a Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International License.

Big shout out to Konsti (https://twitter.com/balkanfur) who suggested the
"podAmp" name.
Binary file added fonts/06-WinAmp2.fnt
Binary file not shown.
67 changes: 67 additions & 0 deletions package_theme.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'fileutils'
require 'tmpdir'

DARK_THEME = ARGV.include?('dark')

THEME_NAME = if DARK_THEME then 'podAmp-dark' else 'podAmp' end

DEST_DIR = File.join(__dir__, 'dist', THEME_NAME)
DEST_ZIP = File.join(__dir__, 'dist', "#{THEME_NAME}.zip")

if ARGV.include?("clean")
puts "===> Removing dest dir"
FileUtils.rm_f(DEST_DIR)
end
FileUtils.mkdir_p(DEST_DIR)

COPIED_FILES = Array.new

File.join(DEST_DIR, 'wps', "#{THEME_NAME}.wps").tap do |dest_file|
puts "===> Copying WPS theme"
FileUtils.mkdir_p(File.dirname(dest_file))
COPIED_FILES << dest_file
puts dest_file
FileUtils.cp(File.join(__dir__, 'wps', 'podAmp.wps'), dest_file)
end

def copy(kind, pattern, dest_dir)
source_files = Dir[*pattern]
return if source_files.empty?

puts "===> Copying #{kind}"
FileUtils.mkdir_p(dest_dir)
source_files.each do |source_file|
dest_file = File.join(dest_dir, File.basename(source_file))
COPIED_FILES << dest_file
puts dest_file
FileUtils.cp(source_file, dest_file)
end
end

copy :fonts, File.join(__dir__, 'fonts', '*.fnt'), File.join(DEST_DIR, 'fonts')
copy :images, File.join(__dir__, 'wps', THEME_NAME, '*.bmp'), File.join(DEST_DIR, 'wps', THEME_NAME)

puts "===> Creating zip archive for distribution ..."
FileUtils.rm_f DEST_ZIP
rootdir = __dir__
dirs = COPIED_FILES.map { |x| File.dirname(x.sub("#{rootdir}/dist/#{THEME_NAME}", '.rockbox')) }.uniq

Dir.mktmpdir do |tmpdir|
Dir.chdir(tmpdir) do
dirs.each do |d|
puts "mkdir\t#{d}"
FileUtils.mkdir_p(d)
end
COPIED_FILES.each do |source_file|
dest_file = source_file.sub("#{rootdir}/dist/#{THEME_NAME}", '.rockbox')
puts "cp\t#{source_file} -> #{dest_file}"
FileUtils.cp(source_file, dest_file)
end
zip_command = ["zip", DEST_ZIP, "-r", ".rockbox"]
puts zip_command.join(' ')
system *zip_command
end
end
13 changes: 13 additions & 0 deletions tools/gems.locked
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
GEM
remote: https://rubygems.org/
specs:
rmagick (4.1.2)

PLATFORMS
ruby

DEPENDENCIES
rmagick (~> 4.1)

BUNDLED WITH
2.1.4
6 changes: 6 additions & 0 deletions tools/gems.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

source "https://rubygems.org"


gem "rmagick", "~> 4.1"
83 changes: 83 additions & 0 deletions tools/skintext2bdf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env ruby
# convert a text.bmp over to a .bdf file for feeding it to rockbox's convbdf
#
# usage:
# ./skintext2bdf.rb text.bmp > 06-WinAmp2.bdf
# .../rockbox/tools/convbdf -f 06-WinAmp2.bdf
#
# known limitations:
# - the '@' symbol is wider and therefore skipped for now
# - it only works with text.bmp having a black background
# - the '&' symbol is weirdly cutoff

require 'rmagick'

CHAR_WIDTH = 5
CHAR_HEIGHT = 6

BACKGROUND = Magick::Pixel.new(0, 0, 0, 65535) # background colour. everything else in the image will be filled

# Rows: rows in text.txt
# Columns: what characters this letter is mapped to
TEXT_CHARS = [
[['A', 'a'], ['B', 'b'], ['C', 'c'], ['D', 'd'], ['E', 'e'], ['F', 'f'], ['G', 'g'], ['H', 'h'], ['I', 'i'], ['J', 'j'], ['K', 'k'], ['L', 'l'], ['M', 'm'], ['N', 'n'], ['O', 'o'], ['P', 'p'], ['Q', 'q'], ['R', 'r'], ['S', 's'], ['T', 't'], ['U', 'u'], ['V', 'v'], ['W', 'w'], ['X', 'x'], ['Y', 'y'], ['Z', 'z'], ['"'], [], [], [' ']],
[['0'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9'], ['…'], ['.'], [':'], ['(', '<'], [')', '>'], ['-'], ["'"], ['!'], ['_'], ['+'], ['\\'], ['/'], ['[', '{'], [']', '}'], ['^'], ['&'], ['%'], [','], ['='], ['$'], ['#']],
[['Å', 'å'], ['Ö', 'ö'], ['Ä', 'ä'], ['?'], ['*']]
]

bitmap_file = ARGV.shift
abort "usage: #$0 TEXT.BMP" unless bitmap_file

bitmap = Magick::Image.read(bitmap_file).first

# write BDF header
puts 'STARTFONT 2.1'
puts 'FONT WinAmp2'
puts "SIZE #{CHAR_HEIGHT} 75 75"

DESCENT = 1

puts "FONTBOUNDINGBOX #{CHAR_WIDTH} #{CHAR_HEIGHT} 0 -#{DESCENT}"
puts 'STARTPROPERTIES 4'
puts "FONT_ASCENT #{CHAR_HEIGHT}"
puts "FONT_DESCENT #{DESCENT}"
puts 'CHARSET_REGISTRY "ISO10646"'
puts 'CHARSET_ENCODING "1"'
puts "ENDPROPERTIES"
puts "CHARS #{TEXT_CHARS.flatten.size}"

TEXT_CHARS.each_with_index do |chars, row|
chars.each_with_index do |char, column|
# build bitmap for char
char_bitmap = []
xoff = CHAR_WIDTH * column
yoff = CHAR_HEIGHT * row
CHAR_HEIGHT.times do |crow|
char_row = 0
CHAR_WIDTH.times do |ccol|
char_row |= 1 unless bitmap.pixel_color(xoff + ccol, yoff + crow) == BACKGROUND
char_row <<= 1
end
char_row <<= 1
char_bitmap << char_row
end

char.each do |c|
puts 'STARTCHAR U+%04X' % c.ord
puts 'ENCODING %d' % c.ord

puts "SWIDTH #{CHAR_WIDTH * 1000} 0"
puts "DWIDTH #{CHAR_WIDTH} 0"
puts "BBX #{CHAR_WIDTH + 1} #{CHAR_HEIGHT} 0 -#{DESCENT}"

puts 'BITMAP'
char_bitmap.each do |crow|
puts('%02X' % crow)
end

puts 'ENDCHAR'
end
end
end

puts 'ENDFONT'
Binary file added wps/podAmp-dark/buffering.bmp
Binary file not shown.
Binary file added wps/podAmp-dark/numbers.bmp
Binary file not shown.
Binary file added wps/podAmp-dark/playpaus.bmp
Binary file not shown.
Binary file added wps/podAmp-dark/seekbar.bmp
Binary file not shown.
Binary file added wps/podAmp-dark/seekbar_backdrop.bmp
Binary file not shown.
Binary file added wps/podAmp-dark/volume.bmp
Binary file not shown.
Binary file added wps/podAmp-dark/volume_active.bmp
Binary file not shown.
Binary file added wps/podAmp-dark/volume_backdrop.bmp
Binary file not shown.
Binary file added wps/podAmp-dark/wps.bmp
Binary file not shown.
116 changes: 116 additions & 0 deletions wps/podAmp.wps
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# podAmp Rockbox theme
#
# Theme made by Georg Gadinger <[email protected]> in 2021.
# Licensed under CC BY-NC-SA

# Disable status bar
%wd
# Set backdrop
%X(wps.bmp)

####################
# Fonts and images #
####################
%Fl(2,06-WinAmp2.fnt)

%xl(seekbar, seekbar.bmp, 0, 0)
%xl(sbbd, seekbar_backdrop.bmp, 0, 0)
%xl(volume, volume.bmp, 0, 0)
%xl(volume_active, volume_active.bmp, 0, 0)
%xl(volbd, volume_backdrop.bmp, 0, 0)
%xl(numbers, numbers.bmp, 0, 0, 11)
%xl(playpaus, playpaus.bmp, 0, 0, 9)
%xl(buffering, buffering.bmp, 0, 0, 2)

#############
# Viewports #
#############
# Display volume if there's a change in volume, infotext otherwise
%?mv<%Vd(infovol)|%Vd(infoscroller)>
%Vd(kbps)
%Vd(khz)
# Same deal as before, but with the active volume slider
%?mv<%Vd(volume_active)|%Vd(volume)>
# If shuffle is active, render the "active LED" part of the shuffle button
%?if(%ps, =, s)<%Vd(shuffle_active)>
%Vd(seekbar)

# TODO: figure out how rockbox handles tracks that are >1 hour in length
# for now the display will be cut off on tracks longer than 99:59mins
#%Vd(timedigit1)
%Vd(timedigit2)
%Vd(timedigit3)
%Vd(timedigit4)
%Vd(timedigit5)

%Vd(playpaus)
%?if(%mp, =, 2)<%Vd(buffering)>

########################
# Current time in song #
########################
# first timedigit skipped, see TODO above
#%Vl(timedigit1, 34, 21, 9, 13, -)
#%xd(numbers, %ss(-1, 1, %pc, number))

%Vl(timedigit2, 46, 21, 9, 13, -)
# HACK: need to compare with the substring of the entire string of %pc, as
# %?if turns %pc into a number (seconds) otherwise.
%?if(%ss(0, 4, %pc), =, %ss(0, -, %pc))<%xd(numbers, 1)|%xd(numbers, %ss(0, 1, %pc, number))>

%Vl(timedigit3, 58, 21, 9, 13, -)
%?if(%ss(0, 4, %pc), =, %ss(0, -, %pc))<%xd(numbers, %ss(0, 1, %pc, number))|%xd(numbers, %ss(1, 1, %pc, number))>

%Vl(timedigit4, 76, 21, 9, 13, -)
%?if(%ss(0, 4, %pc), =, %ss(0, -, %pc))<%xd(numbers, %ss(2, 1, %pc, number))|%xd(numbers, %ss(3, 1, %pc, number))>

%Vl(timedigit5, 88, 21, 9, 13, -)
%?if(%ss(0, 4, %pc), =, %ss(0, -, %pc))<%xd(numbers, %ss(3, 1, %pc, number))|%xd(numbers, %ss(4, 1, %pc, number))>

#####################
# Status indicators #
#####################
%Vl(playpaus, 24, 23, 9, 9, -)
%xd(playpaus, %mp)

%Vl(buffering, 22, 23, 3, 9, -)
%?if(%lh, =, h)<%xd(buffering, 2)|%xd(buffering, 1)>

#####################
# Track information #
#####################
# current volume (displayed on change)
%Vl(infovol, 12, 43, 115, 8, 2)%Vf(3)%Vb(0)
Volume: %?if(%pv, >, 0)<+|>%pvdB

# current track
%Vl(infoscroller, 12, 43, 115, 8, 2)%Vf(3)%Vb(0)
%s%pp. %?ia<%ia - |%?iA<%iA - |>>%?it<%it|%fn> - (%pt) ***

# bitrate
%Vl(kbps, 10, 58, 16, 8, 2)%Vf(3)%Vb(0)
%ar%fb

# sample rate
%Vl(khz, 55, 58, 11, 8, 2)%Vf(3)%Vb(0)
%ar%fk

##############
# Volume bar #
##############
%Vl(volume, 9, 74, 65, 11, -)
%pv(0, 0, -, -, nobar, nofill, slider, volume, backdrop, volbd)
%Vl(volume_active, 9, 74, 65, 11, -)
%pv(0, 0, -, -, nobar, nofill, slider, volume_active, backdrop, volbd)

#####################
# Shuffle indicator #
#####################
%Vl(shuffle_active, 89, 77, 3, 2, -)%Vf(2)
%dr(0, 0, -, -)

##################
# Track position #
##################
%Vl(seekbar, 9, 90, 121, 10, -)
%pb(0, 0, -, -, nobar, nofill, slider, seekbar, backdrop, sbbd)
Binary file added wps/podAmp/buffering.bmp
Binary file not shown.
Binary file added wps/podAmp/numbers.bmp
Binary file not shown.
Binary file added wps/podAmp/playpaus.bmp
Binary file not shown.
Binary file added wps/podAmp/seekbar.bmp
Binary file not shown.
Binary file added wps/podAmp/seekbar_backdrop.bmp
Binary file not shown.
Binary file added wps/podAmp/volume.bmp
Binary file not shown.
Binary file added wps/podAmp/volume_active.bmp
Binary file not shown.
Binary file added wps/podAmp/volume_backdrop.bmp
Binary file not shown.
Binary file added wps/podAmp/wps.bmp
Binary file not shown.

0 comments on commit 7ccd44a

Please sign in to comment.