Team ACM can see the Matrix. (or at least the tick count)

So here’s our codes detailing how we did things. This ticks the clock, checks if it needs to play a sound, and manages the sound it plays.

So one of the more… complicated things we ran into while programming this thing was being able to play the chime while keeping the clock ticking. The board didn’t have any multi-process support (unless we fancied writing our own scheduler), so we couldn’t just have it run both functions simultaneously. Instead, we got a bit more creative (desperate?) and made it so that while the clock is ticking, it is also checking to see if it should be playing a sound. See lines 30 and on for how we did this. We used ticks to count how long a note should play for (and for extending the DAAAAAAAAH at the end) The extension of the last note in particular was incredibly trying. We found that depending on the amount of ticks we told it to wait, the sound we continue (or not). However, the compiler did not like this solution. Any tick count below 55000 resulted in a short length, and any above 55000 resulted in a just too long length. BUT! adjusting the tick count for the length of the first three notes (which all play for the same amount of  time) would in fact actually basically adjust the play time accordingly! We stuck with the long one in the end, but still have no idea why the compiler couldn’t count correctly. Maybe, just maybe, it’s bad :p

  1.         //Run the clock
  2.         LED_Toggle(LED0);
  3.         struct pwm_config mypwm; //For PWM for speaker
  4.         uint16_t counter = 0; //Keep track of how long chime note has been playing
  5.         uint8_t playing = 0; //Keep track if our chime is playing
  6.         uint8_t chimeIndex = 0; //Keep track of position in Chime
  7.         uint16_t chime[4] = {440, 466, 493, 523};
  8.         while (true) {
  9.                 rtc_timestamp = rtc_get_time();
  10.                 // Update printed time if the time has changed
  11.                 if(rtc_timestamp != past_timestamp) {
  12.                         calendar_add_second_to_date(&date);
  13.                         LED_Toggle(LED0);
  14.                         LED_Toggle(LED1);
  15.                         drawNumber(secMSBColumn, date.second/10);
  16.                         drawNumber(secLSBColumn, date.second%10);
  17.                         drawNumber(minMSBColumn, date.minute/10);
  18.                         drawNumber(minLSBColumn, date.minute%10);
  19.                         drawNumber(hourMSBColumn, date.hour/10);
  20.                         drawNumber(hourLSBColumn, date.hour%10);
  21.                         //Make noises on quarter minutes
  22.                         if(date.second%15 == 0) {
  23.                                 playing = 1;
  24.                                 chimeIndex = 0;
  25.                                 pwm_init(&mypwm, PWM_TCC0, PWM_CH_A, chime[chimeIndex]);
  26.                                 pwm_start(&mypwm, 75);
  27.                         }
  28.                         past_timestamp = rtc_timestamp;
  29.                 }
  30.                 if(playing) {
  31.                         counter++;
  32.                         if(chimeIndex < (uint8_t) 3) {
  33.                                 if(counter%50000 == 0) {
  34.                                         chimeIndex++;
  35.                                         counter = (uint16_t)0;
  36.                                         pwm_set_frequency(&mypwm, chime[chimeIndex]);
  37.                                         pwm_start(&mypwm, 75);
  38.                                 }
  39.                         } else {
  40.                                 if(counter%70000 == 0) {
  41.                                         playing = (uint8_t) 0;
  42.                                         counter = (uint16_t) 0;
  43.                                         pwm_stop(&mypwm);
  44.                                 }
  45.                         }
  46.                 }
  47.         }

Team ACM project v2.0: Electric Boogaloo

So what exactly are we up to? After project v1.0 crashed and burned (figuratively) all efforts have been moved v2.0. Our current project is to construct a cute little binary clock!

Just look at the little guy 😀

IMG_20150423_130605Here’s a close up of all that heart-pounding binary counting action!

IMG_20150423_113917The big idea here, is that in addition displaying the time in the best way possible, it also blinks the on-board LED’s like the second hand of an analogue (deprecated) clock. It also plays a little *boop* every quarter second (for demo purposes. No self respecting clock should *boop* that often)



Team ACM project v1.0 FAILURE :ᗡ

Our original plan was to interface with a Trellis board and do some fancy lighty buttony things, but we were unable to successfully communicate with the board from our A3BU. We found great difficulty in finding appropriate documentation for communicating from our A3BU via I2C.

Attempting to establish communication!

2015-04-23 (1)

The super cool Trellis board!
…That we couldn’t get to work 🙁                                         All that soldering though…








Team ACM is now moving forward with project v2.0!
Here’s a tease: