⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 powerman.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 2 页
字号:
    }				// end of Battery timevals menu button    {	NxOutput *o = new NxOutput(curx, cury, _mainw->w(), BUTTON_HEIGHT);	instance->def_font(o);	o->box(FL_FLAT_BOX);	o->selection_color(o->color());	o->align(FL_ALIGN_LEFT);	o->textfont(FL_BOLD);	o->value("In External Power Mode:");	cury += BUTTON_HEIGHT;    }				// end of ACPower label widget    {	NxCheckButton *o = new NxCheckButton(curx, cury);	instance->def_font(o);	o->when(FL_WHEN_CHANGED);	o->callback(cb_cb, (void *) this);	o->box(FL_FLAT_BOX);	o->label("Turn off device if\nidle for: ");	_cbtns[1] = o;	curx = _mainw->w() - ((2 * mar) + MB_W);    }				// end of battery power down check button    {	NxMenuButton *o = new NxMenuButton(curx, cury, MB_W + mar, MB_H);	instance->def_font(o);	for (int i = 0; tmout_lbls[AC_IDX][i]; i++)	    o->add(tmout_lbls[AC_IDX][i]);	o->box(FL_BORDER_BOX);	o->when(FL_WHEN_CHANGED);	o->callback(mb_cb, (void *) this);	o->label("Unset");	_mbtns[AC_IDX] = o;	curx = mar;	cury += BUTTON_HEIGHT;    }				// end of Battery timevals menu button    _mainw->end();    _mainw->hide();    return;}				// end of NxPowerman::MakeWindow(void)/*******************************************************************************\****	Function:	void SetAppPrefs()**	Desc:		Stores any changed values into the PAR database**	Accepts:	Nothing (void)**	Returns:	Nothing (void)**	\*******************************************************************************/voidNxPowerman::SetAppPrefs(void){    char *pardb;		// Database name    db_handle *hdb;		// Database handle    if ((pardb = db_getDefaultDB()) == NULL) {	printf("No Default database! Changes lost");	return;    }				// end of if    if ((hdb = db_openDB(pardb, PAR_DB_MODE_RW)) == NULL) {	printf("Unable to open %s, error=%d", pardb, pardb_errno);	return;    }				// end of if    // Write out any ACPOWER changes    if ((_pwr_settings[AC_IDX].dirty_flg & PWR_DFLGS_PWRCB) &&	par_setGlobalPref(hdb, "power", "ac_off", PAR_BOOL,			  (char *) &_pwr_settings[AC_IDX].pwr_off,			  sizeof(bool)) == -1)	printf("PAR error writing power.ac_off(%d) error=%d",	       _pwr_settings[AC_IDX].pwr_off, pardb_errno);    if ((_pwr_settings[AC_IDX].dirty_flg & PWR_DFLGS_TMVAL)	&& par_setGlobalPref(hdb, "power", "ac_offval", PAR_INT,			     (char *) &_pwr_settings[AC_IDX].timeval,			     sizeof(int)) == -1)	printf("PAR error writing power.ac_offval(%d) error=%d",	       _pwr_settings[AC_IDX].timeval, pardb_errno);    // Write out any BATTERY changes    if ((_pwr_settings[BAT_IDX].dirty_flg & PWR_DFLGS_PWRCB) &&	par_setGlobalPref(hdb, "power", "bat_off", PAR_BOOL,			  (char *) &_pwr_settings[BAT_IDX].pwr_off,			  sizeof(bool)) == -1)	printf("PAR error writing power.bat_off(%d) error=%d",	       _pwr_settings[BAT_IDX].pwr_off, pardb_errno);    if ((_pwr_settings[BAT_IDX].dirty_flg & PWR_DFLGS_TMVAL)	&& par_setGlobalPref(hdb, "power", "bat_offval", PAR_INT,			     (char *) &_pwr_settings[BAT_IDX].timeval,			     sizeof(int)) == -1)	printf("PAR error writing power.bat_offval, error=%d", pardb_errno);    // Need to send broadcast message about power changes    char col_msg[CL_MAX_MSG_LEN] = { '\0' };    int col_len = sprintf(col_msg, "sc_power^SYSCON_PWR_CHANGE");    sysconf_ipc_write(CL_MSG_BROADCAST_ID, col_msg, col_len);    return;}				// end of NxPowerman::SetAppPrefs(void)/*******************************************************************************\****	Function:	void SetValues()**	Desc:		Sets the widgets values based upon the current state of the **				application (_mode)**	Accpets:	Nothing (void)**	Returns:	Nothing (void)**\*******************************************************************************/voidNxPowerman::SetValues(void){    int i,			// Loop iterator      j;			// Loop iterator    // Set check buttons and menu buttons....    for (i = 0; i < AC_IDX + 1; i++) {	// Get the current time out value and activate the menu button	for (j = 0; tmout_vals[i][j] != -1; j++) {	    if (tmout_vals[i][j] == _pwr_settings[i].timeval) {		_mbtns[i]->label(tmout_lbls[i][j]);		break;	    }			// end of if	}			// end of for	if (tmout_vals[i][j] == -1)	    _mbtns[i]->label("Unset");	if (_pwr_settings[i].pwr_off == true) {	    _cbtns[i]->value(1);	    _mbtns[i]->activate();	}			// end of if	else {	    _cbtns[i]->value(0);	    _mbtns[i]->deactivate();	}			// end of else	_mbtns[i]->redraw();    }				// end of for     // Set the slider value    // Determine if we are on battery power or line power    if (pix_pwr_onBattery()) {	// We are on battery power */	_batsl->value(pix_pwr_getbat(PWR_BAT_PERCENT));	_batstate->value("Power state: Battery");    }				// end of if    else {	// We are on External power	if (pix_pwr_isCharging()) {	    float curval;	// Current value	    curval = _batsl->value();	    curval += 10.0;	    if (curval > _batsl->maximum())		curval = _batsl->minimum();	    _batsl->value(curval);	    _batstate->value("Power State: Charging");	}			// end of if	else {	    _batsl->value(_batsl->maximum());	    _batstate->value("Power State: External");	}			// end of else    }				// end of else    _batsl->redraw();    return;}				// end of NxBPowerman::SetValues(void)//-------------------------------------------------------------------------------////      Private static callback methods//              static void cb_cb(Fl_Widget *, void *)//              static void mb_cb(Fl_Widget *, void *)//              static void save_exit_cb(Fl_Widget *, void *)//              static void sl_upd_tmr(void *d)////-------------------------------------------------------------------------------/*******************************************************************************\****	Function:	void cb_cb()**	Desc:		Callback for setting the activeness of the menu buttons**	Accepts:	Fl_Widget *w = Ptr to the widget responsible for the branch**				void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidNxPowerman::cb_cb(Fl_Widget * w, void *d){    NxPowerman *me = (NxPowerman *) d;    NxCheckButton *nxcb = (NxCheckButton *) w;    int idx;    if (me->_cbtns[0] == nxcb)	idx = BAT_IDX;    else	idx = AC_IDX;    // If we are in here, the value had to have changed!    me->_pwr_settings[idx].dirty_flg |= PWR_DFLGS_PWRCB;    if (nxcb->value())	me->_pwr_settings[idx].pwr_off = true;    else	me->_pwr_settings[idx].pwr_off = false;    me->SetValues();    return;}				// end of NxPowerman::cb_cb(Fl_Widget *, void *)/*******************************************************************************\****	Function:	void mb_cb()**	Desc:		Callback for time value selections**	Accepts:	Fl_Widget *w = Ptr to widget responsible for the branch**				void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidNxPowerman::mb_cb(Fl_Widget * w, void *d){    NxPowerman *me = (NxPowerman *) d;    NxMenuButton *nxmb = (NxMenuButton *) w;    int idx;    if (nxmb == me->_mbtns[0])	idx = BAT_IDX;    else	idx = AC_IDX;    if (nxmb->value() > -1) {	me->_pwr_settings[idx].timeval = tmout_vals[idx][nxmb->value()];	me->_pwr_settings[idx].dirty_flg |= PWR_DFLGS_TMVAL;    }				// end of if    me->SetValues();    return;}				// end of NxPowerman::mb_cb(Fl_Widget *, void *)/*******************************************************************************\****	Function:	void save_exit_cb()**	Desc:		Handles the save/exit of this application/utility**	Accepts:	Fl_Widget *w = Ptr to the widget responsible for the branch**				void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidNxPowerman::save_exit_cb(Fl_Widget * w, void *d){    NxPowerman *me = (NxPowerman *) d;    NxButton *nxb = (NxButton *) w;    if (!strcmp(nxb->label(), "Save")) {	me->SetAppPrefs();    }				// end of if    // Update as needed (incase of a reset)    me->GetAppPrefs();    me->SetValues();    return;}				// end of NxPowerman::save_exit_cb(Fl_Widget *, void *)/*******************************************************************************\****	Function:	void sl_upd_tmr()**	Desc:		Timer callback to get the current battery level, and update the slider**	Accepts:	void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidNxPowerman::sl_upd_tmr(void *d){    NxPowerman *me = (NxPowerman *) d;    if (pix_pwr_isCharging())	f_sltimer = PWR_CHARGE_TMR;    else	f_sltimer = PWR_BATTERY_TMR;    me->SetValues();    Fl::add_timeout(f_sltimer, me->sl_upd_tmr, d);    return;}				// end of NxPowerman::sl_upd_tmr(void *)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -