{"id":1502,"date":"2018-04-09T12:34:53","date_gmt":"2018-04-09T19:34:53","guid":{"rendered":"http:\/\/www.donluc.com\/?p=1502"},"modified":"2018-04-09T12:34:53","modified_gmt":"2018-04-09T19:34:53","slug":"project-6-microview-mk02","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=1502","title":{"rendered":"Project #6: MicroView &#8211; Mk02"},"content":{"rendered":"<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04a.png\" alt=\"\" width=\"720\" height=\"540\" class=\"alignnone size-full wp-image-1503\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04a-300x225.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04b.png\" alt=\"\" width=\"720\" height=\"540\" class=\"alignnone size-full wp-image-1504\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04b-300x225.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04c.png\" alt=\"\" width=\"720\" height=\"540\" class=\"alignnone size-full wp-image-1505\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04c-300x225.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-1502-1\" width=\"720\" height=\"406\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/04\/DonLuc1804Mk04.mp4<\/a><\/video><\/div>\n<p>DonLuc1804Mk04a.ino<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"DonLuc1804Mk04a.ino\">\r\n\/\/ ***** Don Luc *****\r\n\/\/ Software Version Information\r\n\/\/ 2.01\r\n\/\/ DonLuc1804Mk04 2.01\r\n\/\/ MicroView\r\n\r\n#include &lt;MicroView.h&gt;\r\n#include &lt;Time.h&gt;\r\n#include &lt;TimeLib.h&gt;\r\n\/\/ This is the radius of the clock:\r\n#define CLOCK_SIZE 23\r\n\/\/ Use these defines to set the clock&#039;s begin time\r\n#define HOUR 9\r\n#define MINUTE 00\r\n#define SECOND 00\r\n#define DAY 9\r\n#define MONTH 4\r\n#define YEAR 2018\r\n\/\/ LCD W\/H\r\nconst uint8_t maxW = uView.getLCDWidth();\r\nconst uint8_t midW = maxW\/2;\r\nconst uint8_t maxH = uView.getLCDHeight();\r\nconst uint8_t midH = maxH\/2;\r\n\/\/ Clock\r\nlong zzz = 0;\r\nstatic boolean firstDraw = false;\r\nstatic unsigned long mSec = millis() + 1000;\r\nstatic float degresshour, degressmin, degresssec, hourx, houry, minx, miny, secx, secy;\r\n  \r\nvoid loop() {\r\n\r\n  drawFace();\r\n  \r\n  zzz = 0;\r\n  while(zzz &lt; 5000)\r\n  {\r\n\r\n     drawTime();\r\n     zzz++;\r\n     \r\n  }\r\n  \r\n  uView.clear(PAGE);\r\n  \r\n  firstDraw = false;\r\n  \r\n  uView.setFontType(0);\r\n  uView.setCursor(0,20);\r\n  uView.print(&quot;09\/04\/2018&quot;);\r\n  uView.display();\r\n  delay(5000);\r\n  \r\n  uView.clear(PAGE);\r\n\r\n}\r\n<\/pre>\n<p>drawFace.ino<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"drawFace.ino\">\r\nvoid drawFace()\r\n{\r\n\r\n  \/\/ Draw the clock face. That includes the circle outline and\r\n  \/\/ the 12, 3, 6, and 9 text.\r\n  uView.setFontType(0); \/\/ set font type 0 (Smallest)\r\n  \r\n  uint8_t fontW = uView.getFontWidth();\r\n  uint8_t fontH = uView.getFontHeight();\r\n  \r\n  \/\/uView.setCursor(27, 0); \/\/ points cursor to x=27 y=0\r\n  uView.setCursor(midW-fontW-1, midH-CLOCK_SIZE+1);\r\n  uView.print(12);  \/\/ Print the &quot;12&quot;\r\n  uView.setCursor(midW-(fontW\/2)-1, midH+CLOCK_SIZE-fontH-1);\r\n  uView.print(6);  \/\/ Print the &quot;6&quot;\r\n  uView.setCursor(midW-CLOCK_SIZE+1, midH-fontH\/2);\r\n  uView.print(9);  \/\/ Print the &quot;9&quot;\r\n  uView.setCursor(midW+CLOCK_SIZE-fontW-2, midH-fontH\/2);\r\n  uView.print(3);  \/\/ Print the &quot;3&quot;\r\n  uView.circle(midW-1, midH-1, CLOCK_SIZE);\r\n  \r\n  \/\/Draw the clock\r\n  uView.display();\r\n  \r\n}\r\n<\/pre>\n<p>drawTime.ino<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"drawTime.ino\">\r\nvoid drawTime()\r\n{\r\n   \r\n  \/\/ If mSec\r\n  if (mSec != (unsigned long)second()) \r\n  {\r\n    \/\/ First time draw requires extra line to set up XOR&#039;s:\r\n    if (firstDraw) \r\n    {\r\n      uView.line(midW, midH, 32 + hourx, 24 + houry, WHITE, XOR);\r\n      uView.line(midW, midH, 32 + minx, 24 + miny, WHITE, XOR);\r\n      uView.line(midW, midH, 32 + secx, 24 + secy, WHITE, XOR);\r\n    }\r\n    \/\/ Calculate hour hand degrees:\r\n    degresshour = (((hour() * 360) \/ 12) + 270) * (PI \/ 180);\r\n    \/\/ Calculate minute hand degrees:\r\n    degressmin = (((minute() * 360) \/ 60) + 270) * (PI \/ 180);\r\n    \/\/ Calculate second hand degrees:\r\n    degresssec = (((second() * 360) \/ 60) + 270) * (PI \/ 180);\r\n\r\n    \/\/ Calculate x,y coordinates of hour hand:\r\n    hourx = cos(degresshour) * (CLOCK_SIZE \/ 2.5);\r\n    houry = sin(degresshour) * (CLOCK_SIZE \/ 2.5);\r\n    \/\/ Calculate x,y coordinates of minute hand:\r\n    minx = cos(degressmin) * (CLOCK_SIZE \/ 1.4);\r\n    miny = sin(degressmin) * (CLOCK_SIZE \/ 1.4);\r\n    \/\/ Calculate x,y coordinates of second hand:\r\n    secx = cos(degresssec) * (CLOCK_SIZE \/ 1.1);\r\n    secy = sin(degresssec) * (CLOCK_SIZE \/ 1.1);\r\n\r\n    \/\/ Draw hands with the line function:\r\n    uView.line(midW, midH, midW+hourx, midH+houry, WHITE, XOR);\r\n    uView.line(midW, midH, midW+minx, midH+miny, WHITE, XOR);\r\n    uView.line(midW, midH, midW+secx, midH+secy, WHITE, XOR);\r\n    \r\n    \/\/ Set firstDraw flag to true, so we don&#039;t do it again.\r\n    firstDraw = true;\r\n    \r\n    \/\/ Actually draw the hands with the display() function.\r\n    uView.display();\r\n    \r\n  }\r\n\r\n}\r\n<\/pre>\n<p>setup.ino<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"setup.ino\">\r\nvoid setup() {\r\n\r\n  \/\/ Set the time in the time library:\r\n  setTime(HOUR, MINUTE, SECOND, DAY, MONTH, YEAR);\r\n \r\n  uView.begin();       \/\/ begin of MicroView\r\n  uView.clear(ALL);    \/\/ erase hardware memory inside the OLED controller\r\n  uView.display();     \/\/ display the content in the buffer memory, by default it is the MicroView logo\r\n  delay(1000);\r\n  uView.clear(PAGE);   \/\/ erase the memory buffer, when next uView.display() is called, the OLED will be cleared.\r\n\r\n  uView.setFontType(1);\r\n  uView.setCursor(0,20);\r\n  uView.print(&quot;Don Luc&quot;);\r\n  uView.display();\r\n  delay(5000);\r\n  \r\n  uView.clear(PAGE);\r\n\r\n  uView.display();  \/\/ display the content in the buffer\r\n\r\n  \/\/ Draw clock face (circle outline &amp; text):\r\n  drawFace();\r\n  \r\n}\r\n<\/pre>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>DonLuc1804Mk04a.ino \/\/ ***** Don Luc ***** \/\/ Software Version Information \/\/ 2.01 \/\/ DonLuc1804Mk04 2.01 \/\/ MicroView #include &lt;MicroView.h&gt; #include &lt;Time.h&gt; #include &lt;TimeLib.h&gt; \/\/ This is the radius of the clock: #define CLOCK_SIZE 23 \/\/ Use these defines to set the clock&#039;s begin time #define HOUR 9 #define MINUTE 00 #define SECOND 00 #define DAY &#8230; <a title=\"Project #6: MicroView &#8211; Mk02\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=1502\" aria-label=\"Read more about Project #6: MicroView &#8211; Mk02\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70,50,38,5,58,10,43],"tags":[],"class_list":["post-1502","post","type-post","status-publish","format-standard","hentry","category-microview","category-arduino","category-digitalelectronics","category-microcontrollers","category-arduino-programming","category-projects","category-sparkfun"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1502"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1502\/revisions"}],"predecessor-version":[{"id":1508,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1502\/revisions\/1508"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}