ESP8266 BASIC
  • Home
  • Documentation
    • Editor Interface
    • Flashing Instructions
    • Language Reference
    • FAQ
    • Videos
    • Examples
      • ESP8266-projects.com
      • Wifi Station & AP Examples
      • GPIO & PWM & Servo Example
      • GUI Example
      • Hello World Example
      • Graphics Example
      • Blink example
      • I2C READING DS1321 REAL TIME CLOCK
      • Timer Example
      • MSG URL Usage
      • MSG URL (Advanced)
      • DS18B20 Wifi Thermostat
      • CSS Example
      • WIFI Scanner Example
      • Graphic Clock Example
      • Analog Input Graph
  • Flashing Instructions
  • Download
  • Forum
  • Store
  • Home
  • Documentation
    • Editor Interface
    • Flashing Instructions
    • Language Reference
    • FAQ
    • Videos
    • Examples
      • ESP8266-projects.com
      • Wifi Station & AP Examples
      • GPIO & PWM & Servo Example
      • GUI Example
      • Hello World Example
      • Graphics Example
      • Blink example
      • I2C READING DS1321 REAL TIME CLOCK
      • Timer Example
      • MSG URL Usage
      • MSG URL (Advanced)
      • DS18B20 Wifi Thermostat
      • CSS Example
      • WIFI Scanner Example
      • Graphic Clock Example
      • Analog Input Graph
  • Flashing Instructions
  • Download
  • Forum
  • Store

Graphic Clock Example ​(3.0 branch only)

​timer 10000, [drawClock]
print "Graphic Clock"
print
graphics 500, 500
[drawClock]
gosub [dotime]
gcls
gosub [drawface]
gosub [drawhour]
gosub [drawminute]
wait

[drawhour]
x = myhour * 30
x = x / 57.29577951
xx = sin(x)
xx = xx * 150
xx = 250 + xx
yy = cos(x)
yy = yy * 150
yy = 250 - yy
line 250, 250, xx, yy
return

[drawminute]
x = mymin * 6
x = x / 57.29577951
xx = sin(x)
xx = xx * 200
xx = 250 + xx
yy = cos(x)
yy = yy * 200
yy = 250 - yy
line 250, 250, xx, yy, 12
return

[drawface]
circle 250, 250, 210, 3
circle 250, 250, 205, 15
for t = 1 to 12
x = t * 30
x = x / 57.29577951
xx = sin(x)
xx = xx * 205
xx = 250 + xx
yy = cos(x)
yy = yy * 205
yy = 250 - yy
circle xx, yy, 4, 3
next t
return

[dotime]
mytime = time()
myhour = mid(mytime,12,2)
mymin = mid(mytime,15,2)
mysec = mid(mytime,18,2)
partmin = mysec / 60
mymin = mymin + partmin
parthour = mymin / 60
myhour = myhour + parthour
return
 This is an advanced graphics example that will produce an analog clock in the web browser.
Example comes courteously of cwilt and TassyJim on the forum. Original forum post (http://www.esp8266.com/viewtopic.php?f=40&t=6995).
Picture
Powered by Create your own unique website with customizable templates.
  • Home
  • Documentation
    • Editor Interface
    • Flashing Instructions
    • Language Reference
    • FAQ
    • Videos
    • Examples
      • ESP8266-projects.com
      • Wifi Station & AP Examples
      • GPIO & PWM & Servo Example
      • GUI Example
      • Hello World Example
      • Graphics Example
      • Blink example
      • I2C READING DS1321 REAL TIME CLOCK
      • Timer Example
      • MSG URL Usage
      • MSG URL (Advanced)
      • DS18B20 Wifi Thermostat
      • CSS Example
      • WIFI Scanner Example
      • Graphic Clock Example
      • Analog Input Graph
  • Flashing Instructions
  • Download
  • Forum
  • Store