{"id":1021,"date":"2013-04-24T14:53:42","date_gmt":"2013-04-24T14:53:42","guid":{"rendered":"http:\/\/xronosclock.com\/home\/?p=1021"},"modified":"2019-02-15T11:46:30","modified_gmt":"2019-02-15T11:46:30","slug":"work-in-progress-autodimming","status":"publish","type":"post","link":"http:\/\/xronosclock.com\/home\/?p=1021","title":{"rendered":"Work in Progress: AutoDimming"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>Almost from very beginning when I started working on Xronos clock I had in mind to implement AutoDimming functionality. Concept is simple and used in smartphones, tablets, etc.\u00a0 In the dark room LEDs become dim, so it don&#8217;t bother you when you sleeping.\u00a0 In sunny conditions they become bright so it&#8217;s easier to see.\u00a0 Nothing new here \ud83d\ude42\u00a0 However it proved to be biggest challenge for me. Only about a week ago I discovered root cause of the issue and found solution.<\/p>\n<p><!--more--><\/p>\n<p>Brains of my clock is ATMega644p processor, which runs Sanguino bootloader. I&#8217;m also using Sanguino hardware files to make it compatible with Arduino IDE.\u00a0 That&#8217;s the background information, now to the issue.<\/p>\n<p>Xronos uses 5 out of 8 ATMega644&#8217;s available Analog ports. A2-A4 used for buttons, A0 is used for Temperature sensor (I actually use it as digital port because temp sensor is digital), and A1 for photoresistor\/light sensor.\u00a0 However no matter what I tried I could not access A1 port!\u00a0 What&#8217;s more confusing was I found that addressing A0 port will actually address both A0 and A1!\u00a0 So I could use light sensor or temperature sensor but not both, eve tho the were physically not connected together!<\/p>\n<p>I thought I had a PCB hardware problem, but with help of some great folks at <a href=\"http:\/\/arduino.cc\/forum\/index.php?topic=157826\">Arduino Forums<\/a>, I found out that it was software bug in Sanguino port definition file.\u00a0 I&#8217;m really surprised that nobody before me noticed this, issue is super obvious, but as to the band aid solution that I applied it was transplanting some lines from other Arduino hardware variants into Sanguino file.<\/p>\n<p>To fix A1 port definition, open <strong>pins_arduino.h<\/strong> inside your <em>Arduino\\hardware\\sanguino\\variants\\standard<\/em> folder and change this line:<\/p>\n<blockquote>\n<pre>static const uint8_t A1 = <strong>30<\/strong>;<\/pre>\n<p>with<\/p>\n<pre>static const uint8_t A1 = <strong>15<\/strong>;<\/pre>\n<\/blockquote>\n<p>There are possibly other ports that affected, but I didn&#8217;t have time to go thru all of them.<\/p>\n<p>Since now Light Sensor works, it was just a matter of writing new function and menu option into the code, drilling and hot gluing sensor to the enclosure prototype.<\/p>\n<p><a href=\"http:\/\/xronosclock.com\/home\/wp-content\/uploads\/2013\/04\/auto_light2.jpg\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-1023\" alt=\"auto_light2\" src=\"http:\/\/xronosclock.com\/home\/wp-content\/uploads\/2013\/04\/auto_light2-300x279.jpg\" width=\"300\" height=\"279\" \/><\/a><\/p>\n<p>It&#8217;s a bigger challenge however to modify current production enclosures to hold this small photo-resistor, and sorry but it won&#8217;t happen for a while, at least not until I can sell current stock of 15 clocks&#8230;<\/p>\n<p>But you can always add one yourself \ud83d\ude42 Probably the best way would be to drill a hole in faceplate, and hot-glue sensor from inside to the front panel.\u00a0 PCB already has place for 2 pin connector and 10K resistor so it should be pretty easy. I added functionality to the latest<a href=\"http:\/\/www.xronosclock.com\/?action=about&amp;about=data#details\"> Beta release of the sketch<\/a>, just change:<\/p>\n<p>#define AUTO_BRIGHTNESS_ON 0<br \/>\nto<br \/>\n#define AUTO_BRIGHTNESS_ON 1<\/p>\n<p>P.S. On the pictures you see enclosure made out of clear acrylic and face plate is mirrored acrylic. This is my first prototype. I think black acrylic looks a lot better, but if I get a lot of requests I can make you custom clear enclosure \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Almost from very beginning when I started working on Xronos clock I had in mind to implement AutoDimming functionality. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1022,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[11,12],"tags":[],"class_list":["post-1021","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alarmclockupdates","category-work-in-progress"],"_links":{"self":[{"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=\/wp\/v2\/posts\/1021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1021"}],"version-history":[{"count":5,"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=\/wp\/v2\/posts\/1021\/revisions"}],"predecessor-version":[{"id":4489,"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=\/wp\/v2\/posts\/1021\/revisions\/4489"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=\/wp\/v2\/media\/1022"}],"wp:attachment":[{"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1021"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xronosclock.com\/home\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}