Skip to content

Commit

Permalink
Added configuration export in PGUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
rombrew committed Jan 11, 2025
1 parent 5d04bbc commit 21f7f97
Show file tree
Hide file tree
Showing 37 changed files with 692 additions and 257 deletions.
3 changes: 0 additions & 3 deletions bench/tsfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,6 @@ void ts_script_test()
ts_script_base();
blm_restart(&m);

//pm.config_DCU_VOLTAGE = PM_DISABLED;
//pm.dcu_tol = 1.f;

ts_script_speed();
blm_restart(&m);

Expand Down
13 changes: 11 additions & 2 deletions doc/TroubleShooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ completely inoperable.
the output terminals. Power stages or terminal voltage sensors are definitely
broken.

`PM_ERROR_LOW_ACCURACY` - Result of adjustment shows the parameter deviation is
above the fault threshold. Check the voltage and current measurement circuit.
`PM_ERROR_LOW_CURRENT_ACCURACY` - Result of current sensor adjustment shows the
deviation is above the fault threshold. Check your current measurement circuit
or increse the fault threshold.

`PM_ERROR_LOW_VOLTAGE_ACCURACY` - Result of voltage circuit adjustment shows
the deviation is above the fault threshold. Check your voltage measurement
circuit or increse the fault threshold.

`PM_ERROR_LOW_DEADBAND_ACCURACY` - Result of deadband distortion adjustment
shows the deviation is above the fault threshold. If your motor winding
resistance is too high (over ~0.1 Ohm) consider to disable DCU compensation.

`PM_ERROR_CURRENT_LOOP_FAULT` - This means that we apply the full voltage but
actual current is still low. If current sensing circuit is OK this may be
Expand Down
2 changes: 1 addition & 1 deletion pgui/Makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CFLAGS += -fno-math-errno \

CFLAGS += -fno-stack-protector
CFLAGS += -I$(MINGW)/include
CFLAGS += -D_EMBED_GP -D_WINDOWS
CFLAGS += -D_EMBED_GP -D_LOCAL_GP -D_LOCAL_PGUI -D_WINDOWS

LFLAGS = -lm -lSDL2 -lSDL2_ttf -lSDL2_image -static -mwindows
LFLAGS += -L$(MINGW)/lib
Expand Down
43 changes: 31 additions & 12 deletions pgui/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ void config_read(struct config_phobia *fe)
name = strtok(line, sep);
value = strtok(NULL, sep);

if ( name == NULL
|| value == NULL) {
if (name == NULL)
goto config_read_SKIP;

/* Skip empty lines */
}
else if (strcmp(name, "version") == 0) {
if (value == NULL)
value = "";

if (strcmp(name, "version") == 0) {

fe->version = strtol(value, NULL, 10);
}
Expand Down Expand Up @@ -113,6 +114,8 @@ void config_read(struct config_phobia *fe)

fe->regfile = strtol(value, NULL, 10);
}
config_read_SKIP:

}

fclose(fd);
Expand All @@ -123,8 +126,6 @@ void config_open(struct config_phobia *fe)
{
char *path_HOME;

config_default(fe);

#ifdef _WINDOWS
path_HOME = getenv("APPDATA");
#else /* _WINDOWS */
Expand All @@ -136,6 +137,10 @@ void config_open(struct config_phobia *fe)
fe->local = 1;
}

#ifdef _LOCAL_PGUI
fe->local = 1;
#endif /* _LOCAL_PGUI */

if (fe->local == 0) {

#ifdef _WINDOWS
Expand All @@ -145,6 +150,8 @@ void config_open(struct config_phobia *fe)
#endif
strcat(fe->rcfile, DIRSEP FILE_HIDDEN_CONFIG);

config_default(fe);

if (config_rcfiletry(fe) == 0) {

config_write(fe);
Expand Down Expand Up @@ -224,21 +231,33 @@ void config_default(struct config_phobia *fe)

fe->windowsize = 1;

#ifdef _WINDOWS
if (fe->local == 0) {

#ifdef _WINDOWS
GetTempPathA(sizeof(lptemp), lptemp);
config_ACP_to_UTF8(fe->storage, lptemp, sizeof(fe->storage));
#else /* _WINDOWS */
strcpy(fe->storage, "/tmp");
#endif
}
else {
fe->storage[0] = 0;
}
#else /* _WINDOWS */
strcpy(fe->storage, "/tmp");
#endif

strcpy(fe->fuzzy, "setpoint");

fe->regfile = 500;
}

void config_storage_path(struct config_phobia *fe, char *lbuf, const char *file)
{
lbuf[0] = 0;

if (fe->storage[0] != 0) {

strcat(lbuf, fe->storage);
strcat(lbuf, DIRSEP);
}

strcat(lbuf, file);
}

2 changes: 2 additions & 0 deletions pgui/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ void config_open(struct config_phobia *fe);
void config_write(struct config_phobia *fe);
void config_default(struct config_phobia *fe);

void config_storage_path(struct config_phobia *fe, char *lbuf, const char *file);

#endif /* _H_CONFIG_ */

2 changes: 1 addition & 1 deletion pgui/gp/dirent.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int dirent_open(struct dirent_stat *sb, const char *path)

MultiByteToWideChar(CP_UTF8, 0, path, -1, p->wpath, DIRENT_PATH_MAX);

wcscat(p->wpath, L"/*");
wcscat(p->wpath, L"\\*");

p->hDIR = FindFirstFileW(p->wpath, &p->fDATA);

Expand Down
4 changes: 4 additions & 0 deletions pgui/gp/gp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4694,6 +4694,10 @@ gpcon_t *gp_Alloc()

gpFileGetPath(gp);

#ifdef _LOCAL_GP
gpFileGetLocal(gp);
#endif /* _LOCAL_GP */

if (gp->rcfile[0] != 0) {

if (gpFileExist(gp->rcfile) == 0) {
Expand Down
Loading

0 comments on commit 21f7f97

Please sign in to comment.