Alpha Clock Five - Making lowercase and custom letters

edited September 2014 in Clock Kits
Hello everyone: I'm experimenting with adding lower case letters in the .cpp file. Everything seems to work until I get past the letter 't.' (ASCII 116) After that, instead of the desired letter (u-z), I get a bunch of garbage. I plugged the values I got into the Alpha 5 char generator in the wiki and this is what was produced:

Desired letter: 'u', 4,1,4

What I got: 4,0,0 (half an underscore)

"v", 0,2,4 (I got 0,0,0. a Space.)

"w", 12,1,6 (I got 3,0,0. A Negative symbol.)

"x", same as Capital "X." (0,2,208). (I got 9,3,3. Garbage.)

"y", 20,1,40 (I got 255,3,1. Garbage with both decimal points.)

"z", 20,2,0 (I got 42,1,3. Looks like a backwards 6.)

The last 3 characters ("{","|",and "}") work fine as special characters.

If I put these into the .ino file as an a5editFontChar() in the DisplayWordSequence, only then the actual letters come up, however an extra segment lights up on (sp) ASCII 32.

I changed the upper limit in the a5editFontChar section of the cpp file to 126 (or '~') to accommodate the extra characters. I also commented out the a5LoadNextFadeStage() in both files to save RAM.

Any suggestions? Thanks! ~Chuck


  • Take a look at how a5editFontChar works. 
    Inside, it has:
     byte offset = (3 * (asciiChar - a5_asciiOffset)); 

    A byte is the same as a uint8_t, an unsigned 8-bit variable. It can only range between 0 and 255.  Noting that a5_asciiOffset is 32, it is the case that if asciiChar is equal to 117, you get

    offset = 3*(117 - 32) = 3*85 = 255.

    For any asciiChar greater than 117 (ascii 'u'), you'll run into a problem there.  

    The following lines of code are:

     a5_FontTable[offset++] = A; 
     a5_FontTable[offset++] = B; 
     a5_FontTable[offset] = C;

    So, it should be clear that even that edge case of 'u' will not actually work, because it still increases the value of offset, even if it began at "only" 255.
  • Now that I looked at it, it is quite obvious. I don't know why it didn't click for me. I was trying everything last night. I even tried making a secondary font table (a5_FontTableB) with a different offset. I did manage to find a temporary solution.. I remember you talking to me (when I was doing the marriage proposal) about using some of the symbols as extra characters. So I substituted #&,:; for uvwyz (I left x out because when mapped on the display, it's the same as X) and used ^ and ` for special characters.

    Thanks Windell! I now have 3 out of 5 things accomplished. All that's left is the Temperature Sensor (Where would be a good place to put it on the PC board? And where in the code (and which file) do I it put it in?) and more clock options.
  • The best method depends on a couple things: What kind of temperature sensor, and what you want to do with the data. If it's an analog sensor, you might want to use pin PA5 as an input (pin 35 of the IC), which is not otherwise used.

    As far as the software goes, it again depends what you're trying to do.  One easy way would be to put the display routine in place of one of the features that you're not using, like the 5 letter words, for example.
  • edited September 2014
    I will more than likely be using the popular DS18B20 for the sensor. I would use the data as an ordinary thermometer and display it on the display. As for code, I put in the #include OneWire.h in ino file for the time being. I thought about making a new menu option, after "Time and..." (#define TempDispMenuItem 11) and using the +/- buttons to switch between Fahrenheit and Celsius (or maybe include just for fun, Kelvin and Rankine) as well as include it as an alternating mode with the current time. Come to think of it, I really don't use the 5 letter words display too much, so yeah, maybe I could replace that and save some memory.
Sign In or Register to comment.