LCD Display on/off - page 2 - Script Writing - CHDK Forum

LCD Display on/off

  • 10 Replies
  • 5476 Views
*

Offline lapser

  • *****
  • 1093
Re: LCD Display on/off
« Reply #10 on: 11 / March / 2013, 01:29:28 »
Advertisements
Here's a small modification to luascript.c that I use to keep the backlight off after set_backlight(0). It might make a nice addition to the trunk, just to keep from having to answer so many questions about set_backlight(0) :)

Code: [Select]
static int bldark=0; //flags backlight off

static int luaCB_set_backlight( lua_State* L )
{
  bldark = (luaL_checknumber(L,1)==0);
  //if (bldark) TurnOffBackLight();
  //else TurnOnBackLight();
  if (!bldark) TurnOnBackLight(); //else will turn off next yield
  return 0;
}


// run a timeslice of lua script
int lua_script_run(void)
{
  int Lres;
  int top;
  if (run_first_resume) {
      run_first_resume = 0;
      top = 0;
      bldark=0;
  } else {
      top = lua_gettop(Lt);
  }
  run_start_tick = get_tick_count();
  run_hook_count = 0;
  if (bldark) TurnOffBackLight();
  Lres = lua_resume( Lt, top );

  if (Lres == LUA_YIELD)return SCRIPT_RUN_RUNNING; //yielded

  bldark=0;
  TurnOnBackLight();

  if (Lres != 0)return lua_script_error(Lt,1);
  // finished normally, add ptp result
  lua_script_finish(Lt);
  // Display 'Finished message', unless running from PTP
  if (lua_script_is_ptp == 0)
      script_console_add_line(LANG_CONSOLE_TEXT_FINISHED);
  return SCRIPT_RUN_ENDED;
}

EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics


SimplePortal © 2008-2014, SimplePortal