ButterflyMP3
|
Butterfly MP3 main. More...
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "main.h"
#include "types.h"
#include "uart.h"
#include "delay.h"
#include "vs1001.h"
#include "mmc.h"
#include "avrfat16.h"
#include "timer0.h"
#include "button.h"
#include "eeprom.h"
#include "lcdgraphics.h"
#include "power.h"
#include "utils.h"
#include "BCD.h"
Go to the source code of this file.
Functions | |
const uint8 | __attribute__ ((progmem)) |
setup volume levels 0 1 2 3 4 5 6 7 8 9 | |
void | flush_decoder (char reset_type) |
flush_decoder | |
void | cue_file (void) |
cue_file | |
void | streaming (void) |
Data Streaming. | |
void | handle_interface (void) |
handle_interface | |
void | update_LCD (void) |
update_LCD | |
void | mainTimer (void) |
uint8 | init_mmc_fat (void) |
init_mmc_fat | |
uint8 | handle_mmc (uint8 MMC_present) |
handle_mmc | |
void | init_HW (void) |
init_HW | |
uint8 | open_Dir (uint32 dir_lba) |
uint8 | restore_player (void) |
restore_player | |
void | play_track_number (uint8 num) |
play_track_number | |
void | volume_up (void) |
void | volume_down (void) |
int | main (void) |
main | |
Variables | |
const char VERSIONINFO1[] | PROGMEM = "ButterflyMP3_sf_net V0.7" |
tag rom with verion info | |
uint8 | gmusic_vol = 5 |
music volume. | |
volatile uint8 | gbass_boost = 0 |
bass boost off. | |
volatile uint8 | gFastForward = 0 |
Fast forward mode. | |
uint8 | gMode = 0 |
mode of player, idle, playing, off, etc | |
char | gLCD_Refresh |
Update LCD. | |
uint32 | gFAT_entry = 0 |
global current entry number in FAT table. (aka file number) | |
uint32 | gCluster |
current cluster in song | |
uint32 | gFileSectorSize |
size of current file in complete sectors. | |
uint32 | gFileSectorsPlayed |
number of full sectors played. (aka position) | |
char | gFile_good |
File has been read from Fat and ready to go. | |
char | cluster_pos = 0 |
position in cluster | |
char | buff_pos = 16 |
position in buffer | |
volatile uint16 | gPlayTimeSeconds |
# of seconds current file has been playing. | |
uint8 | gDisplayTimeOut = 0 |
# of seconds+1 before changing display; |
Butterfly MP3 main.
Definition in file main.c.
const uint8 __attribute__ | ( | (progmem) | ) |
setup volume levels 0 1 2 3 4 5 6 7 8 9
Definition at line 96 of file main.c.
Referenced by __attribute__().
void cue_file | ( | void | ) |
cue_file
Gets file info for file pointed to by gFAT_entry and inits MP3 chip. Checks for MMC card as well. Reads ID3v2 tag for title and artist If successful then gFile_good is set
Definition at line 481 of file main.c.
References buff_pos, cluster_pos, EOL, FALSE, FAT16_dir_first_sector, FAT16_filetype, FAT16_LFNArtistLen, FAT16_LFNTitleLen, FAT16_longfilename, FAT16_sectors_per_cluster, FAT_buffer, FAT_NextCluster(), FAT_readCluster(), FAT_readFile(), FAT_scratch, FAT_Scratch2Cluster(), FILE_TYPE_DIR, flush_decoder(), gCluster, gFAT_entry, gFile_good, gFileSectorSize, gFileSectorsPlayed, gPlayTimeSeconds, LFN_ARTIST_INDEX, LFN_ARTIST_LENGTH, LFN_TITLE_INDEX, LFN_TITLE_LENGTH, LFN_TYPE_ID3_ARTIST, LFN_TYPE_ID3_TITLE, LFN_TYPE_INDEX, PRINT, SOFT_RESET, strLen(), TRUE, and UART_Printfu32().
Referenced by handle_interface(), open_Dir(), play_track_number(), restore_player(), and streaming().
void flush_decoder | ( | char | reset_type | ) |
flush_decoder
Resets the decoder and prepares it for a new stream of audio data. all setup params must be resent.
Definition at line 432 of file main.c.
References gbass_boost, gFastForward, gmusic_vol, SCI_CLOCKF, SCI_MODE, SM_SDINEW, vs1001_read(), vs1001_reset(), vs1001_write(), and vs_1001_setvolume().
Referenced by cue_file(), handle_interface(), and streaming().
void handle_interface | ( | void | ) |
handle_interface
Scans for button presses and change activity accordingly
Definition at line 997 of file main.c.
References cue_file(), EOL, FAT16_dir_first_sector, FAT16_entryMAX, FAT16_entryMIN, FAT16_filetype, FAT_cluster2lba(), FAT_getNextSong(), FAT_getParentDir(), FAT_getPrevSong(), FAT_readFile(), FAT_Scratch2Cluster(), FILE_TYPE_DIR, flush_decoder(), gCluster, getkey(), gFastForward, gFAT_entry, gFile_good, gLCD_Refresh, gMode, gPowerSaveTimer, KEY_ENTER, KEY_JOYSTICKMAX, KEY_MINUS, KEY_NEXT, KEY_NULL, KEY_PLUS, KEY_PREV, MODE_IDLE, MODE_PAUSE, MODE_PLAY, MODE_STOP, open_Dir(), play_track_number(), Power_off(), PRINT, SAMPLEMODE_ALLBUTONS, SCAN_JUMPTOSTART, SOFT_RESET, TRUE, UART_HasChar(), UART_Printfu08(), UART_ReceiveByte(), volume_down(), volume_up(), and vs1001_sine_test().
Referenced by main().
handle_mmc
Check for MMC insertion/removal
old | status of MMC |
Definition at line 881 of file main.c.
References EOL, FALSE, FAT16_entryMAX, FAT16_entryMIN, gFAT_entry, gFile_good, gLCD_Refresh, gMode, gPowerSaveTimer, init_mmc_fat(), MMC_Check(), MMC_Detect(), MMC_Reset(), MODE_IDLE, MODE_STOP, PRINT, and TRUE.
Referenced by main(), and restore_player().
void init_HW | ( | void | ) |
init_HW
Initialize basic hardware for the butterfly.
Definition at line 142 of file main.c.
References Button_Init(), EOL, FAT16_entryMAX, FAT16_entryMIN, FAT_buffer, FAT_read, FAT_scratch, gmusic_vol, LCD_Initialize(), load_player_options(), mainTimer(), MMC_Read(), mmc_sbuf, mmc_scratch, Power_check(), Power_Init(), PRINT, PWR_MIN_V, SpiInit(), Timer0_Init(), Timer0_RegisterCallbackFunction(), UART_Init(), vs1001_init_chip(), vs1001_init_io(), and vs_1001_setvolume().
Referenced by main().
uint8 init_mmc_fat | ( | void | ) |
init_mmc_fat
initialize the mmc and read fat/partition details from the disk. Needs to be run everytime MMC is changed.
Definition at line 401 of file main.c.
References EOL, FAT16_entryMAX, FAT16_entryMIN, FAT16_root_dir_first_sector, FAT_initFat16(), gFAT_entry, MMC_Reset(), open_Dir(), and UART_Printfu32().
Referenced by handle_mmc().
int main | ( | void | ) |
main
The guts.
Definition at line 1294 of file main.c.
References AUTOPOWEROFF_TIMEOUT, DREQ_PIN, DREQ_PORT, gLCD_Refresh, gMode, gPowerSaveTimer, handle_interface(), handle_mmc(), init_HW(), MODE_IDLE, MODE_PLAY, Power_idle(), Power_off(), restore_player(), streaming(), TRUE, and update_LCD().
void mainTimer | ( | void | ) |
do stuff every second in here
Definition at line 202 of file main.c.
References AUTOPOWEROFF_TIMEOUT, BUTTON_TIMEOUT_VALUE, EOL, gButtonTimeout, gDisplayTimeOut, gLCD_Refresh, gMode, gPlayTimeSeconds, gPowerSaveTimer, LCD_FileName(), MODE_PAUSE, MODE_PLAY, Power_check(), PRINT, PWR_ABS_MIN_V, PWR_GOOD_V, PWR_LOW_V, PWR_MIN_V, save_player_options(), save_player_state(), TIMER0_TICKSPERSECOND, and TRUE.
Referenced by init_HW().
Definition at line 314 of file main.c.
References cue_file(), FAT16_entryMIN, FAT_scanDir_lba(), gFAT_entry, LCD_FileName(), LCD_Scanning(), and TRUE.
Referenced by handle_interface(), init_mmc_fat(), and restore_player().
void play_track_number | ( | uint8 | num | ) |
play_track_number
will find and play the track whos filename starts with 'nn' where nn is a number from 00-99 with a leading zero
Definition at line 940 of file main.c.
References CHAR2BCD2(), cue_file(), FAT16_dir_first_sector, FAT_getNumberedSong(), gCurrentSongNum, gFAT_entry, gLCD_Refresh, gMode, MODE_PLAY, SAMPLEMODE_CONTROLOUT_PIN, SAMPLEMODE_CONTROLOUT_PORT, and TRUE.
Referenced by handle_interface().
uint8 restore_player | ( | void | ) |
restore_player
Restore the player state from eeprom if possible
Definition at line 341 of file main.c.
References cue_file(), FALSE, FAT16_entryMIN, FAT_getNextSong(), gCluster, gFAT_entry, gFileSectorsPlayed, gLCD_Refresh, gMode, gPlayTimeSeconds, handle_mmc(), load_player_state(), MODE_IDLE, MODE_PAUSE, open_Dir(), and TRUE.
Referenced by main().
void streaming | ( | void | ) |
Data Streaming.
Take care of feeding data to mp3 chip and reading mmc in free time. AKA playing.
Definition at line 798 of file main.c.
References buff_pos, cluster_pos, cue_file(), DREQ_PIN, DREQ_PORT, FALSE, FAT16_dir_first_sector, FAT16_entryMIN, FAT16_filetype, FAT16_sectors_per_cluster, FAT_buffer, FAT_getNextSong(), FAT_NextCluster(), FAT_readCluster(), FILE_TYPE_DIR, flush_decoder(), gCluster, gFAT_entry, gFile_good, gFileSectorsPlayed, gLCD_Refresh, gMode, MMC_Reset(), MODE_PLAY, MODE_STOP, PLAY_NEXT_SONG, PLAY_REPEAT_ALL, RECURSE_DIRECTORIES, SAMPLEMODE_CONTROLOUT_PIN, SAMPLEMODE_CONTROLOUT_PORT, SOFT_RESET, TRUE, and vs1001_send_32().
Referenced by main().
void update_LCD | ( | void | ) |
update_LCD
Update the display depending on mode.
Definition at line 1180 of file main.c.
References FALSE, gbass_boost, gDisplayTimeOut, gFAT_entry, gLCD_Refresh, gMode, gmusic_vol, gPlayTimeSeconds, LCD_Battery(), LCD_Blank(), LCD_FileName(), LCD_Pause(), LCD_Play(), LCD_Stop(), LCD_Tester(), LCD_Time(), LCD_Vol(), MODE_IDLE, MODE_PAUSE, MODE_PLAY, MODE_STOP, Power_check(), Power_pcnt(), and STAT_DISPLAY_TIME.
Referenced by main().
void volume_down | ( | void | ) |
Definition at line 982 of file main.c.
References gLCD_Refresh, gmusic_vol, TRUE, and vs_1001_setvolume().
Referenced by handle_interface().
void volume_up | ( | void | ) |
Definition at line 973 of file main.c.
References gLCD_Refresh, gmusic_vol, TRUE, and vs_1001_setvolume().
Referenced by handle_interface().
char buff_pos = 16 |
char cluster_pos = 0 |
position in cluster
Definition at line 83 of file main.c.
Referenced by cue_file(), and streaming().
volatile uint8 gbass_boost = 0 |
bass boost off.
Definition at line 71 of file main.c.
Referenced by flush_decoder(), and update_LCD().
current cluster in song
current sector (cluster) in song main.h
Definition at line 79 of file main.c.
Referenced by cue_file(), FAT_Scratch2Cluster(), handle_interface(), restore_player(), save_player_state(), and streaming().
uint8 gDisplayTimeOut = 0 |
# of seconds+1 before changing display;
Definition at line 93 of file main.c.
Referenced by mainTimer(), and update_LCD().
volatile uint8 gFastForward = 0 |
Fast forward mode.
Definition at line 72 of file main.c.
Referenced by flush_decoder(), and handle_interface().
uint32 gFAT_entry = 0 |
global current entry number in FAT table. (aka file number)
Definition at line 78 of file main.c.
Referenced by cue_file(), handle_interface(), handle_mmc(), init_mmc_fat(), open_Dir(), play_track_number(), restore_player(), save_player_state(), streaming(), and update_LCD().
char gFile_good |
File has been read from Fat and ready to go.
Definition at line 82 of file main.c.
Referenced by cue_file(), handle_interface(), handle_mmc(), and streaming().
size of current file in complete sectors.
Definition at line 80 of file main.c.
Referenced by cue_file().
number of full sectors played. (aka position)
Definition at line 81 of file main.c.
Referenced by cue_file(), restore_player(), save_player_state(), and streaming().
char gLCD_Refresh |
Update LCD.
Definition at line 76 of file main.c.
Referenced by handle_interface(), handle_mmc(), main(), mainTimer(), play_track_number(), restore_player(), streaming(), update_LCD(), volume_down(), and volume_up().
mode of player, idle, playing, off, etc
Definition at line 75 of file main.c.
Referenced by handle_interface(), handle_mmc(), LEDMatrix_timer(), main(), mainTimer(), play_track_number(), restore_player(), save_player_state(), streaming(), and update_LCD().
uint8 gmusic_vol = 5 |
music volume.
Definition at line 70 of file main.c.
Referenced by flush_decoder(), init_HW(), load_player_options(), save_player_options(), update_LCD(), volume_down(), and volume_up().
volatile uint16 gPlayTimeSeconds |
# of seconds current file has been playing.
Definition at line 92 of file main.c.
Referenced by cue_file(), mainTimer(), restore_player(), save_player_state(), and update_LCD().
const char VERSIONINFO2 [] PROGMEM = "ButterflyMP3_sf_net V0.7" |