Post about your Basic project here

Moderator: Mmiscool

User avatar
By russm
#53975 So I did some research on EDT and EDST. Currently the UTC adjust for my location is -4 as it is DST. In the winter it will change to -5. Personally I wish we could just stay on EDST all year, I hate loosing evening light in winter. :(

I thought that timesetup(offset,DST) would perform this function for me. It does not seem to do this. I may just add a button on the final clock that will toggle and persist regular and DST if it truly is not built into the timesetup function. I did this on my aquarium light timer but via the web browser.

Reading time doesn't require any special wait delay. It runs very fast and seeing seconds displayed on the analog panel meter is pretty cool. Can't wait to get the 3rd panel meter. Since the new ESP8266Basic code has had MASSIVE speed improvements, it is capable of nearly everything I want to do right now. The clock code runs perfectly in debug! Soon, I may try to do some BackEMF motor control for my model train control system.
User avatar
By russm
#53982 Decided to see how adding to hours the proportion of minutes elapsed and to minutes the proportion of seconds elapsed. It makes the panel meters act more like an analog clock, rather than an analog representation of a digital clock.

Here's the code:
Code: Select all'******************************************************
'* Analog Panel Meter Clock                           *
'*   by Russ McIntire, 8/27/16                        *
'*   D0 = Hours                                       *
'*   D1 = Minutes                                     *
'*   D2 = Seconds                                     *
'*                                                    *
'* To do: HTML setup screen to select DST, TZ, SSID   *
'******************************************************

timesetup(-4,1)  'Need to figure out what is wrong with DST
delay 5000

udpbegin 5001


hour = 0
min = 0
sec = 0
M = " "
udptimer = 0
hourpwm = 0
minpwm = 0
secpwm = 0

'Determine broadcast address
let localIP = ip()
pos = instrrev(localIP,".")
netIP = left(localIP,pos)
nodeIP = mid(localIP,pos+1)
let broadcastaddr = netIP & "255"


timer 1000, [updatetime]
wait
end

[updatetime]
'Get time values from NTP server
 hour = val(time("hour"))
 min = val(time("min"))
 sec = val(time("sec"))

'Set 12 hour time and determine AM/PM
 if hour > 12 then
  hour = hour - 12
  M = "PM"
 else
  if hour = 0 then
   hour = 12
  endif
  M = "AM"
 endif

'Panel PWM calculation
'hourpwm = 93.1 * (hour - 1)                 'divide 1024/11
hourpwm = 93.1 * (hour - 1) + (1.55 * min)  'divide 1024/11 add proportion of minutes (~1.5/min)
'minpwm = 17.36 * min                        'divide 1024/59
minpwm = 17.36 * min + (.29 * sec)          'divide 1024/59 add proportion of seconds (.29/sec)
secpwm = 17.36 * sec                        'divide 1024/59

'Panel output
io(pwo,d0,hourpwm)
io(pwo,d1,minpwm)
io(pwo,d2,secpwm)

'Daily NTP refresh at 2:00 AM
if ((hour=2) and (min=0) and (sec>0) and (sec<5) and (M="AM")) then
 timesetup(-4,1)  'Need to figure out what is wrong with DST
 delay 5000
endif

'Send UDP broadcast message out for current time every 30 seconds
 udptimer = udptimer + 1
 if udptimer > 30 then
  ct = str(hour)&":"&time("min:sec")&" "&M
  udpwrite broadcastaddr, 5001, ct
  udptimer = 0
 endif
wait
User avatar
By Mmiscool
#53983 This seems pretty cool.

Can wait to see a video . . .
User avatar
By russm
#54008
Mmiscool wrote:This seems pretty cool.

Can wait to see a video . . .


HAHA, watching a clock is kind of like watching paint dry! OK, when I get my 3rd panel meter with seconds it's worth it!. :D