bcs.helpers.getTimerValues

Get help and insight.
User avatar
oakbarn
Posts: 846
Joined: Thu Jan 05, 2012 2:28 pm
Bot?: No
Location: Texas
Contact:

Re: bcs.helpers.getTimerValues

Post by oakbarn »

var process = 1;
bcs.helpers.getTimerValues(process).then(function (timeobject) {
var timer_val = (timeobject[2].value)
function toTimeString(time) {
function formatNumber(n) {
return n < 10 ? '0' + n : '' + n;
}

var hours = Math.floor(Math.abs(time / 3600));
var minutes = Math.floor(Math.abs((time % 3600) / 60));
var seconds = Math.floor(Math.abs(time % 60));
return (time < 0 ? '-' : '') + hours + ":" + formatNumber(minutes) + ":" + formatNumber(seconds);
}
timer_val = toTimeString(timeobject[2].value);
$('#timer_val').html(timer_val);
b
});

Works Great! :D Thanks for the help. I have both the value and the String. Now to just get it to flip between temps and timer!
User avatar
oakbarn
Posts: 846
Joined: Thu Jan 05, 2012 2:28 pm
Bot?: No
Location: Texas
Contact:

Re: bcs.helpers.getTimerValues

Post by oakbarn »

Pix of it:
I can read it from across a room (maybe 50 feet away on a 19 inch screen). Very easy to read in the Brewery. I just hard Coded the titles for now but will work on those later.
MashTimer.jpg
MashTimer.jpg (193.41 KiB) Viewed 2770 times
brahn
Posts: 543
Joined: Thu Dec 13, 2012 11:01 am
Bot?: No

Re: bcs.helpers.getTimerValues

Post by brahn »

I think I see why you were off by a digit in the previous version. As I pointed out in the earlier post, getTimeValues returns a BCS.Time object. (Meaning you could simply use timeobject[2].toString())

The BCS.Time object does a bit of magic to (hopefully!) make things easier for normal use cases. Namely, when you create a new instance of a BCS.Time object it divides the value passed in by 10 so it can store the value in seconds as opposed to tenths of a second the way the API returns it.

So by doing BCS.Time(timeobject[2].value) you were dividing the value by 10 again!

bbrally's version is fine too, it just shouldn't be necessary.

Again the documentation on this method is not good, it should indicate what you get is an array of BCS.Time objects instead of making you guess.
User avatar
bbrally
Posts: 210
Joined: Sat Mar 27, 2010 3:59 am
Bot?: No
Location: Vancouver, BC
Contact:

Re: bcs.helpers.getTimerValues

Post by bbrally »

Thanks Brent, I was pretty sure that whatever I was doing wrong was simple.
User avatar
oakbarn
Posts: 846
Joined: Thu Jan 05, 2012 2:28 pm
Bot?: No
Location: Texas
Contact:

Re: bcs.helpers.getTimerValues

Post by oakbarn »

brahn wrote:I think I see why you were off by a digit in the previous version. As I pointed out in the earlier post, getTimeValues returns a BCS.Time object. (Meaning you could simply use timeobject[2].toString())

....
I did use the timeobject[2].toString()) for a var timer_string and kept my timer_val as the raw seconds. I decided I did not need to flip between a timer and Temp and just display them at the same time. I had to mess with the CSS file to get it all to fit but I can easily read the timer and Temp across the room. The Temp changes color if more or less 1 degree F off the Setpoint. Blue for lower, green for Correct and red for above so I can set if it is off without knowing the exact Setpoint (which I really know anyway). I can read it all from about 10 feet. Should make life easier on Brew Days as I am always getting up to see how much time is left (I use countdown). I will also make one for the Hop Additions and maybe have some type of visual clue about a minute before a drop. Might have to get the current State value to program that one unless I hard program to a specific brew.
final Timer.jpg
final Timer.jpg (101.59 KiB) Viewed 2762 times
Post Reply