[Armadeus-commitlog] armadeus branch, master, updated. release-3.4-283-gbf0ff1b
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2011-07-03 08:39:34
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via bf0ff1bfdb1a2349d2f16744394cd1fd94baca78 (commit)
via cf77c5f418a13073f9a34aab0ae9b5c1387b31b3 (commit)
via 18152a26c24dea1dc60f12b58cb99069ae877f64 (commit)
from 36382b6bb5c84b4e1996922874bee30b7e47567d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bf0ff1bfdb1a2349d2f16744394cd1fd94baca78
Author: Julien Boibessot <jul...@ar...>
Date: Sun Jul 3 10:38:46 2011 +0200
[BUILD] Correct SDL build dir name
commit cf77c5f418a13073f9a34aab0ae9b5c1387b31b3
Author: Julien Boibessot <jul...@ar...>
Date: Sun Jul 3 10:37:35 2011 +0200
[DEMOS] Makes music player retrieve data files from system wide path also and makes it more CPU friendly
commit 18152a26c24dea1dc60f12b58cb99069ae877f64
Author: Julien Boibessot <jul...@ar...>
Date: Sat Jul 2 20:05:40 2011 +0200
[TESTS] Add gpiolib test for APF27
-----------------------------------------------------------------------
Summary of changes:
Makefile.in | 2 +-
target/demos/music_player/Makefile | 6 +-
target/demos/music_player/S60mp | 1 -
target/demos/music_player/player.c | 157 +++++++++++++++++++++--------------
target/test/test_gpio.sh | 36 ++++++---
5 files changed, 126 insertions(+), 76 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index c4b5009..4ae61e9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -47,7 +47,7 @@ ARMADEUS_STAGING_DIR:=$(BUILDROOT_BUILD_DIR)/staging_dir
ARMADEUS_TOOLCHAIN_PATH:=$(ARMADEUS_STAGING_DIR)/usr/bin
ARMADEUS_BUILD_DIR:=$(BUILDROOT_BUILD_DIR)
-ARMADEUS_SDL_DIR:=$(ARMADEUS_BUILD_DIR)/SDL-$(ARMADEUS_SDL_VERSION)
+ARMADEUS_SDL_DIR:=$(ARMADEUS_BUILD_DIR)/sdl-$(ARMADEUS_SDL_VERSION)
ARMADEUS_XENOMAI_DIR:=$(ARMADEUS_BUILD_DIR)/xenomai-$(ARMADEUS_XENOMAI_VERSION)
ARMADEUS_QT_DIR:=$(ARMADEUS_BUILD_DIR)/qt-everywhere-opensource-src-$(ARMADEUS_QT_VERSION)
diff --git a/target/demos/music_player/Makefile b/target/demos/music_player/Makefile
index 134ba82..4719911 100755
--- a/target/demos/music_player/Makefile
+++ b/target/demos/music_player/Makefile
@@ -2,8 +2,10 @@
ARMADEUS_BASE_DIR:=$(shell pwd)/../../..
-include $(ARMADEUS_BASE_DIR)/Makefile.in
+# Default values
STAGING_DIR:=$(ARMADEUS_BUILD_DIR)/staging_dir/
INSTALL_DIR:=$(ARMADEUS_ROOTFS_DIR)/usr/bin/
+INSTALL_DATA_DIR:=$(ARMADEUS_ROOTFS_DIR)/usr/share
CC=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
STRIP=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-sstrip
DEFINES=-DAPF
@@ -34,10 +36,12 @@ main.o: player.c
$(EXEC_NAME): player.o
$(CC) $(LDFLAGS) -o $@ $^
-install:
+install: $(EXEC_NAME)
mkdir -p $(INSTALL_DIR)
cp -f $(EXEC_NAME) $(INSTALL_DIR)/
$(STRIP) $(INSTALL_DIR)/$(EXEC_NAME)
+ mkdir -p $(INSTALL_DATA_DIR)/$(EXEC_NAME)/data
+ cp data/* $(INSTALL_DATA_DIR)/$(EXEC_NAME)/data/
uninstall:
rm -f $(INSTALL_DIR)/$(EXEC_NAME)
diff --git a/target/demos/music_player/S60mp b/target/demos/music_player/S60mp
index a6a8d4b..5019e97 100755
--- a/target/demos/music_player/S60mp
+++ b/target/demos/music_player/S60mp
@@ -17,4 +17,3 @@ cd /home
# launch aplayer
/home/aplayer /mnt/mmc
-
diff --git a/target/demos/music_player/player.c b/target/demos/music_player/player.c
index eca7b70..7b91a80 100644
--- a/target/demos/music_player/player.c
+++ b/target/demos/music_player/player.c
@@ -21,6 +21,10 @@
#include <stdio.h>
#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
#include "SDL/SDL.h"
#include "SDL/SDL_mixer.h"
#include "SDL/SDL_ttf.h"
@@ -62,7 +66,7 @@ void displayAll();
SDL_Surface *screen = NULL,
*background = NULL,
*icoMusic = NULL,
- *icoPlay = NULL,
+ *icoPlay[3] = {NULL, NULL, NULL},
*icoVol = NULL,
*textVol = NULL,
*textSong = NULL,
@@ -98,7 +102,28 @@ void displayAll();
int second = 0, minute = 0;
int nbSongHigh = 0;
int nb_song_display=0;
- int next=0,prev=0, yRep=0;
+ int next=0, prev=0, yRep=0;
+
+/* If file exists in current dir, use it, otherwise takes system one */
+char temp_filename[64];
+char * get_file(const char *filename)
+{
+ struct stat buf;
+ int ret;
+
+ /* printf("Asked for %s\n", filename); */
+ ret = stat(filename, &buf);
+ if (ret == 0) {
+ /* file exists in current dir*/
+ sprintf(temp_filename, "%s", filename);
+ } else {
+ perror("get_file");
+ sprintf(temp_filename, "/usr/share/aplayer/%s", filename);
+ }
+
+ /* printf("gives %s\n", temp_filename); */
+ return temp_filename;
+}
/*
* main
@@ -108,9 +133,9 @@ int main(int argc, char **argv)
{
/* Take the arg if there is one */
if (argc == 2) {
- strcpy(musicDir,argv[1]);
+ strcpy(musicDir, argv[1]);
}
- else strcpy(musicDir,MUSIC_DIR);
+ else strcpy(musicDir, MUSIC_DIR);
/* We initialise all we need */
initAll();
@@ -136,7 +161,7 @@ int main(int argc, char **argv)
displayAll();
/* Limit the use of the CPU */
- SDL_Delay(50);
+ SDL_Delay(100);
}
/* This is the cleaning up part */
@@ -169,16 +194,16 @@ void initAll()
screen = SDL_SetVideoMode(480, 272, 0, SDL_ANYFORMAT);
if (screen == NULL) {
printf("Unable to set video mode: %s\n", SDL_GetError());
- exitr();;
+ exitr();
}
/* Fonts opening */
- fontSong = TTF_OpenFont("data/font.ttf", 42);
- fontTimer = TTF_OpenFont("data/font.ttf", 30);
- fontVol = TTF_OpenFont("data/font.ttf", 20);
- fontRep = TTF_OpenFont("data/font.ttf", 16);
+ fontSong = TTF_OpenFont(get_file("data/font.ttf"), 42);
+ fontTimer = TTF_OpenFont(get_file("data/font.ttf"), 30);
+ fontVol = TTF_OpenFont(get_file("data/font.ttf"), 20);
+ fontRep = TTF_OpenFont(get_file("data/font.ttf"), 16);
/* To avoid seg-error if problems with fonts */
- if (!fontSong||!fontTimer||!fontVol||!fontRep) {
+ if (!fontSong || !fontTimer || !fontVol || !fontRep) {
printf("TTF_OpenFont: %s\n", TTF_GetError());
exitr();
}
@@ -209,7 +234,9 @@ void cleanAll()
SDL_FreeSurface(timer);
SDL_FreeSurface(icoMusic);
SDL_FreeSurface(icoVol);
- SDL_FreeSurface(icoPlay);
+ SDL_FreeSurface(icoPlay[0]);
+ SDL_FreeSurface(icoPlay[1]);
+ SDL_FreeSurface(icoPlay[2]);
SDL_FreeSurface(background);
SDL_FreeSurface(screen);
@@ -256,7 +283,7 @@ void handleKey(SDL_KeyboardEvent key)
/* 32 volume levels */
case SDLK_KP_MINUS: // volume down
if (key.state == SDL_PRESSED)
- if (vol>0) {
+ if (vol > 0) {
vol=vol-4;
Mix_VolumeMusic(vol);
}
@@ -264,7 +291,7 @@ void handleKey(SDL_KeyboardEvent key)
case SDLK_KP_PLUS: // volume up
if (key.state == SDL_PRESSED)
- if (vol<128) {
+ if (vol < 128) {
vol=vol+4;
Mix_VolumeMusic(vol);
}
@@ -278,8 +305,8 @@ void handleKey(SDL_KeyboardEvent key)
case SDLK_LEFT: // previous song
if( key.state == SDL_PRESSED) {
- if (numSongPlay>0) {
- if (music !=NULL) musicDone();
+ if (numSongPlay > 0) {
+ if (music != NULL) musicDone();
numSongPlay=numSongPlay-1;
openSong();
}
@@ -288,8 +315,8 @@ void handleKey(SDL_KeyboardEvent key)
case SDLK_RIGHT: // next song
if (key.state == SDL_PRESSED) {
- if (numSongPlay<nbFile-1) {
- if (music !=NULL) musicDone();
+ if (numSongPlay < nbFile-1) {
+ if (music != NULL) musicDone();
numSongPlay=numSongPlay+1;
openSong();
}
@@ -298,7 +325,7 @@ void handleKey(SDL_KeyboardEvent key)
/* Song cursor with highlighting ... */
case SDLK_UP: // Up
- if (nbSongHigh>0) {
+ if (nbSongHigh > 0) {
nbSongHigh--;
prev=1;
next=0;
@@ -339,15 +366,15 @@ void musicDone()
void openSong()
{
/* if music=NULL, load one */
- if(music == NULL) {
+ if (music == NULL) {
/* Add the path to the song */
char wps[32] = ""; // char "music/song"
- strcat(wps,musicDir); /* wps="music" */
- strcat(wps,"/"); /* wps="music/" */
- strcat(wps,tracks[numSongPlay]);/* wps="music/song" */
+ strcat(wps, musicDir); /* wps="music" */
+ strcat(wps, "/"); /* wps="music/" */
+ strcat(wps, tracks[numSongPlay]);/* wps="music/song" */
/* Loads up the music */
- music = Mix_LoadMUS(wps);
+ music = Mix_LoadMUS(get_file(wps));
/* Set its volume */
Mix_VolumeMusic(vol);
/* Reset the timer */
@@ -355,7 +382,7 @@ void openSong()
/* And play it */
Mix_PlayMusic(music, 0);
/* Set play icon */
- numIcon=0;
+ numIcon = 0;
/* When the song's over, play the next one */
Mix_HookMusicFinished(playRep);
@@ -372,8 +399,8 @@ void playRep()
{
/* Free Music then load another */
musicDone();
- if (numSongPlay<nbFile-1) {
- numSongPlay=numSongPlay+1;
+ if (numSongPlay < nbFile-1) {
+ numSongPlay = numSongPlay+1;
openSong();
} else numIcon=2; // stop icon
}
@@ -383,11 +410,11 @@ void playRep()
* */
void openRep()
{
- DIR *rep ;
- struct dirent *file ;
+ DIR *rep;
+ struct dirent *file;
/* open rep ****/
- rep = opendir (musicDir) ;
+ rep = opendir(musicDir);
int count=0;
if (rep != NULL) { // if rep not null, we put filenames in a tab
@@ -414,7 +441,7 @@ void openRep()
/* close rep ****/
(void) closedir (rep) ;
} else { // else program shutdown
- printf("Unable to load musicDir ! Check if your music repertory is called '%s'\n",musicDir);
+ printf("Unable to load musicDir ! Check if your music directory is called '%s' or pass one as argument\n", musicDir);
exitr();
}
@@ -422,7 +449,7 @@ void openRep()
* by default, songs are displayed by 9
*/
if (nbFile == 0) {
- printf("No file in %s directory ! Please put some.\n",musicDir);
+ printf("No file in %s directory ! Please put some.\n", musicDir);
exitr();
}
@@ -434,7 +461,7 @@ void openRep()
/* if too many files */
if (nbFile > NB_FILES_MAX) {
- printf("Too many files in %s directory ! Please remove some.\n",musicDir);
+ printf("Too many files in %s directory ! Please remove some.\n", musicDir);
exitr();
}
}
@@ -471,11 +498,12 @@ void timeReset()
* */
void displayBack()
{
- SDL_FreeSurface(background);
- background = SDL_LoadBMP("data/back.bmp");
if (!background) {
- printf("%s\n", SDL_GetError());
- exitr();
+ background = SDL_LoadBMP(get_file("data/back.bmp"));
+ if (!background) {
+ printf("%s\n", SDL_GetError());
+ exitr();
+ }
}
SDL_BlitSurface(background, NULL, screen, 0);
}
@@ -489,21 +517,22 @@ void displayTime()
SDL_Rect position;
/* Display play/pause/stop icons */
- SDL_FreeSurface(icoPlay);
- icoPlay = SDL_LoadBMP(icons[numIcon]);
- if(!icoPlay) {
- printf("%s\n", SDL_GetError());
- exitr();
+ if (!icoPlay[numIcon]) {
+ icoPlay[numIcon] = SDL_LoadBMP(get_file(icons[numIcon]));
+ if (!icoPlay[numIcon]) {
+ printf("%s\n", SDL_GetError());
+ exitr();
+ }
+ /* Set transparency */
+ SDL_SetColorKey(icoPlay[numIcon], SDL_SRCCOLORKEY, SDL_MapRGB(icoPlay[numIcon]->format, 255, 255, 255));
+ SDL_SetAlpha(icoPlay[numIcon], SDL_SRCALPHA, 128);
}
- /* Set transparency */
- SDL_SetColorKey(icoPlay, SDL_SRCCOLORKEY, SDL_MapRGB(icoPlay->format, 255, 255, 255));
- SDL_SetAlpha(icoPlay, SDL_SRCALPHA, 128);
position.x = 29;
position.y = 150;
- SDL_BlitSurface(icoPlay, NULL, screen, &position);
+ SDL_BlitSurface(icoPlay[numIcon], NULL, screen, &position);
/* Display Timer */
- second=counter/1000;
+ second = counter/1000;
/* when 60s, pass to 1 min */
if (second+1 > 60) {
second=0;
@@ -522,8 +551,8 @@ void displayTime()
sprintf(secondes, "%d", second);
/* add minute and second */
- strcat(minutes,":"); /* minutes= 00: */
- strcat(minutes,secondes); /* minutes= 00:00 */
+ strcat(minutes, ":"); /* minutes= 00: */
+ strcat(minutes, secondes); /* minutes= 00:00 */
/* the real Display part */
SDL_FreeSurface(timer);
@@ -542,15 +571,16 @@ void displayVol()
SDL_Rect position;
/* Display icoVol */
- SDL_FreeSurface(icoVol);
- icoVol = SDL_LoadBMP("data/vol.bmp");
if (!icoVol) {
- printf("%s\n", SDL_GetError());
- exitr();
+ icoVol = SDL_LoadBMP(get_file("data/vol.bmp"));
+ if (!icoVol) {
+ printf("%s\n", SDL_GetError());
+ exitr();
+ }
+ /* Set transparency */
+ SDL_SetColorKey(icoVol, SDL_SRCCOLORKEY, SDL_MapRGB(icoVol->format, 255, 255, 255));
+ SDL_SetAlpha(icoVol, SDL_SRCALPHA, 128);
}
- /* Set transparency */
- SDL_SetColorKey(icoVol, SDL_SRCCOLORKEY, SDL_MapRGB(icoVol->format, 255, 255, 255));
- SDL_SetAlpha(icoVol, SDL_SRCALPHA, 128);
position.x = 35;
position.y = 200;
SDL_BlitSurface(icoVol, NULL, screen, &position);
@@ -573,15 +603,16 @@ void displaySong()
SDL_Rect position;
/* Display icoMusic */
- SDL_FreeSurface(icoMusic);
- icoMusic = SDL_LoadBMP("data/mus.bmp");
if (!icoMusic) {
- printf("%s\n", SDL_GetError());
- exitr();
+ icoMusic = SDL_LoadBMP(get_file("data/mus.bmp"));
+ if (!icoMusic) {
+ printf("%s\n", SDL_GetError());
+ exitr();
+ }
+ /* Set transparency */
+ SDL_SetColorKey(icoMusic, SDL_SRCCOLORKEY, SDL_MapRGB(icoMusic->format, 255, 255, 255));
+ SDL_SetAlpha(icoMusic, SDL_SRCALPHA, 128);
}
- /* Set transparency */
- SDL_SetColorKey(icoMusic, SDL_SRCCOLORKEY, SDL_MapRGB(icoMusic->format, 255, 255, 255));
- SDL_SetAlpha(icoMusic, SDL_SRCALPHA, 128);
position.x = 18;
position.y = 80;
SDL_BlitSurface(icoMusic, NULL, screen, &position);
diff --git a/target/test/test_gpio.sh b/target/test/test_gpio.sh
index 49798dc..b6e2c1e 100755
--- a/target/test/test_gpio.sh
+++ b/target/test/test_gpio.sh
@@ -40,6 +40,26 @@ unload_module()
fi
}
+# $1 == LED number to blink
+blink_led_gpiolib()
+{
+ if [ "$1" == "" ]; then
+ echo "Please give a correct GPIO number"
+ return
+ fi
+ LED="$1"
+ echo $LED > /sys/class/gpio/export
+ ls /sys/class/gpio/gpio$LED/
+ echo out > /sys/class/gpio/gpio$LED/direction
+ for i in `seq 0 5`; do
+ echo 1 > /sys/class/gpio/gpio$LED/value
+ usleep 500000
+ echo 0 > /sys/class/gpio/gpio$LED/value
+ usleep 500000
+ done
+ echo $LED > /sys/class/gpio/unexport
+}
+
blink_led()
{
if [ "$1" == "APF9328" ]; then
@@ -53,6 +73,7 @@ blink_led()
done
elif [ "$1" == "APF27" ]; then
LED_NAME="D14"
+ echo "oO- Old way to do it... -Oo"
gpio_mode PF14 1
for i in `seq 0 5`; do
gpio_set_value PF14 0
@@ -60,17 +81,12 @@ blink_led()
gpio_set_value PF14 1
usleep 500000
done
+ echo "oO- New way to do it (gpiolib)... -Oo"
+ # PF14 -> GPIO 174 (5x32 + 14)
+ blink_led_gpiolib 174
elif [ "$1" == "APF51" ]; then
- LED="2"
- echo $LED > /sys/class/gpio/export
- ls /sys/class/gpio/gpio$LED/
- echo out > /sys/class/gpio/gpio$LED/direction
- for i in `seq 0 5`; do
- echo 1 > /sys/class/gpio/gpio$LED/value
- usleep 500000
- echo 0 > /sys/class/gpio/gpio$LED/value
- usleep 500000
- done
+ LED_NAME="i.MX"
+ blink_led_gpiolib 2
else
echo "Platform not supported by this test"
fi
hooks/post-receive
--
armadeus
|