[web2py] Need help displaying value from the controller to view

2015-04-10 Thread DXX
Hi all, 

Im really new to coding and im trying to do a little project for learning 
purposes.  Im controlling some leds attached to a raspberry pi.

Currently this is code im using to turn on the GPIO22:

*on default.py*

def index():
return dict(message='LED Test - Main Menu')


def redon():
pinstatus=GPIO.input(22)
GPIO.output(22,GPIO.HIGH)

*on the default/index.html *

{{extend 'layout.html'}}

html
header/header
body
h1font color=redRed/font/h1
button onclick=ajax('redon',[],null);
{{=T('Turn On')}}
/button
/body
/html

When i press the Turn on button it will turn the led attached to the 
GPIO22. 

What i would like to do its to display the pinstatus value on the 
index.html.  The value will be either 0 or 1  ... so i would like to see 
something like this when i load the html  .   Status:  0/1

Can anyone shed some light.   Thanks,


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Dumb Question - from a real beginner

2015-04-10 Thread DXX
Richard thanks,  

I followed your instructions and i get the button now, which is great, but 
once i press it nothing happens. It is suppose to turn on a led connected 
to GPIO22 but it doenst do it.  Any ideas?  i dont really have knowledge of 
web programming and maybe im just way out of my league but any advice on 
this will be greatly appreciate it.

Thanks

On Thursday, April 9, 2015 at 8:42:24 AM UTC-5, Richard wrote:

 In default/index.html view try something like this :

 button onclick=ajax('btnon',[],null);
 {{=T('Name of your button')}}
 /button

 Richard

 On Wed, Apr 8, 2015 at 8:39 PM, DXX dxxp...@gmail.com javascript: 
 wrote:

 So im just starting with Python / Web2py  i want to do a simple test 
 page to have a button to turn on a led on a RPi...

 the default.py looks like this 

 import RPi.GPIO as GPIO

 def index():
 return dict(message=this is a test)

 def btnon():
 GPIO.setmode(GPIO.BCM)
 GPIO.setup(22, GPIO.OUT)
 GPIO.output(22,GPIO.HIGH)


 What i would like to do is call that btnon on an event, like a click on 
 something to make it exectute the commands if this something i can do 
 on a simple way, if you can guide me, i will be greatly appreciated

  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Dumb Question - from a real beginner

2015-04-09 Thread DXX
So im just starting with Python / Web2py  i want to do a simple test 
page to have a button to turn on a led on a RPi...

the default.py looks like this 

import RPi.GPIO as GPIO

def index():
return dict(message=this is a test)

def btnon():
GPIO.setmode(GPIO.BCM)
GPIO.setup(22, GPIO.OUT)
GPIO.output(22,GPIO.HIGH)


What i would like to do is call that btnon on an event, like a click on 
something to make it exectute the commands if this something i can do 
on a simple way, if you can guide me, i will be greatly appreciated

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.