app/src/main/java/org/sil/hearthis/LevelMeterView.java
// Divide space per LED by this to get gap width
Divide space per LED by this to get gap width
Divide space per LED by this to get gap width
@Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int width = canvas.getWidth();
        int height = canvas.getHeight();
        Paint background = new Paint();
        canvas.drawRect(0.0F, 0.0F, (float)width, (float)height,backgroundPaint);
        int gap = width / ledCount  / gapFraction;
        int ledWidth = width / ledCount - gap;
        int ledsToShow = Math.round((float)ledCount * displayLevel / 100);
        int top = height / 6;
        int barHeight = height - 2 * top;
        for (int i = 0; i < ledsToShow; i++) {
            int left = i * (gap + ledWidth);
            Paint howToPaint = goodLevelPaint;
            if (i >= ledCount - 2) {
                howToPaint = badLevelPaint;
            }
            canvas.drawRect((float)left, (float) top, (float) ledWidth + left, (float) top + barHeight, howToPaint);
        }
    }
@ Override protected void onDraw ( Canvas canvas ) { super . onDraw ( canvas ) ; int width = canvas . getWidth ( ) ; int height = canvas . getHeight ( ) ; Paint background = new Paint ( ) ; canvas . drawRect ( 0.0F , 0.0F , ( float ) width , ( float ) height , backgroundPaint ) ; int gap = width / ledCount / gapFraction ; int ledWidth = width / ledCount - gap ; int ledsToShow = Math . round ( ( float ) ledCount * displayLevel / 100 ) ; int top = height / 6 ; int barHeight = height - 2 * top ; for ( int i = 0 ; i < ledsToShow ; i ++ ) { int left = i * ( gap + ledWidth ) ; Paint howToPaint = goodLevelPaint ; if ( i >= ledCount - 2 ) { howToPaint = badLevelPaint ; } canvas . drawRect ( ( float ) left , ( float ) top , ( float ) ledWidth + left , ( float ) top + barHeight , howToPaint ) ; } }
Divide space per LED by this to get gap width
Divide space per LED by this to get gap width
// Top 3db is dangerous...about 2 leds.