-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because `mp_tracked_calloc` does not survive a soft reset but the memory region will, resulting in half-initialised frankenclasses that behave unpredictably. Using the class pattern fixes this since it's always guaranteed to be initialised when a user instantiates it, and __del__ can handle cleanup.
- Loading branch information
Showing
6 changed files
with
141 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import time | ||
import picokeypad as keypad | ||
import picokeypad | ||
|
||
keypad.init() | ||
keypad = picokeypad.PicoKeypad() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Gadgetoid
Author
Member
|
||
keypad.set_brightness(1.0) | ||
|
||
lit = 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
// Include MicroPython API. | ||
#include "py/runtime.h" | ||
|
||
extern const mp_obj_type_t PicoKeypad_type; | ||
|
||
// Declare the functions we'll make available in Python | ||
extern mp_obj_t picokeypad_init(); | ||
extern mp_obj_t picokeypad_get_width(); | ||
extern mp_obj_t picokeypad_get_height(); | ||
extern mp_obj_t picokeypad_get_num_pads(); | ||
extern mp_obj_t picokeypad_update(); | ||
extern mp_obj_t picokeypad_set_brightness(mp_obj_t brightness_obj); | ||
extern mp_obj_t picokeypad_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); | ||
extern mp_obj_t picokeypad___del__(mp_obj_t self_in); | ||
extern mp_obj_t picokeypad_get_width(mp_obj_t self_in); | ||
extern mp_obj_t picokeypad_get_height(mp_obj_t self_in); | ||
extern mp_obj_t picokeypad_get_num_pads(mp_obj_t self_in); | ||
extern mp_obj_t picokeypad_update(mp_obj_t self_in); | ||
extern mp_obj_t picokeypad_set_brightness(mp_obj_t self_in, mp_obj_t brightness_obj); | ||
extern mp_obj_t picokeypad_illuminate_xy(mp_uint_t n_args, const mp_obj_t *args); | ||
extern mp_obj_t picokeypad_illuminate(mp_uint_t n_args, const mp_obj_t *args); | ||
extern mp_obj_t picokeypad_clear(); | ||
extern mp_obj_t picokeypad_get_button_states(); | ||
extern mp_obj_t picokeypad_clear(mp_obj_t self_in); | ||
extern mp_obj_t picokeypad_get_button_states(mp_obj_t self_in); |
this version is not running in Thonny
AttributeError: 'module' object has no attribute 'RGBKeypad'
I tried the previous version and it worked well.