Alpha Clock Five – Making lowercase and custom letters

Home Evil Mad Scientist Forums Clock Kits Alpha Clock Five – Making lowercase and custom letters

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #20395
    Chuck
    Participant

    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

    #21963
    Windell Oskay
    Keymaster

    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.
    #21964
    Chuck
    Participant

    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.

    #21965
    Windell Oskay
    Keymaster

    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.
    #21966
    Chuck
    Participant

    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.

    #29986
    Neusse
    Participant

    I know this is very old. But I found that if you are using the chronodot with your Alpha 5 Clock there is already a temperature sensor built into the ds3231 chip. there is already an Arduino library for the specific chip. But the code that is distributed with the Alpha 5 is using the DS1307RTC library. I added the DS3231 library and could access the temperature. just a couple lines of code and your good. I checked its accuracy against an indor thermometer and it was about .5 degrees off. Good enough.

    Here is some of the code.

    else if (DisplayModeLocal == 99) // show DS3231 RTC chip temperature
    {
    // conversion of C to F (28.25°C × 9/5) + 32 = 82.85°F
    int myTemp = ((myclock.getTemperature() * 1.8) + 32) * 100; // * 100 to shift the decimal out

    int frac = myTemp % 100;
    int t = myTemp / 100;

    WordIn[0] = U16DIVBY10(t) + a5_integerOffset;
    WordIn[1] = t % 10 + a5_integerOffset;
    WordIn[2] = U16DIVBY10(frac) + a5_integerOffset;
    //WordIn[3] = frac % 10 + a5_integerOffset;
    WordIn[3] = ‘ ‘;
    WordIn[4] = ‘F’;

    if (forceUpdateCopy)
    {
    a5clearOSB();
    a5loadOSB_Ascii(WordIn, a5_brightLevel);
    a5loadOSB_DP(“01020”, a5_brightLevel);

    if (AlarmIndicate())
    a5loadOSB_DP(“20000”, a5_brightLevel);
    else
    a5loadOSB_DP(“00000”, a5_brightLevel);

    a5BeginFadeToOSB();
    }

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.