Esempio n. 1
0
/* update information */
void upsdrv_updateinfo(void)
{
	char	val[32];
	
	if (!ups_getinfo()){
		return;
	}
	
	/* input.frequency */
	upsdebugx(3, "input.frequency   (raw data): [raw: %u]",
	                            raw_data[INPUT_FREQUENCY]);
	dstate_setinfo("input.frequency", "%02.2f", input_freq());
	upsdebugx(2, "input.frequency: %s", dstate_getinfo("input.frequency"));

	/* output.frequency */
	upsdebugx(3, "output.frequency   (raw data): [raw: %u]",
	                            raw_data[OUTPUT_FREQUENCY]);
	dstate_setinfo("output.frequency", "%02.2f", output_freq());
	upsdebugx(2, "output.frequency: %s", dstate_getinfo("output.frequency"));

	/* ups.load */	
	upsdebugx(3, "ups.load  (raw data): [raw: %u]",
	                            raw_data[UPS_LOAD]);
	dstate_setinfo("ups.load", "%03.1f", load_level());
	upsdebugx(2, "ups.load: %s", dstate_getinfo("ups.load"));

	/* battery.charge */
	upsdebugx(3, "battery.charge (raw data): [raw: %u]",
	                            raw_data[BATTERY_CHARGE]);
	dstate_setinfo("battery.charge", "%03.1f", batt_level());
	upsdebugx(2, "battery.charge: %s", dstate_getinfo("battery.charge"));

	/* input.voltage */	
	upsdebugx(3, "input.voltage (raw data): [raw: %u]",
	                            raw_data[INPUT_VOLTAGE]);
	dstate_setinfo("input.voltage", "%03.1f",input_voltage());
	upsdebugx(2, "input.voltage: %s", dstate_getinfo("input.voltage"));
	
	/* output.voltage */	
	upsdebugx(3, "output.voltage (raw data): [raw: %u]",
	                            raw_data[OUTPUT_VOLTAGE]);
	dstate_setinfo("output.voltage", "%03.1f",output_voltage());
	upsdebugx(2, "output.voltage: %s", dstate_getinfo("output.voltage"));

	status_init();
	
	*val = 0;
	if (!(raw_data[STATUS_A] & MAINS_FAILURE)) {
		!(raw_data[STATUS_A] & OFF) ? 
			status_set("OL") : status_set("OFF");
	} else {
		status_set("OB");
	}

	if (raw_data[STATUS_A] & LOW_BAT)  status_set("LB");

	if (raw_data[STATUS_A] & AVR_ON) {
		input_voltage() < linevoltage ? 
			status_set("BOOST") : status_set("TRIM");
	}

	if (raw_data[STATUS_A] & OVERLOAD)  status_set("OVER");

	if (raw_data[STATUS_B] & BAD_BAT)  status_set("RB");

	if (raw_data[STATUS_B] & TEST)  status_set("TEST");

	status_commit();

	upsdebugx(2, "STATUS: %s", dstate_getinfo("ups.status"));
	dstate_dataok();
}
Esempio n. 2
0
void menu_dispupdate(void)
{
//	char temp[256];
//	char disptxt[20][256];

	//memset(GFX.Screen + 320*12*2,0x11,320*200*2);
	//draw blue screen
	for(int y=0;y<240;y++){
		for(int x=0;x<256*2;x+=2){
			memset(GFX.Screen + 320*y*2+x,0x11,2);
		}
	}
	

	strcpy(disptxt[0],"Snes9x4P v20120226");

	strcpy(disptxt[1],"------------------");
	strcpy(disptxt[2],"Exit Emulator");
	strcpy(disptxt[3],"Reset Game");
	strcpy(disptxt[4],"Credits");
	strcpy(disptxt[5],"------------------");
	strcpy(disptxt[6],"Save State");
	strcpy(disptxt[7],"Load State");
	strcpy(disptxt[8],"State Slot                  No.");
	sprintf(temp,"%s%d",disptxt[8],SaveSlotNum);
	strcpy(disptxt[8],temp);
	strcpy(disptxt[9],"------------------");
	
	strcpy(disptxt[10],"Display mode     ");
	sprintf ( temp, "%s%s", disptxt [10], blit_scalers [ g_scale ].desc_en );
	strcpy ( disptxt[10], temp );
	
	strcpy(disptxt[11],"Frameskip                  ");
	if (Settings.SkipFrames == AUTO_FRAMERATE)
		sprintf(temp,"%s Auto",disptxt[11]);
	else
		sprintf(temp,"%s %02d/%d",disptxt[11],(int) Memory.ROMFramesPerSecond, Settings.SkipFrames);
	strcpy(disptxt[11],temp);
	
	strcpy(disptxt[12],"V-Sync                     ");
	if(g_vsync)
		sprintf(temp,"%s   On",disptxt[12]);
	else
		sprintf(temp,"%s  Off",disptxt[12]);
	strcpy(disptxt[12],temp);
	
	strcpy(disptxt[13],"Display Frame Rate         ");
	if(Settings.DisplayFrameRate)
		sprintf(temp,"%s   On",disptxt[13]);
	else
		sprintf(temp,"%s  Off",disptxt[13]);
	strcpy(disptxt[13],temp);
	
	strcpy(disptxt[14],"Transparency               ");
	if(Settings.Transparency)
		sprintf(temp,"%s   On",disptxt[14]);
	else
		sprintf(temp,"%s  Off",disptxt[14]);
	strcpy(disptxt[14],temp);
	
	strcpy(disptxt[15],"Cut Top                        ");
	sprintf(temp,"%s%d",disptxt[15],cut_top);
	strcpy(disptxt[15],temp);
	strcpy(disptxt[16],"Cut Bottom                     ");
	sprintf(temp,"%s%d",disptxt[16],cut_bottom);
	strcpy(disptxt[16],temp);
	strcpy(disptxt[17],"Cut Left                       ");
	sprintf(temp,"%s%d",disptxt[17],cut_left);
	strcpy(disptxt[17],temp);
	strcpy(disptxt[18],"Cut Right                      ");
	sprintf(temp,"%s%d",disptxt[18],cut_right);
	strcpy(disptxt[18],temp);
	
	strcpy(disptxt[19],"------------------");
	
	strcpy(disptxt[20],"Alt. Sample Decoding       ");
	if(Settings.AltSampleDecode)
		sprintf(temp,"%s   On",disptxt[20]);
	else
		sprintf(temp,"%s  Off",disptxt[20]);
	strcpy(disptxt[20],temp);
	
	strcpy(disptxt[21],"");
	battery_level = batt_level();
	strcpy(disptxt[22],"                   Battery:");
	if (battery_level >= 100)
		sprintf(temp,"%s %d%%",disptxt[22],battery_level);
	else if (battery_level >=10)
		sprintf(temp,"%s  %d%%",disptxt[22],battery_level);
	else
		sprintf(temp,"%s   %d%%",disptxt[22],battery_level);
	strcpy(disptxt[22],temp);
	


	for(int i=0;i<=22;i++)
	{
		if(i==cursor)
			sprintf(temp," >%s",disptxt[i]);
		else
			sprintf(temp,"  %s",disptxt[i]);
		strcpy(disptxt[i],temp);

		if ( i<=21 )
			S9xDisplayString (disptxt[i], GFX.Screen, 640,i*10+50);
		else //put the last line (for the battery indicator) a little lower than the rest
			S9xDisplayString (disptxt[i], GFX.Screen, 640,i*10+55);
	}

	//show screen shot for snapshot
	if(SaveSlotNum_old != SaveSlotNum)
	{
		strcpy(temp," Loading...");
		S9xDisplayString (temp, GFX.Screen +320/*280*/, 640,80/*204*/);
		//S9xDeinitUpdate (320, 240);
		char fname[256], ext[8];
		sprintf(ext, ".s0%d", SaveSlotNum);
		strcpy(fname, S9xGetFilename (ext));
		load_screenshot(fname);
		SaveSlotNum_old = SaveSlotNum;
	}
	show_screenshot();
	S9xDeinitUpdate (320, 240);
}