From 46e1f26615a75c6dafe87c82c9ab641eec39acb9 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 21 Apr 2014 18:28:23 +0100 Subject: [PATCH] stmhal, usrsw: Update comments for new switch API. --- stmhal/usrsw.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/stmhal/usrsw.c b/stmhal/usrsw.c index fd90aaf2a1..088b53ad18 100644 --- a/stmhal/usrsw.c +++ b/stmhal/usrsw.c @@ -14,19 +14,15 @@ // Usage Model: // -// pyb.switch() returns True if the user switch is pressed, False otherwise. -// -// pyb.switch(callback) will register a callback to be called when the user -// switch is pressed. -// -// pyb.switch(None) will remove the callback. +// sw = pyb.Switch() # create a switch object +// sw() # get state (True if pressed, False otherwise) +// sw.callback(f) # register a callback to be called when the +// # switch is pressed down +// sw.callback(None) # remove the callback // // Example: // -// def switch_pressed(): -// print("User Switch pressed") -// -// pyb.switch(switch_pressed) +// pyb.Switch().callback(lambda: pyb.LED(1).toggle()) // this function inits the switch GPIO so that it can be used void switch_init0(void) {