Skip to content

Commit

Permalink
Add option to disable cassette in webui for #471
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzwald committed Mar 20, 2022
1 parent f9c131b commit 51b90b7
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 5 deletions.
13 changes: 13 additions & 0 deletions data/BUILD_ATARI/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,19 @@ <h2 style="text-align: center;">Need help? Go to the <a href="https://github.com
</div>
<div class="cform">
<div class="formwrapper">
<form action="/config" method="post">
<br>Use FujiNet as your virtual Program Recorder?
<select name="cassette_enabled" id="select_cassette_enabled">
<optgroup>
<option value="1">Yes</option>
<option value="0">No</option>
</optgroup>
</select>
<input type="submit" value="Save">
</form>
<script>
var current_cassette_enabled = "<%FN_CASSETTE_ENABLED%>";
</script>
<br>Rewind
<form action="/config" method="post">
<input type="hidden" id="rew" name="rew" value="rew" />
Expand Down
1 change: 1 addition & 0 deletions data/BUILD_ATARI/www/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ selectListValue("select_config_enable", current_config_enabled);
selectListValue("select_boot_mode", current_boot_mode);
selectListValue("select_play_record", current_play_record);
selectListValue("select_pulldown", current_pulldown);
selectListValue("select_cassette_enabled", current_cassette_enabled);
selectListValue("select_status_wait_enable", current_status_wait_enabled);
6 changes: 3 additions & 3 deletions include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#define FN_VERSION_MAJOR 0
#define FN_VERSION_MINOR 5

#define FN_VERSION_BUILD "1ddbcc10"
#define FN_VERSION_BUILD "f9c131b9"

#define FN_VERSION_DATE "2022-03-12 22:10:16"
#define FN_VERSION_DATE "2022-03-20 03:33:32"

#define FN_VERSION_FULL "0.5.1ddbcc10"
#define FN_VERSION_FULL "0.5.f9c131b9"


4 changes: 2 additions & 2 deletions lib/bus/sio/sio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ void systemBus::service()
return; // break!
}

// check if cassette is mounted first
if (_fujiDev->cassette()->is_mounted())
// check if cassette is mounted and enabled first
if (_fujiDev->cassette()->is_mounted() && Config.get_cassette_enabled())
{ // the test which tape activation mode
if (_fujiDev->cassette()->has_pulldown())
{ // motor line mode
Expand Down
19 changes: 19 additions & 0 deletions lib/config/fnConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ bool fnConfig::get_cassette_pulldown()
return _cassette.pulldown;
}

bool fnConfig::get_cassette_enabled()
{
return _cassette.cassette_enabled;
}

void fnConfig::store_cassette_buttons(bool button)
{
if (_cassette.button != button)
Expand All @@ -500,6 +505,15 @@ void fnConfig::store_cassette_pulldown(bool pulldown)
}
}

void fnConfig::store_cassette_enabled(bool cassette_enabled)
{
if (_cassette.cassette_enabled != cassette_enabled)
{
_cassette.cassette_enabled = cassette_enabled;
_dirty = true;
}
}

// Saves CPM Command Control Processor Filename
void fnConfig::store_ccp_filename(std::string filename)
{
Expand Down Expand Up @@ -627,6 +641,7 @@ void fnConfig::save()
ss << LINETERM << "[Cassette]" << LINETERM;
ss << "play_record=" << ((_cassette.button) ? "1 Record" : "0 Play") << LINETERM;
ss << "pulldown=" << ((_cassette.pulldown) ? "1 Pulldown Resistor" : "0 B Button Press") << LINETERM;
ss << "cassette_enabled=" << _cassette.cassette_enabled << LINETERM;

// CPM
ss << LINETERM << "[CPM]" << LINETERM;
Expand Down Expand Up @@ -1158,6 +1173,10 @@ void fnConfig::_read_section_cassette(std::stringstream &ss)
{
_cassette.pulldown = util_string_value_is_true(value);
}
else if (strcasecmp(name.c_str(), "cassette_enabled") == 0)
{
_cassette.cassette_enabled = util_string_value_is_true(value);
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/config/fnConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ class fnConfig
// CASSETTE
bool get_cassette_buttons();
bool get_cassette_pulldown();
bool get_cassette_enabled();
void store_cassette_buttons(bool button);
void store_cassette_pulldown(bool pulldown);
void store_cassette_enabled(bool cassette_enabled);

// CPM
std::string get_ccp_filename(){ return _cpm.ccp; };
Expand Down Expand Up @@ -259,6 +261,7 @@ class fnConfig

struct cassette_info
{
bool cassette_enabled = true;
bool pulldown = false;
bool button = false;
};
Expand Down
13 changes: 13 additions & 0 deletions lib/http/httpServiceConfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ void fnHttpServiceConfigurator::config_boot_mode(std::string boot_mode)
Config.save();
}

void fnHttpServiceConfigurator::config_cassette_enabled(std::string cassette_enabled)
{
Debug_printf("New Cassette Enable Value: %s\n",cassette_enabled.c_str());

// Store
Config.store_cassette_enabled(atoi(cassette_enabled.c_str()));
// Save*
Config.save();
}

void fnHttpServiceConfigurator::config_cassette(std::string play_record, std::string resistor, bool rew)
{
Expand Down Expand Up @@ -385,6 +394,10 @@ int fnHttpServiceConfigurator::process_config_post(const char *postdata, size_t
{
config_cassette(std::string(), std::string(), true);
}
else if (i->first.compare("cassette_enabled") == 0)
{
config_cassette_enabled(i->second);
}
else if (i->first.compare("rotation_sounds") == 0)
{
config_rotation_sounds(i->second);
Expand Down
1 change: 1 addition & 0 deletions lib/http/httpServiceConfigurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class fnHttpServiceConfigurator
static void config_hostname(std::string hostname);
static void config_midimaze(std::string host_ip);
static void config_cassette(std::string play_record, std::string resistor, bool rew);
static void config_cassette_enabled(std::string cassette_enabled);
static void config_rotation_sounds(std::string rotation_sounds);
static void config_enable_config(std::string enable_config);
static void config_boot_mode(std::string boot_mode);
Expand Down
5 changes: 5 additions & 0 deletions lib/http/httpServiceParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const string fnHttpServiceParser::substitute_tag(const string &tag)
FN_PRINTER1_PORT,
FN_PLAY_RECORD,
FN_PULLDOWN,
FN_CASSETTE_ENABLED,
FN_CONFIG_ENABLED,
FN_STATUS_WAIT_ENABLED,
FN_BOOT_MODE,
Expand Down Expand Up @@ -136,6 +137,7 @@ const string fnHttpServiceParser::substitute_tag(const string &tag)
"FN_PRINTER1_PORT",
"FN_PLAY_RECORD",
"FN_PULLDOWN",
"FN_CASSETTE_ENABLED",
"FN_CONFIG_ENABLED",
"FN_STATUS_WAIT_ENABLED",
"FN_BOOT_MODE",
Expand Down Expand Up @@ -331,6 +333,9 @@ const string fnHttpServiceParser::substitute_tag(const string &tag)
else
resultstream << "0 B Button Press";
break;
case FN_CASSETTE_ENABLED:
resultstream << Config.get_cassette_enabled();
break;
#endif /* BUILD_ATARI */
case FN_CONFIG_ENABLED:
resultstream << Config.get_general_config_enabled();
Expand Down

0 comments on commit 51b90b7

Please sign in to comment.