Page 4 of 6 FirstFirst 123456 LastLast
Results 31 to 40 of 55

Thread: Autodimming monitor after 2 seconds of inactivity. (Solution inside)

  1. #31
    Join Date
    Jan 2004
    St. Louis
    Quote Originally Posted by justintime
    hey Tipastar, this works very well!

    Would you have the knowledge to incorporate this VB6 code into your script, so that it can automatically calculate sunrise/sunset time based on your predefined coordinates? (same thing GammaControl does)
    That wouldn't be a problem. Let me find this gamma control and see what it's all about. My build is embedded so I don't use these front ends but this shouldn't take long.

  2. #32
    Raw Wave justintime's Avatar
    Join Date
    Apr 2005
    Ahaha! I took tipastar's script and enhanced it for auto calculation of sunset/sunrise times!

    Here is a script that will turn your screensaver ON at night, and it will turn it OFF during daylight. It will calculate your sunrise/sunset times automatically based on your Longitude and Latitude (you need to hardcode your LON and LAT values in the script).

    Just like tipastar said, copy/paste this into a text file, save as script.vbs and run it. You can set it as a repeat task every 10 mins or whatever. Combine this with powerdimmer etc as per first post and you're all set.

    'This script will enable the screensaver if ran after sunset and before sunrise. 
    'Otherwise it will disable it (during daylight).
    'You must specifiy the parameters longitude, latitude, tzoff, and DSTactive below.
    'Sunrise and Sunset times are clculated automatically based on your location.
    Option Explicit
    Dim objShell
    Dim strRegKey, strRegValue
    Dim strOn, curTime, SunriseTime, SunsetTime, activate, varOn, strScr, RADEG, DEGRAD, ThisTime, Tmp, TmpSunrise, TmpSunset, StrOut
    'For your specific LAT and LON values use
    Const longitude = -84.229452
    Const latitude = 39.336644
    Const tzoff = -5
    Const DSTactive = 0
    'Inserted From SunTimes.vbs ( 
    'and slightly modified output formatting to meet our needs
    ' Other Constants & Defs
    Const pi = 3.1415926535897932384626433832795
    ' Main function
    Function SunTimes (strYear, strMonth, strDay, longitude, latitude, TZ, isdst)
    Dim d, n, i, w, m, l, e, e1, a, xv, yv, v, xs, ys, xe, ecl, lonsun, ye, ze, ra, dec, h, r
    Dim GMST0, UT_Sun_in_south, LHA, hour_rise, hour_set, min_rise, min_set
    'calculate days since 2000 jan 1
      d = ( 367 * (strYear) - int((7 * ((strYear) + (((strMonth) + 9) / 12))) / 4) + int((275 * (strMonth)) / 9) + (strDay) - 730530)
    ' Orbital elements of the Sun:
      N = 0.0
      i = 0.0
      w = 282.9404 + 4.70935E-5 * d
      a = 1.000000
      e = 0.016709 - 1.151E-9 * d
      M = 356.0470 + 0.9856002585 * d
      M = rev(M)
      ecl = 23.4393 - 3.563E-7 * d
      L = w + M
      if (L < 0 OR L > 360) then
        L = rev(L)
      end if
    ' position of the Sun
      E1 = M + e*(180/pi) * sind(M) * ( 1.0 + e * cosd(M) )
      xv = cosd(E1) - e
      yv = sqrt(1.0 - e * e) * sind(E1)
      v = atan2d(yv, xv)
      r = sqrt(xv * xv + yv * yv) 
      lonsun = v + w
      if (lonsun < 0 OR lonsun > 360) then
        lonsun = rev(lonsun)
      end if
      xs = r * cosd(lonsun)
      ys = r * sind(lonsun)
      xe = xs
      ye = ys * cosd(ecl)
      ze = ys * sind(ecl)
      RA = atan2d(ye, xe)
      Dec = atan2d(ze, (sqrt((xe * xe)+(ye * ye))))
      GMST0 = L + 180
      if (GMST0 < 0 OR GMST0 > 360) then
        GMST0 = rev(GMST0)
      end if
      UT_Sun_in_south = ( RA - GMST0 - longitude ) / 15.0
      if (UT_Sun_in_south < 0) then
        UT_Sun_in_south=UT_Sun_in_south + 24
      end if
      LHA= (sind(h) - (sind(latitude) * sind(Dec)))/(cosd(latitude) * cosd(Dec))
      if (LHA > -1 AND LHA < 1) then
        SunTimes = "No sunrise,No sunset"
        exit function
      end if 
      hour_rise=UT_Sun_in_south - LHA
      hour_set=UT_Sun_in_south + LHA
      min_rise=int((hour_rise-int(hour_rise)) * 60)
      min_set=int((hour_set-int(hour_set)) * 60)
      hour_rise=(int(hour_rise) + (TZ + isdst))
      hour_set=(int(hour_set) + (TZ + isdst))
      if (min_rise < 10) then
        min_rise = right("0000" & min_rise, 2)
      end if
      if (min_set < 10) then
        min_set = right("0000" & min_set, 2)
      end if
      'slightly modified the formatting of the following line format from original version.
      SunTimes = hour_rise & "," & min_rise & "," & "00" & ";" & hour_set & "," & min_set & "," & "00"
    End Function
    ' Support Functions
    Function sind(qqq)
      sind = sin((qqq) * DEGRAD)
    End Function
    Function cosd(qqq)
     cosd = cos((qqq) * DEGRAD)
    End Function
    Function tand(qqq)
     tand = tan((qqq) * DEGRAD)
    End Function
    Function atand(qqq)
     atand = (RADEG * atan(qqq))
    End Function
    Function asind(qqq)
     asind = (RADEG * asin(qqq))
    End Function
    Function acosd(qqq) 
     acosd = (RADEG * acos(qqq))
    End Function
    Function atan2d (qqq, qqq1)
     atan2d = (RADEG * atan2(qqq, qqq1))
    End Function
    Function rev(qqq) 
    Dim x
     x = (qqq - int(qqq/360.0) * 360.0)
     if (x <= 0) then
      x = x + 360
     end if
     rev = x
    End Function
    Function atan2(ys,xs)
    ' from the Draw Arrows tip
    ' @
    ' by —Jim Deutch, Syracuse, New York
    Dim theta
     If xs <> 0 Then
      theta = Atn(ys / xs)
      If xs < 0 Then
       theta = theta + pi
      End If
      If ys < 0 Then
       theta = 3 * pi / 2 '90
       theta = pi / 2 '270
      End If
     End If
     atan2 = theta
    End Function
    function acos(x)
     acos = Atn(-X / Sqrt(-X * X + 1)) + 2 * Atn(1)
    end function
    function sqrt(x)
     if x > 0 then
      sqrt = Sqr(x)
      sqrt = 0
     end if
    end function
    ThisTime = SunTimes(Year(Now), Month(Now), Day(Now), longitude, latitude, tzoff, DSTactive)
    Tmp = split(ThisTime, ";")
    TmpSunrise = split(Tmp(0), ",")
    TmpSunset = split(Tmp(1), ",")
    'Time is in the format TimeSerial(hh,mm,ss)
    'hh is 24 hour format so 6:35 PM would be set as TimeSerial(18,35,00)
    'Sunset and Sunrise times are being calculated from function SunTimes as per above.
    'No hardcode necessary.
    SunsetTime = TimeSerial(TmpSunset(0),TmpSunset(1),TmpSunset(2))
    SunriseTime = TimeSerial(TmpSunrise(0),TmpSunrise(1),TmpSunrise(2))
    'strOut = "Sunrise: " & SunriseTime & "      Sunset: "  & SunsetTime
    'wscript.echo strOut
    If curTime > SunriseTime and curTime < SunsetTime Then
    varOn = "0"
    varOn = "1"
    End if
    'strOut = Varon
    'wscript.echo strOut
    strRegKey = "HKCU\Control Panel\Desktop\"
    strRegValue = "ScreenSaveActive"
    strOn = varOn
    Set objShell = CreateObject("WScript.Shell")
    objShell.RegWrite strRegKey & strRegValue, strOn, "REG_SZ"
    'Always make sure PowerDimmer is the active screensaver for this...
    'strRegKey = "HKCU\Control Panel\Desktop\"
    'strRegValue = "SCRNSAVE.EXE"
    'strScr = "C:\WINDOWS\system32\POWERD~1.SCR"
    'Set objShell = CreateObject("WScript.Shell")
    'objShell.RegWrite strRegKey & strRegValue, strScr, "REG_SZ"
    2002 Honda CR-V
    Carputer progress: 90% [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ -]
    Spent so far: $1105.90

    Download the NEXUS Skin for Centrafuse
    ...or even Listen to my music

  3. #33
    Para Laura thanatos106's Avatar
    Join Date
    Nov 2004
    Miami Beach,FL U.S.A
    Nice pice of script

    JIT you should delete this part of you firts post cus you got the answer already

    Hope this helps. I think this is useful for night driving. I just wish there was a way to enable this ONLY at night. Any ideas?!
    RexBruMet Skin for FrodoPlayer

    Nissan Aux-in MOD

    Quote Originally Posted by bgoodman
    We're an international forum, post in whatever langauge you like.

  4. #34
    Raw Wave justintime's Avatar
    Join Date
    Apr 2005
    thanatos, you're right. Removed that now.

    I just noticed that the CLICK on the screen will not pass-through. Too bad. need to tap once to brighten, and then again to push the button you intended to push. That's a Windows limitation though (by design).
    2002 Honda CR-V
    Carputer progress: 90% [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ -]
    Spent so far: $1105.90

    Download the NEXUS Skin for Centrafuse
    ...or even Listen to my music

  5. #35
    Join Date
    Jan 2004
    St. Louis
    Good job JIT. I'll test this. I my self am going to turn this into a Windows service so I don't have to rely on the System Scheduler. Actually, I may also look into just making the screen dim period based on the powerdimmer. Like you said, it might be nicer to be able to just have the click events pass through instead of just turning off the ss. On a similar but different note, how do DVD's play through powerdimmer? Does it look alright?

    So what's wrong with gammacontrol as a dimmer option instead of the screensaver? Am I missing something as to why you guys wanted to go the powerdimmer route?

  6. #36
    SMKFree liquid_smoke's Avatar
    Join Date
    Aug 2003
    very cool, i have a screensaver for MCE similar to this one, but it dosent work too good.

    Ive been using this

    which does the tint thing like the screensaver, but its a yahoo widget, has a timer and a lot of customization.
    01101100 01101001 01110001 01110101 01101001 01100100 01011111 01110011
    01101101 01101111 01101011 01100101

    beer replenishment fund
    mp3car live search

    i have joost invites, just hit me up for one.

  7. #37
    Constant Bitrate WhoIsThisGuy?'s Avatar
    Join Date
    Sep 2004
    Manchester, UK
    Quote Originally Posted by dfk70
    Yes, actually, all of my cars have dimmers. It controls the dash lights as well as the radio brightness.
    Cool! Any car i've had with a dimmer it only affects the dash lights, not the head unit. Be cool to hook up the microcontroller I refered to earlier directly to your dimmer so that all your dash lights gradually fade as dusk sets in

    Judging by the lack of reference to my suggestion, most people don't think its a good idea. I'm aiming to use this method with my system. When its done, if this thread is still active, or an equivalent exists, I'll put a link to my work log so people can check it out. It reasonably simple (8 components?) and inexpensive to do - the microcontroller i'm using costs about 1.50 (near $2) and thats traditionally the most expensive component in this type of rig.

    I reckon it'll be cool to have the brightness fade over time in relation to ambient light as opposed to a sudden switch to "dark mode". And i'm willing to have one extra small piece of hardware for this which will hardly draw any power. Just my 2 cents (or pence since I'm British).

    Anyways, good luck guys

    M10K, Lilli 7", 512MB, 80Gb HD, slim CD-RW/DVD Combi, nLite Win XP, CentraFuse.

    Planned for years, built for ages, tested for a while, almost installed, never gonna be perfect...

  8. #38
    Raw Wave justintime's Avatar
    Join Date
    Apr 2005
    So, have not heard any comments on how well the script is working for you guys... you all to scared to try it out LOL?
    2002 Honda CR-V
    Carputer progress: 90% [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ -]
    Spent so far: $1105.90

    Download the NEXUS Skin for Centrafuse
    ...or even Listen to my music

  9. #39
    The Curator
    Auto Apps:loading...
    Blue ZX3's Avatar
    Join Date
    Aug 2004
    Chicago area,IL
    Quick Q..
    not sure if this could be done or not but could a script maybe know when the screen saver kicks in and then enter a loop that watches for a mouse click and when it detects one record what posistion and pause for like 50ms then excute a mouse click at that some recorded spot...basically passing the click...

    I mess around in autoit quite a bit and was thinking maybe something like that above mentioned could be would only be a rough start but a start at that...

    RideRunner...The #1 FE, PERIOD.

    Current Project: DFXVoice [v1.0 Released]
    Next in line: RRMedia v2.0

    DFX 5.1.1 Skin
    Appstore Link

    My RideRunner Plugins

    "There are no bugs - only undocumented features."

  10. #40
    Newbie Thann's Avatar
    Join Date
    Jun 2005
    New Orleans, baby!
    Quote Originally Posted by RPM_VR4
    Most cars are simply on/off to the radio. More expensive cars usually have a second wire for dim-level as well as the normal on/off (...and a few cars just have the dim-level). In any case, I always have my dimmer level on full bright.

    I really think the two best options here are:
    1) Sunrise/Sunset times calculated off ZIP-code or GPS. (software only)
    2) A light sensor connected to a micro or joystick axis. (better, but requires wiring extra hardware)
    RPM, have a look here: USB Light Sensor
    Ride: 2004 Nissan Murano SL AWD/Sheer Silver/Black Leather/factory HIDs.
    MoPuter: Transflectivized Lilli 7", EPIA M-10000, 512Mb RAM, 160Gb WD, SBLive!, 54g WLAN, Holux GM-213, 160W M2-ATX PSU

Page 4 of 6 FirstFirst 123456 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 07-08-2005, 05:08 PM
  2. A solution for powering 12v stuff inside
    By zootjeff in forum Power Supplies
    Replies: 21
    Last Post: 12-17-2004, 07:21 PM
  3. Best Carputer Solution. Ideas Inside!
    By voidunknown in forum Newbie
    Replies: 16
    Last Post: 08-25-2004, 12:35 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts