📄 backlite.cxx
字号:
// Write out any ACPOWER changes idx = (int) blACPOWER; if ((_bl_settings[idx].dirty_flgs & BLVAL_DFLGS_BRITE) && par_setGlobalPref(hdb, "backlight", "ac_level", PAR_INT, (char *) &_bl_settings[idx].brite_val, sizeof(int)) == -1) printf("PAR error writing backlight.ac_level(%d) error=%d", _bl_settings[idx].brite_val, pardb_errno); if ((_bl_settings[idx].dirty_flgs & BLVAL_DFLGS_TMOUT) && par_setGlobalPref(hdb, "backlight", "ac_timeout", PAR_INT, (char *) &_bl_settings[idx].tmout_val, sizeof(int)) == -1) printf("PAR error writing backlight.ac_timeout(%d) error=%d", _bl_settings[idx].tmout_val, pardb_errno); if ((_bl_settings[idx].dirty_flgs & BLVAL_DFLGS_WAKEUP) && par_setGlobalPref(hdb, "backlight", "ac_wakeup", PAR_BOOL, (char *) &_bl_settings[idx].wake_up, sizeof(bool)) == -1) printf("PAR error writing backlight.ac_wakeup, error=%d", pardb_errno); // Write out any BATTERY changes idx = (int) blBATTERY; if ((_bl_settings[idx].dirty_flgs & BLVAL_DFLGS_BRITE) && par_setGlobalPref(hdb, "backlight", "bat_level", PAR_INT, (char *) &_bl_settings[idx].brite_val, sizeof(int)) == -1) printf("PAR error writing backlight.bat_level(%d) error=%d", _bl_settings[idx].brite_val, pardb_errno); if ((_bl_settings[idx].dirty_flgs & BLVAL_DFLGS_TMOUT) && par_setGlobalPref(hdb, "backlight", "bat_timeout", PAR_INT, (char *) &_bl_settings[idx].tmout_val, sizeof(int)) == -1) printf("PAR error writing backlight.bat_timeout(%d) error=%d", _bl_settings[idx].tmout_val, pardb_errno); if ((_bl_settings[idx].dirty_flgs & BLVAL_DFLGS_WAKEUP) && par_setGlobalPref(hdb, "backlight", "bat_wakeup", PAR_BOOL, (char *) &_bl_settings[idx].wake_up, sizeof(bool)) == -1) printf("PAR error writing backlight.bat_wakeup, error=%d", pardb_errno); // Send broadcast message to anyone who cares... char col_msg[CL_MAX_MSG_LEN] = { '\0' }; int col_len = sprintf(col_msg, "sc_backlite^SYSCON_BL_CHANGE"); /* Call back to the main sysconfig app */ sysconf_ipc_write(CL_MSG_BROADCAST_ID, col_msg, col_len); return;} // end of NxBacklite::SetAppPrefs(void)/*******************************************************************************\**** Function: void SetBl()** Desc: Performs the actual setting (i.e. making the pixlib calls) of the** backlight.** Accepts: Nothing (void)** Returns: Nothing (void)** \*******************************************************************************/voidNxBacklite::SetBl(void){ char col_msg[CL_MAX_MSG_LEN]; int bl_max, // Maximum value of the backlight bl_val, // Value to set col_len, idx, // Array index scrtp_id; static int bl_oldval = 0; // Statically saved value DPRINTF("In SetBl() -- top\n"); idx = (int) _blMode; bl_max = pix_bl_getmxval(); bl_val = (int) (((float) ((bl_max * _bl_settings[idx].brite_val) / 100.0))); // Get the screen top id from colosseum if (bl_val == 0 || bl_oldval == 0) { DPRINTF("Getting scrtop id, values=(N)%d (O)%d\n", bl_val, bl_oldval); scrtp_id = sysconf_ipc_find("nxscrtop"); if (scrtp_id > -1) { scrtop_message msg; // Message to send to the screentop col_len = sizeof(msg.action); memset(&msg, 0, col_len); // Send a message to the screentop to switch to bl off image DPRINTF("Preparing \"%s\" message\n", bl_val == 0 ? "BL_OFF" : "BL_ON"); if (bl_val == 0) msg.type = CATEGORY_ITEM(CATEGORY_NA_ACTION, NA_ACTION_BLOFF); else msg.type = CATEGORY_ITEM(CATEGORY_NA_ACTION, NA_ACTION_BLON); memcpy(col_msg, &msg, col_len); sysconf_ipc_write(scrtp_id, col_msg, col_len); } else { DPRINTF("Find_Fd() failed on \"nxscrtop\"\n"); } } // Make the call after communicating with the screen top, to ensure the levels // are correctly set. DPRINTF("Before pix_bl_ctrl()\n"); pix_bl_ctrl(bl_val ? 1 : 0, bl_val); DPRINTF("Saving %d into bl_oldval\n", bl_val); bl_oldval = bl_val; return;} // end of NxBacklite::SetBl(void)/*******************************************************************************\**** Function: void SetValues()** Desc: Sets the widgets values based upon the current state of the ** application (_mode)** Accpets: Nothing (void)** Returns: Nothing (void)**\*******************************************************************************/voidNxBacklite::SetValues(void){ int idx; // Shorthand notation printf("MBMODE is still %p\n", _mbmode); switch (_blMode) { case blUNKNOWN: _mbmode->label("Unknown"); _bat_warning->hide(); _pwrdn_ck->hide(); _wake_ck->hide(); _brightness->hide(); _mbtimeunit[(int) blBATTERY]->hide(); _mbtimeunit[(int) blACPOWER]->hide(); break; case blBATTERY: _mbmode->label(mode_lbls[(int) blBATTERY]); _mbtimeunit[(int) blBATTERY]->show(); _mbtimeunit[(int) blACPOWER]->hide(); _bat_warning->show(); _pwrdn_ck->show(); _wake_ck->show(); _brightness->show(); break; case blACPOWER: _mbmode->label(mode_lbls[(int) blACPOWER]); _mbtimeunit[(int) blBATTERY]->hide(); _mbtimeunit[(int) blACPOWER]->show(); _bat_warning->hide(); _pwrdn_ck->show(); _wake_ck->show(); _brightness->show(); break; } // end of switch // Set the values.... if (_blMode != blUNKNOWN) { idx = (int) _blMode; // Set the timeout stuff if (_bl_settings[idx].tmout_val > 0) { int i; // Loop iterator _pwrdn_ck->value(1); _mbtimeunit[idx]->activate(); for (i = 0; tmout_vals[idx][i] != -1; i++) { if (_bl_settings[idx].tmout_val == tmout_vals[idx][i]) { _mbtimeunit[idx]->label(tmout_lbls[idx][i]); break; } // end of if } // end of for if (tmout_vals[idx][i] == -1) _mbtimeunit[idx]->label("Not Set"); } // end of if else { _pwrdn_ck->value(0); _mbtimeunit[idx]->deactivate(); } // end of else // Set the wakeup stuff if (_bl_settings[idx].wake_up == true) _wake_ck->value(1); else _wake_ck->value(0); // Set the backlite brightness value if (_bl_settings[idx].brite_val >= 0) { _bl_settings[idx].brite_val = (int) _brightness->clamp(_bl_settings[idx].brite_val); _brightness->value(_bl_settings[idx].brite_val); } // end of if } // end of if return;} // end of NxBacklite::SetValues(void)//-------------------------------------------------------------------------------//// Private static callback methods// void brite_sel_cb(Fl_Widget *, void *)// void mode_sel_cb(Fl_Widget *, void *)// void pwrdn_ck_cb(Fl_Widget *, void *)// void save_exit_cb(Fl_Widget *, void *)// void tm_sel_cb(Fl_Widget *, void *)////-------------------------------------------------------------------------------/*******************************************************************************\**** Function: void brite_sel_cb()** Desc: Callback for the brightness level widget, will adjust the level using** pixlib calls** Accepts: Fl_Widget *w = Ptr to the widget responsible for the branch** void *d = Ptr to any ancillary data** Returns: Nothing (void)**\*******************************************************************************/voidNxBacklite::brite_sel_cb(Fl_Widget * w, void *d){ NxBacklite *me = (NxBacklite *) d; NxValueSlider *nxvs = (NxValueSlider *) w; int idx; idx = (int) me->_blMode; me->_bl_settings[idx].brite_val = (int) nxvs->value(); me->_bl_settings[idx].dirty_flgs |= BLVAL_DFLGS_BRITE; // Actuall change the backlight value.... me->SetBl(); return;} // end of NxBacklite::brite_sel_cb(Fl_Widget *, void *)/*******************************************************************************\**** Function: void mode_sel_cb()** Desc: Callback for mode selection (toggles between battery/external power)** Accepts: Fl_Widget *w = Ptr to widget responsible for the branch** void *d = Ptr to any ancillary data** Returns: Nothing (void)**\*******************************************************************************/voidNxBacklite::mode_sel_cb(Fl_Widget * w, void *d){ NxBacklite *me = (NxBacklite *) d; NxMenuButton *nxmb = (NxMenuButton *) w; me->_blMode = (bl_mode_t) nxmb->value(); me->SetValues(); me->SetBl(); return;} // end of NxBacklite::mode_sel_Cb(Fl_Widget *, void *)/*******************************************************************************\**** Function: void pwrlnk_cb()** Desc: Callback to start the power-management app/utility** Accepts: Fl_Widget *w = Ptr to the widget responsible for the branch** void *d = Ptr to any ancillary data** Returns: Nothing (void)**\*******************************************************************************/voidNxBacklite::pwrlnk_cb(Fl_Widget * w, void *d){ DPRINTF("In pwrlnk_cb()\n"); return;} // end of NxBacklite::pwrlnk_cb(Fl_Widget *, void *)/*******************************************************************************\**** Function: void pwrdn_ck_cb()** Desc: Callback to for the powerdown checkbox widget** Accepts: Fl_Widget *w = Ptr to the widget responsible for the branch** void *d = Ptr to any ancillary data** Returns: Nothing (void)**\*******************************************************************************/voidNxBacklite::pwrdn_ck_cb(Fl_Widget * w, void *d){ NxBacklite *me = (NxBacklite *) d; NxCheckButton *nxcb = (NxCheckButton *) w; if (nxcb->value()) me->_mbtimeunit[(int) me->_blMode]->activate(); else { me->_mbtimeunit[(int) me->_blMode]->deactivate(); me->_bl_settings[(int) me->_blMode].tmout_val = 0; me->_bl_settings[(int) me->_blMode].dirty_flgs |= BLVAL_DFLGS_TMOUT; } // end of else return;} // end of NxBacklite::pwrdn_ck_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)**\*******************************************************************************/voidNxBacklite::save_exit_cb(Fl_Widget * w, void *d){ NxBacklite *me = (NxBacklite *) d; NxButton *nxb = (NxButton *) w; if (!strcmp(nxb->label(), "Save")) { DPRINTF("Saving any changed data!\n"); me->SetAppPrefs(); me->_mbmode->value(-1); me->_mbtimeunit[0]->value(-1); me->_mbtimeunit[1]->value(-1); } // end of if // Need to set the backlight back to what it was last stored as (in case we've just // canceled/reset if (pix_pwr_onBattery()) me->_blMode = blBATTERY; else me->_blMode = blACPOWER; me->GetAppPrefs(); me->SetValues(); me->SetBl(); return;} // end of NxBacklite::save_exit_cb(Fl_Widget *, void *)/*******************************************************************************\**** Function: void tm_sel_cb()** Desc: Callback for the timeunit menu button widgets** Accepts: Fl_Widget *w = Ptr to the widget responsible for the branch** void *d = Ptr to any ancillary data** Returns: Nothing (void)**\*******************************************************************************/voidNxBacklite::tm_sel_cb(Fl_Widget * w, void *d){ NxBacklite *me = (NxBacklite *) d; NxMenuButton *nxmb = (NxMenuButton *) w; int idx; // Index DPRINTF("In tm_sel_cb()\n"); idx = (int) me->_blMode; // Store the value.... me->_bl_settings[idx].tmout_val = tmout_vals[idx][nxmb->value()]; me->_bl_settings[idx].dirty_flgs |= BLVAL_DFLGS_TMOUT; nxmb->label(tmout_lbls[idx][nxmb->value()]); nxmb->redraw(); return;} // end of NxBacklite::tm_sel_cb(Fl_Widget *, void *)/*******************************************************************************\**** Function: void wake_toggle_cb()** Desc: Sets the value of the wake up on touch variable depending on current** state of the check button** Accepts: Fl_Widget *w = Ptr to the widget responsible for branch** void *d = Ptr to any ancillary data** Returns: Nothing (void)**\*******************************************************************************/voidNxBacklite::wake_toggle_cb(Fl_Widget * w, void *d){ NxBacklite *me = (NxBacklite *) d; NxCheckButton *nxcb = (NxCheckButton *) w; int idx; // index idx = (int) me->_blMode; if (nxcb->value()) me->_bl_settings[idx].wake_up = true; else me->_bl_settings[idx].wake_up = false; me->_bl_settings[idx].dirty_flgs |= BLVAL_DFLGS_WAKEUP; return;} // end of NxBacklite::wake_toggle_cb(Fl_Widget *, void *)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -