src/Display.h
// values {min valuetarget valuecurrent max}
values {min valuetarget valuecurrent max}
values { min valuetarget valuecurrent max }
void displayBars(unsigned int x, unsigned int y, unsigned int width, unsigned int height, VarSpeedServo *servos[]) {
        for (size_t i = 0; i < 6; i++) {
            int neutral = (int)map_float2(servos[i]->getHomeRadAngle(), servos[i]->getMinRadAngle(), servos[i]->getMaxRadAngle(), 0, width);
            int mappedValueTarget = (int)map_float2(servos[i]->getTargetRadAngle(), servos[i]->getMinRadAngle(),
                                                    servos[i]->getMaxRadAngle(), 0, width);
            int mappedValueCurrent = (int)map_float2(servos[i]->getCurrentAngle(), servos[i]->getMinRadAngle(),
                                                     servos[i]->getMaxRadAngle(), 0, width);
            unsigned int heightPerBar = height / 6;
            unsigned int offsetLineOne;
            unsigned int offsetLineTwo;
            switch (height) {
            case 6:
                offsetLineOne = 0;
                offsetLineTwo = 0;
                break;
            case 12:
                offsetLineOne = 0;
                offsetLineTwo = 1;
                break;
            case 18:
            case 24:
                offsetLineOne = 1;
                offsetLineTwo = 2;
                break;
            default:
                offsetLineOne = 1;
                offsetLineTwo = 2;
            }
            display.fillRect(x + neutral, y + i * heightPerBar, 1, heightPerBar, WHITE);
            if (neutral - mappedValueTarget > 0) {
                display.fillRect(x + mappedValueTarget, y + offsetLineOne + i * heightPerBar, -mappedValueTarget + neutral, 1, WHITE);
            } else {
                display.fillRect(x + neutral, y + offsetLineOne + i * heightPerBar, mappedValueTarget - neutral, 1, WHITE);
            }
            if (neutral - mappedValueCurrent > 0) {
                display.fillRect(x + mappedValueCurrent, y + offsetLineTwo + i * heightPerBar, -mappedValueCurrent + neutral, 1, WHITE);
            } else {
                display.fillRect(x + neutral, y + offsetLineTwo + i * heightPerBar, mappedValueCurrent - neutral, 1, WHITE);
            }
        }
    }
void displayBars ( unsigned int x , unsigned int y , unsigned int width , unsigned int height , VarSpeedServo * servos [ ] ) { for ( size_t i = 0 ; i < 6 ; i ++ ) { int neutral = ( int ) map_float2 ( servos [ i ] -> getHomeRadAngle ( ) , servos [ i ] -> getMinRadAngle ( ) , servos [ i ] -> getMaxRadAngle ( ) , 0 , width ) ; int mappedValueTarget = ( int ) map_float2 ( servos [ i ] -> getTargetRadAngle ( ) , servos [ i ] -> getMinRadAngle ( ) , servos [ i ] -> getMaxRadAngle ( ) , 0 , width ) ; int mappedValueCurrent = ( int ) map_float2 ( servos [ i ] -> getCurrentAngle ( ) , servos [ i ] -> getMinRadAngle ( ) , servos [ i ] -> getMaxRadAngle ( ) , 0 , width ) ; unsigned int heightPerBar = height / 6 ; unsigned int offsetLineOne ; unsigned int offsetLineTwo ; switch ( height ) { case 6 : offsetLineOne = 0 ; offsetLineTwo = 0 ; break ; case 12 : offsetLineOne = 0 ; offsetLineTwo = 1 ; break ; case 18 : case 24 : offsetLineOne = 1 ; offsetLineTwo = 2 ; break ; default : offsetLineOne = 1 ; offsetLineTwo = 2 ; } display . fillRect ( x + neutral , y + i * heightPerBar , 1 , heightPerBar , WHITE ) ; if ( neutral - mappedValueTarget > 0 ) { display . fillRect ( x + mappedValueTarget , y + offsetLineOne + i * heightPerBar , - mappedValueTarget + neutral , 1 , WHITE ) ; } else { display . fillRect ( x + neutral , y + offsetLineOne + i * heightPerBar , mappedValueTarget - neutral , 1 , WHITE ) ; } if ( neutral - mappedValueCurrent > 0 ) { display . fillRect ( x + mappedValueCurrent , y + offsetLineTwo + i * heightPerBar , - mappedValueCurrent + neutral , 1 , WHITE ) ; } else { display . fillRect ( x + neutral , y + offsetLineTwo + i * heightPerBar , mappedValueCurrent - neutral , 1 , WHITE ) ; } } }
values {min valuetarget valuecurrent max}
values { min valuetarget valuecurrent max }
// float range        = servos[i]->getCurrentAngle() - servos[i]->getMinRadAngle(); // x, y, width, height // target angle // target angle // current angle // current angle