Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Multichron
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Multichron

by jamesm on Fri Mar 19, 2010 12:58 am

I'm planning to try to merge several versions of the monochron firmware together, ideally to make one version with runtime selectable behaviour.

The default firmware takes most of the space available, but there's a lot of common code between versions and I think there's a lot of room for space optimization.

Has anyone already attempted this?

jamesm
 
Posts: 41
Joined: Wed Aug 12, 2009 11:42 pm
Location: Vancouver, British Columbia

Re: Multichron

by jamesm on Fri Mar 19, 2010 6:34 pm

I'm starting by doing memory optimizations on the original monochron firmware. So far I've made a few minor changes and saved 1310 bytes. I figure even if I can't get far enough to add in another whole clock version, the smaller code will still be useful for people who want to make new mods.

Next step will be to isolate the differences between the firmware versions and refactor the code so multiple versions can be linked in at once.

jamesm
 
Posts: 41
Joined: Wed Aug 12, 2009 11:42 pm
Location: Vancouver, British Columbia

Re: Multichron

by dataman on Fri Mar 19, 2010 6:49 pm

I've begun on this project, and happy to team on it. I've been working on an update to Intruder Chron, and have paired out all non essential code. I was bit dirty in the initial version and only changed what I needed to get it to work.

I was thinking about moving common elements into a library, especally the randomization routines, and allows for a call to menu of choice from the config menu.

dataman
 
Posts: 98
Joined: Wed May 20, 2009 7:03 pm

Re: Multichron

by jamesm on Fri Mar 19, 2010 8:20 pm

Sounds great.

My thought was to separate all the special case behaviour into a single .c file, and add some support for calling multiple versions from the main code.

For example, I'd expect that we'd end up with anim_monochron.c, anim_sevenchron.c, etc. and all of the common code changed to call the new functions.

The major change I've made to my monochron code so far is to remove the cryptographically strong PRNG and replace it with a much simpler one. You really don't need that strong a random number generator.

I haven't done any significant testing of this version yet, but here's the new code:
Code: Select all | TOGGLE FULL SIZE
uint32_t lcg_internal = 0;

void init_crand() {
  uint32_t temp;
  temp = alarm_h;
  temp<<=8;
  temp|=time_h;
  temp<<=8;
  temp|=time_m;
  temp<<=8;
  temp|=time_s;
  lcg_internal = temp;
}

// Linear congruential generator
// I believe these constants are from Numerical Recipies in C
uint16_t crand(uint8_t type) {
  lcg_internal = 1664525* lcg_internal + 1013904223;
  return (uint16_t) lcg_internal;
}

jamesm
 
Posts: 41
Joined: Wed Aug 12, 2009 11:42 pm
Location: Vancouver, British Columbia

Re: Multichron

by adafruit on Fri Mar 19, 2010 8:22 pm

this would be +++ rad. we would like to have 'multiple clocks' in the firmware as well! as everyone saw when we released the kit, it's a blank slate you can put anything on it since it's a clock platform, but there's not a ton of room :)

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Please be positive and constructive with your questions and comments.