A4000IS porting thread - page 3 - DryOS Development - CHDK Forum

A4000IS porting thread

  • 205 Replies
  • 71055 Views
Re: A4000IS porting thread
« Reply #20 on: 06 / March / 2013, 16:31:00 »
Advertisements
The battery just ran out of juice, so I'll have to do this later after it is charged.  I don't know what I'm doing in lua or chdkptp console/exec input, so I needed the time to learn anyway.

Somewhat later...
I've been trying but I can't make this work.  I cut'n'pasted the commands into the Execute box, but none of them are recognized.  Here's what I got:

> call_event_proc('Driver.Create')
error: unknown command 'call_event_proc'
> =call_event_proc('Driver.Create')
error: :80: attempt to call global 'call_event_proc' (a nil value)
user code: 1
> camera_set_led(8,1,60)
error: unknown command 'camera_set_led'
> =camera_set_led(8,1,60)
error: :80: attempt to call global 'camera_set_led' (a nil value)
user code: 1

So, it's clear that I don't know what I'm doing.  What commands should I be typing into the input box?  Or is there some option I need to enable on the camera?
« Last Edit: 07 / March / 2013, 00:30:20 by rkomar »

*

Offline reyalp

  • ******
  • 14080
Re: A4000IS porting thread
« Reply #21 on: 07 / March / 2013, 01:53:50 »
Or is there some option I need to enable on the camera?
You need to enable lua 'native calls' to sue call_event_proc. In trunk builds, this can be done under the misc menu. In earlier versions, it needs to be enabled at compile time.
Quote
> =camera_set_led(8,1,60)
error: :80: attempt to call global 'camera_set_led' (a nil value)
The correct script function name is set_led, not camera_set_led. A handy list of script functions can be found here http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page

To call functions on the camera, = is the correct syntax in chdkptp. For things like call_event_proc that can return a value, you probably want to use
=return call_event_proc('Driver.Create')
so you can see the return value. For event procs, -1 usually means the function isn't registered or doesn't exist.

Don't forget what the H stands for.

Re: A4000IS porting thread
« Reply #22 on: 07 / March / 2013, 03:38:43 »
Ah, thanks for the extra details.  I looked around the miscellaneous menu, but didn't see anything there about native calls.  I'd been running the stable 1.1.0 version of CHDK, so I switched to the 1.2.0 developer's version, and saw that menu item there.  I enabled it, and was able to make those call_event_proc and set_led calls after that without generating errors.

What I found was that set_led didn't seem to do anything, but call_event_proc('LEDDrive',X,Y) did.  I can only see two LEDs on the camera (one on the front face and one on the back).  Using call_event_proc('LEDDrive',0,0) turned on the back green LED, and call_event_proc('LEDDrive',0,1) turned it off.  I could turn the front red LED on and off the same way but with the LED_NUM set to any of 4, 5 or 6.  In all cases, the VALUE '0' turned it on and '1' turned it off.  None of the other LED_NUM values between 1 and 10 had any effect.  I tried adding a third parameter for brightness for the ON commands, but it didn't seem to have any effect when I varied it between 0 and 200.

*

Offline nafraf

  • *****
  • 1308
Re: A4000IS porting thread
« Reply #23 on: 07 / March / 2013, 09:52:12 »
What I found was that set_led didn't seem to do anything, but call_event_proc('LEDDrive',X,Y) did.
camera_set_led() was disabled, it has a return at first line.

Quote
I can only see two LEDs on the camera (one on the front face and one on the back).  Using call_event_proc('LEDDrive',0,0) turned on the back green LED, and call_event_proc('LEDDrive',0,1) turned it off. 
OK, it's the expected behavior.

Quote
I could turn the front red LED on and off the same way but with the LED_NUM set to any of 4, 5 or 6.  In all cases, the VALUE '0' turned it on and '1' turned it off.  None of the other LED_NUM values between 1 and 10 had any effect.  I tried adding a third parameter for brightness for the ON commands, but it didn't seem to have any effect when I varied it between 0 and 200.
Your test confirmed LED address indexes for led_table, I'll submit the patch.
Thanks


Re: A4000IS porting thread
« Reply #24 on: 07 / March / 2013, 12:00:21 »
I was a bit surprized that it was 0 - on and 1- off, because the CHDK_Scripting_Cross_Reference_Page for set_led states that it's the other way around.  Since set_led didn't work for me, I can't test to see if that's how it works with that function.  Perhaps someone else can check to see that the documentation is correct.

*

Offline nafraf

  • *****
  • 1308
Re: A4000IS porting thread
« Reply #25 on: 07 / March / 2013, 13:09:26 »
Please test set_led with this version
0 LED is off 1 LED is on

Values translation is done here:
Code: [Select]
void camera_set_led(int led, int state, int bright) {
    static char led_table[2]={0,4};
    if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
}

EDIT: Attachment deleted, download latest version from autobuild server.
« Last Edit: 12 / March / 2013, 01:28:45 by nafraf »

Re: A4000IS porting thread
« Reply #26 on: 07 / March / 2013, 13:58:28 »
It seems to work fine.  Any even LED_VALUE controls the green back LED, and any odd one the red/orange front LED.  The value 0 turns it off and 1 turns it on.  The brightness control works on the front led (I tried values of 10, 20, 30, 50, 100, 200 and each was brighter than the last).  The back green led is not affected by the brightness setting (not even setting it to 0).

trying the 101a zip
« Reply #27 on: 08 / March / 2013, 11:12:34 »
I ve already downloaded the 101a    , installed on sd card  and tryit on the cam.
Please keep in mind that I m very new at this.

The app started ... trying to discribe the process.........the logo was displayed like only the top half , I mean only the wheels, the bottom half of the logo appeard in white ,

Right now I am seeing on the display more things ,starting from the upper left corner, like reading a book

availlable free megabites, batery icon in colour, clock, battery porcentage, opt 31 degrees I think,and some white bar very thin almost on the bottom left edge.

I have like 4 scripts working ,,, not always,,,,    I mean that I can use a live histogram , I zebra histogram ,the ovverides thing, 

the main problem in my case        is that i m not able to find or use the alt button



Thank you  for your work, and forgive my manor of speaking , I really need some sleep


*

Offline nafraf

  • *****
  • 1308
Re: A4000IS porting thread
« Reply #28 on: 08 / March / 2013, 11:28:06 »
the main problem in my case        is that i m not able to find or use the alt button
I'll send you a private message with the link to a new version.  Please test it and report.

this is big stuff
« Reply #29 on: 08 / March / 2013, 13:06:57 »
Thank u ........... Now the alt menu is working...... wow
I will bring the stuff with me at work
I ts not bad at all!

 

Related Topics