-
• #2
That looks great - thanks for posting it up!
-
• #3
Great! Thank your for sharing.
Have you considered using digitalPulse?
digitalPulse(LED2, 1, 100);
Flashes the LED once, for 100 ms. -
• #4
Wow. Haven't found it. Thanks. Will try it.
-
• #5
Very interesting, this was the first example I tried with to get started after the 'Hello world..'. Does the Puck know the date and time, or do you need to set it somehow?
-
• #6
The Puck has its own RTC, and it's "synced" everytime you upload something from your pc.
You can use if for example as an alarm clock (do something at given date/time), that's great! -
• #7
The Puck has its own RTC, and it's "synced" everytime you upload something from your pc.
Yes it does, but not by default. One would need to turn the option On in the web IDE settings.
For some reason it set Puck time to 0:22 am, whereas it's 11:22 am in my time zone currently.
Thus, I would not recommend to sync puck time with your browser time because Espruino has no knowledge about time zones. The missing time zone complicates development.My puck came to me with the time set close to Unix epoch ~
Jan 1970
.For simplicity the code above assumes the Puck time zone is set to the local time (i.e. the local timezone is +00 hours). I did it with the setTime function. Here is how to get a value for the
setTime
using node.js or a browser REPL:(Date.now() / 1000) + tzHours*60*60
.However, if you don't need the schedule feature, which relies on time, just remove lines 78-112.
-
• #8
Yes, my "dirty workaround" was to add +1 hour in the code, more or less like you suggest, while creating the Date object.
Didn't think about using setTime to make it "permanent".
I bought Puck.js basically to make sure none in our office changes the aircon settings.
The below app
The app memory and CPU usage are optimized up to my knowledge of JS engines.
Below is the source code of the v1. The latest source code is hosted here.
Suggestions are very welcome.