help VB - Off-topic

can some one tell me whats wrong with this code
Code:
Private Sub btnDisplay_Click( . . . ) Handles btnDisplay. Click
‘Toggle switch from on to off and from off to on.
Dim switchOn As Boolean
switchOn = CBool( InputBox( " Enter True or False. " , " The switch is on. " ) )
If switchOn Then
switchOn = False
End If
If Not switchOn Then
switchOn = True
End If
txtOutput. Text = CStr( switchOn)
End Sub
and also
Code:
Private Sub btnDisplay_Click( . . . ) Handles btnDisplay. Click
‘Display twice the length of a word.
Dim word As String
word = InputBox( " Enter your favorite word " )
txtOutput.Text = “When the word is written twice, “ &
Twice (word) & “ letters are used.”
End Sub
Function Twice (w As String) As Integer
‘Compute twice the length of a string.
Dim len As Integer
Return len = 2 * w.Length
End Function

Is that java? I haven't programmed in a while, if that's java then you need ; at the end of line
Edit: oh that's vb, disregard my post
Sent from my Xperia L using Tapatalk

fujirio said:
can some one tell me whats wrong with this code
Click to expand...
Click to collapse
The first one is wrong where you do this...
Code:
If switchOn Then
switchOn = False
End If
If Not switchOn Then
switchOn = True
End If
You need an else or you're setting it to false and then saying "if it's false make it true" immediately after....
Code:
If switchOn Then
switchOn = False
Else
switchOn = True
End If
Also, I'd recommend looking at using MessageBox as you can show a message and specify what buttons to have - MUCH better than asking someone to type true or false (and then have to worry about people typing other things, or spelling mistakes or upper/lower case characters).
The second one is wrong in the Twice function. You are returning the value of setting the variable len, not the actual value of it. It's easier to get rid of the variable in this case as it serves no purpose...
Code:
Function Twice (w As String) As Integer
‘Compute twice the length of a string.
Return 2 * w.Length
End Function

Related

Mortscript: How to set backlight?

Hi!
How can I set the backlight brightness on my Kaiser using mortscript?
I tried the SetBacklight(10, 10) command and also the commands
RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", 10)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACBrightness", 10)
If I check in ControlPanel, only the slider that is not in use is changed.
So if I am on Battery power, only the slider for AC power is changed and vice versa.
I need to set the backlight to full (10) and half (5) when my bt headset connects.
Thanks a lot!!
This is the script:
RunCheck = 0
Application = "\Windows\AudioManager.exe"
WindowName = "Audio Manager"
While (1)
HandsFreeState = RegRead("HKLM", "System\State\Hardware", "Handsfree")
If (HandsFreeState = 1 && RunCheck = 0)
ToggleDisplay(1)
Run (Application)
#RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", 10)
#RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACBrightness", 10)
SetBacklight(10,10)
SetVolume(255)
RunCheck = 1
EndIf
If (HandsFreeState = 0 && RunCheck = 1)
If (wndExists (WindowName))
Close(WindowName)
EndIf
#RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", 5)
#RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACBrightness", 5)
SetBacklight(5,5)
SetVolume(150)
ToggleDisplay(0)
Vibrate(50)
RunCheck = 0
EndIf
Sleep (1000)
EndWhile
You cant do it using mortscript, on Kaiser and newer HTC devices.
HTC has changed the standard way to manage the backlight. It was done (in older devices) changing the registry and signaling a Windows Event. Now you must invoke some hidden functions of HTCUtil.dll. Unfortunatelly they are undocumented and Its not easy althought the name of the calls are clear. I am watching it right now to let CommMgrPro manage backlight on kaiser. If you unassamble backlight.exe you will see how Its done. But not easy....
Dani
When I got this problem on my PDA (Gsmart I) I found that there are another registry keys for backlight setting I found them on HKLM>SOFTWARE>GigabyeCM>LCDBacklight.
after changing this value with mortscript I run
SetBacklight(10,10)
command then my back light changed.
I wish this comment helps you.
Thanks!
Thanks for your replies!
Too bad mortscript can't manage backlight on the kaiser.
I use the kaiser in my car a lot and am looking for a way to control the backlight by time of day. So its dimmed at night and full brightness at daytime.
Best would be via a program and command line parameter so I can integrate it into my script,
which launches/exits the audio manager when my car bluetooth stereo/handsfree is connected.
Unfortunately I am no developer and don't know how to write a program like this.
There is an application called PhoneAlarm that will do exactly what you are trying to do. I use it for this purpose on my Cingular 8525 (HTC Tytn).
Sets MANY parameters on the phone by profile and/or time of day. There are lots of skins to minimize or maximize the screen footprint...
Hope that helps.
LightningDammitt said:
There is an application called PhoneAlarm that will do exactly what you are trying to do. I use it for this purpose on my Cingular 8525 (HTC Tytn).
Sets MANY parameters on the phone by profile and/or time of day. There are lots of skins to minimize or maximize the screen footprint...
Hope that helps.
Click to expand...
Click to collapse
Yes, with Tynt. CommMgrPro and many other programs does it too. The problem is HTC Kaiser (Tilt). HTC uses a new system. Classic ways used by many program doesnt work in kaiser
LightningDammitt said:
There is an application called PhoneAlarm that will do exactly what you are trying to do. I use it for this purpose on my Cingular 8525 (HTC Tytn).
Sets MANY parameters on the phone by profile and/or time of day. There are lots of skins to minimize or maximize the screen footprint...
Hope that helps.
Click to expand...
Click to collapse
Thank you for pointing out PhoneAlarm. I have been using PhoneAlarm for a couple of years now and like it very much. But I try to avoid it by doing what I need with Mortscript, because PhoneAlarm really slows down my Kaiser and has some issues with adjusting volume and sometimes switches power of phone when it should switch wifi.
After I spent some time disassembling backlight.exe, I found some usefull information here:
jianwu.spaces.live.com/blog/cns!C80015801668BB53!233.entry?ccr=9532#comment
It saved me a lot of time, as the program I was writing started working fine in minutes.
The problem with the backllight control seems to be common for newer HTC models - mine is Polaris with WM65X from pacrvalho.
make backlight control programm
Hello everybody!
Who can write a programm using the following
Code:
for .NET users (C#, can easily be translated on VB.NET), here are the calling functions :
[DllImport("HTCUtil.dll")]
private static extern int HTCUtilGetOnPowerBrightnessLevel(ref int pValue);
[DllImport("HTCUtil.dll")]
private static extern int HTCUtilGetOnBatteryBrightnessLevel(ref int pValue);
[DllImport("HTCUtil.dll")]
private static extern int HTCUtilSetOnPowerBrightnessLevel(ref int pValue);
[DllImport("HTCUtil.dll")]
private static extern int HTCUtilSetOnBatteryBrightnessLevel(ref int pValue);
[DllImport("HTCUtil.dll")]
private static extern int HTCUtilGetBacklightMinBrightness(ref int pValue);
[DllImport("HTCUtil.dll")]
private static extern int HTCUtilGetBacklightMaxBrightness(ref int pValue);
In program I need the next parameters:
-g (Set somewhere in registry the value of current brighteness level. For example:
HKCU\Software\MyBrightness\OnPower=80,
HKCU\Software\MyBrightness\OnBattery=20)
-p Value (Set OnPower brightness level and set in registry
HKCU\Software\MyBrightness\OnPower=Value)
-b Value (Set OnBattery brightness level and set in registry
HKCU\Software\MyBrightness\OnBattery =Value)
-pr (Set OnPower and OnBattery brightness level in previos state if it's possible)
Thank you beforehand.

Excel VB question: re: Arrays

Hey,
I am working on something for work and it has to do with a simple database (excel file) with data kept in rows. This data is accessed using a userform that looks up a query that happens to be the data kept in the first column of the spreadsheet. Basically, each row contains 46 cells, including the first cell (the query).
I am hoping to use the same userform to search, update, save, print and quit excel. So far search works:
Code:
Sub CommandButton1_Click()
dim query as range
set query = range("A:A")
call readData(query.find(TextBox1, lookat:=xlWhole).row)
End Sub
Private Sub readData(x as integer)
Dim boxes as range
set boxes = range("A:A")
TextBox1 = boxes.cells(x).offset(0,0)
TextBox2 = boxes.cells(x).offset(0,1)
....
End Sub
This works fine for search; however, as there is 45 boxes containing different kinds of data, I would rather read the cells from the spreadsheet using a loop and setting the TextBoxN as a static array:
Code:
Sub readData(x as integer)
***** VB treats array(45) as an array having 46 elements *****
dim textBoxArray(45) as [u]Variant[/u]
set textBoxArray = array(TextBox1, TextBox2... TextBox46)
For i = 1 to 46
textBoxArray(i-1) = cells(x, i)
Next i
End Sub
Note that "query.find(TextBox1, lookat:=xlWhole).row" returns the row number of the query and this is passed as an integer to the readData sub-routine and is referred to as "x".
I would like to do this for the read and then do the same, although opposite for the update (i guess I could call it the 'write' back to the excel worksheet).
The problem is, with this code I get an error that says the array is not declared or arranged (Japanese laptop: 配列は割り当てられません。)
Question 1
Any of you developers with any vb experience know how I can correctly declare my array (would be nice if I could decare the array globally so that I don't have to re-declare it for every sub-routine, and I can just use the for loop in each sub-routine)?
At present, all the code is within the userform and I cannot seem to declare outside of a subroutine:
Code:
Public boxArray(45) as Variant
Sub CommandButton_Click()
...
End Sub
Question 2 SOLVED I removed the "set" from the line where I filled the array with each textbox. Tested it again and all data is flowing correctly. Only need question 1 answered.
Thank you.
Hey all, thanks for the replies; I didn't think the thread would be this popular.
I solved the problem with global variables. Instead of setting a fixed array size in the main code section dec area, I found another way of assigning values to all 46 textboxes.
Instead of:
Code:
Dim boxArray(45) as Variant
boxArray(45) = array(TextBox1, TextBox2, ... TextBox46)
then
Code:
For i = 1 to 46
boxArray(i-1) = cells(x,i)
Next i
I used vb's Control method/function (no array necessary):
Code:
For i = 1 to 46
Control("TextBox" + CStr(i)) = cells(x,i)
Next i
So i turned 46+ lines into 6+ lines into 3 lines.
MODS, this thread may be closed. THanks.

[MOD] Kernel - Display Backlight (WIP): 30 Limit now Removed! Down to 01

This project started becaues at night the Atrix display is far too bright. I've successfully compiled the kernel (faux's) and made some changes to the display driver, and from there I found a world of useful info and hacks which enhance our display.
Kernel Update
I have compiled faux's kernel and attached it to this thread. please note, this is NOT the cyanogen version of the kernel, only standard ROM's that use faux123's kernel. i can compile the cyan kernel next. this kernel change is simple, it defaults both the display and buttons to the lowest 5mA display mode. this way a reboot puts you right into the lowest mode, and you can manually set reg 17 to higher as-needed. reg 17 will stay set until the next next reboot.
NOTE: THIS RAMDISK WAS MINE PULLED FROM THE STOCK ROM "WITH EXTRAS", SO PLEASE IF YOU TRY A DIFFERENT ROM HAVE A NAND BACKUP READY TO RESTORE JUST IN CASE!!! I HAVENT TRIED THE OTHER ROMS.
it is the zImage and Ramdisk, so it is flashed like:
boot into fastboot (volume down and power on, then vol down till fastboot shows, then vol up to select).
Code:
moto-fastboot flash:raw boot zImage ramdisk.gz
sorry it's not a flashable zip. i purposely uses RAR so nobody tries to flash it with CWM.
Update - The brightness limit of 30 has now been removed:
The autobrightness can now go all the way down to 00 even with your stock kernel and ROM. The limit was coming from the frameworks. I've re-compiled the frameworks for the stock ROM and also for Cyan pre-beta 3. There are 2 frameworks attached to this post, stock and cyanogen. download from this post and unzip your correct file for your ROM, and ADB push the files to your phone:
Code:
- boot to recovery
- mount system
adb push framework-res.apk /system/framework/framework-res.apk
adb reboot
Update - Cyanogen Pre Beta 4 frameworks added
unzup and flash with adb shown above.
Here is what is found in the frameworks, under res/values/arrays.xml:
Code:
10
50
100
150
200
700
1300
2000
3000
4000
5000
6000
7000
8000
9000
20
20
34
46
62
81
100
119
137
138
153
170
187
206
221
255
255
255
255
192
128
0
0
0
0
0
0
0
0
0
0
0
I changed the first value in config_autoBrightnessLcdBacklightValues from a 20 to a 2, and now in auto brightness mode the screen goes all the way down to 2.
Update:
We now have the proper official data sheet (link below) thanks to Saltinbas.
Documentation - Data Sheet
Our backlight chip is the lm3532, which is basically same as lm3530 which is used in the moto droid. i've read the entire data sheet twice and still trying to grasp everything. the data sheet can be found here:
http://www.national.com/ds/LM/LM3532.pdf
Not all registers are exactly the same, so some reverse engineering is needed.
Source Code (Kernel)
The relevant kernel source code:
leds-lm3532.c - Driver
leds-lm3532.h - Headers
board-mot-lights.c - Initialization
What I've Tried So Far
The first change I made was in board-mot-lights.c.
Code:
struct lm3532_platform_data lm3532_pdata = {
.flags = LM3532_CONFIG_BUTTON_BL | LM3532_HAS_WEBTOP,
.init = disp_backlight_init,
.power_on = disp_backlight_power_on,
.power_off = disp_backlight_power_off,
.ramp_time = 0, /* Ramp time in milliseconds */
.ctrl_a_fs_current = LM3532_26p6mA_FS_CURRENT,
.ctrl_b_fs_current = LM3532_8p2mA_FS_CURRENT,
.ctrl_a_mapping_mode = LM3532_LINEAR_MAPPING,
.ctrl_b_mapping_mode = LM3532_LINEAR_MAPPING,
.ctrl_a_pwm = 0x82,
};
I changed lines 99 and 100 to this:
Code:
.ctrl_a_fs_current = LM3532_5mA_FS_CURRENT,
.ctrl_b_fs_current = LM3532_5mA_FS_CURRENT,
Success
And bingo, display brightness reduced significantly lower than stock. the display has many different "modes" and I went right to the lowest on the list. Here are the brightness modes which can be found in the header file leds-lm3532.h:
Brightness Config Values (Header File)
Code:
#define LM3532_5mA_FS_CURRENT 0x00
#define LM3532_5p8mA_FS_CURRENT 0x01
#define LM3532_6p6mA_FS_CURRENT 0x02
#define LM3532_7p4mA_FS_CURRENT 0x03
#define LM3532_8p2mA_FS_CURRENT 0x04
#define LM3532_9mA_FS_CURRENT 0x05
#define LM3532_9p8mA_FS_CURRENT 0x06
#define LM3532_10p6mA_FS_CURRENT 0x07
#define LM3532_11p4mA_FS_CURRENT 0x08
#define LM3532_12p2mA_FS_CURRENT 0x09
#define LM3532_13mA_FS_CURRENT 0x0A
#define LM3532_13p8mA_FS_CURRENT 0x0B
#define LM3532_14p6mA_FS_CURRENT 0x0C
#define LM3532_15p4mA_FS_CURRENT 0x0D
#define LM3532_16p2mA_FS_CURRENT 0x0E
#define LM3532_17mA_FS_CURRENT 0x0F
#define LM3532_17p8mA_FS_CURRENT 0x10
#define LM3532_18p6mA_FS_CURRENT 0x11
#define LM3532_19p4mA_FS_CURRENT 0x12
#define LM3532_20p2mA_FS_CURRENT 0x13
#define LM3532_21mA_FS_CURRENT 0x14
#define LM3532_21p8mA_FS_CURRENT 0x15
#define LM3532_22p6mA_FS_CURRENT 0x16
#define LM3532_23p4mA_FS_CURRENT 0x17
#define LM3532_24p2mA_FS_CURRENT 0x18
#define LM3532_25mA_FS_CURRENT 0x19
#define LM3532_25p8mA_FS_CURRENT 0x1A
#define LM3532_26p6mA_FS_CURRENT 0x1B
#define LM3532_27p4mA_FS_CURRENT 0x1C
#define LM3532_28p2mA_FS_CURRENT 0x1D
#define LM3532_29mA_FS_CURRENT 0x1E
#define LM3532_29p8mA_FS_CURRENT 0x1F
Then i discovered that we don't even need to compile a new kernel to access this chip. We have the proper sysfs files already given to us by motorola engineers. here are some useful commands:
Terminal Commands
Use terminal app and navigate to:
Code:
su
cd sys/bus/i2c/drivers/lm3532/0-0038/leds/lcd-backlight
you can set any of the above modes you want. as an example let's say I want to set to maximum brightness mode, use the corresponding hex value in the header file from earlier, and type:
Code:
echo 17 1F > registers
that sets register 0x17 (the brightness register) with value 0x1F (the maximum brightness value from the list).
To set the minimum brightness:
Code:
echo 17 00 > registers
now for those of you who would like to help out with this and test other registers, you can see all register values by typing:
Code:
cat registers
that brings up this:
Code:
OUTPUT_CFG_REG (0x10) = 0xD4
START_UP_RAMP_REG (0x11) = 0xC0
RUN_TIME_RAMP_REG (0x12) = 0xC0
CTRL_A_PWM_REG (0x13) = 0x86
CTRL_B_PWM_REG (0x14) = 0x82
CTRL_C_PWM_REG (0x15) = 0x82
CTRL_A_BR_CFG_REG (0x16) = 0xE3
CTRL_A_FS_CURR_REG (0x17) = 0xFF
CTRL_B_BR_CFG_REG (0x18) = 0xE3
CTRL_B_FS_CURR_REG (0x19) = 0xE4
CTRL_C_BR_CFG_REG (0x1a) = 0xF1
CTRL_C_FS_CURR_REG (0x1b) = 0xF3
ENABLE_REG (0x1d) = 0xFF
FEEDBACK_ENABLE_REG (0x1c) = 0xF9
ALS1_RES_SEL_REG (0x20) = 0xE0
ALS2_RES_SEL_REG (0x21) = 0xE0
ALS_CFG_REG (0x23) = 0x44
ALS_ZONE_REG (0x24) = 0xF0
ALS_BR_ZONE_REG (0x25) = 0xF8
ALS_UP_ZONE_REG (0x26) = 0xF8
ZB1_REG (0x60) = 0x35
ZB2_REG (0x61) = 0x33
ZB3_REG (0x62) = 0x6A
ZB4_REG (0x63) = 0x66
CTRL_A_ZT1_REG (0x70) = 0x51
CTRL_A_ZT2_REG (0x71) = 0x66
CTRL_A_ZT3_REG (0x72) = 0x99
CTRL_A_ZT4_REG (0x73) = 0xCC
CTRL_A_ZT5_REG (0x74) = 0xFF
CTRL_B_ZT1_REG (0x75) = 0x00
CTRL_B_ZT2_REG (0x76) = 0x66
CTRL_B_ZT3_REG (0x77) = 0x99
CTRL_B_ZT4_REG (0x78) = 0xCC
CTRL_B_ZT5_REG (0x79) = 0xFF
CTRL_C_ZT1_REG (0x7a) = 0x33
CTRL_C_ZT2_REG (0x7b) = 0x66
CTRL_C_ZT3_REG (0x7c) = 0x99
CTRL_C_ZT4_REG (0x7d) = 0xCC
CTRL_C_ZT5_REG (0x7e) = 0xFF
VERSION_REG (0xcc) = 0xE4
You can set any register XX with any value YY as follows:
Code:
echo XX YY > registers
additional knowledge i've learned so far. Ctrl A is the main display. Ctrl B is the bottom buttons. Ctrl C is webtop. So all we really care about are Ctrl A registers for now.
Additional Info
The display is set to linear mapping mode by default. but changing to exponential mapping mode gives a huge range from minimum to maximum brightness. but it's still not ready for primetime. to try out exponential, type:
Code:
echo 16 01 > registers
now go to your main phone settings, display, brightness, and drag the slider from min to max and see the enormous full range now available. dont worry, to reset exponential mode just lock the screen with power button then unlock, exponential mode gets cleared. that can be fixed later in the kernel when we get it working better.
just setting to minimum brightness alone gives a huge increase in battery life for display-on time, specifically at night. there's more potential to get out of this chip so hopefully you guys can dig up more stuff that i'm missing.
at some point I can compile the kernel with any changes discovered from this thread, and perhaps we can merge the code changes back into the kernel repo if faux doesn't mind.
Problem 1
I don't fully understand the meaning of the header file brightness values. The names list current mA values, that is clear. but there are also other info in the name which I don't understand yet.
similarly, in the data sheet, they give detailed examples of how to calculate the current draw of each brightness mode, and walk thru setting up the general configuration register. i've been reverse engineering the registers by looking at the data sheet, seeing each 8 bits and what they are assigned, then using appropriate hex value to turn off and on each of those bits in the output config reg. i echo a value, and see the result. most of the time it matches the data sheet, but not always.
Problem 2
There are also 4 boundary zones which trigger the backlight to adjust it's brightness. i've attempted to set these boundaries to different values, but so far i've not had any success with this.
Problem 3
Before this all started, no matter what the display brightness only goes down to 30 from a range of 0-255. even changing all the modes i've listed above, in every one it stops at 30. you can check brightness level by:
Code:
cat brightness
I'm stumped on where the 30 limit is coming from.
Ultimately, we can permanently change the following code in board-mot-lights.c to whatever desired values we want to be in the kernel permanently:
Code:
struct lm3532_platform_data lm3532_pdata = {
.flags = LM3532_CONFIG_BUTTON_BL | LM3532_HAS_WEBTOP,
.init = disp_backlight_init,
.power_on = disp_backlight_power_on,
.power_off = disp_backlight_power_off,
.ramp_time = 0, /* Ramp time in milliseconds */
.ctrl_a_fs_current = LM3532_26p6mA_FS_CURRENT,
.ctrl_b_fs_current = LM3532_8p2mA_FS_CURRENT,
.ctrl_a_mapping_mode = LM3532_LINEAR_MAPPING,
.ctrl_b_mapping_mode = LM3532_LINEAR_MAPPING,
.ctrl_a_pwm = 0x82,
};
And a companion app could also be made to automate the setting of these registers and such.
last thing, above notice the PWM value being set to 0x82. this is pulse width modulation mode, and is a significant power saving method in electronics. fortunately this is turned on by default, which is what the value 0x82 is doing. i've experimented turning it off and on for the hell of it.
hope some experts can join in this thread and see how far it goes. any questions feel free to ask.
Curious about the difference between software modification (screen brightness apps) and kernel modification (for brightness)
Excellent I like tinkerers and thanks for info so far
Magnetox said:
Curious about the difference between software modification (screen brightness apps) and kernel modification (for brightness)
Click to expand...
Click to collapse
Well this project is both kernel and could use an app to control the registers. But primarily this is to make kernel changes for now.
is this able to lower the brightness to BELOW the '2' setting? that's as low as AdjBrightness app lets me go, and also doesn't allow me to dim the home buttons. it would be nice to be able to dim the buttons at least, especially if watching a movie or something in the dark.
dLo GSR said:
is this able to lower the brightness to BELOW the '2' setting? that's as low as AdjBrightness app lets me go, and also doesn't allow me to dim the home buttons. it would be nice to be able to dim the buttons at least, especially if watching a movie or something in the dark.
Click to expand...
Click to collapse
Yes this can absolutely dim the buttons, anywhere from off to full brightness. Just echo to ctrl B register.
I'm not aware of the display app you mentioned. Does it do all the things I already listed in this thread? If so I feel dumb, I've not heard of the app you said.
Edit: I see that app in the market. This thread is specific to the atrix kernel, so it offers much more control. Activate exponential mapping mode and the display brightness goes down so low you wont even believe it. We'd then maybe make an app to automate it.
Forgive my ignorance, but the app SuperDim changes the brightness on my Atrix. Perhaps you guys are talking about something else though?
The lowest brightness setting is still much too bright to enjoy my Atrix in the dark (lol). The wife gets pissed... but this app definitely works.
Very cool!
'cat registers' only works when display is on. I'll have to see if an app can be done that doesn't have to fight the system.
Cheers!
or you could get an app called screen filter which does all this o.o
xepter said:
or you could get an app called screen filter which does all this o.o
Click to expand...
Click to collapse
Well, no, actually.
Hopefully something similiar to this, kernel maybe, all contains settings for the touch screen(digitizer)and we can alleviate the pesky rain drop detection issue.
A little late for me to start playing with this, maybe tomorrow!
Thanks
Sent from my MB860 using xda premium
what this is doing is reducing the current sent to the backlight to dim it.
Screen filter doesnt reduce current to the backlight past the stock minimum limit. It just puts a transparent "mask" over the display with the opacity depending on your setting, done entirely in software.
m0biusace said:
what this is doing is reducing the current sent to the backlight to dim it.
Screen filter doesnt reduce current to the backlight past the stock minimum limit. It just puts a transparent "mask" over the display with the opacity depending on your setting, done entirely in software.
Click to expand...
Click to collapse
Yes you bring up my next point, this isn't just brightness. This let's us reduce the current draw pulled by the display, and a good amount at that if you read the data sheet and look at the registers.
Additionally this let's us set and change the zone boundaries of the light sensor. It let's us change mapping mode between linear and exponential.
It also let's us control PWM, though that should just stay on all the time. Also there is ramp time register, which is set to zero by Motorola, so that might be useful.
Also there is the brightness config reg, full scale current reg, and general output config reg. All these look to have purpose needed to be tested.
There are many registers to tweak which gives us control, and that's the goal of this thread I think. Once we crack it all open then we can make permanent kernel changes if we want. Or an app would work. I think we could do something crazy like double screen time by finding optimal combo of reg settings, e.g. set min brightness mode with exponential mapping mode, then adjust the zone boundaries slightly,and it literally could give huge display savings for power. At least worth testing to see.
faux123 said:
Excellent I like tinkerers and thanks for info so far
Click to expand...
Click to collapse
Dude thank you for letting me compile your kernel. Much appreciated! And tinkering is what's fun about android!
some interesting behavior here:
lowest brightness in Stock 2.3.4 is "20", you can adjust to "2" by using app "adjbrightness", while you can set brightness lower to "1" in "moboplayer".
Even though, the "1" brightness is not good enough.
I'm wondering if this MOD can make brightness lower than "1"?
NFHimself said:
Very cool!
'cat registers' only works when display is on. I'll have to see if an app can be done that doesn't have to fight the system.
Cheers!
Click to expand...
Click to collapse
Yeah the driver is overriding some things, we could easily fix the code though. For example if you change the gen config reg to activate a different mode, soon as screen goes off locked the register is set back to previous value cause its hard coded. We just change that. So during testing I just keep the screen on.
I do have a battery app which does the echo and cat commands already written. Could just change the path and use it for this project...
kenyloveg said:
some interesting behavior here:
lowest brightness in Stock 2.3.4 is "20", you can adjust to "2" by using app "adjbrightness", while you can set brightness lower to "1" in "moboplayer".
Even though, the "1" brightness is not good enough.
I'm wondering if this MOD can make brightness lower than "1"?
Click to expand...
Click to collapse
Yes. Just enable exponential mapping mode, then use the slider in main display setting to see the full range.
echo 16 01 > registers
Be ready, super dim with that setting. Note still even with that being much lower brightness, the actual brightness value still wont go lower than 30. I can't figure out why.
SuperDim
As member bongd mentions already, SuperDim does the thing, free on the Market. I've pressed thanks button to show appreciation to the OP's efforts.
maajstor said:
As member bongd mentions already, SuperDim does the thing, free on the Market. I've pressed thanks button to show appreciation to the OP's efforts.
Click to expand...
Click to collapse
Superdim does not allow the brightness to even get close to the minimum level that the screen does by setting the registers. Testing is needed and that's kinda the point here.
So the lm3532 chip has brightness capabilities from 5mA up to 29the mA. Stock value in the kernel is set to very high at 26 mA. So just setting the lowest brings the current draw to 5 mA. The data sheet then shows the equation gives final result of close to 0.78 mA with all set properly. So there's savings to be had which is what needs to be tested here.
As an example, last night I changed to the lowest register setting, and after an hour of web screen-on time I was still at 86%the battery still.
maajstor said:
As member bongd mentions already, SuperDim does the thing, free on the Market. I've pressed thanks button to show appreciation to the OP's efforts.
Click to expand...
Click to collapse
Wow! You guys just aren't getting it. The apps you find in the market do not do the same thing. "Yes in the aspect they dim the screen" but they do it in to completely different ways. The way the op is talking about could add hours of battery life to are phones if done right. Because it changes how much power the display uses. There is not an app in the market or out that does that.

how does boolean logic works on vaarible value context?

Hi,
I've searching on the web but with no luck so far.
As you know, variable value context has the option to add several conditions linked by AND/OR/XOR operations. So we can have something like
If %var1~val1 AND %var2~val2 OR %var3~val3
Since boolean operators are binary, my question is how are they grouped? Since (P AND Q) OR R is different than P AND (Q OR R)...
Regards,
You determine grouping by how you write your code.
If (P and Q) or R:
If P & Q
Do something
Else If R
Do something
End If
Or....
If P
If Q
Do something
End If
Else If R
Do something
End If
If P and (Q or R):
If P
If Q
Do something
Else If R
Do something
End If
End If
Or....
If P & Q
Do something
Else If P & R
Do something
End If
..... You might also find matching Regex useful.
Hi,
this works inside a task, but my question is how is P OR Q AND R interpreted in a variable value context, where we only have the if (no else) and only one if.
Regards,
Single conditions consist of a left-hand side (usually a variable name), an operator and a right-hand-side for example %number, Equals, 1 indicates that the action will be executed if the variable %number has the value 1.
When more than one condition is specified, they must be combined via And (all conditions must be true), Or (at least one condition must be true) or Xor (exactly one must be true). These 'combiners' are called boolean operators.
Usually, 2 or 3 conditions will be combined with all Ands or all Ors, but in order to allow more complicated logic, Tasker also offers And and Or in high-precedence versions. Of the 4 boolean operators which are available, the selection goes from low to high precedence ones.
The higher the precedence of a boolean operator, the further to the right it is shown. This enables the logical groups to be visualised.
Examples:
True | False & True | False is the same as ( True | False ) & ( True | False ) so is True.
True & False | True & False is the same as True & ( False | True ) & False so is False.
True & False | True |+ False is the same as True & ( False | ( True | False ) ) so is True.
Note that the order of the conditions can mean that some conditions are never evaluated. For instance, when two conditions are present and the one above an And is false then the condition below it will never be evaluated. This can be advantageous if the second condition takes relatively more resources e.g. involves matching against a lot of text.
hello, so if i'm getting this right, P & Q | R would be P&(Q|R)?

Null value

I am trying to determine if it is a variable is null. Currently if I have a variable %car it will return "ford". However if it is empty the variable will return as a string %car. How do I turn that into a null value or have tasker recognize it should treat it as null.
qwertnard said:
I am trying to determine if it is a variable is null. Currently if I have a variable %car it will return "ford". However if it is empty the variable will return as a string %car. How do I turn that into a null value or have tasker recognize it should treat it as null.
Click to expand...
Click to collapse
That is by design. If you test for "not set", it will be TRUE when %car = %car and FALSE when %car = ford.
Uninitialized Variables
User-variables which have not had a value assigned do not have replacements carried out e.g. in the expression I love %fruit, if %fruit is uninitialized, the expression remains as it is, otherwise %fruit is replaced with the value.
Exception: uninitialized variables used in mathematical expressions are replaced with 0.

Categories

Resources