Skip to content

Commit b71a330

Browse files
diggerbonkidolpxtschak909markjfisherFozzTexx
authored
merge local branch into mainline (#7)
* update * tnfs menu changes * updating dir_seek and dir_tell menu options * removing unused option * removing unused method * remove unused var * update * remove planning doc * merge lateset firmware changes into local branches (#2) * sync latest from ML * [iec] sync latest from Meatloaf * [iec] oops forgot this one * [f256] Add missing DW commands. * [iwm network] Add 0x0a line ending to JSON parser * [sio][fuji] revert fujinet.cpp changes to allocate network device in PSRAM until work out why it is corrupting data * [network] initialise field values - fixes PSRAM issues where translation value was not initialised to 0 and was corrupting binary values * [network][sio] Fix memory leak when network is not closed before reopening * Removed direct access to _fnDisk2s to eliminate shadowing issues with _fnDisks.disk_dev and ensure more consistent access. * Move IWM byte decoding into a function. * Split up service() into sub services to make it easier to add more services (such as Disk II write). * [network] fix crash when device spec is empty. REDUCE DEFAULT LOGGING Most logging is now hidden behind VERBOSE_HTTP or VERBOSE_PROTOCOL which you should enable if you want more logging * drivewire: return config disk sectors (if mounted) only for drive 0 * [dw][foenix] adding boards and pinmap for foenix w/ d32 * [dw][foenix] board fix up * [dw][foenix] builds but not working, no opcode logging seen * Added support for missing DriveWire commands * [dw][foenix] fix board by not inverting tx rx in fnuart2 * Fix Disk II mounting from web interface. * [sio][pc] guard esp32 code to fix fujinet-pc on atari * [webui] fixes FujiNetWIFI#785 Add Alaska AKST+9AKDT * There are no _fnDisk2s on PC build, don't try to return them. * [iwm][fuji] Make fuji a real device so it doesn't rely on the DISK_0 hack The DISK_0 hack is sadly still there, but fujinet-lib doesn't use it by default anymore, but does fall back to it for older firmware that still has this god forsaken hack in it. * [iwm] protect against FN crash after a reset on an open network connection * fnFTP: skip sending password if server didn't 331 * Added support for missing DriveWire commands Moved to a state machine for processing DriveWire commands Moved to a state machine for processing FujiNet commands * Renamed onTimer because it's a global and conflicts. * build: add CoCo esp32s3 support * build.sh - only show board name, not full ini file name when listing available boards * [device] Add new Clock device class independent of platforms * Remove clock debug * Fixed issue where readexError wasn't being reset on each call into op_readex(), causing returns of errors from previous iterations. * use USB instead of ACM * [coco] add force uart baud to s3 * [coco] change S3 UART to 1 from 2 * Remove immediate exit from build.sh if there is an error * [clock] add missing include for gcc build * cause build.sh to exit if pio tasks fail * [iwm] Return correct error code when there is a status call on non-opened protocol This was incorrectly returning 1, which is also the OK code and causing fujinet-lib to tightly loop as it did not think there was an error. * Revert "Use driver/gptimer.h" This reverts commit a017eba. * Improve relative path resolution (retry) * Added ability for Disk II to write. * Allocate track buffer when starting disk, free it when stopping. * Remove unused track buffer allocation. * Restore version.h. * Use heap_caps_free * Add comments about ack is used as write protect. * apple2: fuji: add lobby boot option * Define more SmartPort command constants. * No Disk II write support on PC. * apple2: update autorun.po. Adds Lobby and DiskII Write support * ATARI: Improve trailing slash in sio_set_prefix * Added SmartPort CONTROL and STATUS commands to clear/get monitor Disk II /DRIVEn enable status. * added config.prg to IEC, basic framework * [iec] add mlb to filesystem for testing * [iec] move mlb to the correct folder * [iec] fix release ATN wait on bus process * [iec] add "t1" test loader program * Add debug_version.py to put commit ID into FN_VERSION_FULL during build without altering include/version.h * No need to check what Slot/Drive Disk II responds to on PC. * Add FujiNet-PC nightly builds/releases * [GHA] re-enable targets in Build FN-PC * [GHA] Get ready for FN-PC nightly! * [iec] sync and troubleshooting protocol * Revert block-size values in devrelay to fixed 512 byte size * Fix string_utils use of contains * [iec] check ATN status before and after EOI * [iec] use timer for EOI detection * [iec] disable interrupts during EOI detect * [iec] do check before calling selectProtocol() * [iec] reset protocol to standard serial before read_command() adjust bus state for device detect * [iec] reset bus data after TALK * ATARI: Corrected 'NCD N1:' to clear mount * [PC] precise gettimeofday() for Windows 7 * By default, don't use most recent modified date since it causes everything to rebuild. * Print characters per second when finished sending file. * Fix D64 to not read past the end of a sector on large reads. * Eliminate a bunch of warnings. * Make conditionals match where setup_card_detect is being used. * ini for my cococart * disable pull resistors on NMI pin 27 * Rebuild IEC state machine so it's handled in ISR (FujiNetWIFI#816) * Eliminate a bunch of warnings. * There doesn't seem to be a contains() method in std::string * Use commit date instead of newest modified file date by default. * Print IEC transfer speed. * Clarify which pins are used for IEC on Lolin D32 * There is no up/down/pull/true/false/high/low/0/1, only assert/release. * Start moving IEC bus access and state management out of virtual devices. * Make IEC state private and move IEC access macros to _protocol.h * Speed up transfer. * Don't blindly read past end of D64 sector. * Whitespace cleanup. * Put state machine into cbm_on_clk_isr_handler() * Add dynamic delaying before starting transfer. * JiffyDOS. * Remove unused functions. * Don't set bus idle when there's no current command. * Remove COMPLEX_WAIT ifdef * Remove legacy IEC_ASSERT_RELEASE_AS_FUNCTIONS * Don't send command on EOI, wait for unlisten. * Don't releaseLines() until ATN is released. * Don't try to do secondary command if there's no primary command. * Don't discard bytes during LISTEN. * Release lines immediately on LISTEN. * Set state to BUS_IDLE when releasing lines. * Fix problems with transferDelaySinceLast() * Revert CoCo WIPs so latest firmware builds work for CoCo (FujiNetWIFI#817) * Revert "Renamed onTimer because it's a global and conflicts." This reverts commit fd750ff. * Revert "Added support for missing DriveWire commands" This reverts commit 7a0f211. * sync latest changes from Meatloaf * skip clk isr after unlisten/untalk add delay after clk release in turnaround * careful with constant changes for s3. * [iec] add PIN_DEBUG remove skip in CLK ISR * [iec] fix ml http client add define for JIFFYDOS replace timer functions in _protocol * [iec] enhance ML HTTP client streaming * [iec] adjustments to ML HTTP client * [iec] loading media via HTTP is almost as fast as from SD now! * Merge branch 'iec-tnfs' * [CoCo] WebUI mark some sections as experimental Printer, Modem, Tape Recorder and CP/M as experimental - hidden unless "Show experimental features" is checked * [CoCo] Add Emulator section into WebUI - Added Emulator Settings to enable/disable Becker port, FN-PC, FN-ESP - Added Serial Port section to configure port and baud rate, FN-PC only - Used BOIP configuration to keep enabled/disabled, host or IP and port - For Atari NetSIO, used BOIP configuration section too - Removed NetSIO configuration section - Introduced tweaks.platform in webui/config yaml to allow platform specific texts and controls in WebUI * [PC] update fnconfig.ini * [coco] Update Becker interface on ESP - On ESP, restart FujiNet after Becker enable/disable Serial port driver on ESP was not happy when loaded/unloaded from web server task. - On ESP, no Becker host:port setting in WebUI Default settings is to listen on all IPs (i.e. WiFi IP on FN-ESP) * fnSystem: fix SD card detect for non Atari platforms * [fuji][sio]: QR encoder initial proof of concept * [fuji][atari] QR: to_bits, to_atascii, dynamic sizes * [fuji][sio] QR: use diagonal line atascii * [fuji] QR: add docs/comments * [fuji] QR: fix non-pc builds * [http] add simple URL shortening to web server * [sio] QR: add url shorten option to encode * [http] fix: include algorithm header for all_of * [http] fix missing include vector * small correction in index.tmpl.html * [PC] fix Windows build * [rs232] tweaks. * [fujinet-pc] fix HSIO with serial port SIO * atari: new Altirra 850 handler and relocator to fix break key crash. modem now checks filesize of handler and relocator * add clock SOS time format back in * Device ESP32-S3 : Add Analogic & I2s Audio Out * Only set the network unit if the command count has a value sent by fujinet-lib that supports it * [FN-PC/Atari] poll NetSIO from sio_copy_file() * [network-protocol][http] try GET if PROPFIND fails. * [network-protocol][http] add 408 timeout to the propfind check. * [network-protocol][http] force http_transaction() on open dir handle if propfind fails. * Be smarter about finding python3 * [iwm][fuji] set read_only prior to mount. * FsSD: remove uneeded ternary for debug print * [network-protocol] do not emit EOF on write. * [printer-emulator] PDF printers should support form feed. * Updated SP-over-SLIP protocol. Note: This is an incompatible protocol change. It requires a companion change in AppleWin. FujiNet makes use of command list bytes there weren't used so far. This only works with CBus because CBus alwaways tranports all possible command list bytes no matter what command is given. Now the SP-over-SLIP protocol shows exactly the same behavior CBus protocol. * Fixed tabs. * [rs232][fuji] autorun.img * [rs232][fuji] add some debug msgs. * [rs232][disk] add disk read debugging. * [rs232] undo atari hacks. * Validate the path in Fujinet "hosts list" browser in the web UI. Before this commit it's possible to escape the configured root by specifying .. in the escaped slash: http://localhost:8000/browse/host/1/%2F..%2F..%2F..%2F --------- Co-authored-by: Jaime Idolpx <[email protected]> Co-authored-by: Thomas Cherryhomes <[email protected]> Co-authored-by: Mark Fisher <[email protected]> Co-authored-by: Chris Osborn <[email protected]> Co-authored-by: mozzwald <[email protected]> Co-authored-by: Andrew Diller <[email protected]> Co-authored-by: Boisy Pitre <[email protected]> Co-authored-by: Noah Burney <[email protected]> Co-authored-by: Jeff Piepmeier <[email protected]> Co-authored-by: Michael Sternberg <[email protected]> Co-authored-by: Jan Krupa <[email protected]> Co-authored-by: Eric Carr <[email protected]> Co-authored-by: robjustice <[email protected]> Co-authored-by: naeloob <[email protected]> Co-authored-by: Oliver Schmidt <[email protected]> Co-authored-by: Tomek Rękawek <[email protected]> * update * tnfs menu changes * updating dir_seek and dir_tell menu options * removing unused option * removing unused method * remove unused var * update * remove planning doc * update * update * updating menu parse --------- Co-authored-by: Jaime Idolpx <[email protected]> Co-authored-by: Thomas Cherryhomes <[email protected]> Co-authored-by: Mark Fisher <[email protected]> Co-authored-by: Chris Osborn <[email protected]> Co-authored-by: mozzwald <[email protected]> Co-authored-by: Andrew Diller <[email protected]> Co-authored-by: Boisy Pitre <[email protected]> Co-authored-by: Noah Burney <[email protected]> Co-authored-by: Jeff Piepmeier <[email protected]> Co-authored-by: Michael Sternberg <[email protected]> Co-authored-by: Jan Krupa <[email protected]> Co-authored-by: Eric Carr <[email protected]> Co-authored-by: robjustice <[email protected]> Co-authored-by: naeloob <[email protected]> Co-authored-by: Oliver Schmidt <[email protected]> Co-authored-by: Tomek Rękawek <[email protected]>
1 parent d2db587 commit b71a330

File tree

6 files changed

+304
-5
lines changed

6 files changed

+304
-5
lines changed

lib/FileSystem/fnFS.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ enum fsType
4242
FSTYPE_COUNT
4343
};
4444

45+
enum resourceType
46+
{
47+
RESOURCE_TYPE_TEXT = 0,
48+
RESOURCE_TYPE_FOLDER,
49+
RESOURCE_TYPE_LINK,
50+
RESOURCE_TYPE_FILE
51+
};
52+
4553
#define DIR_OPTION_DESCENDING 0x0001 // Sort descending, not ascending
4654
#define DIR_OPTION_FILEDATE 0x0002 // Sort by date, not name
4755

@@ -51,6 +59,7 @@ struct fsdir_entry
5159
bool isDir;
5260
uint32_t size;
5361
time_t modified_time;
62+
uint8_t resourceType;
5463
};
5564
typedef struct fsdir_entry fsdir_entry_t;
5665

lib/device/sio/fuji.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,14 +1133,17 @@ void _set_additional_direntry_details(fsdir_entry_t *f, uint8_t *dest, uint8_t m
11331133

11341134
dest[8] = f->isDir ? FF_DIR : 0;
11351135

1136-
maxlen -= 10; // Adjust the max return value with the number of additional bytes we're copying
1136+
maxlen -= 11; // Adjust the max return value with the number of additional bytes we're copying
11371137
if (f->isDir) // Also subtract a byte for a terminating slash on directories
11381138
maxlen--;
11391139
if (strlen(f->filename) >= maxlen)
11401140
dest[8] |= FF_TRUNC;
11411141

11421142
// File type
11431143
dest[9] = MediaType::discover_disktype(f->filename);
1144+
1145+
// Resource Type
1146+
dest[10] = f->resourceType;
11441147
}
11451148

11461149
// TODO: VERIFY THIS CODE. THE STASH SEEMED CORRUPT

lib/fuji/fujiHost.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ uint16_t fujiHost::dir_tell()
108108
case HOSTTYPE_TNFS:
109109
case HOSTTYPE_SMB:
110110
case HOSTTYPE_FTP:
111-
result = _fs->dir_tell();
111+
if (_menu.get_initialized()) result = _menu.get_pos();
112+
else result = _fs->dir_tell();
112113
break;
113114
case HOSTTYPE_UNINITIALIZED:
114115
break;
@@ -129,7 +130,8 @@ bool fujiHost::dir_seek(uint16_t pos)
129130
case HOSTTYPE_TNFS:
130131
case HOSTTYPE_SMB:
131132
case HOSTTYPE_FTP:
132-
result = _fs->dir_seek(pos);
133+
if (_menu.get_initialized()) result = _menu.set_pos(pos);
134+
else result = _fs->dir_seek(pos);
133135
break;
134136
case HOSTTYPE_UNINITIALIZED:
135137
break;
@@ -165,6 +167,13 @@ bool fujiHost::dir_open(const char *path, const char *pattern, uint16_t options)
165167
case HOSTTYPE_UNINITIALIZED:
166168
break;
167169
}
170+
171+
// if there is a tnfs.menu file, initialize the menu for
172+
if (strlen(realpath) > 1) strlcat(realpath, "/tnfs.menu", 256);
173+
else strlcat(realpath, "tnfs.menu", 256);
174+
FILE * mf = _fs->file_open(realpath, "r");
175+
if (mf) _menu.init(realpath, mf);
176+
168177
return result;
169178
}
170179

@@ -178,7 +187,8 @@ fsdir_entry_t *fujiHost::dir_nextfile()
178187
case HOSTTYPE_TNFS:
179188
case HOSTTYPE_SMB:
180189
case HOSTTYPE_FTP:
181-
return _fs->dir_read();
190+
if (_menu.get_initialized()) return _menu.next_menu_entry();
191+
else return _fs->dir_read();
182192
case HOSTTYPE_UNINITIALIZED:
183193
break;
184194
}
@@ -188,6 +198,7 @@ fsdir_entry_t *fujiHost::dir_nextfile()
188198

189199
void fujiHost::dir_close()
190200
{
201+
_menu.release();
191202
if (_type != HOSTTYPE_UNINITIALIZED && _fs != nullptr)
192203
_fs->dir_close();
193204
}
@@ -500,4 +511,10 @@ bool fujiHost::umount()
500511

501512
// Try unmounting TNFS/SMB/FTP
502513
return 0 == unmount_fs();
503-
}
514+
}
515+
516+
fujiMenu * fujiHost::get_menu()
517+
{
518+
if (_menu.get_initialized()) return &_menu;
519+
else return nullptr;
520+
}

lib/fuji/fujiHost.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _FUJI_HOST_
33

44
#include "fnFS.h"
5+
#include "fujiMenu.h"
56

67
#define MAX_HOSTNAME_LEN 32
78
#define MAX_HOST_PREFIX_LEN 256
@@ -21,6 +22,8 @@ class fujiHost
2122
const char * _sdhostname = "SD";
2223
FileSystem *_fs = nullptr;
2324
fujiHostType _type;
25+
fujiMenu _menu;
26+
2427
char _hostname[MAX_HOSTNAME_LEN] = { '\0' };
2528
char _prefix[MAX_HOST_PREFIX_LEN] = { '\0' };
2629

@@ -43,6 +46,7 @@ class fujiHost
4346

4447
void set_type(fujiHostType type);
4548
fujiHostType get_type() { return _type; };
49+
fujiMenu * get_menu();
4650

4751
void set_hostname(const char *hostname);
4852
const char* get_hostname(char *buffer, size_t buffersize);

lib/fuji/fujiMenu.cpp

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
#include "fujiMenu.h"
2+
3+
#include <cstring>
4+
#include <stdlib.h>
5+
#include <stdio.h>
6+
7+
#include "../../include/debug.h"
8+
9+
#include "fnFsSD.h"
10+
#include "fnFsTNFS.h"
11+
12+
#include "utils.h"
13+
14+
bool fujiMenu::init(const char *path, FILE * mf)
15+
{
16+
Debug_printf("fujiMenu::init, IN\r\n");
17+
release();
18+
_menu_file = mf;
19+
return true;
20+
}
21+
22+
void fujiMenu::release()
23+
{
24+
_current_offset = 0;
25+
_current_pos = 0;
26+
27+
if (_menu_file != nullptr)
28+
{
29+
fclose(_menu_file);
30+
_menu_file = nullptr;
31+
}
32+
}
33+
34+
bool fujiMenu::set_pos(uint16_t newPos)
35+
{
36+
37+
char tempBuf[TNFSMENU_MAX_LINE_LEN];
38+
39+
// find the offset of the new menu position.
40+
_current_pos = 0;
41+
_current_offset = 0;
42+
int linelen = 0;
43+
44+
while (_current_pos < newPos && fgets(tempBuf, TNFSMENU_MAX_LINE_LEN, _menu_file))
45+
{
46+
47+
linelen = strlen(tempBuf);
48+
49+
if (linelen <= 0)
50+
{
51+
break;
52+
}
53+
else if ((_current_offset + linelen) > TNFSMENU_MAX_SIZE) {
54+
Debug_printf("fujiMenu::init, truncating menu because it is over TNFSMENU_MAX_SIZE\r\n");
55+
break;
56+
}
57+
else if ((_current_pos + 1) > TNFSMENU_MAX_LINES) {
58+
Debug_printf("fujiMenu::init, truncating menu because it is over TNFSMENU_MAX_LINES\r\n");
59+
break;
60+
}
61+
62+
_current_pos += 1;
63+
_current_offset += linelen;
64+
}
65+
66+
return true;
67+
}
68+
69+
int16_t fujiMenu::decode_menutype(const char * buf, int numDigits)
70+
{
71+
Debug_printf("fujiMenu decode menutype in\r\n");
72+
int16_t retval = 0;
73+
int mult = 1;
74+
for (int i = (numDigits-1); i >= 0; i--) {
75+
if (buf[i] < 48 || buf[i] > 57) return -1;
76+
retval += ((buf[i]-48)*mult);
77+
mult = (mult*10);
78+
}
79+
Debug_printf("fujiMenu decode menutype out %i\r\n", retval);
80+
return retval;
81+
}
82+
83+
/*
84+
* Get the next menu item. Menu items have the format:
85+
*
86+
* <type>|<resource>|<display name>
87+
*
88+
* OR
89+
*
90+
* <item resource>
91+
*
92+
* Where:
93+
*
94+
* <type> is the numeric type ID of the menu item.
95+
* <resource> this is the name of the item as shoudl be displyed on screen
96+
* <displayname> screen friendly display name for the resource.
97+
*/
98+
99+
fsdir_entry_t * fujiMenu::next_menu_entry()
100+
{
101+
char tempBuf[TNFSMENU_MAX_LINE_LEN];
102+
char myBuf[TNFSMENU_MAX_LINE_LEN];
103+
_type = RESOURCE_TYPE_TEXT;
104+
_displayname_len = 0;
105+
_resource_len = 0;
106+
memset(_displayname, 0, TNFSMENU_MAX_DISPLAY_NAME);
107+
memset(_resource, 0, TNFSMENU_MAX_RESOURCE);
108+
uint8_t displayNameStart = 0;
109+
uint8_t resourceStart = 0;
110+
111+
// if we have an offset, skip to it.
112+
if (_current_offset > 0)
113+
{
114+
if (fseek(_menu_file, _current_offset, 0) != 0)
115+
{
116+
Debug_printf("fujiMenu::next_menu_entry, cannot seek to current offset.\r\n");
117+
return nullptr;
118+
}
119+
}
120+
121+
if (!fgets(tempBuf, TNFSMENU_MAX_LINE_LEN, _menu_file))
122+
{
123+
Debug_printf("fujiMenu::next_menu_entry, can't read next line from menu file\r\n");
124+
return nullptr;
125+
}
126+
127+
_current_pos += 1;
128+
_current_offset += strlen(tempBuf);
129+
130+
// menu format: [<type>|]<name>[|<item>]
131+
132+
int len = strlen(tempBuf);
133+
134+
if (len>0 && tempBuf[len-1] == '\n') {
135+
tempBuf[len-1] = 0;
136+
len--;
137+
}
138+
else return nullptr;
139+
140+
int newBufPos = 0;
141+
int offsets[4];
142+
char lastChar = ' ';
143+
int count = 0;
144+
_displayname_len = len;
145+
_resource_len = len;
146+
147+
for (int i=0; i<len; i++)
148+
{
149+
if (tempBuf[i] == '|' && lastChar != '\\') {
150+
myBuf[newBufPos] = 0;
151+
newBufPos++;
152+
offsets[count] = newBufPos;
153+
if (count == 0) {
154+
displayNameStart = newBufPos;
155+
_displayname_len = (len - newBufPos);
156+
resourceStart = displayNameStart;
157+
_resource_len = _displayname_len;
158+
}
159+
else if (count == 1) {
160+
_displayname_len = (i - displayNameStart);
161+
resourceStart = newBufPos;
162+
_resource_len = (len - resourceStart);
163+
}
164+
count++;
165+
lastChar = tempBuf[i];
166+
}
167+
else if (tempBuf[i] == '\\') {
168+
lastChar = '\\';
169+
}
170+
else {
171+
myBuf[newBufPos] = tempBuf[i];
172+
newBufPos++;
173+
lastChar = tempBuf[i];
174+
}
175+
}
176+
177+
if (count > 0) {
178+
_type = decode_menutype(tempBuf, displayNameStart-1);
179+
}
180+
181+
if (_debug) {
182+
for (int i = 0; i < count; i++) {
183+
Debug_printf("fujiMenu::read_menu_entry offset %i: %s\r\n", i, &myBuf[offsets[i]]);
184+
}
185+
}
186+
187+
if (_displayname_len >= TNFSMENU_MAX_DISPLAY_NAME) _displayname_len = TNFSMENU_MAX_DISPLAY_NAME-1;
188+
if (_resource_len >= TNFSMENU_MAX_RESOURCE) _resource_len = TNFSMENU_MAX_RESOURCE-1;
189+
190+
strncpy(_displayname, &myBuf[displayNameStart], _displayname_len);
191+
strncpy(_resource, &myBuf[resourceStart], _resource_len);
192+
193+
if (_debug) {
194+
Debug_printf("fujiMenu::read_menu_entry _displayname: %s\r\n", _displayname);
195+
Debug_printf("fujiMenu::read_menu_entry _resource: %s\r\n", _resource);
196+
}
197+
198+
// populate _direntry;
199+
strncpy(_direntry.filename, _resource, MAX_PATHLEN);
200+
_direntry.isDir = (_type == RESOURCE_TYPE_FOLDER);
201+
_direntry.size = 0;
202+
_direntry.modified_time = 0;
203+
_direntry.resourceType = _type;
204+
return &_direntry;
205+
}
206+
207+
uint8_t fujiMenu::get_displayname(char * p)
208+
{
209+
strcpy(p, _displayname);
210+
return _displayname_len;
211+
}
212+
213+
uint8_t fujiMenu::get_resource(char *p)
214+
{
215+
strcpy(p, _resource);
216+
return _resource_len;
217+
}

lib/fuji/fujiMenu.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef _FUJI_MENU_
2+
#define _FUJI_MENU_
3+
4+
#include <stdio.h>
5+
#include "fnFS.h"
6+
7+
#define TNFSMENU_MAX_SIZE 65535
8+
#define TNFSMENU_MAX_DISPLAY_NAME 80
9+
#define TNFSMENU_MAX_RESOURCE 168
10+
#define TNFSMENU_MAX_LINE_LEN MAX_PATHLEN
11+
#define TNFSMENU_MAX_LINES 4096
12+
13+
class fujiMenu
14+
{
15+
private:
16+
17+
FILE * _menu_file = nullptr;
18+
uint16_t _current_offset = 0;
19+
uint16_t _current_pos = 0;
20+
fsdir_entry _direntry;
21+
bool _debug = false;;
22+
23+
uint8_t _type = RESOURCE_TYPE_TEXT;
24+
uint8_t _displayname_len = 0;
25+
char _displayname[TNFSMENU_MAX_DISPLAY_NAME];
26+
uint8_t _resource_len = 0;
27+
char _resource[TNFSMENU_MAX_RESOURCE];
28+
int16_t decode_menutype(const char * buf, int numDigits);
29+
30+
public:
31+
32+
fujiMenu() {};
33+
~fujiMenu() {};
34+
35+
uint16_t get_menu_entry_type() { return _type; };
36+
uint8_t get_displayname_len() { return _displayname_len; };
37+
uint8_t get_resource_len() { return _resource_len; };
38+
uint8_t get_displayname(char * p);
39+
uint8_t get_resource(char * p);
40+
bool init(const char *path, FILE * mf);
41+
void release();
42+
bool get_initialized() { return (_menu_file != nullptr); };
43+
uint16_t get_pos() { return _current_offset; };
44+
bool set_pos(uint16_t newPos);
45+
fsdir_entry_t * next_menu_entry();
46+
47+
};
48+
49+
#endif // _FUJI_MENU_

0 commit comments

Comments
 (0)