mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 00:05:17 +03:00
[X10 Express] Spectrum analyser, first version
This commit is contained in:
parent
01c88fbba8
commit
ffb731dc30
11 changed files with 281 additions and 140 deletions
|
@ -49,48 +49,11 @@ void addRadioModuleTool(uint8_t index, const char * label, void (* tool)(event_t
|
|||
#define TOOL_NAME_MAXLEN 16
|
||||
|
||||
#if defined(LUA)
|
||||
bool readToolName(const char * filename, char * name)
|
||||
{
|
||||
FIL file;
|
||||
char buffer[1024];
|
||||
UINT count;
|
||||
|
||||
if (f_open(&file, filename, FA_READ) != FR_OK) {
|
||||
return "Error opening file";
|
||||
}
|
||||
|
||||
if (f_read(&file, &buffer, sizeof(buffer), &count) != FR_OK) {
|
||||
f_close(&file);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char * tns = "TNS|";
|
||||
auto * start = std::search(buffer, buffer + sizeof(buffer), tns, tns + 4);
|
||||
if (start >= buffer + sizeof(buffer))
|
||||
return false;
|
||||
|
||||
start += 4;
|
||||
|
||||
const char * tne = "|TNE";
|
||||
auto * end = std::search(buffer, buffer + sizeof(buffer), tne, tne + 4);
|
||||
if (end >= buffer + sizeof(buffer) || end <= start)
|
||||
return false;
|
||||
|
||||
uint8_t len = end - start;
|
||||
if (len > TOOL_NAME_MAXLEN)
|
||||
return false;
|
||||
|
||||
strncpy(name, start, len);
|
||||
memclear(name + len, TOOL_NAME_MAXLEN + 1 - len);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void addRadioScriptTool(uint8_t index, const char * path)
|
||||
{
|
||||
char toolName[TOOL_NAME_MAXLEN + 1];
|
||||
|
||||
if (!readToolName(path, toolName)) {
|
||||
if (!readToolName(toolName, path)) {
|
||||
strAppendFilename(toolName, getBasename(path), TOOL_NAME_MAXLEN);
|
||||
}
|
||||
|
||||
|
@ -102,12 +65,6 @@ void addRadioScriptTool(uint8_t index, const char * path)
|
|||
luaExec(path);
|
||||
}
|
||||
}
|
||||
|
||||
bool isRadioScriptTool(const char * filename)
|
||||
{
|
||||
const char * ext = getFileExtension(filename);
|
||||
return ext && !strcasecmp(ext, SCRIPT_EXT);
|
||||
}
|
||||
#endif
|
||||
|
||||
void menuRadioTools(event_t event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue