Battery Power

Share your advanced PureBasic knowledge/code with the community.
michaeled314
Enthusiast
Enthusiast
Posts: 340
Joined: Tue Apr 24, 2007 11:14 pm

Battery Power

Post by michaeled314 »

:cry:
Last edited by michaeled314 on Tue Aug 21, 2007 8:38 pm, edited 2 times in total.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Re: Battery Power

Post by Derek »

michaeled314 wrote: HA! HA! I'm a neater coder than any of you guys on this forum
You might have neat code but using a GOTO is not very neat. :twisted: :wink:

Could of used REPEAT and FOREVER.
michaeled314
Enthusiast
Enthusiast
Posts: 340
Joined: Tue Apr 24, 2007 11:14 pm

Post by michaeled314 »

Code: Select all

Procedure Refresh(timeout)
 Repeat
  powerpolicyglobal.GLOBAL_POWER_POLICY
  powerpolicy.POWER_POLICY
  syspowerstat.SYSTEM_POWER_STATUS
  
  If GetSystemPowerStatus_(syspowerstat)
   Select syspowerstat\ACLineStatus
    Case 0
     SetGadgetText(0,"You are currently on Battery Power")
    Case 1
     SetGadgetText(0,"You are currently on AC Power")
   EndSelect
   
   SetGadgetText(1,Str(syspowerstat\BatteryLifePercent)+"%")
   
   Select syspowerstat\BatteryFlag
    Case 1
     SetGadgetColor(1,#PB_Gadget_FrontColor,RGB(0,0,0))
    Case 2
     SetGadgetColor(1,#PB_Gadget_FrontColor,RGB(0,255,0))
    Case 4
     SetGadgetColor(1,#PB_Gadget_FrontColor,RGB(0,0,255))
   EndSelect
  EndIf
  Delay(1000)
 ForEver
EndProcedure

If OpenWindow(0,0,0,300,500,"Power Meter",#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
 hWnd = WindowID(0)
 hDC = GetDC_(hWnd)
 
 If Not CreateGadgetList(hWnd)
  End
 EndIf
 
 TextGadget(0,20,20,270,20,"",#PB_Text_Center)
 TextGadget(1,20,40,270,20,"",#PB_Text_Center)
 If CreateMenu(0,hWnd)
  MenuTitle("Power")
   MenuItem(0,"Settings")
 EndIf
 
 CreateThread(@Refresh(),timeout)
 
 Repeat
  Event = WindowEvent()
  Select Event
   Case #PB_Event_Menu
    Menu = EventMenu()
    Select Menu
     Case 0
      CreateThread(@PowerPoliciesWin(),hWnd)
    EndSelect
  EndSelect
 Until Event = #PB_Event_CloseWindow
EndIf
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

@michaeled314

Noticed your sig, this kind of thing pops on the news here from time to time, currently the record for memorising Pi is...

http://pi-world-ranking-list.com/lists/memo/index.html

:shock:
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

It's amazing what useless information the brain is capable of remembering and what important stuff it tends to forget! :lol:

67890 digits of PI, no problem..... the shopping that the misses sent me out to get.. hmm, nope, can't remember.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

:lol:

And of course, you can't just dump your brain to disk, to prove you can do it you have to sit there for hours and say it while someone checks.

at 2 numbers per second this would take 9 hours. :shock:
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

24 hours and 4 minutes according to the link on that page, can you imagine the state that guy would have been in at the end of that, probably still rattling off numbers in his sleep. :lol:
michaeled314
Enthusiast
Enthusiast
Posts: 340
Joined: Tue Apr 24, 2007 11:14 pm

Post by michaeled314 »

This will move to the off topic section post memorizing pi
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Especially since your first post is gone :D
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post by dobro »

hum structure no found
"GLOBAL_POWER_POLICY"
:shock:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

dobro wrote:hum structure no found
"GLOBAL_POWER_POLICY"
:shock:
Have a look at this post : http://www.purebasic.fr/english/viewtopic.php?t=25132
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Post by Arctic Fox »

You can find the structure here
http://www.purebasic.fr/english/viewtop ... 306#175306

Too slow :lol:
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

what is this... :shock: a zombie ritual?

or why exhuming an almost two years buried thread...
oh... and have a nice day.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post by dobro »

thanks :)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post by dobro »

Kaeru Gaman wrote:what is this... :shock: a zombie ritual?
si on te le demande, tu dira que t'en sais rien
or why exhuming an almost two years buried thread...
c'est ptete parceque j'ai besoin de ce code, t'y avais pas pensé ? .... m'étonne pas ...

t'ira snober quelqu'un d'autre la prochaine fois .... merci :)

je te parle dans ma langue , parceque je ne connais pas l'anglais,
et qu'il m'est plus facile de te moucher comme ça :D
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Post Reply