10000 Merge pull request #5 from mwelling/master · acamilo/micropython@e356d70 · GitHub
[go: up one dir, main page]

Skip to content

Commit e356d70

Browse files
authored
Merge pull request #5 from mwelling/master
More awesome updates
2 parents bf58466 + 274d735 commit e356d70

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

ports/esp32/machine_touchpad.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,17 @@ STATIC mp_obj_t mtp_callback(mp_obj_t self_in, mp_obj_t callback) {
129129
}
130130
MP_DEFINE_CONST_FUN_OBJ_2(mtp_callback_obj, mtp_callback);
131131

132+
STATIC mp_obj_t mtp_wake_reason(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
133+
return MP_OBJ_NEW_SMALL_INT(esp_sleep_get_touchpad_wakeup_status());
134+
}
135+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mtp_wake_reason_obj, 0, mtp_wake_reason);
136+
132137
STATIC const mp_rom_map_elem_t mtp_locals_dict_table[] = {
133138
// instance methods
134139
{ MP_ROM_QSTR(MP_QSTR_config), MP_ROM_PTR(&mtp_config_obj) },
135140
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mtp_read_obj) },
136141
{ MP_ROM_QSTR(MP_QSTR_callback), MP_ROM_PTR(&mtp_callback_obj) },
142+
{ MP_ROM_QSTR(MP_QSTR_wake_reason), MP_ROM_PTR(&mtp_wake_reason_obj) },
137143
};
138144

139145
STATIC MP_DEFINE_CONST_DICT(mtp_locals_dict, mtp_locals_dict_table);

ports/esp32/modules/gxgde0213b1.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def __init__(self, reset, dc, busy, cs):
3030
self.height = EPD_HEIGHT
3131
self.rotate = ROTATE_0
3232

33+
def __del__(self):
34+
self.spi.deinit()
35+
3336
def free(self):
3437
self.spi.deinit()
3538

@@ -274,17 +277,17 @@ def draw_custom_font_char(self,frame_buffer,x,y,size,char,font,color):
274277
xx = 0
275278
while (xx<w):
276279
#
277-
bit += 1
278280
if (bit%8 == 0):
279-
bo += 1
280281
bits = font.Bitmaps[bo]
282+
bo += 1
281283
if (bits&0x80 == 0x80):
282284
if size==1:
283285
self.set_pixel(frame_buffer,x+xo+xx,y+yo+yy,color)
284286
else:
285287
xp = x + (xo16 + xx) * size
286288
yp = y + (yo16 + yy) * size
287289
self.draw_filled_rectangle(frame_buffer,xp,yp,size, size, color)
290+
bit += 1
288291
bits = bits<<1
289292
xx += 1
290293
yy += 1

ports/esp32/modules/ohsbadge.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import ubinascii
1010
import urandom
1111
import machine
12+
import time
1213
from microWebSrv import MicroWebSrv
1314

1415
#initialize the epaper
@@ -105,11 +106,20 @@ def _httpHandlerTestPost(httpClient, httpResponse) :
105106
goto_deepsleep()
106107

107108
def goto_deepsleep():
108-
#go to deepsleep wait for user to press the send button
109-
button = machine.TouchPad(machine.Pin(33))
110-
reading = button.read()
111-
button.config(int(2/3 * reading))
112-
button.callback(lambda t:print("Pressed"))
109+
#go to deepsleep wait for user to press one of the buttons
110+
button1 = machine.TouchPad(machine.Pin(33))
111+
time.sleep_ms(100)
112+
reading = button1.read()
113+
button1.config(int(2/3 * reading))
114+
button1.callback(lambda t:print("Pressed 33"))
115+
116+
button2 = machine.TouchPad(machine.Pin(32))
117+
time.sleep_ms(100)
118+
reading = button1.read()
119+
reading = button2.read()
120+
button2.config(int(2/3 * reading))
121+
button2.callback(lambda t:print("Pressed 32"))
122+
113123
machine.deepsleep()
114124

115125
def start_web_server():
@@ -128,10 +138,16 @@ def start():
128138
epd.display_frame(fb)
129139

130140
if machine.wake_reason() == machine.TOUCHPAD_WAKE:
131-
#go into AP mode
132-
#TODO add support for detecting which button cause the wakeup
133-
start_ap_mode()
134-
start_web_server()
141+
if machine.TouchPad.wake_reason() == 9:
142+
#go into AP mode
143+
#TODO add support for detecting which button cause the wakeup
144+
start_ap_mode()
145+
start_web_server()
146+
else:
147+
epd.clear_frame(fb)
148+
epd.display_string_at(fb, 0, 0, "OHS 2018", font24, gxgde0213b1.COLORED)
149+
epd.display_string_at(fb, 0, 24, "Serial REPL Mode", font16, gxgde0213b1.COLORED)
150+
epd.display_frame(fb)
135151
else:
136152
goto_deepsleep()
137153

0 commit comments

Comments
 (0)
0