Forum Index > Projects > Clock Kits
 Hardcode Autodim Questions
 |  Printable Version
By: Anonymous: tbirdrv () on Monday, January 25 2010 @ 08:10 PM PST (Read 1833 times)  
Anonymous: tbirdrv

First I want to say thanks for the wonderful kit - I put my first one together Saturday and am amazed by the quality of the parts and instructions.

I read the other thread about hacking it for a dimmer, which I think is a good idea, and that got me thinking about hardcoding it to autodim during the evening.

This is all new to me - I've got some experience with a basicstamp but this is my first AVR or exposure to C/C++.

Looking through the code I see you always set the hours to be less than 12 with this code at line 595:

if ( HrNow > 11) // Convert 24-hour mode to 12-hour mode
HrNow -= 12;


Will the display work correctly if we use 24 instead of 12 hour time? If so, would some code like this work to autodim from 11PM till 6AM without reading the RTC again? Or would I have to create a new var for 24 hr time?

byte tempbright = MainBright; // your existing code line1402

if (HrNow > 22 || HrNow < 6) // my attempt at nighttime auto-dim
tempbright = 2;


I'm not even sure this code is correct for what I expect it to do.

I have the Arduino, the Cronodot and the programming cable.

Thanks for your awesome work.

Tony





       
   
By: Windell (offline) on Monday, January 25 2010 @ 10:50 PM PST  
Windell

It's not absolutely necessary that HrNow be restricted to be under 12, but you should search through the code for every instance of HrNow to make sure that you catch the several instances that check the time rollover and set them to 24 hour rollover instead.
A copy of this variable, HrDisp, is used to actually pick which LEDs are lit. If you want to extend HrNow to be a 24-hour variable, them you should also check for the part that says

PHP Formatted Code
if ( HrDisp > 11)
    HrDisp -= 12;  

and change it to

PHP Formatted Code
if ( HrDisp > 23)
    HrDisp -= 12;
if ( HrDisp > 11)
    HrDisp -= 12;  



Once you've done that, it should still give correct time display, even when it's aware of 24 hour mode internally. You can then hook onto HrNow to do the autodimming, as you had planned to.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   



 All times are PDT. The time is now 09:31 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?