Fixed menu flow for recording

Fixed missing zero terminator in lcdutils when writing the status line
Reworded some strings
Added initial support for signal inversion (only playback and hardcoded atm)
This commit is contained in:
sweetlilmre
2014-08-20 20:56:26 +02:00
parent 4295412605
commit c67e4a4c50
5 changed files with 77 additions and 38 deletions
+34 -17
View File
@@ -1,5 +1,5 @@
#include <inttypes.h>
#include <string.h>
#include "ff.h"
#include "config.h"
#include "fileutils.h"
@@ -17,13 +17,34 @@ uint8_t g_fat_buffer[FAT_BUF_SIZE];
/* User Provided RTC Function called by FatFs module */
DWORD get_fattime (void) {
/* Returns current time packed into a DWORD variable */
return ((DWORD)(2014 - 1980) << 25) /* Year 2013 */
| ((DWORD)6 << 21) /* Month 7 */
| ((DWORD)1 << 16) /* Mday 28 */
| ((DWORD)0 << 11) /* Hour 0 */
| ((DWORD)0 << 5) /* Min 0 */
| ((DWORD)0 >> 1); /* Sec 0 */
/* Returns current time packed into a DWORD variable */
return ((DWORD)(2014 - 1980) << 25) /* Year 2014 */
| ((DWORD)6 << 21) /* Month 6 */
| ((DWORD)1 << 16) /* Mday 1 */
| ((DWORD)0 << 11) /* Hour 0 */
| ((DWORD)0 << 5) /* Min 0 */
| ((DWORD)0 >> 1); /* Sec 0 */
}
int is_valid_file(FILINFO* pfile_info) {
char* file_name;
int len;
file_name = pfile_info->lfname[0] ? pfile_info->lfname : pfile_info->fname;
len = strlen(file_name);
if ((pfile_info->fattrib & INVALID_FILE_ATTR)) {
return 0;
}
if ((pfile_info->fattrib & AM_DIR)) {
return (file_name[0] != '.');
}
if (len < 5) {
return 0;
}
return 1;
}
int get_num_files(FILINFO* pfile_info) {
@@ -42,13 +63,11 @@ int get_num_files(FILINFO* pfile_info) {
break;
}
if (pfile_info->fname[0] == '.') {
if (!is_valid_file(pfile_info)) {
continue;
}
if (!(pfile_info->fattrib & INVALID_FILE_ATTR)) {
num_files++;
}
num_files++;
}
return num_files;
}
@@ -71,14 +90,12 @@ int get_file_at_index(FILINFO* pfile_info, int index) {
break;
}
if (pfile_info->fname[0] == '.') {
if (!is_valid_file(pfile_info)) {
continue;
}
if (!(pfile_info->fattrib & INVALID_FILE_ATTR)) {
if (cur_file_index == index) {
return 1;
}
if (cur_file_index == index) {
return 1;
}
cur_file_index++;
}
+2 -1
View File
@@ -92,6 +92,7 @@ void lcd_spinner_internal(uint32_t cur_tick, int8_t perc, uint16_t rate) {
}
g_char_buffer[5] = MOTOR_IS_OFF() ? 'm' : 'M';
g_char_buffer[6] = indicators[pos++];
g_char_buffer[7] = 0;
lcd_print(g_char_buffer);
if (pos > 3) {
@@ -106,7 +107,7 @@ void lcd_spinner(uint32_t cur_tick, int8_t perc) {
void lcd_busy_spinner() {
uint8_t i;
for (i = 0; i < 100; i++) {
lcd_spinner_internal(i, 100, 0);
lcd_spinner_internal(i, -1, 0);
_delay_ms(20);
}
}
+3 -3
View File
@@ -6,9 +6,9 @@ prog_char S_MKDIR_FAILED[] PROGMEM = "MKDIR failed!";
prog_char S_CHDIR_FAILED[] PROGMEM = "CHDIR failed!";
prog_char S_NAME_PATTERN[] PROGMEM = "rec-%.4d.tap";
prog_char S_RECORDING[] PROGMEM = "Recording";
prog_char S_SELECT_RECORD_MODE[] PROGMEM = "Recording mode:";
prog_char S_REC_MODE_MANUAL[] PROGMEM = "Manual name";
prog_char S_REC_MODE_AUTO[] PROGMEM = "Auto name";
prog_char S_SELECT_RECORD_MODE[] PROGMEM = "TAP name mode:";
prog_char S_REC_MODE_MANUAL[] PROGMEM = "Manual";
prog_char S_REC_MODE_AUTO[] PROGMEM = "Auto";
prog_char S_ENTER_FILENAME[] PROGMEM = "Enter file name";
prog_char S_FILENAME_CHARS[] PROGMEM = " abcdefghijklmnopqrstuvwxyz0123456789_-";
+17 -13
View File
@@ -39,13 +39,24 @@ uint8_t get_cur_command() {
}
void handle_play_mode(FILINFO* pfile_info) {
lcd_title_P(S_SELECT_FILE);
if (!get_file_at_index(pfile_info, g_cur_file_index)) {
// shouldn't happen...
// reset to the root after a possible record operation
change_dir("/");
// refresh the file list to avoid blank entries bug
if ((g_num_files = get_num_files(pfile_info)) == 0) {
lcd_title_P(S_NO_FILES_FOUND);
lcd_busy_spinner();
return;
}
g_cur_file_index = 0;
if (!get_file_at_index(pfile_info, g_cur_file_index)) {
// shouldn't happen...
lcd_title_P(S_NO_FILES_FOUND);
lcd_busy_spinner();
return;
}
lcd_title_P(S_SELECT_FILE);
display_filename(pfile_info);
while (1) {
@@ -122,9 +133,7 @@ void handle_record_mode_ready(char* pfile_name) {
case COMMAND_SELECT:
{
record_file(pfile_name);
lcd_title_P(S_READY_RECORD);
lcd_status_P(S_PRESS_START);
break;
return;
}
case COMMAND_ABORT:
{
@@ -264,10 +273,12 @@ void handle_record_mode_select(FILINFO* pfile_info) {
{
case REC_MODE_AUTO:
handle_record_mode_ready(NULL);
return;
break;
case REC_MODE_MANUAL:
if (handle_manual_filename(pfile_info)) {
handle_record_mode_ready(pfile_info->lfname);
return;
}
break;
}
@@ -278,13 +289,6 @@ void handle_record_mode_select(FILINFO* pfile_info) {
}
case COMMAND_ABORT:
{
// reset to the root after a record operation
change_dir("/");
// refresh the file list to avoid blank entries bug
if ((g_num_files = get_num_files(pfile_info)) == 0) {
lcd_title_P(S_NO_FILES_FOUND);
return;
}
return;
}
case COMMAND_NEXT:
+21 -4
View File
@@ -50,6 +50,7 @@ static uint32_t g_pulse_length = 0; // length of pulse in uS
static uint32_t g_pulse_length_save; // save length for read
static volatile uint32_t g_overflow; // write signal overflow timer detection
static volatile uint32_t g_timer_tick = 0; // timer tick at 100Hz (10 ms interval)
static volatile uint8_t g_invert_signal = 0; // invert the signal for transmission/reception to/from a real Datasette
uint32_t get_timer_tick() {
return g_timer_tick;
@@ -118,7 +119,11 @@ ISR(TIMER1_COMPA_vect) {
g_pulse_length = 0; // clear this, for 1st half check so that the next data is loaded
g_signal_2nd_half = 0; // next time round switch to 1st half
}
TAPE_READ_HIGH(); // set the signal high
if (g_invert_signal) {
TAPE_READ_LOW(); // set the signal high
} else {
TAPE_READ_HIGH(); // set the signal high
}
} else { // 1st half of the signal
if (g_pulse_length) { // do we have any pulse left?
if (g_pulse_length > 0xFFFF) { // check to see if its bigger than 16 bits
@@ -155,7 +160,11 @@ ISR(TIMER1_COMPA_vect) {
g_pulse_length = g_pulse_length_save; // restore pulse length for the 2nd half of the signal
g_signal_2nd_half = 1; // next time round switch to 2nd half
}
TAPE_READ_LOW();
if (g_invert_signal) {
TAPE_READ_HIGH(); // set the signal high
} else {
TAPE_READ_LOW(); // set the signal high
}
}
}
}
@@ -232,7 +241,11 @@ int play_file(FILINFO* pfile_info)
lcd_title_P(S_LOADING);
TAPE_READ_LOW();
if (g_invert_signal) {
TAPE_READ_LOW(); // set the signal low
} else {
TAPE_READ_HIGH(); // set the signal high
}
SENSE_ON();
// Start send-ISR
signal_timer_start(0);
@@ -282,7 +295,11 @@ int play_file(FILINFO* pfile_info)
signal_timer_stop();
f_close(&g_fil);
TAPE_READ_LOW();
if (g_invert_signal) {
TAPE_READ_LOW(); // set the signal high
} else {
TAPE_READ_HIGH(); // set the signal high
}
SENSE_OFF();
if (g_cur_command == COMMAND_ABORT) {