Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions OpenGarage/OpenGarage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ OptionStruct OpenGarage::options[] = {
{"dns1", 0, 0, "8.8.8.8"},
{"ntp1", 0, 0, ""},
{"host", 0, 0, ""},
{"ohwd", 0, 1, ""},
{"hwv", 0, 1, ""},
};

/* Variables and functions for handling Ultrasonic Distance sensor */
Expand Down Expand Up @@ -168,13 +170,6 @@ void OpenGarage::begin() {
digitalWrite(PIN_RELAY, LOW);
pinMode(PIN_RELAY, OUTPUT);

has_swrx = 0;
pinMode(PIN_SWRX_DETECT, INPUT_PULLUP);
if(digitalRead(PIN_SWRX_DETECT) == 0) {
digitalWrite(PIN_SW_RX, INPUT); // software rx exists, set it up
has_swrx = 1;
}

// detect LED logic
pinMode(PIN_LED, INPUT);
// use median filtering to detect led logic
Expand Down Expand Up @@ -209,6 +204,22 @@ void OpenGarage::begin() {
}
}

void OpenGarage::swrx_setup() {
has_swrx = 0;
if(options[OPTION_OHWD].ival) {
if(options[OPTION_HWV].ival) {
digitalWrite(PIN_SW_RX, INPUT); // software rx exists, set it up
has_swrx = 1;
}
} else {
pinMode(PIN_SWRX_DETECT, INPUT_PULLUP);
if(digitalRead(PIN_SWRX_DETECT) == 0) {
digitalWrite(PIN_SW_RX, INPUT); // software rx exists, set it up
has_swrx = 1;
}
}
}

void OpenGarage::options_setup() {
if(!FILESYS.exists(config_fname)) { // if config file does not exist
DEBUG_PRINTLN(F("create config file"));
Expand Down
1 change: 1 addition & 0 deletions OpenGarage/OpenGarage.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class OpenGarage {
static byte led_reverse;
static byte has_swrx;
static void begin();
static void swrx_setup();
static void options_setup();
static void options_load();
static void options_save();
Expand Down
2 changes: 2 additions & 0 deletions OpenGarage/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ typedef enum {
OPTION_DNS1, // dns1 IP
OPTION_NTP1, // custom NTP server
OPTION_HOST, // custom host name
OPTION_OHWD, // override hardware detection
OPTION_HWV, // hardware version
NUM_OPTIONS // number of options
} OG_OPTION_enum;

Expand Down
23 changes: 22 additions & 1 deletion OpenGarage/html/sta_options.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ <h3 class='ui-title' id='popupStatusText'>Detecting Security+ Version ....</h3>
<tr><td><b>HTTP Port:</b></td><td><input type='text' size=5 maxlength=5 id='htp' value=0 data-mini='true'></td></tr>
<tr><td><b>Host Name:</b></td><td><input type='text' size=15 maxlength=32 id='host' data-mini='true' placeholder='(optional)'></td></tr>
<tr><td><b>NTP Server:</b></td><td><input type='text' size=15 maxlength=64 id='ntp1' data-mini='true' placeholder='(optional)'></td></tr>
<tr><td colspan=2><input type='checkbox' id='ohwd' data-mini='true' onclick='update_ohwd()'><label for='ohwd' title='Warning: Only use this if you are absolutely sure you need it!'>Override Hardware Detection</label></td></tr>
<tr class='hv'><td><b>HW Version:</b></td><td>
<fieldset data-role='controlgroup' data-mini='true' data-type='horizontal'>
<input type='radio' name='rd_hv' id='hv_2_2' value=0><label for='hv_2_2'>2.2</label>
<input type='radio' name='rd_hv' id='hv_2_3' value=1><label for='hv_2_3'>2.3+</label>
</fieldset>
</td></tr>
<tr><td colspan=2><input type='checkbox' id='usi' data-mini='true' onclick='update_usi()'><label for='usi'>Use Static IP</label></td></tr>
<tr class='si'><td><b>Device IP:</b></td><td><input type='text' size=15 maxlength=15 id='dvip' data-mini='true'></td></tr>
<tr class='si'><td><b>Gateway IP:</b></td><td><input type='text' size=15 maxlength=15 id='gwip' data-mini='true'></td></tr>
Expand Down Expand Up @@ -218,13 +225,17 @@ <h3 class='ui-title' id='popupStatusText'>Detecting Security+ Version ....</h3>
if(eval_cb('#usi')) $('.si').show();
else $('.si').hide();
}
function update_ohwd(){
if(eval_cb('#ohwd')) $('.hv').show();
else $('.hv').hide();
}
function toggle_opt() {
$('#div_basic').hide();
$('#div_cloud').hide();
$('#div_other').hide();
if(eval_cb('#basic')) $('#div_basic').show();
if(eval_cb('#cloud')) {$('#div_cloud').show(); update_cld(); update_mqtt(); update_email();}
if(eval_cb('#other')) {$('#div_other').show(); update_usi();}
if(eval_cb('#other')) {$('#div_other').show(); update_usi(); update_ohwd(); }
}
$('#btn_back').click(function(e){
e.preventDefault(); goback();
Expand Down Expand Up @@ -271,6 +282,12 @@ <h3 class='ui-title' id='popupStatusText'>Detecting Security+ Version ....</h3>
}
bc('nkey',1);bc('ckey',1);
}
if($('#ohwd').is(':checked')) {
comm+='&ohwd=1';
comm+='&hwv='+eval_cb('#hv_2_3');
} else {
comm+='&ohwd=0';
}
if($('#usi').is(':checked')) {
comm+='&usi=1';
bc('dvip');bc('gwip')+bc('subn');bc('dns1');
Expand Down Expand Up @@ -402,6 +419,10 @@ <h3 class='ui-title' id='popupStatusText'>Detecting Security+ Version ....</h3>
$('#apwd').val(jd.apwd);
$('#recp').val(jd.recp);
update_email();
if(jd.hwv) cbt('hv_2_3');
else cbt('hv_2_2');
if(jd.ohwd>0) cbt('ohwd');
update_ohwd();
$('#dvip').val(jd.dvip);
$('#gwip').val(jd.gwip);
$('#subn').val(jd.subn);
Expand Down
Loading