Suggestion about fixed point use

Store Forums Digit Shield Bugs/Problems Suggestion about fixed point use

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #512
    Baby Bertha
    Member

    Hi – I just received a digit shield, had it assembled and working without a hitch in 30 minutes or so. Nice 🙂

    I’m just experimenting and familiarising myself with the API, but one thing I noticed straight away, since it affects my project. I used setDecimalPoint( 2, true ) to set a fixed point position after the second digit. Otherwise the configuration is the default, with leading zero blanking on. I expected that the LZB would take this into account, so that it would only blank leading zeroes once the “fixed point” format had been taken into account, so for example, 0 would be displayed as 0.00, 1 as 0.01, etc. Of course it doesn’t – the point itself is blanked until there are at least 3 digits. I can’t think of any good use for that behaviour (you might be able to suggest one!) and I’m sure I can figure out a workaround, but can I suggest that the leading zero blanking is made smarter to give the expected outcome for a fixed point display? Or perhaps have a “fixed point mode” that can smarten up the LZB behaviour.

    Thoughts?

    #1068
    Michael
    Keymaster

    I think you are misinterpretting the meaning of the API functions [tt:2bo3kbzi]setDecimalPoint[/tt:2bo3kbzi] and [tt:2bo3kbzi]setDigit[/tt:2bo3kbzi] They are simply a way to directly control the LEDs directly without any interpretation by the library about how to display values. They are an alternative to using [tt:2bo3kbzi]setValue[/tt:2bo3kbzi]. So, [tt:2bo3kbzi]setDecimalPoint(2, true)[/tt:2bo3kbzi] does not mean “always display the decimal in position 2 when I display numbers”. It just means “turn on the decimal for digit 2”. It is not a “fixed point mode” for displaying values. Hope that makes sense.

    You could implement a “fixed point mode” easily enough, I think.


    int fixedPointModePosition = -1;

    void setFixedPointMode(int position) {
    DigitShield.setPrecision(position);
    fixedPointModePosition = position;
    }

    void setFixedPointValue(int v) {
    if (fixedPointModePosition < 0) {
    // not in fixed point mode
    DigitShield.setValue(v);
    return;
    } else {
    DigitShield.setValue(v / fixedPointModePosition);
    }
    }

    Or something like that. I wrote that really fast.

    #1071
    Baby Bertha
    Member

    I understand that, but nevertheless, the setDecimalPoint API interacts with the leading zero blanking in a way that doesn’t make any sense (and probably wasn’t anticipated). LZB should blank zeroes, but never points! As it stands it basically means I have to implement the digit drive code myself, since the API doesn’t work in a way that’s useful here (I’m not saying the standard setValue methods aren’t useful, they are). In fact using a floating point value works pretty much how I need it to, so as long as that proves to be fast enough it will do the job nicely.

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