Ejemplo n.º 1
0
void drawUsage(double usage)
{
	int lineHeight = getFontHeight();
	int y1 = lcdGetCrsrY();
	int y2 = y1 + lineHeight;
	static const int frameSize = 1;
	BYTE color_frame = 0x00;

	// Colors: green - yellow - red
	static const BYTE colors[] = {
		0x1C, 0x3C, 0x5C, 0x7C, 0x9C, 0xBC, 0xDC, 0xFC,
		0xF8, 0xF4, 0xF0, 0xEC, 0xE8, 0xE4, 0xE0
	};

	drawRectFill(0, y1+frameSize, frameSize, lineHeight-2*frameSize, color_frame);
	drawRectFill(0, y1, 3*frameSize, frameSize, color_frame);
	drawRectFill(0, y2-frameSize, 3*frameSize, frameSize, color_frame);

	drawRectFill(RESX-frameSize, y1+frameSize, frameSize, lineHeight-2*frameSize, color_frame);
	drawRectFill(RESX-3*frameSize, y1, 3*frameSize, frameSize, color_frame);
	drawRectFill(RESX-3*frameSize, y2-frameSize, 3*frameSize, frameSize, color_frame);

	int lines = (RESX - 2*frameSize - 1) * usage + 0.5;
	for(int i = 0; i < lines; ++i)
		drawVLine(frameSize + i, y1 + frameSize, y2 - frameSize - 1, colors[(int)((double)i / (RESX-2*frameSize) * sizeof(colors) + 0.5)]);

	lcdNl();
}
Ejemplo n.º 2
0
void GFXDrawUtil::drawRectFill( const Point2I &upperLeft, const Point2I &lowerRight, const ColorI &color ) 
{   
   drawRectFill(Point2F((F32)upperLeft.x, (F32)upperLeft.y), Point2F((F32)lowerRight.x, (F32)lowerRight.y), color);
}
Ejemplo n.º 3
0
void GFXDrawUtil::drawRectFill( const RectI &rect, const ColorI &color )
{
   drawRectFill(rect.point, Point2I(rect.extent.x + rect.point.x - 1, rect.extent.y + rect.point.y - 1), color );
}
Ejemplo n.º 4
0
void ram(void){
    getInputWaitRelease();

    uint8_t old_state=-1;
    uint8_t charging_count=0;

    while(1){
        uint32_t mv = batteryGetVoltage();

        if (batteryCharging()) {
            if(!(charging_count % 50)){
                drawCommonThings(true);
                lcdPrintln("   Charging ...");

                if(charging_count>=50)  drawRectFill(16, 65, 22, 26, 0b11100000);
                if(charging_count>=100) drawRectFill(40, 65, 22, 26, 0b11110000);
                if(charging_count>=150) drawRectFill(64, 65, 22, 26, 0b10011100);
                if(charging_count>=200) drawRectFill(88, 65, 22, 26, 0b00011100);
                old_state = 0;
            }

            if(++charging_count > 250) charging_count=0;
            delayms(5);
        } else if (mv<3550 && old_state != 1){
            drawCommonThings(false);
            lcdPrintln("    Charge NOW!");
            drawRectFill(16, 65, 5, 26, 0b11100000);
            old_state = 1;
        }else if (mv<3650 && mv>=3550 && old_state != 2){
            drawCommonThings(false);
            lcdPrintln("    Charge soon");
            drawRectFill(16, 65, 22, 26, 0b11100000);
            old_state = 2;
        }else if (mv<4000 && mv>=3650 && old_state != 3){
            drawCommonThings(false);
            lcdPrintln("        OK");
            drawRectFill(16, 65, 22, 26, 0b11100000);
            drawRectFill(40, 65, 22, 26, 0b11110000);
            old_state = 3;
        }else if (mv<4120 && mv>=4000 && old_state != 4){
            drawCommonThings(false);
            lcdPrintln("       Good");
            drawRectFill(16, 65, 22, 26, 0b11100000);
            drawRectFill(40, 65, 22, 26, 0b11110000);
            drawRectFill(64, 65, 22, 26, 0b10011100);
            old_state = 4;
        }else if (mv>=4120 && old_state != 5) {
            drawCommonThings(false);
            lcdPrintln("       Full");
            drawRectFill(16, 65, 22, 26, 0b11100000);
            drawRectFill(40, 65, 22, 26, 0b11110000);
            drawRectFill(64, 65, 22, 26, 0b10011100);
            drawRectFill(88, 65, 22, 26, 0b00011100);
            old_state = 5;
        }

        // print voltage
        lcdSetCrsr(0, 100);
        uint8_t v = mv/1000;
        lcdPrint("      ");
        lcdPrint(IntToStr(v,2,0));
        lcdPrint(".");
        lcdPrint(IntToStr(mv%1000, 3, F_ZEROS | F_LONG));
        lcdPrintln("V");

        lcdDisplay();

        switch(getInput()){
            case BTN_LEFT:
                return;
            case BTN_ENTER:
                return;
        };
    };
}