Exemplo n.º 1
0
static THD_FUNCTION(ThreadGFXVal, arg)
{
	(void)arg;

	chRegSetThreadName("GFXVal");

	while (true) {
		gwinSetText(ghlblV, util_floatToString(loadvoltage, UNIT_V), TRUE);
		gwinSetText(ghlblA, util_floatToString(current_mA, UNIT_MA), TRUE);
		gwinSetText(ghlblW, util_floatToString(((current_mA*loadvoltage)/1000), UNIT_W), TRUE);
		//gwinSetText(ghlblAH, util_floatToString(milliamphours, UNIT_MAH), TRUE);

		if ((scaleChanged) && (activeGraph != 3)) {
			char str[7];
			snprintf(str, 7, "%d%s", autoscale_limits[activeGraph][graph_MAX[activeGraph]], units[graphUnits[activeGraph]]);
			gwinSetText(ghBtnScale, str, TRUE);
			drawGraphLines(ghContainerGraphC);
			scaleChanged = false;
		}

		if (activeGraph == 3) {
			char str[7];
			snprintf(str, 7, "%d%s", autoscale_limits[0][graph_MAX[0]], units[graphUnits[0]]);
			gwinSetText(ghBtnScale, str, TRUE);
			scaleChanged = false;
			snprintf(str, 7, "%d%s", autoscale_limits[1][graph_MAX[1]], units[graphUnits[1]]);
			gwinDrawString(ghContainerGraphCV_2, gwinGetWidth(ghContainerGraphCV_2)-25, 5, str);
			drawGraphLines(ghContainerGraphCV_1);
			drawGraphLines(ghContainerGraphCV_2);
		}

		chThdSleepMilliseconds(500);
	}
}
Exemplo n.º 2
0
int main(void)
{
	SystemInit(); // Activate settings quartz

	ina219_init();
	nokia5110_init();



    while(1)
    {
    	nokia5110_clear();
    	nokia5110_gotoXY(0, 0);
    	nokia5110_writeString("Voltage (V):");
    	nokia5110_gotoXY(0, 1);
    	voltage = ina219_getBusVoltage_V();
    	result = util_floatToString(voltage);
    	nokia5110_writeString(result);
//    	systick_delayMs(100);

    	nokia5110_gotoXY(0, 2);
    	nokia5110_writeString("Current (mA):");
    	nokia5110_gotoXY(0, 3);
    	current = ina219_getCurrent_mA();
    	result = util_floatToString(current);
    	nokia5110_writeString(result);
//    	systick_delayMs(100);

    	nokia5110_gotoXY(0, 4);
    	nokia5110_writeString("Power (mW):");
    	nokia5110_gotoXY(0, 5);
    	result = util_floatToString(voltage * current);
    	nokia5110_writeString(result);
    	systick_delayMs(300);
    }
}