[UTILITY] Battery calibration tools - Nexus One Android Development

This thread is for those following the battery calibration thread that would like to help build tools to read and set some advanced battery values, and ultimately recalibrate in learning mode.
It takes its inspiration from this forum thread over at precentral :
http://forums.precentral.net/palm-pre/256967-find-out-how-good-bad-your-battery.html
See HOW-TO in post 3 below, or in-thread post from mtw4991, for instructions on using app to calibrate

reference material
battery manufacturer technical info
DS2784 data sheet - http://datasheets.maxim-ic.com/en/ds/DS2784.pdf
Storing Fuel Gauge Parameters in the DS2784 - http://pdfserv.maxim-ic.com/en/an/AN4043.pdf
Lithium-Ion Cell Fuel Gauging with Maxim Battery Monitor ICs - http://pdfserv.maxim-ic.com/en/an/AN131.pdf
code
cyanogenmod github repository / kanged HTC code - http://github.com/CyanogenMod/cm-kernel/blob/android-msm-2.6.34/drivers/power/ds2784_battery.c
HTC Desire - http://developer.htc.com/ (use HTC Desire kernel source code download)
edit 2010/11/17: source code for battery driver mods - http://github.com/thelogin/n1batcal/
edit 2010/12/15: source code for app -
app availability
available from the Android Marketplace
link: https://market.android.com/details?id=net.jonrichards.batterycalibrator.ui (thanks, McFroger3!)
reference info
thread at precentral which was the inspiration for this thread - http://forums.precentral.net/palm-pre/256967-find-out-how-good-bad-your-battery.html
spreadsheet of registers - https://spreadsheets.google.com/ccc...VNzdXpqWVdFejNGM1pLWmc&hl=en&authkey=CJ_ItagO
related apps
Dr. Battery on the Pre - http://discussion.treocentral.com/homebrew-apps/260947-dr-battery.html
specific code references
(with reference to the manufacturer battery info above)
1 - CONTROL REGISTER FORMAT - page 12 - UVEN—Undervoltage Enable
1 - CAPACITY ESTIMATION ALGORITHM - page 21 - Figure 3: Top-Level Algorithm Diagram
1 - page 24
from Active Empty Voltage (VAE) - includes Aging Capacity (AC) and Age Scalar (AS)
CAPACITY ESTIMATION OPERATION - Learn Function ("A continuous charge from empty to full results in a learn cycle." then "First, the active empty point must be detected."!!)
1 - page 25 - STATUS REGISTER FORMAT
(to be completed)
with thanks to RogerPodacter for his help in compiling this list

progress status and useable findings
status
we have made mods to the kernel code (based on 2.6.35.x) to
make any register writable
make the following registers readable: AGE, Vae (ACTIVE_EMPTY_VOLT), and Status Reg (STS)
allow read/write of these registers via virtual files
remove pseudo-extended battery charging
edit 2010/11/17: created a "dumpreg" file to show all registers and their current values
edit 2010/11/17:
work is being done on a GUI app with the following initial functionality:
show when learn mode is hit
save age when learn mode is complete
the following functionality may be in:
option to restore age when app launched
HOW-TO
mtw4991 said:
How to calibrate your battery using the Battery Calibrator App....
(original text: http://forum.xda-developers.com/showpost.php?p=9583271&postcount=340)
1. Use the battery calibrator app v.1.3.0 to do the following:
a. Open the app and go to menu>settings and check all boxes. Auto-on airplane mode is optional
b. set your age to 100 using the battery app under the Learn Prep tab and press Save
c. set your full40 to 1452mAh in the same tab if using the stock capacity OEM battery and press Save
NOTE: set your full40 to 1650mAh or higher if using an aftermarket battery and save
2. In the Learn Prep tab:
a. set your aEvolts to 3201 (type on each line: Register:0x 66 Value: a4 and press save)
b. set your stop charging current to <20mA (Register:0x 65 Value: 06 and press save)
c. if Capacity/mAh drops to near empty prior to 3201mV being reached, the app will automatically raise capacity by 200mAh so phone doesn't auto-shutdown prior to reaching 3201mV
3. Achieving Learn Mode with the app:
a. turn learn mode on in Learn Mode tab
NOTE: to hit learn mode you must keep your current mA above -200mA draw at the empty point! The app will automatically enable GPS polling to keep you above the required minimum current draw.
b. wait for mV to drop to 3201mV (the learn mode pop-up box will appear & learnf button will light up)
c. insert charger IMMEDIATELY! (You will see a pop-up message saying Learn Mode is active.)
d. turn off and close any open apps you have running, but leave Battery Calibrator open.
e. put phone into airplane mode so that you don’t get unexpected current draw near the full point.
f. set SetCPU profile to disable overclocking. (set min/max to the same value, ie. 998\998max)
g. charge for a full 4 hrs with stock battery and screen off, 5 hrs for larger capacity batterys.
NOTE: if you want to, you can actually use your phone until the charge reaches 80-90%, then use airplane mode and DO NOT touch the phone, peek, turn on the screen....DO NOTHING but walk away til time is up.
h. unplug and reboot, your new age should be set automatically. Learn is now complete and your phone should now charge to 100% and die at 0-1%. Also, some have reported having to manually power down/power up with the new app to have age reset by the application. If age isn’t change upon reboot, try power off/power on.
4. Learn Failure:
If your new age shows 94% upon rebooting, then learn mode failed and you need to do it again, paying close attention as charging nears 80% and above. This is where learn mode can be lost by rogue apps, auto-updates, calls, etc pulling the current down below the minimum prematurely.
Note1: As current gets close to <50-60mA don't touch the phone or you may artifically increase the current draw pulling it below 20mA and it will end the learn cycle prematurely. Airplane mode helps prevent that.
Note2: Learn mode cannot be achieve with the phone off. Leave the phone on until learn is complete and the battery status register shows 0x81. Done!
How to perform a Capacity Test for your battery. Credit goes to the infamous Temasek!
Prepare for another learn cycle
This time we will do what I call a capacity test.
Perform another learn cycle.
Once cycle completed do not reboot. Check your battery log using an app like OS Monitor. See your highest achieved capacity at 99-100% before it completed its charge. The capacity should drop below your full40. Read the log properly. The highest achieved capacity before it drop below your full40 will be your new full40 value.
With your new full40 value, perform yet another learn cycle.
Enjoy your new calibrated battery!
Click to expand...
Click to collapse
HOW-TO2:
http://forum.xda-developers.com/showpost.php?p=24599586&postcount=284 (as requested by St4hli)

Initial investigation and analysis
OK, so I'm going to try and use the following repositories in github and in this order:
AOSP > pershoot > CyanogenMod > others
as I'd like it as generic as possible and ideally integrate any patches at the highest level.
Not being an expert in github, you'll have to excuse any obvious noobness! I couldn't see any of the 2784 battery stuff in AOSP so I'm guessing the CM team used the Desire kernel source from developer.htc.com to integrate the files. Actual code here:
http://member.america.htc.com/download/RomCode/Source_and_Binaries/bravo_54b7033a.tar.gz
------
At:
http://github.com/CyanogenMod/cm-kernel/blob/android-msm-2.6.34/drivers/power/ds2784_battery.c
we see device info struct as:
Code:
char raw[DS2784_DATA_SIZE]; /* raw DS2784 data */
struct battery_status status;
struct power_supply bat;
struct workqueue_struct *monitor_wqueue;
struct work_struct monitor_work;
struct alarm alarm;
struct wake_lock work_wake_lock;
with battery_status struct as:
Code:
u8 percentage; /* battery percentage */
u8 charge_source;
u8 status_reg;
u8 battery_full; /* battery full (don't charge) */
i.e. not many properties.
However, from the corresponding include file at:
http://github.com/CyanogenMod/cm-kernel/blob/android-msm-2.6.34/drivers/power/w1_ds2784.h
there are lots of defined registers, including several AGE and FULL_40.
Our 2784 code has both read and write functions (w1_ds2784_read/write), which are used in function ds2784_battery_read_status.
** Objective 1**
title:
to read some additional values such as AGE and FULL_40 and output them.
suggested implementation:
add in some other properties corresponding to AGE and FULL_40 values, populate these in the read function, parse them in the parse_data function, then output them at line 325 of the ds2784_battery.c file. Yes there will be lots of repetition, but the code is easily and quick to modify.
ideal implementation:
write a new app that outputs these but also outputs the status_reg value too. We can then use this to determine if and when our batteries go into "learning" mode. More below.
code-level:
1) modify struct battery_status, adding:
Code:
u16 age;
u16 full_40;
etc, with any other interesting ones too. Might as well grab all of them and output so we can hand-pick the ones that are useful.
2) from line 244 in parse_data, add something like:
Code:
s->age = raw[DS2784_REG_AGE_SCALAR];
etc
may have to convert from hex.
*****************
THEN I opened the HTC ds2784_battery.c and was amazed at what I saw!
*****************
*their* battery_info struct contains:
Code:
u8 level; /* formula */
u8 level_last;
u32 full_bat; /* Full capacity of battery (mAh) */
u32 full_level; /* Full level for battery control */
u8 guage_status_reg;/* guage status*/
u32 acr;
u32 active_empty;
their ds2784_device_info struct:
Code:
int guage_status_reg; /* battery status register offset=01h*/
int full_mah; /* battery full mah */
long full_charge_count; /* Full charge counter */
int acr;
int active_empty;
int full_level; /* Full level for battery control */
OK nothing earthshattering so far, BUT their Calculate_Full_mAh function uses the FULL_40 stuff.
** Objective 2 **
title: write values to registers
implementation: to be discussed once we have the values from Objective 1 and we still need it (i.e. learning mode does not exist or work to recalibrate).
Wrap-up:
The HTC charging code (from line 854) uses the following logic:
Code:
percent < 95, batt full = false
if status_reg = full and current <= 80 and percent = 100
then *IF IT HAS BEEN ONE HOUR OR MORE ON FULL CHARGE*!!!
then stop charging
WOW.

Nice thread. I'll give you a hand with this. Do you still need help getting your kernel compiling set up?

dvgrhl said:
Nice thread. I'll give you a hand with this. Do you still need help getting your kernel compiling set up?
Click to expand...
Click to collapse
yeah - how best to do this? what about gtalk? <mylogin>@gmail.com if you are OK with that. Will be online in two mins

loginwithnoname, very nice summary and overview. the HTC driver is what most interests me. i guess there would be zero chance of using the HTC code and logic, since it seems they A) use the better values of full_capacity, etc rather than the nexus "conservative" estimation. and B) theirs looks a little more straight forward than the nexus one.
where did you find the HTC driver? i cant seem to find it.
nice work!

just in case you still interested, here is the AOSP source code that pershoot used. well he used his code, then he posted this link in the other thread and said this is his current source he's using.
EDIT: sorry i meant this link
EDIT2: geez, still was cm code. i'll find it real quick.
finally:
http://android.git.kernel.org/?p=ke...54cfa3b22c61dd50eae;hb=android-msm-2.6.35-wip

RogerPodacter said:
the HTC driver is what most interests me. i guess there would be zero chance of using the HTC code and logic, since it seems they A) use the better values of full_capacity, etc rather than the nexus "conservative" estimation. and B) theirs looks a little more straight forward than the nexus one.
Click to expand...
Click to collapse
I think their code is old-hat given what we've done in the other thread, apart from the fact they wait an hour before deeming the battery "fully charged". I don't think as techies/devs we need that though.
thelogin said:
I couldn't see any of the 2784 battery stuff in AOSP so I'm guessing the CM team used the Desire kernel source from developer.htc.com to integrate the files. Actual code here:
http://member.america.htc.com/downlo...4b7033a.tar.gz
where did you find the HTC driver? i cant seem to find it.
Click to expand...
Click to collapse
Click to expand...
Click to collapse
aw, come on Rog! that'll be http://developer.htc.com then click the download button for HTC Desire kernel source code

theloginwithnoname said:
I think their code is old-hat given what we've done in the other thread, apart from the fact they wait an hour before deeming the battery "fully charged". I don't think as techies/devs we need that though.
aw, come on Rog! that'll be http://developer.htc.com then click the download button for HTC Desire kernel source code
Click to expand...
Click to collapse
ha i found the HTC developer site, and grabbed the 74mb source kernel for the desire, but i'm at my work computer which i have no admin rights to do anything. how could i view that code? i was hoping for online repositories like github.

RogerPodacter said:
i'm at my work computer which i have no admin rights to do anything. how could i view that code? i was hoping for online repositories like github.
Click to expand...
Click to collapse
It's a .tar.gz so you need to unzip it then extract it. If you're on Windows, I'm told WinZip will unzip/extract it for you (I used 7-Zip); if you're on linux, tar -zxvf <file>.tar.gz will do it for you...

i wont clutter up this thread anymore, but winzip was the first thing i tried. its a strange winzip used here though, so its expected.

theloginwithnoname said:
** Objective 1**
title:
to read some additional values such as AGE and FULL_40 and output them.
suggested implementation:
add in some other properties corresponding to AGE and FULL_40 values, populate these in the read function, parse them in the parse_data function, then output them at line 325 of the ds2784_battery.c file. Yes there will be lots of repetition, but the code is easily and quick to modify.
ideal implementation:
write a new app that outputs these but also outputs the status_reg value too. We can then use this to determine if and when our batteries go into "learning" mode. More below.
Click to expand...
Click to collapse
rather than doing it at line 325, wouldnt it make more sense to modify lines 103-118:
PHP:
unsigned n;
mutex_lock(&battery_log_lock);
seq_printf(sf, "timestamp mV mA avg mA uAh dC %% src mode reg full\n");
for (n = battery_log_tail; n != battery_log_head; n = (n + 1) & BATTERY_LOG_MASK) {
struct battery_status *s = battery_log + n;
seq_printf(sf, "%9d %5d %6d %6d %8d %4d %3d %s %s 0x%02x %d\n",
s->timestamp, s->voltage_uV / 1000,
s->current_uA / 1000, s->current_avg_uA / 1000,
s->charge_uAh, s->temp_C,
s->percentage,
battery_source[s->charge_source],
battery_mode[s->charge_mode],
s->status_reg, s->battery_full);
}
mutex_unlock(&battery_log_lock);
return 0;
how easy would it be to just add on to this? i suck bad a code and talk out my arse, barely enough to see what's going on. i dont even know where to come up with
seq_printf(sf, "%9d %5d %6d %6d %8d %4d %3d %s %s 0x%02x %d\n",
which seems like where the actual data is coming from for each parameter being output. cant we just add our get_full40, scalar, etc onto that output string?
theloginwithnoname said:
code-level:
1) modify struct battery_status, adding:
Code:
u16 age;
u16 full_40;
etc, with any other interesting ones too. Might as well grab all of them and output so we can hand-pick the ones that are useful.
2) from line 244 in parse_data, add something like:
Code:
s->age = raw[DS2784_REG_AGE_SCALAR];
etc
may have to convert from hex.
Click to expand...
Click to collapse
I think the parse function is line 320, i dont see anything at line 244. so the parse and then pr_info is what is output when we see our dmesg log? for the simplest and quickest result, i think adding registers to the batt_log i posted up above would be the path of least resistence, no? (ignore if i make no sense, i'm noob with code).
then objective 2 would be writing back to the register...

this driver also talks about read/write the bits, which i dont know if we looked thru this one yet. its definitely part of all this i think.
cm-kernel / drivers / w1 / w1.h
http://github.com/CyanogenMod/cm-kernel/blob/android-msm-2.6.34/drivers/w1/w1.h
at least i hope it is relevant!

theloginwithnoname said:
yeah - how best to do this? what about gtalk? <mylogin>@gmail.com if you are OK with that. Will be online in two mins
Click to expand...
Click to collapse
Sorry man, I had a hell of a day at work and didn't even get on IM at all or check back on this thread. My IM is my name at gmail.com, so tomorrow I will make sure to be online if you want. I am PST. Have you tried following the guide here: http://wiki.cyanogenmod.com/index.p...m_source#Install_development_support_packages? I assume so. Where do you get stuck at?

Definitely looking forward to this
Something like the Desire one would be nice too,
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I've been wanting to check the "health" of my battery like how they do on Thinkpads forever.
It shows values like "Design Capacity" & "Full Charge Capacity" to let you see how much your battery is worn. Sometimes I feel like my battery life issues is not with Cyanogen but with the actual battery itself (bought it 2 months used so i dunno how well the other person treated it, came in box and had all original stuff (sealed) tho no scratches!! ) I was thinking to buy another battery and see but might as well get a Seidio then if that's the case
So in that case, the main battery should be "1400 mAh" battery but maybe it's current charge capacity is only 1000mAh so that's why my talk/usage time is low.

Not sure this helps, but just to spark some thinking i grabbed this from page 25 of the spec sheet for the ds2784.
http://datasheets.maxim-ic.com/en/ds/DS2784.pdf
STATUS REGISTER FORMAT
The status register contains bits that report the device status. All bits are set internally. The CHGTF, AEF, SEF, and LEARNF bits are read only. The UVF and PORF bits can be cleared by writing a zero to the bit locations.
PHP:
ADDRESS 01h
BIT 7 - CHGTF
BIT 6 - AEF
BIT 5 - SEF
BIT 4 - LEARNF
BIT 3 - X
BIT 2 - UVF
BIT 1 - PORF
BIT 0 - X
CHGTF—Charge-Termination Flag. CHGTF is set to indicate that the voltage and average current register values have persisted above the VCHG and below the IMIN thresholds sufficiently long to detect a fully charged condition. CHGTF is cleared when RARC is less than 90%. CHGTF is read only.
AEF—Active-Empty Flag. AEF is set to indicate that the battery is at or below the active-empty point. AEF is set when the voltage register value is less than the VAE threshold. AEF is cleared when RARC is greater than 5%. AEF is read only.
Click to expand...
Click to collapse

good spot Rog - I might need to decompile all the tech info and add it as a technical analysis post here. Will be a few days before I can do this though.

I'll post these links here for completeness, it kinda wraps everything up with examples of everything. You really should read when you have a sec.
http://pdfserv.maxim-ic.com/en/an/AN3584.pdf
http://pdfserv.maxim-ic.com/en/an/AN131.pdf
http://pdfserv.maxim-ic.com/en/an/AN4043.pdf
http://pdfserv.maxim-ic.com/en/an/AN3463.pdf

been looking over the code, and i'm pretty sure for phase #1, step #1, to grab the info we need we'd have to add the following line 51, line 224-226, and line 325 and 331:
we need to define the additional variable:
PHP:
48 int current_avg_uA;
49 int charge_uAh;
51 int full40_uAh /*This variable added*/
We need to parse the additional data (MSB and LSB for full40):
PHP:
221 /* RAAC is in units of 1.6mAh */
222 s->charge_uAh = ((raw[DS2784_REG_RAAC_MSB] << 8) |
223 raw[DS2784_REG_RAAC_LSB]) * 1600;
224 /* full40 has same conversion units of 1.6mAh */
225 s->full40_uAh = ((raw[DS2784_REG_FULL_40_MSB] << 8) |
226 raw[DS2784_REG_FULL_40_LSB]) * 1600;
and finally, simplest way i see it is to just add it to the dmesg log (at least right now, later we can do whatever with it):
PHP:
ds2784_parse_data(di->raw, &di->status);
324
325 pr_info("batt: %3d%%, %d mV, %d mA (%d avg), %d.%d C, %d mAh, %d full40 mAh\n",
326 di->status.percentage,
327 di->status.voltage_uV / 1000, di->status.current_uA / 1000,
328 di->status.current_avg_uA / 1000,
329 di->status.temp_C / 10, di->status.temp_C % 10,
330 di->status.charge_uAh / 1000,
331 di->status.full40_uAh / 1000); /*added this output to dmesg log*/
332 return 0;
333 }
the only thing i am not sure on is the conversion units for full40, i cant find it yet. we could just not convert it at all and end up with a large raw value, but that would mess up the dmesg log readability. for above i just assumed it was the same conversion as charge capacity (very well could be the same).
next i'll attempt the same for age scalar.
besides, there is another way to find the full40 value, its the one that your dmesg log jumps to when you hit full charge, but you have to be at +40 C temperature (that's what full40 is, its the max our battery can hold at 40C since the higher the temp, the more capacity our battery can hold). in my case, my getfull40 is 1369 mAh.
should i post this in the battery thread and see if pershoot would compile a test kernel for me? i'd try this out.
EDIT: i'm almost positive this will work, so i'll see how to add in age scalar before posting it in the other thread for pershoot.

Related

[PROJ] Overclocking the Adreno GPU on Snapdragon Devices

INFO:
Let me save you the time of reading all this. In it's current form, this is impossible. An inside connect at Qualcomm has told us we can't change the GPU clock from userland or kernel. That mean's we're screwed basically. Here is the post by Jack_R1:
Checked, as promised. Bad news. If I sum it up in one sentence - GPU overclock w/o touching the rest of the system is plain impossible, and GPU overclock while trying to play with the whole system is most probably still impossible (pending further deeper check), and it's definitely impossible for anyone that doesn't have the clock diagram, which is NDA, thus won't be available. The reason isn't software, and don't ask, what it is - I won't give direct explanations.
I've written a long post with some explanations of clock networks, to educate those that want to learn and prevent some of big mistakes that I've seen along this thread, and it's pending approval, since I don't want to accidentally spill more than I can share. I hope it gets approved and I'll post it. It should give some more insight.
The only good news is - global overclocking that affects 1GHz CPU clock will affect GPU too.
Click to expand...
Click to collapse
I'm sure we all heard about being able to overclock the GPU on some of the old MSM devices, but the Snapdragon handles the graphics chip in a different way. The goal of this thread is to try and overclock the GPU on Snapdragon devices as well.
There is nothing GPU related in acpuclock-scorpion.c at least for setting clock speed as far as I can tell.
In board-mahimahi.c there is some kgsl init code, but so far as I can tell it isn't setting the clock there, instead it seems to be pointing to PWR_RAIL_GRP_CLK to set the clock. It defines the variable in board-mahimahi.c but I'm not sure where that variable is set, since it doesn't seem to be in any of the other board files as far as I can tell. I could be completely off here too though.
In drivers/video/msm/gpu/kgsl/kgsl.c there is a method called kgsl_clk_enable that seems to be called whenever the GPU is enabled. It looks like this:
Code:
/* the hw and clk enable/disable funcs must be either called from softirq or
* with mutex held */
static void kgsl_clk_enable(void)
{
//clk_set_rate(kgsl_driver.ebi1_clk, 128000000);
clk_set_rate(kgsl_driver.ebi1_clk, 245000000);
clk_enable(kgsl_driver.imem_clk);
clk_enable(kgsl_driver.grp_clk);
}
The line that's been commented out is the original value, I replaced it with my value on the line below it in a failed attempt to overclock it. Probably a stupid effort on my part, I doubt it's that simple, but it was worth a shot.
According to the clk.h files in the standard linux kernel, clk_set_rate is obviously a method to set the clock rate. The first variable is a struct that tells it which clock to set, and the second variable is a long value that is the rate you want it set at. Is it setting the right clock there for Snapdragon chips? Or is it only the clock for older chips? Actually I've looked again, the kgsl files are ONLY for the newer Qualcomm chips, the QSD8x50 Snapdragons & the midrange MSM7x27 series that replaced the old MSM7x00a chips like in the Dream & Magic. At least thats the way it seems to me judging from what Qualcomm & AMD have written in the source.
I'm in way over my head with this source, I'm but a lowly Java dev , but I really wanna solve this. Can anyone with a little more experience than me throw in a little more info? Sorry if it doesn't make much sense, if it isn't clear just ask me & I'll try to explain a little more.
Regards,
Jesse C
EDIT: Okay I did a little more digging and those kgsl settings should work for QSD8x50 chips. In the config file, under Drivers, Graphics Support, it allows you to enable 3D accelleration for QSD8x50 & MSM7x27 chips. The tag for that is CONFIG_MSM_KGSL_MMU. If you check in kgsl.c it checks to see if that is enabled in the config, and if it is then it compiles and uses kgsl.c & all of the kgsl code. That tells me that the clock is either not being set, or the wrong clock is being set. I'm adding some debug code right now so I can see in dmesg what code is actually being run.
EDIT 2: Another status update. Adding the debug code showed that it is setting the clock at my level whenever the kgsl initializes. Also, as IntersectRaven pointed out, clocks.h in arch/arm/mach-msm nicely lays out what each clock is:
Code:
grp_clock = Graphics clock
ebi1_clock = External Bus Interface 1 clock
imem_clock = Internal Graphics Memory clock
If you want to add your own debug code to it, calling the method "pr_info" and passing it a string with the message you want will output it to the kernel logs you can view with dmesg. An example would be "pr_info("kgsl: clock set at 245mhz\n");"
EDIT 3: I now know the values for all the GPU related clocks.
Code:
<6>[ 70.681793] kgsl: grp_clock= 256000000
<6>[ 70.682464] kgsl: imem_clock= 256000000
<6>[ 70.683441] kgsl: ebi1_clock= 128000000
If you want to get these values yourself, the following code in the kgsl_clk_enable method will output them to the kernel log:
Code:
int clkg = clk_get_rate(kgsl_driver.grp_clk);
int clki = clk_get_rate(kgsl_driver.imem_clk);
int clke = clk_get_rate(kgsl_driver.ebi1_clk);
// this will get the clock rate & print it in the kernel log
pr_info("kgsl: grp_clock = %d", clkg);
pr_info("kgsl: imem_clock = %d", clki);
pr_info("kgsl: ebi1_clock = %d", clke);
Just add that into the function I mentioned and it will output it to the kernel log, quite often in fact, so I wouldn't leave it in there except to see the values
EDIT 4: 7-2-2010
Qualcomm has now released a new driver. It looks a lot better for our purposes. I'm looking through it today but I have other stuff I need to do. I will look at it, but I can't promise I can devote much time to it until at least Sunday.
EDIT 7-7-2010:
I've collaborate with storm99999 over GTalk and things aren't looking good. Here's what it comes down to:
If we try and lock it with any of the clk_set_rate methods, there is no effect. Not matter how we change it, it just stays at the original value. This either means it's set in the radio (impossible for us to change) or that it's set one time on boot and never changes, but we just don't know where it's actually set (more likely, but I'm not sure either way)
If we try and change it with msm_proc_comm, which is a direct interface to the hardware, it causes the kernel not to boot at all. This is really really strange. We can monitor the clock with pr_info as before, and if we read the data1 argument, it prints to the kernel fine, but if we try and read the data2 arg passed to msm_proc_comm, it also freezes on boot.
We seem to be out of ideas here. We're open to any reasonable suggestions, so if you have any, PLEASE let us know in this thread or PM one of us. Or you can email me at [email protected]
This is a great idea for sure. I will certainly lend a hand where I can.
That being said don't know if it is possible to OC the GPU. I remember discussing this with kmobs in the past and he didn't think so. Perhaps tweaking Open GL might prove more fruitful. All of this is definitely worth thinking about.
jlevy73 said:
This is a great idea for sure. I will certainly lend a hand where I can.
That being said don't know if it is possible to OC the GPU. I remember discussing this with kmobs in the past and he didn't think so. Perhaps tweaking Open GL might prove more fruitful. All of this is definitely worth thinking about.
Click to expand...
Click to collapse
Hmm well that may be kind of a downer...
I know it sets the values somewhere, but I can't seem to find anywhere it could be setting them other than the kgsl stuff, and that doesn't have any effect on performance at all. Unless it could be set in hardware?
I don't really care about harming my Nexus at this point, now that I've upgraded to an Evo, so I'm willing to try dangerous kernels on my Nexus (read: any kernel changes I make ).
If someone could give me any more ideas about where to look, I'd be greatful. I've gone through everything I can think of and it doesn't seem to be getting me anywhere closer.
P.S. I love your avatar jlevy! Simpsons FTW!
This is definitely for the kernel masters like Cyanogen, pershoot and kmobs to weigh in on. In the meantime I am going to rip through the code to see what I can find (if anything). To bad you are moving on to the EVO. We'll miss all of the great ideas/solutions you provide (well N1 user will)
jlevy73 said:
This is definitely for the kernel masters like Cyanogen, pershoot and kmobs to weigh in on. In the meantime I am going to rip through the code to see what I can find (if anything). To bad you are moving on to the EVO. We'll miss all of the great ideas/solutions you provide (well N1 user will)
Click to expand...
Click to collapse
Thanks! I'll still be hanging around the N1 forums, since so much of the code is interchangeable with them both having the QSD chips and all. If you're looking through source, can you get with me on GTalk or Wave & we can work together on it. Also I've updated the first post with a little more info.
Geniusdog254 said:
Thanks! I'll still be hanging around the N1 forums, since so much of the code is interchangeable with them both having the QSD chips and all. If you're looking through source, can you get with me on GTalk or Wave & we can work together on it. Also I've updated the first post with a little more info.
Click to expand...
Click to collapse
Sounds good, I will PM you my gtalk address.
So I added the debug code. It shows that it is calling my code every time the GPU is initialized. This means it is setting the EBI1 clock to 245mhz instead of the original 128mhz. However I guess that is the wrong clock. it also defines 2 other clocks along with the EBI1 clock, however EBI1 is the only one that it sets a value for, the other 2 it just turns on (hardware values?).
After looking at the code, the clocks seem to be initialized at kgsl_platform_probe by clk_get. (correct me if I'm wrong since I'm a newbie at tracing through the GPU... )
*Nope...wrong analysis...that was the clock SOURCE instead of clock RATE...
**After looking through a bigger part of everything, I think you can't specifically overclock it. The way I see it, the clock source used by kgsl is unified with different clocks being set elsewhere. This is why you're not getting it to work. When it calls the kgsl part you modified, it sets to the modified clock BUT the moment it exits, some other part which uses the same clock source will reset it to 128Mhz. If you want to modify that, you'll pretty much have to modify everything which uses the same clock source. (again, correct me if I'm wrong but I think that pretty much describes what I'm seeing with the code...)
Geniusdog254 said:
So I added the debug code. It shows that it is calling my code every time the GPU is initialized. This means it is setting the EBI1 clock to 245mhz instead of the original 128mhz. However I guess that is the wrong clock. it also defines 2 other clocks along with the EBI1 clock, however EBI1 is the only one that it sets a value for, the other 2 it just turns on (hardware values?).
Click to expand...
Click to collapse
Yeah, I think the other two value are hardware related. To find the right clock...
intersectRaven said:
After looking at the code, the clocks seem to be initialized at kgsl_platform_probe by clk_get. (correct me if I'm wrong since I'm a newbie at tracing through the GPU... )
*Nope...wrong analysis...that was the clock SOURCE instead of clock RATE...
**After looking through a bigger part of everything, I think you can't specifically overclock it. The way I see it, the clock source used by kgsl is unified with different clocks being set elsewhere. This is why you're not getting it to work. When it calls the kgsl part you modified, it sets to the modified clock BUT the moment it exits, some other part which uses the same clock source will reset it to 128Mhz. If you want to modify that, you'll pretty much have to modify everything which uses the same clock source. (again, correct me if I'm wrong but I think that pretty much describes what I'm seeing with the code...)
Click to expand...
Click to collapse
I think you are reading it correctly and that one would have to manipulate all the other values to ensure it won't reset to 128mhz. However, even if you do modify all that, there could be a master over-ride that controls the clock set at a pre-set value.
One interesting thing I did come across is one can write their own Open GL code. http://android-developers.blogspot.com/search/label/OpenGL ES
So if one could manipulate the values for Open GL, it would almost be equivalent to OC the GPU. Just a thought.
jlevy73 said:
Yeah, I think the other two value are hardware related. To find the right clock...
Click to expand...
Click to collapse
I know for sure 2 of the 3 are set in the kernel. The EBI1 clock of course is the one I'm trying to modify now, it has no effect. Then there is the "imem" clock which I haven't seen any code to set it, and then there is the "grp" clock.
If you see my first post, in board-mahimahi.c it defines PWR_RAIL_GRP_CLK which is the GRP clock. It is set at 8 as I just discovered. Here is that code:
Code:
#define PWR_RAIL_GRP_CLK 8
static int mahimahi_kgsl_power_rail_mode(int follow_clk)
{
int mode = follow_clk ? 0 : 1;
int rail_id = PWR_RAIL_GRP_CLK;
return msm_proc_comm(PCOM_CLKCTL_RPC_RAIL_CONTROL, &rail_id, &mode);
}
The only thing that leaves is the imem clock which may be a memory clock? I haven't found it set anywhere, but it could be in the kgsl_sharedmem.c & .h files. I haven't checked there yet. That covers 2 of the 3 clocks. I don't know what the 8 value on the grp clock means, or even what the grp clock is. But so far, those 2 are for sure set in the kernel...
I forget his username, but maybe the guy who got use all the mem hacks would be of great service? I think it's c00l something
Who got us* damnit I hate these typos. I'm going to bed. Too tired, and tapatalk has no flipping edit button lol
dictionary said:
I forget his username, but maybe the guy who got use all the mem hacks would be of great service? I think it's c00l something
Click to expand...
Click to collapse
Coolbho3000. He posted in the original thread or the MSM7500 chip about how it was handled differently on Snapdragon chips and that we may be able to change it, but that's all he said.
Yup him. I see. I'll have my bro look over this and see if he can find anything relevant, or help in any way
I'm not so advanced with my dev
Geniusdog254 said:
I know for sure 2 of the 3 are set in the kernel. The EBI1 clock of course is the one I'm trying to modify now, it has no effect. Then there is the "imem" clock which I haven't seen any code to set it, and then there is the "grp" clock.
If you see my first post, in board-mahimahi.c it defines PWR_RAIL_GRP_CLK which is the GRP clock. It is set at 8 as I just discovered. Here is that code:
Code:
#define PWR_RAIL_GRP_CLK 8
static int mahimahi_kgsl_power_rail_mode(int follow_clk)
{
int mode = follow_clk ? 0 : 1;
int rail_id = PWR_RAIL_GRP_CLK;
return msm_proc_comm(PCOM_CLKCTL_RPC_RAIL_CONTROL, &rail_id, &mode);
}
The only thing that leaves is the imem clock which may be a memory clock? I haven't found it set anywhere, but it could be in the kgsl_sharedmem.c & .h files. I haven't checked there yet. That covers 2 of the 3 clocks. I don't know what the 8 value on the grp clock means, or even what the grp clock is. But so far, those 2 are for sure set in the kernel...
Click to expand...
Click to collapse
According to clock.h, imem_clk is the clock source for the internal graphics memory so that seems right.
intersectRaven said:
According to clock.h, imem_clk is the clock source for the internal graphics memory so that seems right.
Click to expand...
Click to collapse
Hey look at that! It just nicely lays out what all those clocks are!
grp_clock = Graphics clock
ebi1_clock = External Bus Interface 1 clock
imem_clock = Internal Graphics Memory clock
Not sure what the ebi1_clock is linked to, but kgsl sure sees it as important enough to set it every time it runs. It's the only one set in a recognizable format (hz).
I'm not sure where the imem_clock is set or if it even is. Intersect, did you happen to see it set anywhere? It may be important to change though, it would allow more memory throughput and we could increase the graphic memory size in the board file and that may boost performance.
The grp_clock seems to be actually the real GPU clock according to clock.h. It's set 8 in board-mahimahi.c but I'm not sure what the 8 means. But then it may be that PWR_RAIL_GRP_CLK is setting a voltage or other power level to the graphics bus? Maybe the clock is set somewhere else. That'll take some more digging.
Geniusdog254 said:
Hey look at that! It just nicely lays out what all those clocks are!
grp_clock = Graphics clock
ebi1_clock = External Bus Interface 1 clock
imem_clock = Internal Graphics Memory clock
Not sure what the ebi1_clock is linked to, but kgsl sure sees it as important enough to set it every time it runs. It's the only one set in a recognizable format (hz).
I'm not sure where the imem_clock is set or if it even is. Intersect, did you happen to see it set anywhere? It may be important to change though, it would allow more memory throughput and we could increase the graphic memory size in the board file and that may boost performance.
The grp_clock sleeps to be actually the real GPU clock according to clock.h. It's set 8 in board-mahimahi.c but I'm not sure what the 8 means. But then it may be that PWR_RAIL_GRP_CLK is setting a voltage or other power level to the graphics bus? Maybe the clock is set somewhere else. That'll take some more digging.
Click to expand...
Click to collapse
The EBI clock is the external bus interface clock so I don't think we should mess with it. Anyways, it's set I think to ensure that it's working when the GPU is rendering something. If you'll look at the things that set it, it's usually set to 0 when entering suspend or sleep. Anyways, the variables in clock.h are used as sort of pointers to where the system will actually try to set the clock. (from what I can read at least) As for the imem_clk, I didn't find it set anywhere so it may be that it's on the radio or hardcoded. As for the graphics memory size, I think coolbho3k already knows more about resizing it since he's studied the N1's memory layout in further detail. (he did create that mod which increased the size of the available memory AND also figured out how to get charansingh's camera more memory) Anyways, I'll take a look further.
Interesting, but can we activate hardware acceleration in the device? i think if you can think of a way to do that you will be able to overclock the GPU just like on a PC and easily access the clocking just like the CPU.
I'm no expert on overclocking Phones only PC's.
intersectRaven said:
The EBI clock is the external bus interface clock so I don't think we should mess with it. Anyways, it's set I think to ensure that it's working when the GPU is rendering something. If you'll look at the things that set it, it's usually set to 0 when entering suspend or sleep. Anyways, the variables in clock.h are used as sort of pointers to where the system will actually try to set the clock. (from what I can read at least) As for the imem_clk, I didn't find it set anywhere so it may be that it's on the radio or hardcoded. As for the graphics memory size, I think coolbho3k already knows more about resizing it since he's studied the N1's memory layout in further detail. (he did create that mod which increased the size of the available memory AND also figured out how to get charansingh's camera more memory) Anyways, I'll take a look further.
Click to expand...
Click to collapse
I just woke back up. I guess I will remove the EBI1 overclock since I'm not sure what it does. I'm also not sure what increasing the GPU memory will do, but it's worth a shot.
I had noticed EBI1 is being set to 0 whenever it's diabled, and then setting it back at the time it's enabled. I'm gunna go back through and try to find another setting for the grp clock & a setting for the imem clock.

[APP][22 Feb 2011] Mwunderground - Weather Underground application for Windows Mobile

Hi,
This is my first real Windows Mobile application.
Website:
Mwunderground on SourceForge
Description:
This is a weather application. It uses data from Weather Underground to show current weather conditions, forecast and weather alerts.
Features:
- Weather Underground data for Current Conditions, Forecast, Radar and Alerts
- Can use Personal Weather Station (PWS) as well as Airport station data
- Tower and GPS location
- Working version for VGA, WVGA, WQVGA, QVGA phones
- Sense Look and Feel for settings (thanks to SenseSDK)
- Free and Open-Source (developer contributions encouraged)
- S2U2 support with wildcards (see 2nd post)
License:
LGPL
Tested on:
HTC Raphael (Touch Pro, Fuze)
Screenshots:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
TODO/Known Issues:
- Show All Data (to show both metric and standard units)
- Language Support
- CHT weather support
- Multiple Locations
- Color customizations
- More optimizations (especially xml parsing)
- Port to Android and maybe Windows Phone 7
- Others (suggestions welcome)?
Changelog:
v0.4: Added radar for US Cities (landscape mode using internal browser), customizable in registry (see 2nd post). Moved Settings button on top next to newly added Exit button. Displaying 5 days of forecast instead of 6 with slightly bigger text. Improved QVGA/WVGA support (bigger buttons for WVGA, fixed missing text for QVGA/WQVGA). Many bug fixes (value checking in forecast, GPS thread termination, station re-searching, duplicate location station search). Removed Exit button from Settings as now there is a main Exit button on top right.
v0.3: More error checking (locations and stations). Better resource management on exit. Moved Tower and GPS finding to a timed thread (timer is customizable in registry, see 2nd post). Fixed small bug with showing high and lows of today's rather than tomorrow's forecast. S2U2 support with wildcards in registry (see 2nd post). Better support for browser link (when clicking on logo). Changed chance of rain to chance of precipitation (moved some things around). Enabled stations picking when using GPS.
v0.2.3: Better error handling (more messages, more checks). Faster connection checking. Some Bug fixes (alerts on startup, lows and humidity on non-metric).
v0.2.2: Better error messages. Connection checking. Some GPS fixes. Exit button added on Settings.
v0.2.1: Fixed a bug with startup registry keys
v0.2: Added support for QVGA and WVGA devices
v0.1: Initial release
[size=+1]Download (cab):[/size]
v0.4
v0.3
v0.2.3
v0.2.2
v0.2.1
v0.2
v0.1
Latest Build (cab):
Here. Click download on latest revision.
Credits:
Weather Underground, Inc. (permission to use data)
eboelzner (SenseSDK)
OpenNetCF (Smart Device Framework - Community Edition)
Acoustic (at CodeProject, author of DeepCast)
Any feedback/suggestions very much appreciated.
Reserved
Hints:
- To update the data, either click on the button that is highlighted (i.e. if you are viewing Current data, click on the Current button again to update, etc.), or go to Settings and click Save Settings.
- For using GPS Location, when you enable the option on the settings, it will first try to find your location based on tower information (i.e. you cell provider towers). This does not block the system. Mine takes about 2-3 seconds. If it finds your location, it will show something like: Approx. Location: 37.861111,23.759126. Regardless of finding an approx location, the app will continue on to find your GPS location, based on your GPS receiver. This could take a while but it also does not block the system. Mine (with latest quick gps data) takes another 2-3 seconds. If it finds a GPS location, it will show something like: GPS Location: 37.861123,23.759145. GPS location obviously overwrites Approx Location. You could wait or save settings and come back to settings again later to check if the GPS location is found, at which point you can do save settings again to update with your exact location weather data. By default the app takes 60 seconds to look for a tower location and a GPS position. You can change the timeout in the registry (see Customizations).
Customizations:
Most of the settings data are stored in the registry key (HKCU) HKEY_CURRENT_USER\Software\Mwunderground. You can use Total Commander or Registry Editor to modify these values. Only do so if you know what you are doing. If something is broken, just reinstall the cab (which uninstalls first and clears the registry).
Radar Customization
To modify the Radar, you can edit the registry key HKEY_CURRENT_USER\Software\Mwunderground\RadarURL. The current value is:
Code:
http://radblast-mi.wunderground.com/cgi-bin/radar/WUNIDS_map?station=*RADARID*&brand=manmade&num=6&delay=50&type=N0R&frame=0&scale=1.000&noclutter=0&t=1297546449&lat=*LAT*&lon=*LON*&label=you&showstorms=10&map.x=400&map.y=240&centerx=400&centery=240&transx=0&transy=0&showlabels=1&severe=1&rainsnow=0&lightning=0&smooth=1
The *RADARID* will be replaced in the application by the proper RadarId based on your location, *LAT* and *LON*, Latitude and Longitude, which are replaced by the station's Latitude and Longitude location. You can modify the remainder of the values. For example, to change the speed of the animation, modify delay=50, to delay=75 (will slow it down by 25%), or to not show labels, set showlabels=1 to showlabels=0.
Tower and GPS connection timeout
To modify the Tower and GPS connection timeout, you can edit the registry key HKEY_CURRENT_USER\Software\Mwunderground\GPSTimer to the number of seconds you'd like. Default is 60.
SU2U Wildcards
To modify the S2U2 format, you can edit the registry key HKEY_CURRENT_USER\Software\Mwunderground\S2U2Format.
Code:
Possible S2U2 formats:
ICONS=S, P, W, C
If icon is S, P, W, format is for example: S|*NUMBER*|High|Low
If icon is C, format is: C|*NUMBER*|MESSAGE
*NUMBER* will be replaced by the appropriate icon number based on the ORIGINAL S2U2 icon numbers
Weather Underground icon to S2U2 icon matching:
clear=32(Day)/31(Night), cloudy=26/27, flurries=13, fog=20, hazy=21, mostlycloudy=28/27,
mostlysunny=30/29, partlycloudy=30/29, partlysunny=28/27, rain=12/45, sleet=7,
snow=16/46, sunny=32/31, tstorms=3/47, unknown=0
MESSAGE= can be anything and you can use the following wildcards
*TEMP_C* is replaced by the current temperature in C
*TEMP_F* is replaced by the current temperature in F
*TEMP* is replaced by the current temperature based on your selection in settings (will append °C or °F)
*HIGH_C* is replaced by High temperature in C
*LOW_C* is replaced by Low temperature in C
*HIGH* is replaced by High temperature with units based on your selection in settings (will append °C or °F)
*LOW* is replaced by Low temperature with units based on your selection in settings(will append °C or °F)
*DAY_0_HIGH_C* is replaced by High temperature in C for day 0 (today) of forecast (same as *HIGH_C*)
*DAY_0_LOW_C* is replaced by Low temperature in C for day 0 (today) of forecast (same as *LOW_C*)
*DAY_1_HIGH_C* is replaced by High temperature in C for day 1 (tomorrow) of forecast
...
*DAY_5_LOW_C* is replaced by Low temperature in C for day 5 of forecast
*DAY_0_HIGH* is replaced by High temperature with units based on your selection in settings for day 0 (today) of forecast (same as *HIGH*) (will append °C or °F)
*DAY_0_LOW* is replaced by Low temperature with units based on your selection in settings for day 0 (today) of forecast (same as *LOW*) (will append °C or °F)
*HIGH_F* ...
*LOW_F* ...
*DAY_0_HIGH_F* is replaced by High temperature in F for day 0 (today) of forecast (same as *HIGH_F*)
*DAY_0_LOW_F* is replaced by Low temperature in F for day 0 (today) of forecast (same as *LOW_F*)
...
*DAY_5_LOW_F* is replaced by Low temperature in F for day 5 of forecast
*DAY_5_LOW* is replaced by Low temperature with units based on your selection in settings for day 5 of forecast (will append °C or °F)
*WEATHER* is replaced by the weather message (i.e. Clear, Heavy Thunderstorms and Snow, etc.)
*WEATHER_ICON* is replaced by the text for the weather icon (i.e. clear, mostlycloudy, etc.)
EXAMPLES=
C|*NUMBER*|*HIGH*/*LOW*
will display the icon with 12°C/6°C underneath (default)
C|*NUMBER*|*HIGH_C*°C/*LOW_C*°C
will display the icon with 12°C/6°C underneath
C|*NUMBER*|H:*HIGH_F*°F/L:*LOW_F*°F
will display the icon with H:65°F / L:45°F underneath
C|*NUMBER*|*WEATHER* (*HIGH_F*°F/*LOW_F*°F)
will display the icon with Clear (65°F/45°F) underneath
C|*NUMBER*|*DAY_0_HIGH_C*°C/*DAY_0_LOW_C*°C - *DAY_1_HIGH_C*°C/*DAY_1_LOW_C*°C - *DAY_2_HIGH_C*°C/*DAY_2_LOW_C*°C
will display the icon with 65°F/45°F - 75°F/55°F - 85°F/65°F underneath
Go crazy!
No QVGA support?
glaucos said:
No QVGA support?
Click to expand...
Click to collapse
Once I get in the mode of changing things for WVGA, it'll probably not be too hard to make a QVGA one as well.
very nice interface... will give it a shot
i_konst said:
Once I get in the mode of changing things for WVGA, it'll probably not be too hard to make a QVGA one as well.
Click to expand...
Click to collapse
QVGA support added.
Just grab the v0.2 cab.
doesnt work on my fuze
tried both cab files
after install i soft reset and try to run program but it crashes
before it even starts
Kameirus said:
doesnt work on my fuze
tried both cab files
after install i soft reset and try to run program but it crashes
before it even starts
Click to expand...
Click to collapse
Strange. Does it give you any errors? Data plan/wifi working? .NET framework 3.5 installed? I'll do more investigating tomorrow based on your ROM.
Wow, I love munder weather...thanks bro, will give this a whirl...
Won't work on my Topaz (WVGA). Not sure if its the screen size not being supported or something else. .Net 3.5 is installed and i tried both CABs and same result.
A screenshot of the message I'm getting. thanks for the effort tho- I look foward to this program!
It looks really interersting application!
I would love to have it in other languages too (e.g. Greek )
Kameirus said:
doesnt work on my fuze
tried both cab files
after install i soft reset and try to run program but it crashes
before it even starts
Click to expand...
Click to collapse
Bug fixed. Should work fine now. Sorry for the mishap.
ottoman96 said:
Won't work on my Topaz (WVGA). Not sure if its the screen size not being supported or something else. .Net 3.5 is installed and i tried both CABs and same result.
View attachment 496711
A screenshot of the message I'm getting. thanks for the effort tho- I look foward to this program!
Click to expand...
Click to collapse
Thanks for the image and everything.
Bug fixed. Should work fine now. Sorry for the mishap.
Get latest version of course.
i_konst said:
Bug fixed. Should work fine now. Sorry for the mishap.
Click to expand...
Click to collapse
that did it works great
thanks
a couple suggestions
1. have a close button ...as now i have to close it thru task manager
2. have the option to manuel update and auto update and maybe an update button
i_konst said:
Once I get in the mode of changing things for WVGA, it'll probably not be too hard to make a QVGA one as well.
Click to expand...
Click to collapse
i_konst said:
QVGA support added.
Just grab the v0.2 cab.
Click to expand...
Click to collapse
Thanx, I'll test it in the next days
hi you all. first, big thanks for this software. it's amazing, I was hesitating to buy this of ageye, but as I've found yours...
just to say that it's working very very good on my i900, winmo 6.1 swiss-french rom, installed on besides memory (Ma mémoire), screen res 240x400.
Only the texts are pretty small in forecast, but... PERFECT !
a simple big Thanks !!
works fine on my fuze
Kameirus said:
a couple suggestions
1. have a close button ...as now i have to close it thru task manager
2. have the option to manuel update and auto update and maybe an update button
Click to expand...
Click to collapse
Thanks a lot for the suggestions!
1. Added on version 0.2.2. Thanks for the suggestion.
2. For manual update, check the 2nd post. I posted a hint. For automatic updates, this is a much bigger task because querying for xml data in windows mobile is quite slow. When I work on optimizing the xml parsing code (3rd iteration!) I'll look at how feasible this is. But it's a big task.
Got this error when changing the settings:
Mwunderground.exe
NullReferenceException
bij Mwunderground.MainForm.FillForecastData(ForecastData forecastData, CurrentData currentData, SettingsData settingsData)
bij Mwunderground.MainForm.RetrieveAndFillData()
bij Mwunderground.MainForm.itmSave_OnClick(Object Sender)
bij StedySoft.SenseSDK.SensePanelButtonItem._notifyClick()
bij StedySoft.SenseSDK.SensePanelButtonItem.OnMouseUp(Int32 x, Int32 y)
bij StedySoft.SenseSDK.SenseListControl.OnMouseUp(MouseEventArgs e)
bij System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
bij System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
bij Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
bij System.Windows.Forms.Application.Run(Form fm)
bij Mwunderground.Program.Main()
This error occured after I changed the current location. Now I can not restart the app. I get the same error message every time I restart the app. I can not even get into the start screen.
How can I fix this, besides a reinstall of the cab file?
Another idea I would like to see is support for the CHT 2.0 weather widget.
Can also weather stations from other countries be used. I keep getting a list from Greece.
Post-edit:
I think I have found the issue. I keep getting an error message when changing the weather location based on search option for cell towers/gps option. Somehow this function is causing the app to work incorrectly, perhaps due to interference with the option of a manual search of the location search. The error occurs only after I save the settings. Can you see if this can be fixed?

Battery Gauge enhancements

Here is an enhanced version of the battery gauge driver. It will likely work with all kernels. A couple of bugs have been fixed and new sysfs properties have been added. These changes are in large part based on enhancements of the Ubuntu battery gauge driver for the original Nexus 7.
The following new properties are added to '/sys/class/power_supply/battery/':
charge_now: remaining battery charge in uAh; compensated for load current/temperature (higher load current = lower usable capacity)
charge_avg: remaining battery charge in uAh; uncompensated
charge_full: charge in uAh, when battery is fully charged (as determined by battery gauge -> will go down as the battery ages)
charge_full_design: design value of battery charge (the capacity a new battery is supposed to have)
energy_now: remaining battery charge/energy in uWh; compensated for load current/temperature
charge_counter (signed value): coulomb meter measuring amount of charge that has flowed into or out of the battery; periodically set to 0, when battery has minimal load (e.g. on USB power and fully charged or during deep sleep)
power_now (signed value): amount of power flowing into or out of battery in uW (updated by the gauge every second); useful to see how fast/with how much power the battery is being charged
cycle_count: battery charge cycle count; around 4000mAh worth of charging correspond to a full cycle (e.g. when the battery is charged 50% = 2000mAh two times, you get a full cycle)
Reading the sysfs properties results in the battery gauge driver requesting the current value via I2C from the battery gauge. AFAIK, the I2C transaction uses software I2C and will block the CPU for a few dozen micro seconds.
A public datasheet for the battery gauge exists:
http://www.ti.com/lit/ds/symlink/bq27541.pdf
Disclaimer: The changes are not extensively tested and missing locking has been added to the driver (previously, concurrent requests via sysfs could result in wrong values) - there may be deadlocks lurking. The driver plays a role in controlling the battery charger, use it at your own risk (if your N7 burns and takes your house with it, don't come running to me).
Feel free to submit these changes to Google, I won't. The Ubuntu enhancements for the original N7 were submitted in January and have been ignored.
reserved
This looks awesome!
Sent from my Nexus 7 using xda app-developers app
This sounds interesting, I don't know if it is though!
Sent from my 2014 Nexus 7 using Tapatalk 4.4
For the non-kernel developers a bit more explanation. This is a kernel patch that modifies the battery gauge driver.
The kernel exposes certain information via sysfs, which is a virtual file system. If you have a kernel with this patch, you can open a terminal window and do something like:
Code:
cd /sys/class/power_supply/battery/
cat power_now
This will print the current amount of power used (in micro-Watt). You can also use a root-capable file browser (e.g. ES Explorer) to look at the sysfs files; you can open /sys/class/power_supply/battery/power_now like a 'normal' file (same thing with other properties mentioned in the first post).
If you want to try this, ElementalX 1.6 beta has this patch applied:
http://forum.xda-developers.com/showpost.php?p=45944453&postcount=1034
tni.andro said:
For the non-kernel developers a bit more explanation. This is a kernel patch that modifies the battery gauge driver.
The kernel exposes certain information via sysfs, which is a virtual file system. If you have a kernel with this patch, you can open a terminal window and do something like:
Code:
cd /sys/class/power_supply/battery/
cat power_now
This will print the current amount of power used (in micro-Watt). You can also use a root-capable file browser (e.g. ES Explorer) to look at the sysfs files; you can open /sys/class/power_supply/battery/power_now like a 'normal' file (same thing with other properties mentioned in the first post).
If you want to try this, ElementalX 1.6 beta has this patch applied:
http://forum.xda-developers.com/showpost.php?p=45944453&postcount=1034
Click to expand...
Click to collapse
any others aswell?

SDK or NDK w/o OpenGL in app to save battery?

I would like to develop and app, which has the main functionality to show a 2D chart. There are others and settings, but this is the main.
Existing similar applications aren't using technologies as how it should and they are releasing apps with to few features or they are draining battery like crazy. This I would like to improve it.
This is for web / desktop
View attachment 2397770
Here are a few sentences from my experience, please correct me if I am wrong!
Many-many of implementations are using SDK and 2D graphics. They draw the whole screen every time. Just sere how your battery drained in 1-2 hours! - some really bad implementation they can drain in 3 minutes, I will show later. One exception is: Metatrader 4: it use NDK and OpenGL, Hey pay me, because I am advertising you!
I think the SDK code (.class files) it need to e compiled at runtime execution by virtual machine, which takes CPU usage.
NDK is compiled only one => will use less CPU => will drain less batter as the SDK version.
If this is correct, than it should move more code to NDK if is possible. Not sure about JNI calls overhead!
NDK huuuuge advantage: it will allow to use the phone max available memory ( 1.5GB was last time) instead of SDK max allowed value: 256MB ( in my case, but some devices allow only 24Mb for SDK apps)
If you don't touch this chart than nothing changes, if you set the "Live" option, than the last "candle" will change. The candles are those Red & Green rectangles with the line in upper side and down side with meaning of the open, high, low, close prices. - it is related to business logic, but this special bars can have those 2 lines, which are important. The border of the 1pixel black around the red-green rectangles are for visual effects only. To save battery can be omitted.
(The background text and logos are just for advertisements, nobody cares, not really needed for the user for his actions)
As you can see there is a toolbar, and there are maybe other components too, but when the user want to see highest amount of data than will rotate to landscape and there should be given a Full Screen (in portrait not by default)
I have started the development with a component for rendering with OpenGL ES 2.0.
The UI is in SDK , the renderer there is called, but the method implementation calls the native methods via JNI. The business logic, rendering implementation are all in NDK, which is a native shared library.
Not sure why I started with OpenGL, to have some cool effects, who want to drain his battery faster? or I tough if is faster than will consume less battery? - maybe faster drains, but more: 100 mA from GPU for 0.01 seconds rendering is the same as 10 mA for 0.1 rendering at CPU.
Here I am not sure if I am saving energy. Tell me your opinion!
So I have started learning OpenGL ES 2.0 and all what I saw in tutorials it was triangle triangle triangle, but in this chart there is no triangle, but rectangle, or rectangle+lines or just lines with set width or many triangles?
Here is a cool candle, I would like to see this, but I know the gradients will burn battery.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Here is a bit magnified and you can see how I am thinking:
but can't decide. Because I haven't enough experience, don't know the benchmark results. I would like to see a tear down and expected results:
GL_Lines + glLineWidth
GL_triangles
GL_triangle_strip
As the first option with GL_lines:
A candle would be 1x small line from the Low and High price drawn first. Lets say with 5 pixel width to have room for gradient too, if needed. In worse case only 1 pixel, as how they are using others now.
The candle body: the red/green rectangle with has the info of Open/Close price can be another GL_Lines with 50 pixel width - for example.
Will be gradient or not that would depends on user settings. Not sure how is possible to draw black 1-2 pixel of border for candle body in this case - if the user has that settings.
Seconds option with triangles:
2x triangle can make a square.
There is a square as the small line and there is another one the larger square : the candle body.
The triangle strip case:
if only one GL_triangle_strip:
bottomline: 4 vertices
body other 4
upper line 4 vertices
or small line 4x vertices
+
other 4x vertices , so 2x GL_triangle_strip
I made this:
The first thing it was:
Code:
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY)
It is a rectangle with 2x triangle and a line with width.
The line has less vertices of course, but in this chart is expected to have 50- 200 bars maximum. Minimum 10-20.
What is needed is that cross at mouse location: that dashed line and the numbers ( price ) on the right and some other texts in bottom. X, Y coordinates in text.
Please post your experience, benchmarks, opinion.
Hi matheszabi,
ok, your question was rather compheresive . So right way to find solution is rather complicated too.
I woudn't choose solution according to differences between JDK / NDK to same function calls of OpenGL ES 2.0
According to my experience, performance (and power consumption) is almost the same.
GLOBAL aproach: I suggest
1) you create your application in Java - use JDK versions - creating native function for just few draw calls is, imho, hard compared what you get
2) if your application is NativeActivity
- use direct calls - be prepared for differences between devices, proper creation of surface, .... but it's faster
- subclass Native Activity and use JAVA as well
3) not using OpenGL ES directly at all - i suggest trying layout and buttons / images inside of it, i saw 200 control buttons on 1 screen and it ran perfectly. And layout is movable by 1 command - offset. I suppose, this is completely written in native code anyway. You just get drawing interface in JAVA.
Now, to OPENGL ES itself (JAVA or NDK)
cons:
- OPENGL is 3D interface so pixel perfect drawing is something which is not supported by itself. (note: opengl has pixel / texel center at 0.5 not at 0.0/1.0)
- you need pixel perfect draw - boxes you draw must be perfectly aligned to screen pixels - othewise you get blurry results
- you might not need texturing - thats PLUS, otherwise drawing pixel perfect opengl suraces is "pain in the ..." - viz. texel interpolation and drawing a pixel checker aligned with screen pixels is real nightmare and it differs on each device (I tried )
- pixel perfect with mipmaps - awful again
- alpha blending (when you have something which is transparent) - you will need sorting to draw it properly
- will you need font ? oh my ...
- NO EMULATOR - will need to test each device if it's working properly (not every, at least each vendor)
to consider:
writing vertex/fragment shader in a world with 3500 (number of opengles 2.0 devices according google) suitable devices/compilers/android versions ... ehm
pluses:
- you draw exactly what you want
- use of fragment shader (alhough i suggest using gradient textures instead)
- i suggest draw primitives in vertex buffers (indexed triangles or triangle strips). Not one box by one - compose all in one array and draw it by one draw call. Doubling points in strips can help you
- instancing is not supported) but there is way surpassing this (preparing buffers with)
- i don't recommend using lines with width definition - each implementation draws this differently - and it's equal to drawing lit cylinder
- in native activity loop - handling if you need redraw - it's difficult
I would try normal android GUI first
pluses:
- you get pixel perfect draw, with / without bitmaps, images, gradients ....
- i suppose its fast enough
- no sorting needed
- redraws will be invoked when something changes
- translation / clipping will be handled internally
- no need to care about device !!! that's big plus
cons:
- zoom will be problematic
- rotations as well (but i suppose you don't need them)
note to power consupmption - both OpenGL :
just swaping screen buffers 30 per sec will deplete most of devices within 2-3 hours. But of course, doing it so only when needed is doable
But I might be wrong so best way is to decide by yourself and, of course, try it and see.
If you have qustions about drawing through ES, i'll post some samples of pixel perfect draw (from my gui)
Good luck, post your decision, and if you have some results, post them too! will be very interesting.
PS.
Petr Sovis said:
Hi matheszabi,
ok, your question was rather compheresive . So right way to find solution is rather complicated too.
I woudn't choose solution according to differences between JDK / NDK to same function calls of OpenGL ES 2.0
According to my experience, performance (and power consumption) is almost the same.
GLOBAL aproach: I suggest
1) you create your application in Java - use JDK versions - creating native function for just few draw calls is, imho, hard compared what you get
2) if your application is NativeActivity
- use direct calls - be prepared for differences between devices, proper creation of surface, .... but it's faster
- subclass Native Activity and use JAVA as well
3) not using OpenGL ES directly at all - i suggest trying layout and buttons / images inside of it, i saw 200 control buttons on 1 screen and it ran perfectly. And layout is movable by 1 command - offset. I suppose, this is completely written in native code anyway. You just get drawing interface in JAVA.
Now, to OPENGL ES itself (JAVA or NDK)
cons:
- OPENGL is 3D interface so pixel perfect drawing is something which is not supported by itself. (note: opengl has pixel / texel center at 0.5 not at 0.0/1.0)
- you need pixel perfect draw - boxes you draw must be perfectly aligned to screen pixels - othewise you get blurry results
- you might not need texturing - thats PLUS, otherwise drawing pixel perfect opengl suraces is "pain in the ..." - viz. texel interpolation and drawing a pixel checker aligned with screen pixels is real nightmare and it differs on each device (I tried )
- pixel perfect with mipmaps - awful again
- alpha blending (when you have something which is transparent) - you will need sorting to draw it properly
- will you need font ? oh my ...
- NO EMULATOR - will need to test each device if it's working properly (not every, at least each vendor)
to consider:
writing vertex/fragment shader in a world with 3500 (number of opengles 2.0 devices according google) suitable devices/compilers/android versions ... ehm
pluses:
- you draw exactly what you want
- use of fragment shader (alhough i suggest using gradient textures instead)
- i suggest draw primitives in vertex buffers (indexed triangles or triangle strips). Not one box by one - compose all in one array and draw it by one draw call. Doubling points in strips can help you
- instancing is not supported) but there is way surpassing this (preparing buffers with)
- i don't recommend using lines with width definition - each implementation draws this differently - and it's equal to drawing lit cylinder
- in native activity loop - handling if you need redraw - it's difficult
I would try normal android GUI first
pluses:
- you get pixel perfect draw, with / without bitmaps, images, gradients ....
- i suppose its fast enough
- no sorting needed
- redraws will be invoked when something changes
- translation / clipping will be handled internally
- no need to care about device !!! that's big plus
cons:
- zoom will be problematic
- rotations as well (but i suppose you don't need them)
note to power consupmption - both OpenGL :
just swaping screen buffers 30 per sec will deplete most of devices within 2-3 hours. But of course, doing it so only when needed is doable
But I might be wrong so best way is to decide by yourself and, of course, try it and see.
If you have qustions about drawing through ES, i'll post some samples of pixel perfect draw (from my gui)
Good luck, post your decision, and if you have some results, post them too! will be very interesting.
PS.
Click to expand...
Click to collapse
Hello thanks for sharing your idea experience.
I have asked in other forum a similar question.
It was a response than the GPU has optimised methods so it will have less power consumption
Also he likes to draw the whole frame not only a part - I'm case of my optimisation
Also I have asked an opengl expert and he told me to use the ortho instead of perspective projection. He has right.
Now I don't have bliry results anymore but is pixel perfect!
For benchmark I made 100 candles : 100 line + 200 triangles.
I have calculated how much is the wigth and the height for the surface => how much space can have a candle and used the matrix transformations and render it.
A nice surprise the fist time it took 18 milliseconds but after that only took 5-6 millisec the. Sdk->ndk->opengl-> SDK steps.
That is very good result on MY trash device. But I think it has a trick: the ndk gives order to render to GPU and it will return. So in those 5-6 milliseconds will start to work the GPU for who knows how much....
Note: audio , video , sensor intensive projects should be developed on real devices not at emulators.
With my method the problem is starting with text drawing and leak of knowledge.
Vbo or texture... Not sure which one but if a native 2D can do it than I can me too.
Cairo as rendering 2d engine is a bit big to include in android.
I still think the ndk is the correct place. Also is isn't so easy to watch the engine code as a decompiled SDK code
Ok! you chose your path - good for you!
18/5-6 ms is just for draw (200 triangles+100 lines) ?, or whole frame time ? Can you tell me the the device you are testing your app on ?
Note: Ortho, i didn't mean to advice perspective transform, ortho is still 3d, and pixel perfect - wait for texturing/text drawing, but you'll manage!
Just few tips to font rendering:
bitmap fonts: I can't add links so google: angelcode bmfont
font bitmap creator: google: angelcode bmfont
+ sample: google: nehe 2d_texture_font
freetype implementation - it's possible to compile it with ndk - i use it and it's simple
google: freetype
and code for starters: google: nehe freetype_fonts_in_opengl
Cheers
P.
Petr Sovis said:
Ok! you chose your path - good for you!
18/5-6 ms is just for draw (200 triangles+100 lines) ?, or whole frame time ? Can you tell me the the device you are testing your app on ?
Note: Ortho, i didn't mean to advice perspective transform, ortho is still 3d, and pixel perfect - wait for texturing/text drawing, but you'll manage!
Just few tips to font rendering:
bitmap fonts: I can't add links so google: angelcode bmfont
font bitmap creator: google: angelcode bmfont
+ sample: google: nehe 2d_texture_font
freetype implementation - it's possible to compile it with ndk - i use it and it's simple
google: freetype
and code for starters: google: nehe freetype_fonts_in_opengl
Cheers
P.
Click to expand...
Click to collapse
My phone is a THL W8S. has FHD resolution
It had a mixed layout, but better I show you:
I have misscalculated the lines positions but for now doesn't matter.
The GLSurface takes a considerable amount of the screen space and that is counted.
On a Samsung Note 10" - at least 1 year old device, lower resolution, but better CPU + GPU it is a lot less this numbers.
My device is a trash (by far not for gamming), I told you:
Hi,
ok, as I understand, the time is just for drawing 200 tris + 100 lines - ok that seems a "little to much" for that.
Besides, your device is not trash at all
I don't know if I can share my examples - but scene from app I released week ago draws 50KTris per frame with some heavy shaders (normal mapping + specular ligting from 2 light sources) and draws text over it + particles + GUI (my ndk gles2.0 engine) and I suppose it will run over 30 FPS on your device (its PoverVR 540 or something) (google play: "Asteroid Hunters" by me)
So, can you post fragment of your drawing code ? maybe there something not really right ?
P
Petr Sovis said:
So, can you post fragment of your drawing code ? maybe there something not really right ?
P
Click to expand...
Click to collapse
I will post, but for me this is good enough others are drawing in 200-2000 milliseconds
The SDK part:
Code:
@Override
public void onDrawFrame(GL10 gl) {
long start = System.currentTimeMillis();
LibJNIWrapper.rendererOnDrawFrame();
long end = System.currentTimeMillis();
//Log.e("Renderer", "onDrawFrame() took: "+ (end-start)+" millisec (1e-6)");
}
The related NDK part:
Code:
void renderer_on_draw_frame() //4
{
LOGE("renderer_on_draw_frame");
//copy
static float grey;
grey += 0.01f;
if (grey > 1.0f) {
grey = 0.0f;
}
glClearColor(grey, grey, grey, 1.0f);
checkGlError("glClearColor");
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
checkGlError("glClear");
int i;
for (i = 0; i < CANDLES_COUNT; i++) {
//LOGE("chartengine rendering i= %d",i);
renderLine((candles[i].coloredSingleLine));
renderRectangle((candles[i].coloredSingleRectangle));
}
glFlush();
}
line rendering:
Code:
void renderLine(ColoredSingleLine* pColoredSingleLine) {
if (pColoredSingleLine == NULL) {
return;
}
//matrixTranslateM(mvpMatrix, rndX, rndY, 0);
//LOGE("###renderLine pColoredSingleLine %p\n",pColoredSingleLine);
glUseProgram(pColoredSingleLine->programColoredLine.program);
checkGlError("Line: glUseProgram");
// Enable a handle to the triangle vertices
glEnableVertexAttribArray(pColoredSingleLine->programColoredLine.a_position_location);
checkGlError("Line: glEnableVertexAttribArray");
// Prepare the triangle coordinate data
glVertexAttribPointer(pColoredSingleLine->programColoredLine.a_position_location, pColoredSingleLine->lineData.COORDS_PER_VERTEX_LINE, GL_FLOAT, GL_FALSE,
pColoredSingleLine->lineData.vertexStride, pColoredSingleLine->lineData.vertices);
checkGlError("Line: glVertexAttribPointer");
// Set color for drawing the triangles
glUniform4fv(pColoredSingleLine->programColoredLine.u_color_location, 1, pColoredSingleLine->lineData.color_rgba);
checkGlError("Line: glUniform4fv");
// Apply the projection and view transformation
glUniformMatrix4fv(pColoredSingleLine->programColoredLine.u_mvp_matrix_location, 1, GL_FALSE, pColoredSingleLine->lineData.mvpMatrix);
checkGlError("Line: glUniformMatrix4fv");
glLineWidth(pColoredSingleLine->lineData.lineWidth);
// Draw the line
glDrawArrays(GL_LINES, 0, pColoredSingleLine->lineData.vertexCount); // (GLenum mode, GLint first, GLsizei count);
checkGlError("Line: glDrawArrays"); // GL_INVALID_ENUM
//GL_INVALID_ENUM is generated if mode is not an accepted value.
//GL_INVALID_ENUM is generated if type is not GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.
GLint error = glGetError();
if (error == GL_OUT_OF_MEMORY) {
LOGE("Out of Video memory error...congrats...is your device a stone ?");
}
// Disable vertex array
glDisableVertexAttribArray(pColoredSingleLine->programColoredLine.a_position_location);
}
and the rectangle:
Code:
void renderRectangle(ColoredSingleRectangle* pColoredSingleRectangle) {
if (pColoredSingleRectangle == NULL) {
return;
}
//matrixTranslateM(mvpMatrix, rndX, rndY, 0);
glUseProgram(pColoredSingleRectangle->programColoredRectangle.program);
checkGlError("Rectangle: glUseProgram");
// Enable a handle to the triangle vertices
glEnableVertexAttribArray(pColoredSingleRectangle->programColoredRectangle.a_position_location);
checkGlError("Rectangle: glEnableVertexAttribArray");
// Prepare the triangle coordinate data
glVertexAttribPointer(pColoredSingleRectangle->programColoredRectangle.a_position_location, pColoredSingleRectangle->rectangleData.COORDS_PER_VERTEX_RECTANGLE, GL_FLOAT, GL_FALSE,
pColoredSingleRectangle->rectangleData.vertexStride, pColoredSingleRectangle->rectangleData.vertices);
checkGlError("Rectangle: glVertexAttribPointer");
// Set color for drawing the triangles
glUniform4fv(pColoredSingleRectangle->programColoredRectangle.u_color_location, 1, pColoredSingleRectangle->rectangleData.color_rgba);
checkGlError("Rectangle: glUniform4fv");
// Apply the projection and view transformation
glUniformMatrix4fv(pColoredSingleRectangle->programColoredRectangle.u_mvp_matrix_location, 1, GL_FALSE, pColoredSingleRectangle->rectangleData.mvpMatrix);
checkGlError("Rectangle: glUniformMatrix4fv");
// Draw the square
glDrawElements(GL_TRIANGLES, NELEMS(pColoredSingleRectangle->rectangleData.drawOrder), GL_UNSIGNED_SHORT, pColoredSingleRectangle->rectangleData.drawOrder); // GL_INVALID_ENUM on Galaxy note
checkGlError("Rectangle: glDrawElements"); // GL_INVALID_ENUM
//GL_INVALID_ENUM is generated if mode is not an accepted value.
//GL_INVALID_ENUM is generated if type is not GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.
GLint error = glGetError();
if (error == GL_OUT_OF_MEMORY) {
LOGE("Out of Video memory error...congrats...is your device a stone ?");
}
// Disable vertex array
glDisableVertexAttribArray(pColoredSingleRectangle->programColoredRectangle.a_position_location);
}
At any benchmarks my fps is bellow 12, while other devices has 30 or 50 fps. Believe me not my device has the best CPU + GPU by far:
some output from on old code:
Code:
printGLString("Version", GL_VERSION);
printGLString("Vendor", GL_VENDOR);
printGLString("Renderer", GL_RENDERER);
printGLString("Extensions", GL_EXTENSIONS);
....
void printGLString(const char *name, GLenum s) {
const char *v = (const char *) glGetString(s);
LOGE("GL %s = %s\n", name, v);
}
// ### GT-N8000 ### Galaxy note 10" - GL Renderer = Mali-400 MP
// GL_EXT_debug_marker
// GL_OES_texture_npot
// GL_OES_compressed_ETC1_RGB8_texture
// GL_OES_standard_derivatives
// GL_OES_EGL_image
// GL_OES_depth24
// GL_ARM_rgba8
// GL_ARM_mali_shader_binary
// GL_OES_depth_texture
// GL_OES_packed_depth_stencil
// GL_EXT_texture_format_BGRA8888
// GL_EXT_blend_minmax
// GL_OES_EGL_image_external
// GL_OES_EGL_sync
// GL_OES_rgb8_rgba8
// GL_EXT_multisampled_render_to_texture
// GL_EXT_discard_framebuffer
// ### THL V8S - GL Renderer = PowerVR SGX 544MP
// GL_EXT_debug_marker
// GL_OES_rgb8_rgba8
// GL_OES_depth24
// GL_OES_vertex_half_float
// GL_OES_texture_float
// GL_OES_texture_half_float
// GL_OES_element_index_uint
// GL_OES_mapbuffer
// GL_OES_fragment_precision_high
// GL_OES_compressed_ETC1_RGB8_texture
// GL_OES_EGL_image
// GL_OES_EGL_image_external
// GL_OES_required_internalformat
// GL_OES_depth_texture
// GL_OES_get_program_binary
// GL_OES_packed_depth_stencil
// GL_OES_standard_derivatives
// GL_OES_vertex_array_object
// GL_OES_egl_sync
// GL_OES_texture_npot
// GL_EXT_multi_draw_arrays
// GL_EXT_texture_format_BGRA8888
// GL_EXT_discard_framebuffer
// GL_EXT_shader_texture_lod
// GL_IMG_shader_binary
// GL_IMG_texture_compression_pvrtc
// GL_IMG_texture_compression_pvrtc2
// GL_IMG_texture_npot
// GL_IMG_texture_format_BGRA8888
// GL_IMG_read_format
// GL_IMG_program_binary
// GL_IMG_uniform_buffer_object
// GL_IMG_multisampled_render_to_texture
materials
OK!
i know why it's so slow, you practically draw something 300x per frame and it doesn't really matter if it has 2 trinagles or 300 per one call.
300x setup shader per frame is almost a limit for slower(not slow) devices.
Main issues:
1) do not ever call glGetError when not debugging/running debug build - it makes pipeline stall (pipeline stops and waits until all commands are executed)
2) since you have 100 lines - and using for all of them same program, why not to group them in one array ?
2 solutions
-----------------
A)
= you are not using vertex buffers - so
1) create temporary memory and pre-transform all lines/triangles into one array - will be much faster
2) setup shader once + set uniforms
3) setup attributes - start of temporary array you created (every call - believe me, it will be faster, good practice is create array on stack, but beware of overflow - but for 300 lines is practically impossible)
3) call one draw call for all lines/triangles at once
B) even faster solution (fake instancing) - this is really fast
= create vertex buffer with data (and now create this as real VBO !)
- and not with only 1 instance of line, but with reasonable count - for instance 300 (fake instancing) - 300x line data repeated,
- in tex.x,y (for instance) - set index 0.299 -> x = (float(index % 256) / 256.0f ) y = ( (index & (~255)) / 256.0 ) - using lowp vec2 inTex; attribute
= in shader:
- create uniform array with coordinates for instance uniform mediump vec3 positions[300];
- in vertex part - something like this
gl_Position.xyz = inPosition.xyz + positions[(int) ((inTex.x * 256.0) + (inTex.y * 65536.0)) ];
1) use shader
2) fill array with positions and set it to uniform
3) set attributes
4) draw - and according to situation change count of elements drawn
if you need draw more than 300 lines, enlarge array OR just do more calls this time this is getting efficient
But i suppose 1st solution will be more than enough.
Cheers.
P.
Petr Sovis said:
OK!
i know why it's so slow, you practically draw something 300x per frame and it doesn't really matter if it has 2 trinagles or 300 per one call.
300x setup shader per frame is almost a limit for slower(not slow) devices.
Main issues:
1) do not ever call glGetError when not debugging/running debug build - it makes pipeline stall (pipeline stops and waits until all commands are executed)
2) since you have 100 lines - and using for all of them same program, why not to group them in one array ?
2 solutions
-----------------
A)
= you are not using vertex buffers - so
1) create temporary memory and pre-transform all lines/triangles into one array - will be much faster
2) setup shader once + set uniforms
3) setup attributes - start of temporary array you created (every call - believe me, it will be faster, good practice is create array on stack, but beware of overflow - but for 300 lines is practically impossible)
3) call one draw call for all lines/triangles at once
B) even faster solution (fake instancing) - this is really fast
= create vertex buffer with data (and now create this as real VBO !)
- and not with only 1 instance of line, but with reasonable count - for instance 300 (fake instancing) - 300x line data repeated,
- in tex.x,y (for instance) - set index 0.299 -> x = (float(index % 256) / 256.0f ) y = ( (index & (~255)) / 256.0 ) - using lowp vec2 inTex; attribute
= in shader:
- create uniform array with coordinates for instance uniform mediump vec3 positions[300];
- in vertex part - something like this
gl_Position.xyz = inPosition.xyz + positions[(int) ((inTex.x * 256.0) + (inTex.y * 65536.0)) ];
1) use shader
2) fill array with positions and set it to uniform
3) set attributes
4) draw - and according to situation change count of elements drawn
if you need draw more than 300 lines, enlarge array OR just do more calls this time this is getting efficient
But i suppose 1st solution will be more than enough.
Cheers.
P.
Click to expand...
Click to collapse
Thanks
When I wrote I saw the glerror maybe it will slow down a bit.
Since I am coming from an object oriented development environment it was designed on that way...
The candle: line + triangle can have other data too. Maybe need to keep elsewhere the data...
The last candle line and rectangle and his color can change almost at each draw method: just 1 of the 4 params will nort change.
When the last candle is closed a new one need to be staeted
In this case needs to. Shift to left all other candles. Maybe for this I am keeping in separate methods.
I thought the shader setup is done in other part at least there I am getting the pointer to they. On surface changed/ created - I am not at PC now.
Text with price + time scale should be with a texture to a rectangle?
I will reply inline:
matheszabi said:
Thanks
When I wrote I saw the glerror maybe it will slow down a bit.
Since I am coming from an object oriented development environment it was designed on that way...
Click to expand...
Click to collapse
Object development has nothing to do with this , glGetError is NOT a function to retrieve error status from GL functions, its for debugging purposes only. Its commonly used as: (simple form)
#ifdef _DEBUG
#define CHECKGL(x) x; assert(glGetError() == GL_NO_ERROR)
#else
#define CHECKGL(x) x
#endif
CHECKGL( glUniform4f(.... .) );
or still very fast
#define CHECKGL(x) x; if (globalDebugGL) { assert(glGetError() == GL_NO_ERROR); }
matheszabi said:
Thanks
The candle: line + triangle can have other data too. Maybe need to keep elsewhere the data...
The last candle line and rectangle and his color can change almost at each draw method: just 1 of the 4 params will nort change.
When the last candle is closed a new one need to be staeted
In this case needs to. Shift to left all other candles. Maybe for this I am keeping in separate methods.
Click to expand...
Click to collapse
Again - preparing something to vertex buffer is 100x faster than calling gluseProgram, gluniform and then draw call.
Different values per "candle": you can change (per candle) color, position, tex coords, and another values - to max 16 vec4 attributes per vertex in vertex buffer.
just for your imagination what does exactly glUniform: it recompiles and rebuilds shader with new values. It's not fast at all. So drawing 2 triangles with new shader setup (different uniform values) is not very smart. You have only 800-1000 such operations per frame tops. New card can handle much more. Look for term "draw call batching" to learn more. Unity's main feature.
Just imagine, even chip in your phone can easily draw 20 textured MTris per sec and you draw just few thousands and it's sweating.
Very nice article about GLES 2.0 from apple - google for "OpenGL ES Design Guidelines" most of it is true on android as well
matheszabi said:
Thanks
I thought the shader setup is done in other part at least there I am getting the pointer to they. On surface changed/ created - I am not at PC now.
Text with price + time scale should be with a texture to a rectangle?
Click to expand...
Click to collapse
That differs according to your situation.
- Is price/time always same ? (texture)
- it's changing per frame, (prerender texture)
- it's changing per "candle" ? - I posted articles about text in gl apps in the last post.
I thing you can choose your way !
Cheers
P.
Thanks for answer.
Petr Sovis said:
That differs according to your situation.
- Is price/time always same ? (texture)
- it's changing per frame, (prerender texture)
- it's changing per "candle" ? - I posted articles about text in gl apps in the last post.
Click to expand...
Click to collapse
Price/time is the same until: the user press a button, than will change the time ( From To values) and collecting data will result a min price and a max price. So the price probably will change at that button event, but not all the time.
Also the last candle price value is "moving" at least the close value, but an move the min or max value too, which can be the min or the max of the whole chart, on those rare situations need to change the coordinate system too. Can be used here a trick as it is changing and it will add +20% so what not need to change on each tick (frame)
233528246055
matheszabi said:
Thanks for answer.
Price/time is the same until: the user press a button, than will change the time ( From To values) and collecting data will result a min price and a max price. So the price probably will change at that button event, but not all the time.
Also the last candle price value is "moving" at least the close value, but an move the min or max value too, which can be the min or the max of the whole chart, on those rare situations need to change the coordinate system too. Can be used here a trick as it is changing and it will add +20% so what not need to change on each tick (frame)
Click to expand...
Click to collapse
I would definitely use rendering text technique I already posted. Its very fast (when implemented properly) and you can "print" whatever you want.
One of the following
bitmap fonts: (more content preparations - you need to prepare texture for each font)
-------------------
font bitmap creator: google: angelcode bmfont
+ sample: google: "nehe 2d_texture_font"
freetype implementation: (easier use - free type can generate font you want - also very fast)
-------------------------------------
it's possible to compile it with ndk - i use it and it's simple
google: freetype
and code for starters: google: "nehe freetype_fonts_in_opengl"
Cheers
P.

[APP][ROOT] zTorch Adjustable and extremely bright Flashlight

EDIT: 11/15/2014
This post features version 2.x.x. It is a complete rewrite using Android Studio because importing the project from Eclipse didn't go too well.
For information on version 1.x.x , go to post #28
Downloads for both versions are at the bottom of this page.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
ZTORCH Features:
The goal of ZTorch is to be a extremely quick and lightweight app that does one thing and does it well without extra bloat or ridiculous permissions. ZTorch can vary the brightness of your phones LED and allow you to set brightness levels higher than possible anywhere else.
The Galaxy S4 is capable of 16 different levels of brightness (0-15). Compared to other Apps:
The stock "Assistive Light" that is featured with the phone only sets the level to 1.
The brightest AppStore Apps, such as TeslaLED, are able to set the brightness to a little less than half brightness, level 6.
Typically, flashlight apps take about a second to switch on the LED
ZTorch can adjust the LED in mere milliseconds.
ZTorch stays on when the screen is off and doesn't flicker when the screen switches off.
ZTorch works with the camera. Ever wanted to use the flashlight LED while recording a video or taking a picture? Now you can.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
ZTorch should work across all phones with root if the proper system file is on the phone. ZTorch scans for the following binaries below. If your device isn't supported and you know the path to the proper file, you can set that path in the apps preferences. This app has only ever been tested on the Galaxy S4, if you try it on a different phone, PLEASE let me know how it is!
Code:
"/sys/class/camera/flash/rear_flash", - For Galaxy s4
"/sys/class/camera/rear/rear_flash", - For Galaxy Note and maybe s3
"/sys/class/leds/flashlight/brightness," - HTC devices
"/sys/devices/platform/flashlight.0/leds/flashlight/brightness" - HTC devices
" /sys/class/leds/spotlight/brightness" - Motorolla Droid Devices
"/sys/class/leds/torch-flash/flash_light" - Motorolla Droid 2
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Screenshots from ZTORCH-beta-2.0.0.26.apk:
Main Activity as popup with widget shown in background.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Notification:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Permissions:
ACCESS_SUPERUSER - To set the LED
RECEIVE_BOOT_COMPLETED - Sets LED to 0, allows for persistent notification, notification on bootup.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Version Information:
Download attached at bottom of post.
LATEST: Version 2.0.3.50: (Feb 24, 2015)
Notification now appears on boot if that setting is enabled
Separated BootReceiver from main broadcast receiver so disabling the boot receiver won't break the rest of the app.
Notification icon changed to support Lollipop.
Renamed some app refs.
Somehow cut 50kb from the app, it's now 100.6Kb. Considering the Icons take up 89.5Kb I'm kinda amazed.
I haven't got around to making an actual Settings activity. So features are the same from prior version.
Version 1.2.2: (Mar 3, 2014) All the features work but is less refined.
Version 1.3.0: (June 16,2014) Added TorchPlayer to act similar to PWM. All Features work.
Version 1.4.0 (June 20,2014) Switching speed was the priority in this version; the brightness can be changed in <3ms. I abandoned the very comprehensive and powerful Stericson RootTools library in favor of a purpose built class that toggles the flashlight. Warning: The notification doesn't work on API-19 Android 4.4+. Clicking it does nothing. I need to build a new version sometime.
For more info on version 1.x.x such as the screenshots, see post #28
ZTORCH-beta-2.0.0.28: (November 15,2014) Beta version does not yet have a settings or preference activity implemented as well as other nonessentials. To change settings in this version, see below. Changes include:
Entirely new MainActivity that's now in a Popup window
Entirely New and Fully Working Notification
Widget now fills the entire 1x1 grid. (Let me know if there's problems, I set the left and right margins to -23dp to do this)
Added Warn feature and Torch Fireball icon for when the brightness is higher than the Warn value.
Slider no longer lags while trying to effectively "make a strobe light" by not sending broadcasts, updating views, or saving the brightness until after you take your finger off.
Slider changes color based on level.
ZTORCH-beta-2.0.0.33optimized: Technically should be: 2.0.2.33(November 16,2014) Changes:
Adds RECEIVE_BOOT_COMPLETE permission.
Ongoing Notification is available in AppPrefs.xml
TapGuard enabled by default. (Widget ignores first tap to prevent accidental taps)
ZTORCH-optimizedbeta-2.0.3.41: (November 17,2014) Changes:
New Notification AppPrefs.
ongoingNotif (Can't swipe away, Persistent).
onPriority and offPriority (levels: -2, -1, 0, 1, 2 where 2 is PRIORITY_MAX)
Shell Command Text and Toggle Button updated instantly while slider moves.
ZTorchReceiver enables you to send commands from other apps such as Tasker. Available broadcasts listed further down.
Fixed Force Close if the Main Toggle button is pressed and root was denied or the device is unsupported. (Not like you can use the app like this anyway, but still)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
BETA Version Settings
I'm still trying to figure out how android implements preferences and preference fragments. So in the beta, there is none! To change a setting, get a file browser with root access such as ES File Explorer, then navigate to the location below and edit the file "LEDPrefs.xml"
Code:
/data/data/derekziemba.ztorch/shared_prefs/
Additionally there is another file, "AppPrefs.xml" where you will find app specific settings and be able to configure the Notification.
"LEDPrefs.xml" will look like this on ZTORCH-beta-2.0.0.28. Later versions will be slightly different. I recommend uninstalling the app before installing a new beta.
default - The value the torch will turn on at when Toggled or Enabled.
inc - increment. Value the notifications "+" and "-" will increase or decrease by and the Widget will increase at if multitap = true;
multitap - If true, on successive widget taps the brightness will increase by the inc value. If false, brightness will toggle to default value;
wait - For multitap and tapguard. Time in milliseconds between successive widget taps to increase brightness. If more time than this has passed, the LED will shut off.
tapguard - To prevent accidental widget taps turning on the LED. If true, the widget ignores the first tap and waits for a second tap, unless the LED is already on.
min - just leave at 0, this is the "off" value, it is here in case some phones are reversed
max - maximum value on slider and the max value you can increment to. Only the first 3 digits of this will ever be used, giving a max possible value of 999.
warn - value at which the torch turns from yellow to a fireball and the slider begins changing colors from blue to yellow to red.
lvl - Current Brightness. There is no way to retrieve the current LED level, so the last value is stored here
sys - the system binary that controls the LED;
mask - bitmask. The brightness level is bitwise AND'ed with this value before executing the shell command to prevent invalid values. If you need help configuring this, use windows calculator and set it to programmer mode on Integer then click the bits you want to use, then use the integer value given.
"AppPrefs.xml" settings:
enableTorchOnAppLaunch - If true, opening the app will automatically set the brightness to the default value listed in "LEDPrefs.xml". Default is "false"
persistentNotif - If true, the notification will be persistent and it cannot be swiped away. Default is "false"
showNotifOnBootComplete - Posts the notification when BOOT_COMPLETE is received for easy access. Use with persistentNotif to prevent swiping away. Default is "true"
Notification Priorities. There are 5: MIN(-2), LOW(-1), DEFAULT(0), HIGH(1), and MAX(2). More info here: http://developer.android.com/design/patterns/notifications.html#guidelines
notifPriorityTorchON - Notification Priority when the LED is on. Default is "2"
notifPriorityTorchOFF - Notification Priority when the LED is off. Default is "-1". Versions before 2.0.3.41 including 1.x.x are hardcoded at "-2"
Important: Before changing any settings, be sure to kill ZTorch with a task manager. Otherwise the settings will not take effect and they will be overwritten when the app gets sent to the background.
If you mess up the settings ZTorch will force close on launch. Delete the XML file to restore defaults.
Strobe Light:
You can get some pretty cool stobbing effects by changing the "mask" and "max" settings.
If you set the "max" value to something like 200 with the mask set to 15 (0000-1111), when sliding the slidebar from 0 to 200, the actual brightness set will repeat 0-15 over and over.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Setting Brightness from other apps such as Tasker, using ZTorch's BroadcastReceiver
I still have to test if this works, but in theory it should. The ZTorchReceiver supports the actions below.
Code:
"derekziemba.ztorch.UPDATE_LEVEL"; //Service will check for extra Integer under the key "lvl" and set that brightness if it is valid.
"derekziemba.ztorch.WIDGET_TAP"; //Behave as if the widget was just tapped. MultiTap, TapGuard, and Wait apply.
"derekziemba.ztorch.STEP_UP"; //Increment Brightness by increment value
"derekziemba.ztorch.STEP_DOWN"; //Decrement Brightness by increment value
"derekziemba.ztorch.INCREASE"; //Increase Brightness by 1
"derekziemba.ztorch.DECREASE"; //Decrease Brightness by 1
"derekziemba.ztorch.ENABLE"; //Turn on torch at default level
"derekziemba.ztorch.DISABLE"; //Turn off torch
"derekziemba.ztorch.TOGGLE"; //Toggle the torch opposite its current state.
---------------------------------Internal---------------------------
"derekziemba.ztorch.UPDATE_FROM_MAIN"; //From main activity, prevents service from broadcasting UPDATE_FROM_SERVICE and cause an endless loop. Contains extra Integer under key "lvl"
"derekziemba.ztorch.UPDATE_FROM_SERVICE"; //Sent from the Service to Main, this one is Unregistered when Main is not visible. It is still sent by the service.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Important Note Regarding Brightness:
For default settings I have the max LED value set to 13 because I've experienced flicker. Values higher than 10 change the color of the slider to red and the widget and notification flame from yellow to fireball. Flicker occurs when your battery voltage is to low to support the current level of brightness.
To avoid LED flicker:
>3800+mV or ~50% is needed for Levels >=13.
> 3750mV or ~30% is needed for Levels > 9.
> 3600mV or ~10% is needed for Levels > 7.
I have used my app to work several hours in an attic at brightness 11. I used my phone because it's actually significantly brighter than every flashlight I own. That includes a flashlight with a 6V cell, a 3 LED headlamp, and a 4 battery AAA LED flashlight. My only light that beat it was my spotlight, but the spotlight's beam is too focused whereas the phone lights up everything.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Note: Android displays the build version as 1 higher than the file name. So Android will show version 2.0.3.41 as 2.0.3.42. This is caused by some Gradle Build Config bug.
I use the torch a lot so I just downloaded this and I'll definitely let you know how it goes. Thanks!
Verizon S4
Liquid Smooth 4.4
Sprint S4
Negalite 4.4
Great app. Been using it for a few days with no issues. Love the incremental increases/decreases.
Anyway to get this to stay in the notification drop down?
Sent from my SCH-I545 using Tapatalk 2
rahilkalim said:
Great app. Been using it for a few days with no issues. Love the incremental increases/decreases.
Anyway to get this to stay in the notification drop down?
Sent from my SCH-I545 using Tapatalk 2
Click to expand...
Click to collapse
I might be able to implement that as a setting quick when I get home. And maybe add an option to make it half height too if it's going to be persistent.
DerekZ10 said:
I might be able to implement that as a setting quick when I get home. And maybe add an option to make it half height too if it's going to be persistent.
Click to expand...
Click to collapse
That would be great. Thanks.
Sent from my SCH-I545 using Tapatalk 2
rahilkalim said:
That would be great. Thanks.
Sent from my SCH-I545 using Tapatalk 2
Click to expand...
Click to collapse
Just updated it. Here's what's new:
Settings Activity has had a makeover. The question mark on the side will explain what the settings do. The image on the left shows what it looks like if the Persistent Notification and the Minimizing Notification toggles are enabled. The right shows what it looks like with the Minimizing Notification toggle off. Notice that when the Minimizing Notification toggle is disabled, zTorch's icon is in the notification bar.
Here is what zTorch looks like in the notification drop down with minimization enabled. The left screenshot is with zTorch minimized. In this state the icon is not in the notification bar. The screenshot ion the right shows the notification expanded with the minimize option enabled, In this state the icon will show up in the notification bar.
Disabling Notification minimization but keeping Persistent notification enabled will cause the notification to appear like the left and middle screenshots. When the Torch is off, only an Activate LED button is present. If there are a large number of other notification, the notification will shrink up. With the Torch on more buttons become available as seen in the middle screenshot. The rightmost screenshot is the notification with both the persistent notification and notification minimization disabled.
Note: This version 1.2.0 has some rough edges. I'll polish it when I have more time. In the future the Settings activity will also be changed to an actual Android Settings layout instead of a generic layout.
EDIT: Version 1.2.1 rounds out those edges.
Now that school is out, I'll be updating and posting the source code on github soon
DerekZ10 said:
Now that school is out, I'll be updating and posting the source code on github soon
Click to expand...
Click to collapse
Great job, works great!
This looks great. Do you have any plans to update this for nc5 4.4.2 compatibility?
Sent from my SCH-I545 using Tapatalk
klabit87 said:
This looks great. Do you have any plans to update this for nc5 4.4.2 compatibility?
Sent from my SCH-I545 using Tapatalk
Click to expand...
Click to collapse
This is why I wanna get the source code up. So others can compile it for their versions. I'm running Android 4.2.2 Eclipse 2.0 Rom. It's all customized and set up the way I like, and it's been very reliable. I'm not sure when I will get around to upgrading. Every rom I have tried as a replacement has had problems.
I haven't got around to posting the source code because there was suddenly some issues with the build? I opened the project the other day and was told I needed to upgrade things, I did and now every object and include directive is underlined in red. I looked at it for about a minute before deciding I'll figure it out some other day. Haven't got around to it since.
Oh ok. I was just wondering. Looking forward to the source so we can have it work for updated android versions someday.
Thanks.
Sent from my SCH-I545 using Tapatalk
klabit87 said:
Oh ok. I was just wondering. Looking forward to the source so we can have it work for updated android versions someday.
Thanks.
Sent from my SCH-I545 using Tapatalk
Click to expand...
Click to collapse
Here's the Source Code Everyone, Good Luck! Everything for the project should be on GitHub including external libraries and the .psd files for the icons.
https://github.com/DerekZiemba/zTorch
I haven't been able to build this or other projects since upgrading the SDK and the Eclipse ADT. I'm not getting any errors, I just get "export build failed." Not sure what to do, maybe reinstall everything. Hopefully someone here can get it working. I just really don't have enough time. In fact the whole project was born out of procrastinating a huge report I didn't want to do for school.
I have everything working again and the source code should build the most stable recent version. The 1.3 beta version is on my dropbox now. This version is a work in progress and the new TorchPlayer feature is not in a working state, but everything else works as usual.
I'm releasing this build before this new feature is working so people with newer versions of android can use the apps pre-existing features.
Here is basically what TorchPlayer is and how it will effect the app in future versions:
Once working properly it will be used to define increment steps for things such as rapid-tap and consecutive-tap (currently double-tap). The time element of these steps will define the max time the LED will stay lit before (likely) dropping down a step. It will be a way to prevent the LED being lit in your pocket all day and limiting the max LED brightness to a defined time.
TorchPlayer will eventually allow you to name and save sequences and have a repeat mode so you can use it as a strobe light. I'm not sure yet how fast the LED can be switched on and off. I might also look into having the sequence controlled by Morse code using dots and dashes.
For this to work I have to figure out, basically, multi-threading(handlers, runnables, threads) and a few other things such as Gson or SQLite.
NOTE: Installing this version messed up my widget. If it happens to you just delete it and re add it to fix.
Shown below is version 1.3 beta 4. I've found that I can strobe the led light ridiculously fast. I haven't encountered the limit yet at even the 5 millisecond intervals. At 5millis the LED is flashing so fast that it is almost becoming steady. With this it may be possible to set custom "LightTones" for certain things like you do with ring tones.
EDIT:
Beta 5 added ability to duplicate several values to save on typing as seen below: Also note, the parenthesis and spaces don't actually matter and are only there to make it easier on me to read. The input is sanitized using: String scheme = behavior.replaceAll("[^0-9/sm,.*&]+",""); So only numbers, the letters s and m, and the symbols / , . * & matter. If a brightness value is out of range that command is ignored.
Here is a video of what the above TorchPlayer string yields.
https://www.youtube.com/watch?v=c1lwTHZwr-M&feature=youtu.be
DerekZ10 said:
I have everything working again and the source code should build the most stable recent version. The 1.3 beta version is on my dropbox now. This version is a work in progress and the new TorchPlayer feature is not in a working state, but everything else works as usual.
I'm releasing this build before this new feature is working so people with newer versions of android can use the apps pre-existing features.
Here is basically what TorchPlayer is and how it will effect the app in future versions:
Once working properly it will be used to define increment steps for things such as rapid-tap and consecutive-tap (currently double-tap). The time element of these steps will define the max time the LED will stay lit before (likely) dropping down a step. It will be a way to prevent the LED being lit in your pocket all day and limiting the max LED brightness to a defined time.
TorchPlayer will eventually allow you to name and save sequences and have a repeat mode so you can use it as a strobe light. I'm not sure yet how fast the LED can be switched on and off. I might also look into having the sequence controlled by Morse code using dots and dashes.
For this to work I have to figure out, basically, multi-threading(handlers, runnables, threads) and a few other things such as Gson or SQLite.
NOTE: Installing this version messed up my widget. If it happens to you just delete it and re add it to fix.
Click to expand...
Click to collapse
For some reason the toggle doesn't show in my drop down now, any ideas?
shindiggity said:
For some reason the toggle doesn't show in my drop down now, any ideas?
Click to expand...
Click to collapse
Just confirmed it is a bug. To get the notification to show you need to switch the torch on once. It'll stay in the dropdown after.
I'll try to get a new build together soon. I learned a few things about Android the other day that made me realize my code was overly complicated and difficult to work with, much more so than it ever needed to be. So I actually started a total rewrite since that version that I want to get perfect.
The new version is a different app all together, the system and launcher will see it as zTorch-L. The L stands for it really being the "Lite" version, in app it will refer to it self as zTorch-Lightning. I decided that the TorchPlayer feature went against the whole purpose of making my own app in the first place. I created it to be fast, simple, no-bs or bugs, do one thing and do it well. What I wanted out of TorchPlayer would cause the app to loose focus of its goal, so I started this new version that would be just that.
Because I want it to be totally finished before releasing, I'm not going to post a link to it here. The code wouldn't even compile if I tried. But if you really rely on the notification being in the dropdown PM me. I have an alpha version I compiled before going to far in to rewriting the code. Everything works great AFTER some tweaking first.
Initially it is inoperable unless, starting from the root directory, you navigate to the following file:
Code:
/data/data/derekziemba.ztorchL/shared_prefs/derekziemba.ztorchL_preferences.xml
Open it, delete what ever is in it, then paste the below text :
Code:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<int name="flash_current_value" value="0" />
<int name="tap_time" value="900" />
<int name="brightness_increment_steps" value="3" />
<int name="default_value" value="8" />
<int name="flash_limit_value" value="13" />
<boolean name="rapid_tap" value="true" />
<boolean name="persistent_notif" value="true" />
<boolean name="mini_notif" value="true" />
</map>
I sent you a PM, be happy too.
DerekZ10 said:
Just confirmed it is a bug. To get the notification to show you need to switch the torch on once. It'll stay in the dropdown after.
I'll try to get a new build together soon. I learned a few things about Android the other day that made me realize my code was overly complicated and difficult to work with, much more so than it ever needed to be. So I actually started a total rewrite since that version that I want to get perfect.
The new version is a different app all together, the system and launcher will see it as zTorch-L. The L stands for it really being the "Lite" version, in app it will refer to it self as zTorch-Lightning. I decided that the TorchPlayer feature went against the whole purpose of making my own app in the first place. I created it to be fast, simple, no-bs or bugs, do one thing and do it well. What I wanted out of TorchPlayer would cause the app to loose focus of its goal, so I started this new version that would be just that.
Because I want it to be totally finished before releasing, I'm not going to post a link to it here. The code wouldn't even compile if I tried. But if you really rely on the notification being in the dropdown PM me. I have an alpha version I compiled before going to far in to rewriting the code. Everything works great AFTER some tweaking first.
Initially it is inoperable unless, starting from the root directory, you navigate to the following file:
Code:
/data/data/derekziemba.ztorchL/shared_prefs/derekziemba.ztorchL_preferences.xml
Open it, delete what ever is in it, then paste the below text :
Code:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<int name="flash_current_value" value="0" />
<int name="tap_time" value="900" />
<int name="brightness_increment_steps" value="3" />
<int name="default_value" value="8" />
<int name="flash_limit_value" value="13" />
<boolean name="rapid_tap" value="true" />
<boolean name="persistent_notif" value="true" />
<boolean name="mini_notif" value="true" />
</map>
Click to expand...
Click to collapse
shindiggity said:
I sent you a PM, be happy too.
Click to expand...
Click to collapse
So you guys don't have to keep using that version if you don't want to, try the zTorch-Lightning_v1.Alpha2 . There's a lot of stuff to do yet, but all the basics are working.
You'll notice the notification is way more responsive and that it no longer does that thing "refresh flash" when switching to different notification styles. It responds instantly to setting changes now too.
When tapping the 1x1 incremental widget, the LED is now set to turn on before the system broadcast and before the on screen widget lights up instead of the other way around.
http://db.orangedox.com/FBzt4wNNfVu1xIMc0W/zTorch-Lightning_v1.Alpha2.apk
This is just what i have been looking for!! So what kind of licensing is your code on git under?
Adjustable flash brightness is just what i want to look adding to my Camera app. I need something lower intensity than the stock.
Unfortunately, I am unable to test this app as my rooted devices don't have flash.
hotspot_volcano said:
This is just what i have been looking for!! So what kind of licensing is your code on git under?
Adjustable flash brightness is just what i want to look adding to my Camera app. I need something lower intensity than the stock.
Unfortunately, I am unable to test this app as my rooted devices don't have flash.
Click to expand...
Click to collapse
Free to use as long as you don't repackage it as is but with ads or put a price on the app. However if you are creating your own app and just want to use the flashlight feature, you can use the below code however you want. I think the git code is way out of date, I worked on it a bit a while ago and I don't think I comited it. I've gotten busy and haven't had a chance to work on it in months.
Here is the code for directly changing the brightness. Free to Use however you wish.
Here is the Shell Class. The Static Methods create and maintain the superuser shell. Therefor a command can be executed app wide on a single shell instead of creating multiple Shell instances.
Code:
package derekziemba.misc;
import java.io.*;
public class Shell {
private static Shell rootShell = null;
private final Process proc;
private final OutputStreamWriter writer;
private Shell() throws IOException {//Open with Root Privileges
this.proc = new ProcessBuilder("su").redirectErrorStream(true).start();
this.writer = new OutputStreamWriter(this.proc.getOutputStream(), "UTF-8");
}
private void cmd(String command) {
try{ writer.write(command+'\n'); writer.flush();}
catch(IOException e) { }
}
public void close() {
try {
if (writer != null) { writer.close();
if(proc != null) { proc.destroy(); }
}
} catch (IOException ignore) {}
}
public static void exec(String command) { Shell.get().cmd(command); }
public static Shell get() {
if (rootShell == null) {
while (rootShell == null) {
try { rootShell = new Shell(); }
catch (IOException e) { }
}
}
return rootShell;
}
}
}
Here is what is used for setting the flash brightness. I stripped out all the app logic. SetLevelCovertly is the actual method used for setting the brightness. It is what the TorchPlayer uses to directly change the brightness in just milliseconds. The stripped away normal SetLevel method records the brightness, triggers the broadcasts, sets the widgets, and fires the notification. There is no way of getting the current flashlevel brightness since my Shell implementation is just for blasting commands at the terminal. Anything more will slow it down.
The listOfFlashFiles is a bunch of different files different phones may use. I've only ever tested the samsung file.
Code:
import java.io.File;
import derekziemba.misc.Shell;
public class Torch
{
private static String FLASH_FILE = null;
private static final String[] listOfFlashFiles = {
"/sys/class/camera/flash/rear_flash",
"/sys/class/camera/rear/rear_flash",
"/sys/class/leds/flashlight/brightness",
"/sys/devices/platform/flashlight.0/leds/flashlight/brightness",
"/sys/class/leds/spotlight/brightness",
"/sys/class/leds/torch-flash/flash_light"
};
/**
* Bypasses all checks and settings and just sets the value. The app will not know what the level is because it is not recorded.
* Will not trigger broadcast, widget views, notification
*/
public static void setLevelCovertly(int value) { Shell.exec("echo " + value + " > "+ getSysFsFile()); }
public static String getSysFsFile() {
if (FLASH_FILE != null) return FLASH_FILE;
for (String filePath : listOfFlashFiles) {
File flashFile = new File(filePath);
if (flashFile.exists()) { FLASH_FILE = filePath; }
}
return FLASH_FILE;
}

Categories

Resources