void vfd_gui_trig(void) { vfd_home(); char* time_string = malloc(32); sprintf(time_string, " %d", epoch); vfd_write_string(time_string); free(time_string); vfd_lf(); vfd_cr(); vfd_write_string("Phase Angle: "); vfd_write_string(global_phase_angle_string); vfd_write_string(" "); vfd_lf(); vfd_cr(); vfd_write_string("Power Factor:"); vfd_lf(); vfd_cr(); vfd_write_string(" "); vfd_write_string(global_power_factor_string); vfd_write_string(" "); }
void vfd_gui_cost(void) { char* total_energy_string = malloc(32); char* time_delta_string = malloc(32); char* total_energy_cost_string = malloc(32); float32_t global_watt_hours_fixed = global_watt_hours / 1000; total_energy_string = gcvtf(global_watt_hours_fixed, 5, total_energy_string); int32_t time_delta = epoch - global_watt_hours_epoch; sprintf(time_delta_string, "%d", time_delta); float32_t energy_cost = global_watt_hours_fixed; energy_cost *= 0.0013f; // 13 cents/kWh in cents/Wh total_energy_cost_string = gcvtf(energy_cost, 5, total_energy_cost_string); vfd_home(); vfd_write_string("Energy for "); vfd_write_string(time_delta_string); vfd_write_string("s:"); vfd_lf(); vfd_cr(); vfd_write_string(" "); vfd_write_string(total_energy_string); vfd_write_string("Wh "); vfd_lf(); vfd_cr(); vfd_write_string("13 cents per kWh:"); vfd_lf(); vfd_cr(); vfd_write_string(" $"); vfd_write_string(total_energy_cost_string); vfd_write_string(" "); free(total_energy_string); free(time_delta_string); free(total_energy_cost_string); }
void vfd_gui_config(void) { vfd_home(); vfd_write_string("MAC Address:"); vfd_lf(); vfd_cr(); vfd_write_string(" DE:AD:BE:EF:CA:FE "); vfd_lf(); vfd_cr(); vfd_write_string("DHCP: N/A "); vfd_lf(); vfd_cr(); vfd_write_string("SD Card: N/A "); }
void evfd::vfd_write_string_scrollText(const char* text) { if (!blocked) { int i, len = strlen(text); char out[17]={'\0'}; for (i=0; i<=(len-16); i++) { // scroll text till end memcpy(out, text+i, 16); vfd_write_string(out); usleep(200000); } for (i=1; i<16; i++) { // scroll text with whitespaces from right memcpy(out, text+len+i-16, 16-i); memset(out+(16-i-1), ' ', i); vfd_write_string(out); usleep(200000); } memcpy(out, text, 16); // display first 16 chars after scrolling vfd_write_string(out); } return; }
void vfd_gui_splash(char date[], char time[]) { vfd_home(); vfd_write_string(" "); vfd_write_string("--- WATTR ---"); vfd_lf(); vfd_cr(); vfd_write_string(" "); vfd_lf(); vfd_cr(); vfd_write_string(" "); vfd_write_string(date); vfd_lf(); vfd_cr(); vfd_write_string(" "); vfd_write_string(time); }
void evfd::init() { vfd_write_string("Starting opensif sh4"); }
void evfd::vfd_clear_string() { vfd_write_string(" "); return; }
void vfd_gui_vaf_aar(void) { vfd_home(); char* time_string = malloc(32); sprintf(time_string, " %d", epoch); vfd_write_string(time_string); free(time_string); vfd_lf(); vfd_cr(); vfd_write_string(global_voltage_string); vfd_write_string("V "); vfd_lf(); vfd_cr(); vfd_write_string(global_current_string); vfd_write_string("A "); vfd_lf(); vfd_cr(); vfd_write_string(global_frequency_string); vfd_write_string("Hz "); vfd_set_cursor(9*8, 0, 1, 0); vfd_write_string(global_active_power_string); vfd_write_string("W "); vfd_set_cursor(9*8, 0, 2, 0); vfd_write_string(global_apparent_power_string); vfd_write_string("VA "); vfd_set_cursor(9*8, 0, 3, 0); vfd_write_string(global_reactive_power_string); vfd_write_string("VAR "); }
void evfd::vfd_write_string(const char * str) { vfd_write_string(str, false); }