Time Square - question about code

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
kjata1013
 
Posts: 21
Joined: Sat Mar 03, 2012 6:50 pm

Time Square - question about code

Post by kjata1013 »

Hello! If this is a re-post, I apologize. I tried searching to see if anyone posted this but it didn't look like it.

Anyway, I have a couple of questions. First, I'm interested in displaying the day of the week. "M" for Monday, "Tu" for Tuesday, etc. I'm losing my mind trying to get it to work. I can dispay the letters but I can't get it to play with the code.

Code: Select all

int currentDay;

void mode_test(uint8_t action){
 
   watch.fillScreen(0);
       currentDay =  1;
      
  switch (currentDay){
    
    //"Su" for Sunday [0]
    case 0:
    watch.drawPixel(7, 3, 255);
    watch.drawPixel(7, 4, 255);
    watch.drawPixel(7, 5, 255);
    watch.drawPixel(6, 5, 255);
    watch.drawPixel(5, 3, 255);
    watch.drawPixel(5, 4, 255);
    watch.drawPixel(5, 5, 255);
    watch.drawPixel(3, 1, 255);
    watch.drawPixel(3, 3, 255);
    watch.drawPixel(3, 4, 255);
    watch.drawPixel(3, 5, 255);
    watch.drawPixel(2, 1, 255);
    watch.drawPixel(2, 3, 255);
    watch.drawPixel(2, 5, 255);
    watch.drawPixel(1, 1, 255);
    watch.drawPixel(1, 2, 255);
    watch.drawPixel(1, 3, 255);
    watch.drawPixel(1, 5, 255);
    break;
    
    //"M" for Monday [1]
    case 1:
    watch.drawPixel(5, 1, 255);
    watch.drawPixel(5, 2, 255);
    watch.drawPixel(5, 3, 255);
    watch.drawPixel(5, 4, 255);
    watch.drawPixel(5, 5, 255);
    watch.drawPixel(4, 2, 255);
    watch.drawPixel(3, 3, 255);
    watch.drawPixel(2, 2, 255);
    watch.drawPixel(1, 1, 255);
    watch.drawPixel(1, 2, 255);
    watch.drawPixel(1, 3, 255);
    watch.drawPixel(1, 4, 255);
    watch.drawPixel(1, 5, 255);
    break;
    
    //"Tu" for Tuesday [2]
    case 2:
    watch.drawPixel(6, 3, 255);
    watch.drawPixel(6, 4, 255);
    watch.drawPixel(6, 5, 255);
    watch.drawPixel(5, 5, 255);
    watch.drawPixel(4, 3, 255);
    watch.drawPixel(4, 4, 255);
    watch.drawPixel(4, 5, 255);
    watch.drawPixel(3, 2, 255);
    watch.drawPixel(2, 2, 255);
    watch.drawPixel(2, 3, 255);
    watch.drawPixel(2, 4, 255);
    watch.drawPixel(2, 5, 255);
    watch.drawPixel(1, 2, 255);
    break;
    
    case 3:
    //"W" for Wednesday [3]
    watch.drawPixel(5, 2, 255);
    watch.drawPixel(5, 3, 255);
    watch.drawPixel(5, 4, 255);
    watch.drawPixel(5, 5, 255);
    watch.drawPixel(4, 5, 255);
    watch.drawPixel(3, 4, 255);
    watch.drawPixel(2, 5, 255);
    watch.drawPixel(1, 2, 255);
    watch.drawPixel(1, 3, 255);
    watch.drawPixel(1, 4, 255);
    watch.drawPixel(1, 5, 255);
    break;
    
    //"Th" for Thursday [4]
    case 4:
    watch.drawPixel(6, 3, 255);
    watch.drawPixel(6, 4, 255);
    watch.drawPixel(6, 5, 255);
    watch.drawPixel(5, 4, 255);
    watch.drawPixel(4, 3, 255);
    watch.drawPixel(4, 4, 255);
    watch.drawPixel(4, 5, 255);
    watch.drawPixel(3, 2, 255);
    watch.drawPixel(2, 2, 255);
    watch.drawPixel(2, 3, 255);
    watch.drawPixel(2, 4, 255);
    watch.drawPixel(2, 5, 255);
    watch.drawPixel(1, 2, 255);
    break;
    
    //"F" for Friday [5]
    case 5:
    watch.drawPixel(5, 1, 255);
    watch.drawPixel(4, 1, 255);
    watch.drawPixel(4, 3, 255);
    watch.drawPixel(3, 1, 255);
    watch.drawPixel(3, 3, 255);
    watch.drawPixel(2, 1, 255);
    watch.drawPixel(2, 2, 255);
    watch.drawPixel(2, 3, 255);
    watch.drawPixel(2, 4, 255);
    watch.drawPixel(2, 5, 255);
    break;
    
    //"Sa" for Saturday [6]
    case 6:
    watch.drawPixel(7, 2, 255);
    watch.drawPixel(7, 3, 255);
    watch.drawPixel(7, 4, 255);
    watch.drawPixel(7, 5, 255);
    watch.drawPixel(6, 2, 255);
    watch.drawPixel(6, 3, 255);
    watch.drawPixel(6, 5, 255);
    watch.drawPixel(5, 2, 255);
    watch.drawPixel(5, 4, 255);
    watch.drawPixel(5, 5, 255);
    watch.drawPixel(3, 1, 255);
    watch.drawPixel(3, 3, 255);
    watch.drawPixel(3, 4, 255);
    watch.drawPixel(3, 5, 255);
    watch.drawPixel(2, 1, 255);
    watch.drawPixel(2, 3, 255);
    watch.drawPixel(2, 5, 255);
    watch.drawPixel(1, 1, 255);
    watch.drawPixel(1, 2, 255);
    watch.drawPixel(1, 3, 255);
    watch.drawPixel(1, 5, 255);
    break;
  }
}
I can't seem to be able to read

Code: Select all

 DateTime now = now.RTC 
to play with my code. I want to read in the time and if it's midnight, increment the day to the next number. Once it reaches "6", I wanted to reset it back to "0" and start over. When I try that, it won't compile. I tried figuring out the math and do it that way, and when I did that, it compiled but when I loaded it to the watch, the watch wouldn't turn on. *Also, I know that's not in the above code. Sorry. I posted the code that "works".*

I'm not looking for the answer, or for someone to code it for me. I'm looking for someone to point me in the right direction, if possible. (^_^)v

The second, is I can't seem to wrap my head around how the code reads a pic into what I think is hex and display the picture on the watch. Any help would be awesome. Thank you so much! Sorry to bug everyone!

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: Time Square - question about code

Post by pburgess »

Hi!

Answering the second question first:

Code: Select all

  DateTime now = RTC.now();
  int day = now.dayOfWeek();
'day' (returned) is an integer from 0 (Sunday) to 6 (Saturday).

The other one's much more involved...

Inside the TIMESQUARE-Watch repository is a folder called 'Processing', which is some code written in that language; it can be downloaded from processing.org (be sure to download the 1.5.1 stable release at the bottom of the page, NOT THE 2.0 BETA). The 'img2array' program converts an 8-bit grayscale PNG to a hexadecimal array that can then be copied-and-pasted into an Arduino sketch and subsequently used with the blit() function in the watch code.

This is potentially complicated and nasty. I'd suggest looking at the simplest case to start: the Symbols.png image (alongside the Processing code), which gets converted to the symbols[] array (in the Arduino source file Set.pde), and little pieces of it are copied to the screen with the blit() function (parameters for the latter are: source image array, source image width, source image height, source X (top-left pixel), source Y, destination X, dest Y, width (pixels), height and brightness (0-255, where 255=full brightness)).

kjata1013
 
Posts: 21
Joined: Sat Mar 03, 2012 6:50 pm

Re: Time Square - question about code

Post by kjata1013 »

Thank you so much! I can't believe the dayOfWeek was that simple. Ugh, I tried it so many times, but incorrectly (obviously). (-_-)

Secondly, thank you so, so much for the info! I've been using Processing 2.0 just realizing it's a beta.

Thirdly, I can't tell you how much I love having this watch. It was a blast to build and I'm learning so much from it. And I love the conversations that it starts! I've gotten a lot of compliments and I just love it. Thank you again for all of your help!

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: Time Square - question about code

Post by pburgess »

The code might work as-is in Processing 2.0, but it's caused enough gas pains with Adalight that I just steer folks toward the stable release out of habit. Try it in the 2.0 you have and see if that works.

Glad to hear you're enjoying the watch! If you come up with some new tricks, feel free to post them here to share.

kjata1013
 
Posts: 21
Joined: Sat Mar 03, 2012 6:50 pm

Re: Time Square - question about code

Post by kjata1013 »

Awesome. I'll try both. Thanks!

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”