Skip to content

Commit

Permalink
Added Valve profile state changing
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyanush committed Jan 17, 2012
1 parent 9b4cd64 commit d9f7e18
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
6 changes: 5 additions & 1 deletion BTNIC_PROTOCOL_NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ Reset -- c
Implementation of Reset Level 0 (tested using BT4.0 with v2.4 r761) causes board to Hard-lock, requiring power cycle to regain responsiveness. Reset Level 1 (soft reboot) works as expected.

Set Valve Profile Status -- b
Cannot seem to figure out how it works. (maybe not fully implemented???)
EXAMPLE -->
User 1 profile:
From architecture wiki, User 1 bit mask = 131072
to Activate --> http://address/btnic.cgi?b&131072&1
to DeActivate --> http://address/btnic.cgi?b&131072&0
25 changes: 21 additions & 4 deletions JS/Classes/Valve.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ function Valve() {
{name: 'User 3', bitMask: 524288, config:0, active:false}
];

//BrewTroller command codes
var getProfileStatus = 'w';
var getProfileConfig = 'd';
var setProfileConfig = "Q";
var setProfileStatus = 'b';

//References to active and idle containers
var active;
Expand Down Expand Up @@ -145,11 +147,26 @@ function Valve() {
};

//Method is called when a valve profile is clicked, and should toggle the appropriate valve profile's state
//It has not yet been implemented, as I cannot seem to figure out how to properly set this option using the BTNic architecture.
this.toggleState = function(profileIndex){
/*profiles[profileIndex].active = (!profiles[profileIndex].active);*/
this.updateView();
}

//define the callback function, because the response from the BT is the status code of all profiles we will update them all
var callback = function(profiles, xhr) {
var resp = JSON.parse(xhr.responseText);
var mask = Number(resp[2]);
for ( i = 0; i < 20; i++ ) {
profiles[i].active = Boolean(mask & profiles[i].bitMask);
}
BrewTroller.valves.updateView();
};

//if the profile is active, we will set it inactive
if (profiles[profileIndex].active){
BrewTroller.communicate(BrewTroller.getAddress() + setProfileStatus + '&' + profiles[profileIndex].bitMask + '&0', callback, profiles);
}
else{ //else if it is idle we will activate it
BrewTroller.communicate(BrewTroller.getAddress() + setProfileStatus + '&' + profiles[profileIndex].bitMask + '&1', callback, profiles);
}
};

//Method updates the config for all of the profiles from the BT
this.updateAllConfig = function() {
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Info:

Latest Changes (most recent first):

Added Valve profile state changing (enabling and disabling), to use simply left click on a profile
Fixed valve profile editing view rendering for Gecko engines
Add Valve profile config editing (right click a profile to view/edit config)
Ported Temp Set Point editing from ExtJS app
Expand All @@ -22,7 +23,6 @@ Latest Changes (most recent first):

To DO For Initial Release (In order of Priority):

Complete valve functionality (implement profile state changes)
Implement full settings from BrewTroller Menus
Fully comment and Document Code...

Expand Down

0 comments on commit d9f7e18

Please sign in to comment.