Python Forum
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LED control menu
#19
i think i understand, could you help me with the code?
youve been a great help so far
really is appreciated

just tried this, i dont get errors but cant turn the gpio to true
class Lightcontrol(MenuOption):
    """Control; Lights"""
    def __init__(self):
        self.last = self.millis()
        MenuOption.__init__(self)

    def redraw(self, menu):
        menu.write_row(1,"Turn Lights On?")

        if nav.BUTTON - self.last < 1000 * 5:
            return False
        a = handle_on(self)

    def handle_On(self):
        GPIO.output(13,0)
        GPIO.output(5,0)
        GPIO.output(13,1)
        return
        print('ON! Doing monkey stuff!')
        time.sleep(2)
        print('Done monkey stuff!')
         
 
    def handle_Off():
        GPIO.output(5,0)
        GPIO.output(13,0)
        GPIO.output(5,1)
        print("OFF! Doing donkey stuff!")
        time.sleep(2)
        print("Done donkey stuff!")


     
"""
Using a set of nested lists you can describe
the menu you want to display on dot3k.
 
Instances of classes derived from MenuOption can
be used as menu items to show information or change settings.
 
See GraphTemp, GraphCPU, Contrast and Backlight for examples.
"""

LC = Lightcontrol() 
 
menu = Menu(
    structure={
            'Power Options': {
                'Reboot':GraphSysReboot(),
                'Shutdown':GraphSysShutdown(),
                },
            'Aquarium': {
                'Lighting': {
                    'Control': {
                        'On': LC,
                        }
                    }
                },
        'Clock': Clock(backlight),
        'Status': {
            'IP': IPAddress(),
            'CPU': GraphCPU(backlight),
            'Temp': GraphTemp()
        },
        'Settings': {
            'Display': {
                'Contrast': Contrast(lcd),
                'Backlight': Backlight(backlight)
            }
        }
    },
    lcd=lcd,
    idle_handler=Lightcontrol,
    idle_timeout=30,
    input_handler=Text())
 
"""
You can use anything to control dot3k.menu,
but you'll probably want to use dot3k.touch
"""
nav.bind_defaults(menu)
 
while 1:
    menu.redraw()
    time.sleep(0.05)
Reply


Messages In This Thread
LED control menu - by trippyt - May-31-2018, 06:43 AM
RE: LED control menu - by wavic - May-31-2018, 06:59 AM
RE: LED control menu - by trippyt - May-31-2018, 01:55 PM
RE: LED control menu - by trippyt - May-31-2018, 07:22 AM
RE: LED control menu - by wavic - May-31-2018, 09:27 AM
RE: LED control menu - by trippyt - May-31-2018, 11:58 AM
RE: LED control menu - by wavic - May-31-2018, 12:02 PM
RE: LED control menu - by trippyt - May-31-2018, 12:10 PM
RE: LED control menu - by wavic - May-31-2018, 12:49 PM
RE: LED control menu - by wavic - May-31-2018, 02:30 PM
RE: LED control menu - by trippyt - May-31-2018, 02:40 PM
RE: LED control menu - by wavic - May-31-2018, 03:19 PM
RE: LED control menu - by trippyt - May-31-2018, 03:35 PM
RE: LED control menu - by wavic - May-31-2018, 03:42 PM
RE: LED control menu - by trippyt - May-31-2018, 03:51 PM
RE: LED control menu - by wavic - May-31-2018, 04:02 PM
RE: LED control menu - by trippyt - May-31-2018, 04:13 PM
RE: LED control menu - by wavic - May-31-2018, 04:47 PM
RE: LED control menu - by trippyt - May-31-2018, 04:53 PM
RE: LED control menu - by wavic - May-31-2018, 05:18 PM
RE: LED control menu - by trippyt - May-31-2018, 05:45 PM
RE: LED control menu - by trippyt - May-31-2018, 06:58 PM
RE: LED control menu - by wavic - May-31-2018, 07:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Remote control of the Visual Studio 2013 debug menu using Python MariusTo 0 2,511 Jan-17-2018, 04:58 PM
Last Post: MariusTo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020