[X9D] Many little corrections
[stock] Another flash saving!
This commit is contained in:
+3
-7
@@ -88,7 +88,6 @@ void handle_serial( void ) ;
|
|||||||
uint32_t get_current_block_number( uint32_t block_no, uint16_t *p_size, uint32_t *p_seq ) ;
|
uint32_t get_current_block_number( uint32_t block_no, uint16_t *p_size, uint32_t *p_seq ) ;
|
||||||
void write32_eeprom_block( uint32_t eeAddress, register uint8_t *buffer, uint32_t size, uint32_t immediate=0 ) ;
|
void write32_eeprom_block( uint32_t eeAddress, register uint8_t *buffer, uint32_t size, uint32_t immediate=0 ) ;
|
||||||
void eeLoadModelNames( void ) ;
|
void eeLoadModelNames( void ) ;
|
||||||
uint16_t eeLoadModelName(uint8_t id, char *name);
|
|
||||||
|
|
||||||
// New file system
|
// New file system
|
||||||
|
|
||||||
@@ -403,7 +402,6 @@ void eeLoadModel(uint8_t id)
|
|||||||
if (pulsesStarted()) {
|
if (pulsesStarted()) {
|
||||||
checkAll();
|
checkAll();
|
||||||
resumePulses();
|
resumePulses();
|
||||||
clearKeyEvents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activeFunctions = 0;
|
activeFunctions = 0;
|
||||||
@@ -435,17 +433,15 @@ bool eeModelExists(uint8_t id)
|
|||||||
return ( File_system[id+1].size > 0 ) ;
|
return ( File_system[id+1].size > 0 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t eeLoadModelName(uint8_t id, char *name)
|
void eeLoadModelName(uint8_t id, char *name)
|
||||||
{
|
{
|
||||||
memclear(name, sizeof(g_model.name));
|
memclear(name, sizeof(g_model.name));
|
||||||
if (id < MAX_MODELS) {
|
if (id < MAX_MODELS) {
|
||||||
id += 1;
|
id += 1;
|
||||||
if (File_system[id].size > sizeof(g_model.name) ) {
|
if (File_system[id].size > sizeof(g_model.name) ) {
|
||||||
read32_eeprom_data( ( File_system[id].block_no << 12) + 8, ( uint8_t *)name, sizeof(g_model.name));
|
read32_eeprom_data( ( File_system[id].block_no << 12) + 8, ( uint8_t *)name, sizeof(g_model.name));
|
||||||
return File_system[id].size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void eeLoadModelNames()
|
void eeLoadModelNames()
|
||||||
@@ -700,7 +696,7 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
|||||||
DIR archiveFolder;
|
DIR archiveFolder;
|
||||||
UINT written;
|
UINT written;
|
||||||
|
|
||||||
if (!sd_card_mounted()) {
|
if (!sdMounted()) {
|
||||||
return STR_NO_SDCARD;
|
return STR_NO_SDCARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,7 +752,7 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
|
|||||||
FIL restoreFile;
|
FIL restoreFile;
|
||||||
UINT read;
|
UINT read;
|
||||||
|
|
||||||
if (!sd_card_mounted()) {
|
if (!sdMounted()) {
|
||||||
return STR_NO_SDCARD;
|
return STR_NO_SDCARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-13
@@ -302,11 +302,6 @@ void EFile::rm(uint8_t i_fileId)
|
|||||||
ENABLE_SYNC_WRITE(false);
|
ENABLE_SYNC_WRITE(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t EFile::size()
|
|
||||||
{
|
|
||||||
return eeFs.files[m_fileId].size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open file i_fileId for reading.
|
* Open file i_fileId for reading.
|
||||||
* Return the file's type
|
* Return the file's type
|
||||||
@@ -579,7 +574,7 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
|||||||
*(uint32_t*)&buf[0] = O9X_FOURCC;
|
*(uint32_t*)&buf[0] = O9X_FOURCC;
|
||||||
buf[4] = g_eeGeneral.version;
|
buf[4] = g_eeGeneral.version;
|
||||||
buf[5] = 'M';
|
buf[5] = 'M';
|
||||||
*(uint16_t*)&buf[6] = theFile2.size();
|
*(uint16_t*)&buf[6] = eeModelSize(i_fileSrc);
|
||||||
|
|
||||||
result = f_write(&g_oLogFile, buf, 8, &written);
|
result = f_write(&g_oLogFile, buf, 8, &written);
|
||||||
if (result != FR_OK || written != 8) {
|
if (result != FR_OK || written != 8) {
|
||||||
@@ -840,16 +835,13 @@ bool eeLoadGeneral()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint16_t eeLoadModelName(uint8_t id, char *name)
|
void eeLoadModelName(uint8_t id, char *name)
|
||||||
{
|
{
|
||||||
memclear(name, sizeof(g_model.name));
|
memclear(name, sizeof(g_model.name));
|
||||||
if (id < MAX_MODELS) {
|
if (id < MAX_MODELS) {
|
||||||
theFile.openRlc(FILE_MODEL(id));
|
theFile.openRlc(FILE_MODEL(id));
|
||||||
if (theFile.readRlc((uint8_t*)name, sizeof(g_model.name)) == sizeof(g_model.name)) {
|
theFile.readRlc((uint8_t*)name, sizeof(g_model.name));
|
||||||
return theFile.size();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
@@ -857,7 +849,7 @@ uint16_t eeLoadModelName(uint8_t id, char *name)
|
|||||||
void eeLoadModelNames()
|
void eeLoadModelNames()
|
||||||
{
|
{
|
||||||
for (uint32_t i=0; i<MAX_MODELS; i++) {
|
for (uint32_t i=0; i<MAX_MODELS; i++) {
|
||||||
modelSizes[i] = eeLoadModelName(i, modelNames[i]);
|
eeLoadModelName(i, modelNames[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -903,7 +895,6 @@ void eeLoadModel(uint8_t id)
|
|||||||
if (pulsesStarted()) {
|
if (pulsesStarted()) {
|
||||||
checkAll();
|
checkAll();
|
||||||
resumePulses();
|
resumePulses();
|
||||||
clearKeyEvents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activeFunctions = 0;
|
activeFunctions = 0;
|
||||||
|
|||||||
+5
-3
@@ -82,6 +82,8 @@ PACK(struct EeFs{
|
|||||||
DirEnt files[MAXFILES];
|
DirEnt files[MAXFILES];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
extern EeFs eeFs;
|
||||||
|
|
||||||
#define FILE_TYP_GENERAL 1
|
#define FILE_TYP_GENERAL 1
|
||||||
#define FILE_TYP_MODEL 2
|
#define FILE_TYP_MODEL 2
|
||||||
|
|
||||||
@@ -124,9 +126,6 @@ class EFile
|
|||||||
///return true if the file with given fileid exists
|
///return true if the file with given fileid exists
|
||||||
static bool exists(uint8_t i_fileId);
|
static bool exists(uint8_t i_fileId);
|
||||||
|
|
||||||
///return size of compressed file without block overhead
|
|
||||||
uint16_t size();
|
|
||||||
|
|
||||||
///open file for reading, no close necessary
|
///open file for reading, no close necessary
|
||||||
void openRd(uint8_t i_fileId);
|
void openRd(uint8_t i_fileId);
|
||||||
|
|
||||||
@@ -140,6 +139,9 @@ class EFile
|
|||||||
uint8_t m_ofs; //offset inside of the current block
|
uint8_t m_ofs; //offset inside of the current block
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define eeFileSize(f) eeFs.files[f].size
|
||||||
|
#define eeModelSize(id) eeFileSize(FILE_MODEL(id))
|
||||||
|
|
||||||
#define ERR_NONE 0
|
#define ERR_NONE 0
|
||||||
#define ERR_FULL 1
|
#define ERR_FULL 1
|
||||||
extern uint8_t s_write_err; // error reasons
|
extern uint8_t s_write_err; // error reasons
|
||||||
|
|||||||
+9
-9
@@ -79,12 +79,12 @@ uint8_t lcdLastPos;
|
|||||||
#define LCD_BYTE_FILTER(p, keep, add) \
|
#define LCD_BYTE_FILTER(p, keep, add) \
|
||||||
do { \
|
do { \
|
||||||
if (!(flags & GREY1)) \
|
if (!(flags & GREY1)) \
|
||||||
*(p) = (*(p) & (keep)) + (add); \
|
*(p) = ((*(p)) & (keep)) | (add); \
|
||||||
if (!(flags & GREY2)) \
|
if (!(flags & GREY2)) \
|
||||||
*(p+DISPLAY_PLAN_SIZE) = (*(p+DISPLAY_PLAN_SIZE) & (keep)) + (add); \
|
*(p+DISPLAY_PLAN_SIZE) = ((*(p+DISPLAY_PLAN_SIZE)) & (keep)) | (add); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define LCD_BYTE_FILTER(p, keep, add) *(p) = (*(p) & (keep)) + (add)
|
#define LCD_BYTE_FILTER(p, keep, add) *(p) = (*(p) & (keep)) | (add)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
||||||
@@ -122,13 +122,13 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
b2 = pgm_read_byte(q++); /*top byte*/
|
b2 = pgm_read_byte(q++); /*top byte*/
|
||||||
}
|
}
|
||||||
if (inv) {
|
if (inv) {
|
||||||
b1=~b1;
|
b1 = ~b1;
|
||||||
b2=~b2;
|
b2 = ~b2;
|
||||||
}
|
}
|
||||||
if(&p[DISPLAY_W+1] < DISPLAY_END) {
|
if(&p[DISPLAY_W+1] < DISPLAY_END) {
|
||||||
ASSERT_IN_DISPLAY(p);
|
ASSERT_IN_DISPLAY(p);
|
||||||
ASSERT_IN_DISPLAY(p+DISPLAY_W);
|
ASSERT_IN_DISPLAY(p+DISPLAY_W);
|
||||||
p[0]=b1;
|
p[0] = b1;
|
||||||
p[DISPLAY_W] = b2;
|
p[DISPLAY_W] = b2;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@@ -231,13 +231,13 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
if (r<DISPLAY_END)
|
if (r<DISPLAY_END)
|
||||||
LCD_BYTE_FILTER(r, ~(0xff >> (8-ym8)), b >> (8-ym8));
|
LCD_BYTE_FILTER(r, ~(0xff >> (8-ym8)), b >> (8-ym8));
|
||||||
}
|
}
|
||||||
#ifdef BOLD_FONT
|
#if defined(BOLD_FONT)
|
||||||
if (flags & BOLD) {
|
if (flags & BOLD) {
|
||||||
ASSERT_IN_DISPLAY(p+1);
|
ASSERT_IN_DISPLAY(p+1);
|
||||||
if (inv)
|
if (inv)
|
||||||
*(p+1) &= (b << ym8);
|
LCD_BYTE_FILTER(p+1, b << ym8, 0);
|
||||||
else
|
else
|
||||||
*(p+1) |= (b << ym8);
|
LCD_BYTE_FILTER(p+1, 0xff, b << ym8);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ const pm_char * openLogs()
|
|||||||
DIR folder;
|
DIR folder;
|
||||||
char filename[24];
|
char filename[24];
|
||||||
|
|
||||||
if (!sd_card_mounted())
|
if (!sdMounted())
|
||||||
return STR_NO_SDCARD;
|
return STR_NO_SDCARD;
|
||||||
|
|
||||||
strcpy_P(filename, STR_LOGS_PATH);
|
strcpy_P(filename, STR_LOGS_PATH);
|
||||||
|
|||||||
+6
-6
@@ -38,7 +38,7 @@ int8_t s_editMode;
|
|||||||
uint8_t s_noHi;
|
uint8_t s_noHi;
|
||||||
uint8_t s_noScroll;
|
uint8_t s_noScroll;
|
||||||
|
|
||||||
void menu_lcd_onoff(uint8_t x,uint8_t y, uint8_t value, uint8_t attr)
|
void menu_lcd_onoff(uint8_t x,uint8_t y, uint8_t value, LcdFlags attr)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS)
|
#if defined(GRAPHICS)
|
||||||
if (value) {
|
if (value) {
|
||||||
@@ -668,7 +668,7 @@ void displayWarning(uint8_t event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, int8_t value, int8_t min, int8_t max, uint8_t attr, uint8_t event)
|
int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event)
|
||||||
{
|
{
|
||||||
lcd_putsLeft(y, label);
|
lcd_putsLeft(y, label);
|
||||||
if (values) lcd_putsiAtt(x, y, values, value-min, attr);
|
if (values) lcd_putsiAtt(x, y, values, value-min, attr);
|
||||||
@@ -676,7 +676,7 @@ int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, uint8_t attr, uint8_t event )
|
uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, LcdFlags attr, uint8_t event )
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS)
|
#if defined(GRAPHICS)
|
||||||
menu_lcd_onoff(x, y, value, attr);
|
menu_lcd_onoff(x, y, value, attr);
|
||||||
@@ -686,7 +686,7 @@ uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, uint8_t attr, uint8_t event)
|
int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t event)
|
||||||
{
|
{
|
||||||
lcd_putsLeft(y, STR_SWITCH);
|
lcd_putsLeft(y, STR_SWITCH);
|
||||||
putsSwitches(x, y, value, attr);
|
putsSwitches(x, y, value, attr);
|
||||||
@@ -695,7 +695,7 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, uint8_t attr, uint8_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GVARS)
|
#if defined(GVARS)
|
||||||
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max, uint8_t attr, uint8_t event)
|
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event)
|
||||||
{
|
{
|
||||||
bool invers = attr&INVERS;
|
bool invers = attr&INVERS;
|
||||||
if (invers && event == EVT_KEY_LONG(KEY_MENU)) {
|
if (invers && event == EVT_KEY_LONG(KEY_MENU)) {
|
||||||
@@ -718,7 +718,7 @@ int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max,
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max, uint8_t attr, uint8_t event)
|
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event)
|
||||||
{
|
{
|
||||||
lcd_outdezAtt(x, y, value, attr);
|
lcd_outdezAtt(x, y, value, attr);
|
||||||
if (attr&INVERS) CHECK_INCDEC_MODELVAR(event, value, min, max);
|
if (attr&INVERS) CHECK_INCDEC_MODELVAR(event, value, min, max);
|
||||||
|
|||||||
+11
-7
@@ -63,7 +63,7 @@ extern pgofs_t s_pgOfs;
|
|||||||
extern uint8_t s_noHi;
|
extern uint8_t s_noHi;
|
||||||
extern uint8_t s_noScroll;
|
extern uint8_t s_noScroll;
|
||||||
|
|
||||||
void menu_lcd_onoff(uint8_t x, uint8_t y, uint8_t value, uint8_t mode);
|
void menu_lcd_onoff(uint8_t x, uint8_t y, uint8_t value, LcdFlags attr);
|
||||||
|
|
||||||
extern MenuFuncP g_menuStack[5];
|
extern MenuFuncP g_menuStack[5];
|
||||||
extern uint8_t g_menuStackPtr;
|
extern uint8_t g_menuStackPtr;
|
||||||
@@ -98,11 +98,13 @@ void menuStatisticsDebug(uint8_t event);
|
|||||||
#if defined(PCBX9D)
|
#if defined(PCBX9D)
|
||||||
extern int8_t scrollRE;
|
extern int8_t scrollRE;
|
||||||
extern int16_t p1valdiff;
|
extern int16_t p1valdiff;
|
||||||
|
#define IS_RE_NAVIGATION_ENABLE() true
|
||||||
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (event==type(KEY_ENTER))
|
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (event==type(KEY_ENTER))
|
||||||
#define IS_RE_NAVIGATION_EVT(event) ((event&EVT_KEY_MASK)==KEY_ENTER)
|
#define IS_RE_NAVIGATION_EVT(event) ((event&EVT_KEY_MASK)==KEY_ENTER)
|
||||||
#elif defined(ROTARY_ENCODERS)
|
#elif defined(ROTARY_ENCODERS)
|
||||||
extern int8_t scrollRE;
|
extern int8_t scrollRE;
|
||||||
extern int16_t p1valdiff;
|
extern int16_t p1valdiff;
|
||||||
|
#define IS_RE_NAVIGATION_ENABLE() g_eeGeneral.reNavigation
|
||||||
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (g_eeGeneral.reNavigation && event==type(BTN_REa + g_eeGeneral.reNavigation - 1))
|
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (g_eeGeneral.reNavigation && event==type(BTN_REa + g_eeGeneral.reNavigation - 1))
|
||||||
#define IS_RE_NAVIGATION_EVT(event) (g_eeGeneral.reNavigation && (event&EVT_KEY_MASK)==(BTN_REa + g_eeGeneral.reNavigation - 1))
|
#define IS_RE_NAVIGATION_EVT(event) (g_eeGeneral.reNavigation && (event&EVT_KEY_MASK)==(BTN_REa + g_eeGeneral.reNavigation - 1))
|
||||||
#else
|
#else
|
||||||
@@ -205,14 +207,16 @@ if (!check_submenu_simple(event,(lines_count)-1)) return;
|
|||||||
SIMPLE_SUBMENU_NOTITLE(lines_count); \
|
SIMPLE_SUBMENU_NOTITLE(lines_count); \
|
||||||
TITLE(title)
|
TITLE(title)
|
||||||
|
|
||||||
int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, int8_t value, int8_t min, int8_t max, uint8_t attr, uint8_t event);
|
int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event);
|
||||||
uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, uint8_t attr, uint8_t event );
|
uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, LcdFlags attr, uint8_t event );
|
||||||
int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, uint8_t attr, uint8_t event);
|
int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t event);
|
||||||
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max, uint8_t attr, uint8_t event);
|
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event);
|
||||||
#if defined(GVARS)
|
#if defined(GVARS)
|
||||||
#define displayGVar(x, y, v) gvarMenuItem(x, y, v, 0, 0, 0, 0)
|
#define displayGVar(x, y, v, a) gvarMenuItem(x, y, v, 0, 0, a, 0)
|
||||||
|
#elif defined(PCBX9D)
|
||||||
|
#define displayGVar(x, y, v, a) lcd_outdezAtt(x, y, v, a)
|
||||||
#else
|
#else
|
||||||
#define displayGVar(x, y, v) lcd_outdez8(x, y, v)
|
#define displayGVar(x, y, v, a) lcd_outdez8(x, y, v)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WARNING_TYPE_ASTERISK 0
|
#define WARNING_TYPE_ASTERISK 0
|
||||||
|
|||||||
+66
-28
@@ -241,7 +241,12 @@ void menuModelSelect(uint8_t event)
|
|||||||
#endif
|
#endif
|
||||||
uint8_t _event_ = (IS_RE_NAVIGATION_EVT(event) ? 0 : event);
|
uint8_t _event_ = (IS_RE_NAVIGATION_EVT(event) ? 0 : event);
|
||||||
|
|
||||||
if (s_copyMode || !eeModelExists(g_eeGeneral.currModel)) {
|
if (s_copyMode
|
||||||
|
/* TODO how is it possible? || !eeModelExists(g_eeGeneral.currModel)*/
|
||||||
|
#if defined(PCBX9D)
|
||||||
|
|| s_editMode >= 0
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
if ((event & 0x1f) == KEY_EXIT)
|
if ((event & 0x1f) == KEY_EXIT)
|
||||||
_event_ -= KEY_EXIT;
|
_event_ -= KEY_EXIT;
|
||||||
}
|
}
|
||||||
@@ -298,6 +303,12 @@ void menuModelSelect(uint8_t event)
|
|||||||
sub = m_posVert = (s_copyMode == MOVE_MODE || s_copySrcRow<0) ? (MAX_MODELS+sub+s_copyTgtOfs) % MAX_MODELS : s_copySrcRow;
|
sub = m_posVert = (s_copyMode == MOVE_MODE || s_copySrcRow<0) ? (MAX_MODELS+sub+s_copyTgtOfs) % MAX_MODELS : s_copySrcRow;
|
||||||
s_copyMode = 0;
|
s_copyMode = 0;
|
||||||
}
|
}
|
||||||
|
#if defined(PCBX9D)
|
||||||
|
else {
|
||||||
|
m_posVert = sub = g_eeGeneral.currModel;
|
||||||
|
s_editMode = -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
#if defined(ROTARY_ENCODERS)
|
#if defined(ROTARY_ENCODERS)
|
||||||
case EVT_KEY_BREAK(BTN_REa):
|
case EVT_KEY_BREAK(BTN_REa):
|
||||||
@@ -431,19 +442,19 @@ void menuModelSelect(uint8_t event)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(PCBSKY9X)
|
#if defined(PCBX9D)
|
||||||
|
lcd_puts(11*FW-(LEN_FREE-4)*FW, 0, STR_FREE);
|
||||||
|
if (refresh) reusableBuffer.models.eepromfree = EeFsGetFree();
|
||||||
|
lcd_outdezAtt(20*FW, 0, reusableBuffer.models.eepromfree, 0);
|
||||||
|
lcd_puts(20*FW, 0, "bytes"); // TODO translations
|
||||||
|
#elif !defined(PCBSKY9X)
|
||||||
lcd_puts(9*FW-(LEN_FREE-4)*FW, 0, STR_FREE);
|
lcd_puts(9*FW-(LEN_FREE-4)*FW, 0, STR_FREE);
|
||||||
if (refresh) reusableBuffer.models.eepromfree = EeFsGetFree();
|
if (refresh) reusableBuffer.models.eepromfree = EeFsGetFree();
|
||||||
#if defined(PCBX9D)
|
|
||||||
lcd_outdezAtt(18*FW, 0, reusableBuffer.models.eepromfree, 0);
|
|
||||||
lcd_puts(18*FW, 0, "bytes"); // TODO translations
|
|
||||||
#else
|
|
||||||
lcd_outdezAtt(17*FW, 0, reusableBuffer.models.eepromfree, 0);
|
lcd_outdezAtt(17*FW, 0, reusableBuffer.models.eepromfree, 0);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ROTARY_ENCODERS)
|
#if defined(ROTARY_ENCODERS)
|
||||||
displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? ((g_eeGeneral.reNavigation && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0);
|
displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? ((IS_RE_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0);
|
||||||
#else
|
#else
|
||||||
displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? INVERS : 0);
|
displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? INVERS : 0);
|
||||||
#endif
|
#endif
|
||||||
@@ -475,14 +486,16 @@ void menuModelSelect(uint8_t event)
|
|||||||
k %= MAX_MODELS;
|
k %= MAX_MODELS;
|
||||||
|
|
||||||
if (eeModelExists(k)) {
|
if (eeModelExists(k)) {
|
||||||
#if defined(CPUARM)
|
#if defined(PCBSKY9X)
|
||||||
putsModelName(4*FW, y, modelNames[k], k, 0);
|
putsModelName(4*FW, y, modelNames[k], k, 0);
|
||||||
|
#elif defined(CPUARM)
|
||||||
|
putsModelName(4*FW, y, modelNames[k], k, 0);
|
||||||
|
lcd_outdezAtt(20*FW, y, eeModelSize(k), 0);
|
||||||
#else
|
#else
|
||||||
uint16_t & size = reusableBuffer.models.listsizes[i];
|
|
||||||
char * name = reusableBuffer.models.listnames[i];
|
char * name = reusableBuffer.models.listnames[i];
|
||||||
if (refresh) size = eeLoadModelName(k, name);
|
if (refresh) eeLoadModelName(k, name);
|
||||||
putsModelName(4*FW, y, name, k, 0);
|
putsModelName(4*FW, y, name, k, 0);
|
||||||
lcd_outdezAtt(20*FW, y, size, 0);
|
lcd_outdezAtt(20*FW, y, eeModelSize(k), 0);
|
||||||
#endif
|
#endif
|
||||||
if (k==g_eeGeneral.currModel && (s_copyMode!=COPY_MODE || s_copySrcRow<0 || i+s_pgOfs!=(pgofs_t)sub)) lcd_putc(1, y, '*');
|
if (k==g_eeGeneral.currModel && (s_copyMode!=COPY_MODE || s_copySrcRow<0 || i+s_pgOfs!=(pgofs_t)sub)) lcd_putc(1, y, '*');
|
||||||
}
|
}
|
||||||
@@ -2113,6 +2126,15 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
|
|||||||
uint8_t cur = 1;
|
uint8_t cur = 1;
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
|
|
||||||
|
#if defined(PCBX9D)
|
||||||
|
#define mixsrcattr allattr
|
||||||
|
#define expoweightattr allattr
|
||||||
|
#else
|
||||||
|
#define allattr 0
|
||||||
|
#define mixsrcattr (isMixActive(i) ? BOLD : 0)
|
||||||
|
#define expoweightattr (isExpoActive(i) ? BOLD : 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
for (uint8_t ch=1; ch<=(expo ? NUM_STICKS : NUM_CHNOUT); ch++) {
|
for (uint8_t ch=1; ch<=(expo ? NUM_STICKS : NUM_CHNOUT); ch++) {
|
||||||
void *pointer = NULL; MixData * &md = (MixData * &)pointer; ExpoData * &ed = (ExpoData * &)pointer;
|
void *pointer = NULL; MixData * &md = (MixData * &)pointer; ExpoData * &ed = (ExpoData * &)pointer;
|
||||||
uint8_t y = (cur-s_pgOfs)*FH;
|
uint8_t y = (cur-s_pgOfs)*FH;
|
||||||
@@ -2141,38 +2163,50 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
|
|||||||
if (s_pgOfs < cur && cur-s_pgOfs < 8) {
|
if (s_pgOfs < cur && cur-s_pgOfs < 8) {
|
||||||
uint8_t attr = ((s_copyMode || sub != cur) ? 0 : INVERS);
|
uint8_t attr = ((s_copyMode || sub != cur) ? 0 : INVERS);
|
||||||
if (expo) {
|
if (expo) {
|
||||||
ed->weight = gvarMenuItem(EXPO_LINE_WEIGHT_POS, y, ed->weight, 0, 100, attr | (isExpoActive(i) ? BOLD : 0), event);
|
#if defined(PCBX9D)
|
||||||
|
uint32_t allattr = isMixActive(i) ? 0 : GREY2;
|
||||||
|
#endif
|
||||||
|
ed->weight = gvarMenuItem(EXPO_LINE_WEIGHT_POS, y, ed->weight, 0, 100, attr | expoweightattr, event);
|
||||||
|
|
||||||
if (ed->curveMode == MODE_CURVE)
|
if (ed->curveMode == MODE_CURVE)
|
||||||
putsCurve(EXPO_LINE_EXPO_POS-3*FW, y, ed->curveParam);
|
putsCurve(EXPO_LINE_EXPO_POS-3*FW, y, ed->curveParam, allattr);
|
||||||
else
|
else
|
||||||
displayGVar(EXPO_LINE_EXPO_POS, y, ed->curveParam);
|
displayGVar(EXPO_LINE_EXPO_POS, y, ed->curveParam, allattr);
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
if (ed->name[0]) {
|
if (ed->name[0]) {
|
||||||
putsSwitches(11*FW, y, ed->swtch, 0);
|
putsSwitches(11*FW, y, ed->swtch, allattr);
|
||||||
lcd_putsnAtt(DISPLAY_W-sizeof(ed->name)*FW-MENUS_SCROLLBAR_WIDTH, y, ed->name, sizeof(ed->name), ZCHAR | (isExpoActive(i) ? BOLD : 0));
|
lcd_putsnAtt(DISPLAY_W-sizeof(ed->name)*FW-MENUS_SCROLLBAR_WIDTH, y, ed->name, sizeof(ed->name), ZCHAR | expoweightattr);
|
||||||
}
|
}
|
||||||
#if !defined(LCD212)
|
#if !defined(LCD212)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
putsSwitches(EXPO_LINE_SWITCH_POS, y, ed->swtch, 0); // normal switches
|
putsSwitches(EXPO_LINE_SWITCH_POS, y, ed->swtch, allattr); // normal switches
|
||||||
if (ed->mode!=3) lcd_putc(17*FW, y, ed->mode == 2 ? 126 : 127);//'|' : (stkVal[i] ? '<' : '>'),0);*/
|
if (ed->mode!=3) {
|
||||||
|
#if defined(PCBX9D)
|
||||||
|
lcd_putcAtt(17*FW, y, ed->mode == 2 ? 126 : 127, allattr);
|
||||||
|
#else
|
||||||
|
lcd_putc(17*FW, y, ed->mode == 2 ? 126 : 127);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#if defined(PCBX9D)
|
||||||
|
uint32_t allattr = isMixActive(i) ? 0 : GREY2;
|
||||||
|
#endif
|
||||||
if (mixCnt > 0)
|
if (mixCnt > 0)
|
||||||
lcd_putsiAtt(1*FW+0, y, STR_VMLTPX2, md->mltpx, 0);
|
lcd_putsiAtt(1*FW+0, y, STR_VMLTPX2, md->mltpx, allattr);
|
||||||
|
|
||||||
putsMixerSource(4*FW+0, y, md->srcRaw, isMixActive(i) ? BOLD : 0);
|
putsMixerSource(4*FW+0, y, md->srcRaw, mixsrcattr);
|
||||||
|
|
||||||
md->weight = gvarMenuItem(11*FW+3, y, md->weight, -125, 125, attr, event);
|
md->weight = gvarMenuItem(11*FW+3, y, md->weight, -125, 125, attr|allattr, event);
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
if (md->name[0]) {
|
if (md->name[0]) {
|
||||||
lcd_putsnAtt(DISPLAY_W-sizeof(md->name)*FW-MENUS_SCROLLBAR_WIDTH, y, md->name, sizeof(md->name), ZCHAR | (isMixActive(i) ? BOLD : 0));
|
lcd_putsnAtt(DISPLAY_W-sizeof(md->name)*FW-MENUS_SCROLLBAR_WIDTH, y, md->name, sizeof(md->name), ZCHAR | mixsrcattr);
|
||||||
}
|
}
|
||||||
#if !defined(LCD212)
|
#if !defined(LCD212)
|
||||||
else
|
else
|
||||||
@@ -2181,18 +2215,22 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
|
|||||||
{
|
{
|
||||||
if (md->curveParam) {
|
if (md->curveParam) {
|
||||||
if (md->curveMode == MODE_CURVE)
|
if (md->curveMode == MODE_CURVE)
|
||||||
putsCurve(12*FW+2, y, md->curveParam);
|
putsCurve(12*FW+2, y, md->curveParam, allattr);
|
||||||
else
|
else
|
||||||
displayGVar(15*FW+2, y, md->curveParam);
|
displayGVar(15*FW+2, y, md->curveParam, allattr);
|
||||||
}
|
}
|
||||||
if (md->swtch) putsSwitches(16*FW, y, md->swtch);
|
if (md->swtch) putsSwitches(16*FW, y, md->swtch, allattr);
|
||||||
|
|
||||||
char cs = ' ';
|
char cs = ' ';
|
||||||
if (md->speedDown || md->speedUp)
|
if (md->speedDown || md->speedUp)
|
||||||
cs = 'S';
|
cs = 'S';
|
||||||
if ((md->delayUp || md->delayDown))
|
if ((md->delayUp || md->delayDown))
|
||||||
cs = (cs =='S' ? '*' : 'D');
|
cs = (cs =='S' ? '*' : 'D');
|
||||||
lcd_putcAtt(19*FW+7, y, cs, 0);
|
#if defined(PCBX9D)
|
||||||
|
lcd_putcAtt(19*FW+7, y, cs, allattr);
|
||||||
|
#else
|
||||||
|
lcd_putc(19*FW+7, y, cs);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s_copyMode) {
|
if (s_copyMode) {
|
||||||
@@ -2363,7 +2401,7 @@ void menuModelLimits(uint8_t event)
|
|||||||
if((g_chans512[k] - v) > 50) swVal = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim!
|
if((g_chans512[k] - v) > 50) swVal = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim!
|
||||||
if((g_chans512[k] - v) < -50) swVal = (ld->revert ? 126 : 127);
|
if((g_chans512[k] - v) < -50) swVal = (ld->revert ? 126 : 127);
|
||||||
putsChn(0, y, k+1, 0);
|
putsChn(0, y, k+1, 0);
|
||||||
lcd_putcAtt(LIMITS_DIRECTION_POS, y, swVal, 0);
|
lcd_putc(LIMITS_DIRECTION_POS, y, swVal);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PPM_CENTER_ADJUSTABLE)
|
#if defined(PPM_CENTER_ADJUSTABLE)
|
||||||
|
|||||||
+16
-7
@@ -66,9 +66,6 @@ OS_MutexID audioMutex;
|
|||||||
OS_MutexID mixerMutex;
|
OS_MutexID mixerMutex;
|
||||||
|
|
||||||
char modelNames[MAX_MODELS][sizeof(g_model.name)];
|
char modelNames[MAX_MODELS][sizeof(g_model.name)];
|
||||||
#if defined(PCBX9D)
|
|
||||||
uint16_t modelSizes[MAX_MODELS];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // defined(CPUARM)
|
#endif // defined(CPUARM)
|
||||||
|
|
||||||
@@ -358,7 +355,7 @@ void generalDefault()
|
|||||||
g_eeGeneral.calibSpanNeg[i] = 0x180;
|
g_eeGeneral.calibSpanNeg[i] = 0x180;
|
||||||
g_eeGeneral.calibSpanPos[i] = 0x180;
|
g_eeGeneral.calibSpanPos[i] = 0x180;
|
||||||
}
|
}
|
||||||
g_eeGeneral.chkSum = (0x200 * NUM_STICKS+NUM_POTS) + (0x180 * 5);
|
g_eeGeneral.chkSum = 0x200 * (NUM_STICKS+NUM_POTS) + 0x180 * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t evalChkSum()
|
uint16_t evalChkSum()
|
||||||
@@ -1248,6 +1245,8 @@ void checkAll()
|
|||||||
|
|
||||||
checkTHR();
|
checkTHR();
|
||||||
checkSwitches();
|
checkSwitches();
|
||||||
|
|
||||||
|
clearKeyEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(PCBSKY9X)
|
#if !defined(PCBSKY9X)
|
||||||
@@ -1772,6 +1771,7 @@ BeepANACenter evalSticks(uint8_t mode)
|
|||||||
if(v > RESX) v = RESX;
|
if(v > RESX) v = RESX;
|
||||||
|
|
||||||
#if defined(PCBX9D)
|
#if defined(PCBX9D)
|
||||||
|
// TODO constants
|
||||||
if(i == 2 || i == 3 || i == 4 || i == 6)
|
if(i == 2 || i == 3 || i == 4 || i == 6)
|
||||||
v = -v;
|
v = -v;
|
||||||
#endif
|
#endif
|
||||||
@@ -2324,7 +2324,16 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
|||||||
if (k < NUM_STICKS)
|
if (k < NUM_STICKS)
|
||||||
v = md->noExpo ? rawAnas[k] : anas[k]; //Switch is on. MAX=FULL=512 or value.
|
v = md->noExpo ? rawAnas[k] : anas[k]; //Switch is on. MAX=FULL=512 or value.
|
||||||
#if defined(PCBX9D) || defined(PCBACT)
|
#if defined(PCBX9D) || defined(PCBACT)
|
||||||
if(k < MIXSRC_SH) v = getValue(k); // TODO
|
else {
|
||||||
|
v = getValue(k);
|
||||||
|
// TODO switches: if (v < 0 && !md->swtch) sw = false;
|
||||||
|
if (k>=MIXSRC_CH1-1 && k<=MIXSRC_CHMAX-1 && md->destCh != k-MIXSRC_CH1+1) {
|
||||||
|
if (dirtyChannels & ((bitfield_channels_t)1 << (k-MIXSRC_CH1+1)) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1)))
|
||||||
|
passDirtyChannels |= (bitfield_channels_t) 1 << md->destCh;
|
||||||
|
if (k-MIXSRC_CH1+1 < md->destCh || pass > 0)
|
||||||
|
v = chans[k-MIXSRC_CH1+1] / 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
else if (k >= MIXSRC_THR-1 && k <= MIXSRC_SWC-1) {
|
else if (k >= MIXSRC_THR-1 && k <= MIXSRC_SWC-1) {
|
||||||
v = getSwitch(k-MIXSRC_THR+1+1, 0) ? +1024 : -1024;
|
v = getSwitch(k-MIXSRC_THR+1+1, 0) ? +1024 : -1024;
|
||||||
@@ -2404,7 +2413,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOLD_FONT
|
#ifdef BOLD_FONT
|
||||||
activeMixes |= ((ACTIVE_MIXES_TYPE) 1 << i);
|
activeMixes |= ((ACTIVE_MIXES_TYPE)1 << i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//========== OFFSET ===============
|
//========== OFFSET ===============
|
||||||
@@ -3406,8 +3415,8 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
|||||||
eeLoadModel(g_eeGeneral.currModel);
|
eeLoadModel(g_eeGeneral.currModel);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
checkAll();
|
|
||||||
checkAlarm();
|
checkAlarm();
|
||||||
|
checkAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||||
|
|||||||
+1
-6
@@ -215,10 +215,6 @@ extern void boardInit();
|
|||||||
extern char modelNames[MAX_MODELS][sizeof(g_model.name)];
|
extern char modelNames[MAX_MODELS][sizeof(g_model.name)];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBX9D)
|
|
||||||
extern uint16_t modelSizes[MAX_MODELS];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO try to merge the 2 include files
|
// TODO try to merge the 2 include files
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
#include "eeprom_arm.h"
|
#include "eeprom_arm.h"
|
||||||
@@ -1033,7 +1029,7 @@ void eeDirty(uint8_t msk);
|
|||||||
void eeCheck(bool immediately=false);
|
void eeCheck(bool immediately=false);
|
||||||
void eeReadAll();
|
void eeReadAll();
|
||||||
bool eeModelExists(uint8_t id);
|
bool eeModelExists(uint8_t id);
|
||||||
uint16_t eeLoadModelName(uint8_t id, char *name);
|
void eeLoadModelName(uint8_t id, char *name);
|
||||||
void eeLoadModel(uint8_t id);
|
void eeLoadModel(uint8_t id);
|
||||||
void generalDefault();
|
void generalDefault();
|
||||||
void modelDefault(uint8_t id);
|
void modelDefault(uint8_t id);
|
||||||
@@ -1323,7 +1319,6 @@ union ReusableBuffer
|
|||||||
{
|
{
|
||||||
char mainname[42];
|
char mainname[42];
|
||||||
char listnames[7][LEN_MODEL_NAME];
|
char listnames[7][LEN_MODEL_NAME];
|
||||||
uint16_t listsizes[7];
|
|
||||||
uint16_t eepromfree;
|
uint16_t eepromfree;
|
||||||
|
|
||||||
#if defined(SDCARD)
|
#if defined(SDCARD)
|
||||||
|
|||||||
+2
-2
@@ -82,11 +82,11 @@ extern void sdMountPoll();
|
|||||||
#if defined(CPUARM) && !defined(SIMU)
|
#if defined(CPUARM) && !defined(SIMU)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern uint32_t sd_card_ready();
|
extern uint32_t sd_card_ready();
|
||||||
extern uint32_t sd_card_mounted();
|
extern uint32_t sdMounted();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define sd_card_ready() (true)
|
#define sd_card_ready() (true)
|
||||||
#define sd_card_mounted() (true)
|
#define sdMounted() (true)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBACT)
|
#if defined(PCBACT)
|
||||||
|
|||||||
+2
-2
@@ -122,7 +122,7 @@ void refreshModelAudioFiles()
|
|||||||
|
|
||||||
char filename[64] = SOUNDS_PATH "/";
|
char filename[64] = SOUNDS_PATH "/";
|
||||||
|
|
||||||
if (sd_card_mounted()) {
|
if (sdMounted()) {
|
||||||
char *buf = strcat_modelname(&filename[sizeof(SOUNDS_PATH)], g_eeGeneral.currModel);
|
char *buf = strcat_modelname(&filename[sizeof(SOUNDS_PATH)], g_eeGeneral.currModel);
|
||||||
*buf++ = '/';
|
*buf++ = '/';
|
||||||
|
|
||||||
@@ -616,7 +616,7 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
|
|||||||
printf("playFile(\"%s\")\n", filename); fflush(stdout);
|
printf("playFile(\"%s\")\n", filename); fflush(stdout);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (!sd_card_mounted())
|
if (!sdMounted())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CoEnterMutexSection(audioMutex);
|
CoEnterMutexSection(audioMutex);
|
||||||
|
|||||||
@@ -1091,7 +1091,7 @@ uint32_t sd_card_ready( void )
|
|||||||
return CardIsConnected() && Card_state >= SD_ST_DATA;
|
return CardIsConnected() && Card_state >= SD_ST_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sd_card_mounted( void )
|
uint32_t sdMounted( void )
|
||||||
{
|
{
|
||||||
return CardIsConnected() && Card_state == SD_ST_MOUNTED;
|
return CardIsConnected() && Card_state == SD_ST_MOUNTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ void usbMassStorage()
|
|||||||
if (usbPlugged() && sd_card_ready()) {
|
if (usbPlugged() && sd_card_ready()) {
|
||||||
TRACE_DEBUG("usbMassStorage\n\r");
|
TRACE_DEBUG("usbMassStorage\n\r");
|
||||||
|
|
||||||
if (sd_card_mounted()) {
|
if (sdMounted()) {
|
||||||
Card_state = SD_ST_DATA;
|
Card_state = SD_ST_DATA;
|
||||||
audioQueue.stopSD();
|
audioQueue.stopSD();
|
||||||
closeLogs();
|
closeLogs();
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ extern uint32_t Peri2_frequency ;
|
|||||||
#define SD_IS_HC() (1)
|
#define SD_IS_HC() (1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define sdInit()
|
void sdInit();
|
||||||
void sdPoll10ms();
|
void sdPoll10ms();
|
||||||
|
|
||||||
void usbMassStorage();
|
void usbMassStorage();
|
||||||
|
|||||||
+13
-94
@@ -140,27 +140,6 @@ static void interface_speed( enum speed_setting speed )
|
|||||||
SPI_SD->CR1 = tmp;
|
SPI_SD->CR1 = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOCKET_WP_CONNECTED
|
|
||||||
/* Socket's Write-Protection Pin: high = write-protected, low = writable */
|
|
||||||
|
|
||||||
static void socket_wp_init(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
|
||||||
|
|
||||||
/* Configure I/O for write-protect */
|
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHBxPeriph_GPIO_WP, ENABLE);
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_WP;
|
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_WP;
|
|
||||||
GPIO_Init(GPIO_CTL_SD, &GPIO_InitStructure);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DWORD socket_is_write_protected(void)
|
|
||||||
{
|
|
||||||
return ( GPIO_ReadInputData(GPIO_CTL_SD) & GPIO_Pin_WP ) ? socket_state_mask_wp : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static void socket_wp_init(void)
|
static void socket_wp_init(void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -171,30 +150,6 @@ static inline DWORD socket_is_write_protected(void)
|
|||||||
return 0; /* fake not protected */
|
return 0; /* fake not protected */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SOCKET_WP_CONNECTED */
|
|
||||||
|
|
||||||
|
|
||||||
#if SOCKET_CP_CONNECTED
|
|
||||||
/* Socket's Card-Present Pin: high = socket empty, low = card inserted */
|
|
||||||
|
|
||||||
static void socket_cp_init(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
|
||||||
|
|
||||||
/* Configure I/O for card-present */
|
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHBxPeriph_GPIO_CP, ENABLE);
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_CP;
|
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_CP;
|
|
||||||
GPIO_Init(GPIO_CTL_SD, &GPIO_InitStructure);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline DWORD socket_is_empty(void)
|
|
||||||
{
|
|
||||||
return ( GPIO_ReadInputData(GPIO_CTL_SD) & GPIO_Pin_CP ) ? socket_state_mask_cp : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static void socket_cp_init(void)
|
static void socket_cp_init(void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -205,46 +160,6 @@ static inline DWORD socket_is_empty(void)
|
|||||||
return 0; /* fake inserted */
|
return 0; /* fake inserted */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SOCKET_CP_CONNECTED */
|
|
||||||
|
|
||||||
|
|
||||||
#if CARD_SUPPLY_SWITCHABLE
|
|
||||||
|
|
||||||
static void card_power(BOOL on) /* switch FET for card-socket VCC */
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
|
||||||
|
|
||||||
/* Turn on GPIO for power-control pin connected to FET's gate */
|
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_PWR, ENABLE);
|
|
||||||
/* Configure I/O for Power FET */
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_PWR;
|
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_PWR;
|
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_Init(GPIO_PWR, &GPIO_InitStructure);
|
|
||||||
if (on) {
|
|
||||||
GPIO_ResetBits(GPIO_PWR, GPIO_Pin_PWR);
|
|
||||||
} else {
|
|
||||||
/* Chip select internal pull-down (to avoid parasite powering) */
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_CS;
|
|
||||||
GPIO_Init(GPIO_CS, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
GPIO_SetBits(GPIO_PWR, GPIO_Pin_PWR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (STM32_SD_DISK_IOCTRL == 1)
|
|
||||||
static int chk_power(void) /* Socket power state: 0=off, 1=on */
|
|
||||||
{
|
|
||||||
if ( GPIO_ReadOutputDataBit(GPIO_PWR, GPIO_Pin_PWR) == Bit_SET ) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static void card_power(BYTE on)
|
static void card_power(BYTE on)
|
||||||
{
|
{
|
||||||
on=on;
|
on=on;
|
||||||
@@ -257,9 +172,6 @@ static int chk_power(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CARD_SUPPLY_SWITCHABLE */
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Transmit/Receive a byte to MMC via SPI (Platform dependent) */
|
/* Transmit/Receive a byte to MMC via SPI (Platform dependent) */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
@@ -983,18 +895,25 @@ void sdPoll10ms()
|
|||||||
|
|
||||||
FATFS g_FATFS_Obj;
|
FATFS g_FATFS_Obj;
|
||||||
|
|
||||||
|
void sdInit()
|
||||||
|
{
|
||||||
|
if (f_mount(0, &g_FATFS_Obj) == FR_OK)
|
||||||
|
refreshSystemAudioFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t sdMounted()
|
||||||
|
{
|
||||||
|
return g_FATFS_Obj.fs_type != 0;
|
||||||
|
}
|
||||||
|
|
||||||
void sdMountPoll()
|
void sdMountPoll()
|
||||||
{
|
{
|
||||||
static uint8_t mountTimer;
|
static uint8_t mountTimer;
|
||||||
if (mountTimer-- == 0) {
|
if (mountTimer-- == 0) {
|
||||||
mountTimer = 100;
|
mountTimer = 100;
|
||||||
if (g_FATFS_Obj.fs_type == 0) {
|
if (!sdMounted()) {
|
||||||
f_mount(0, &g_FATFS_Obj);
|
sdInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sd_card_mounted(void)
|
|
||||||
{
|
|
||||||
return g_FATFS_Obj.fs_type != 0;
|
|
||||||
}
|
|
||||||
|
|||||||
+3
-5
@@ -107,8 +107,7 @@
|
|||||||
#define PIN_LCD_A0 GPIO_Pin_13 //PD.13
|
#define PIN_LCD_A0 GPIO_Pin_13 //PD.13
|
||||||
#define PIN_LCD_RST //GPIO_Pin_12 //pd12 test //RESET occurs when powered up,but should delay before initialize
|
#define PIN_LCD_RST //GPIO_Pin_12 //pd12 test //RESET occurs when powered up,but should delay before initialize
|
||||||
|
|
||||||
// Audio----I2S3
|
// Audio - I2S3
|
||||||
//#define CODEC_I2S_ADDRESS 0x4000380C
|
|
||||||
#define CODEC_I2S SPI3
|
#define CODEC_I2S SPI3
|
||||||
#define CODEC_I2S_CLK RCC_APB1Periph_SPI3
|
#define CODEC_I2S_CLK RCC_APB1Periph_SPI3
|
||||||
#define CODEC_I2S_GPIO_AF GPIO_AF_SPI3
|
#define CODEC_I2S_GPIO_AF GPIO_AF_SPI3
|
||||||
@@ -137,7 +136,7 @@
|
|||||||
#define I2C_EE_SDA GPIO_Pin_0 //PE0
|
#define I2C_EE_SDA GPIO_Pin_0 //PE0
|
||||||
#define I2C_EE_WP GPIO_Pin_9 //PB9
|
#define I2C_EE_WP GPIO_Pin_9 //PB9
|
||||||
|
|
||||||
// SD---spi2
|
// SD - SPI2
|
||||||
#define SPI_SD SPI2
|
#define SPI_SD SPI2
|
||||||
#define GPIO_AF_SD GPIO_AF_SPI2
|
#define GPIO_AF_SD GPIO_AF_SPI2
|
||||||
#define RCC_AHB1Periph_GPIO_CS RCC_AHB1Periph_GPIOB
|
#define RCC_AHB1Periph_GPIO_CS RCC_AHB1Periph_GPIOB
|
||||||
@@ -182,8 +181,7 @@
|
|||||||
|
|
||||||
/* set to 1 to provide a disk_ioctrl function even if not needed by the FatFs */
|
/* set to 1 to provide a disk_ioctrl function even if not needed by the FatFs */
|
||||||
#define STM32_SD_DISK_IOCTRL_FORCE (0)
|
#define STM32_SD_DISK_IOCTRL_FORCE (0)
|
||||||
|
#define CARD_SUPPLY_SWITCHABLE (0) // power on not depend any IO
|
||||||
#define CARD_SUPPLY_SWITCHABLE (0) //0£¬power on not depend any IO
|
|
||||||
#define SOCKET_WP_CONNECTED (0)
|
#define SOCKET_WP_CONNECTED (0)
|
||||||
#define SOCKET_CP_CONNECTED (0)
|
#define SOCKET_CP_CONNECTED (0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user