Skip to content

Commit

Permalink
sd card remount -> reinitialize
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Mar 25, 2020
1 parent 8f5f1ca commit 1765413
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 46 deletions.
17 changes: 0 additions & 17 deletions src/eez/gui/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ static uint32_t m_touchDownTime;
static uint32_t m_lastAutoRepeatEventTime;
static bool m_longTouchGenerated;
static bool m_extraLongTouchGenerated;
static int m_lastTouchMoveX = -1;
static int m_lastTouchMoveY = -1;

void processTouchEvent(EventType type);
void onPageTouch(const WidgetCursor &foundWidget, Event &touchEvent);
Expand Down Expand Up @@ -107,18 +105,6 @@ void processTouchEvent(EventType type) {
m_onTouchFunction = onPageTouch;
}
}
#if defined(EEZ_PLATFORM_STM32)
else if (type == EVENT_TYPE_TOUCH_MOVE) {
// ignore EVENT_TYPE_TOUCH_MOVE if it is the same as the last event
// or change is too big
int dx = (m_lastTouchMoveX - x);
int dy = (m_lastTouchMoveY - y);
int d = dx * dx + dy * dy;
if (d == 0 || d > 1000) {
return;
}
}
#endif
else if (type == EVENT_TYPE_TOUCH_UP) {
m_activeWidget = 0;
}
Expand All @@ -131,9 +117,6 @@ void processTouchEvent(EventType type) {

m_onTouchFunction(m_foundWidgetAtDown, event);
}

m_lastTouchMoveX = x;
m_lastTouchMoveY = y;
}

OnTouchFunctionType getTouchFunction(const WidgetCursor &widgetCursor) {
Expand Down
5 changes: 1 addition & 4 deletions src/eez/modules/psu/dlog_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,7 @@ void fileWrite() {
err = event_queue::EVENT_ERROR_DLOG_FILE_REOPEN_ERROR;
}

if (!sd_card::remount()) {
err = SCPI_ERROR_MASS_STORAGE_ERROR;
break;
}
sd_card::reinitialize();
}

event_queue::pushEvent(err);
Expand Down
4 changes: 1 addition & 3 deletions src/eez/modules/psu/list_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,7 @@ bool saveList(
}
}

if (!sd_card::remount()) {
break;
}
sd_card::reinitialize();
}

if (err) {
Expand Down
4 changes: 1 addition & 3 deletions src/eez/modules/psu/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,7 @@ static bool saveProfileToFile(const char *filePath, Parameters &profile, List *l
}
}

if (!sd_card::remount()) {
break;
}
sd_card::reinitialize();
}

if (err) {
Expand Down
17 changes: 4 additions & 13 deletions src/eez/modules/psu/sd_card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,11 @@ void onSdDetectInterruptHandler() {
}
#endif

bool remount() {
SD.unmount();
void reinitialize() {
#if defined(EEZ_PLATFORM_STM32)
FATFS_UnLinkDriver(SDPath);
MX_FATFS_Init();
#endif
return SD.mount(&g_lastError);
}

bool isMounted(int *err) {
Expand Down Expand Up @@ -366,11 +364,7 @@ bool download(const char *filePath, bool truncate, const void *buffer, size_t si
}
}

if (!sd_card::remount()) {
err = SCPI_ERROR_MASS_STORAGE_ERROR;
break;
}

sd_card::reinitialize();

bool ropened = false;

Expand All @@ -382,18 +376,15 @@ bool download(const char *filePath, bool truncate, const void *buffer, size_t si
}
}

if (!sd_card::remount()) {
err = SCPI_ERROR_MASS_STORAGE_ERROR;
break;
}
sd_card::reinitialize();
}

if (!ropened) {
break;
}
}

sd_card::remount();
sd_card::reinitialize();

if (perr) {
*perr = err;
Expand Down
2 changes: 1 addition & 1 deletion src/eez/modules/psu/sd_card.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void onSdDetectInterrupt();
void onSdDetectInterruptHandler();
#endif

bool remount();
void reinitialize();

bool isMounted(int *err);
bool isBusy();
Expand Down
6 changes: 1 addition & 5 deletions src/eez/scpi/scpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ void oneIter() {
}
}

if (!sd_card::remount()) {
event_queue::pushEvent(SCPI_ERROR_MASS_STORAGE_ERROR);
g_screenshotGenerating = false;
return;
}
sd_card::reinitialize();
}

// timeout
Expand Down

0 comments on commit 1765413

Please sign in to comment.