Skip to content

Commit 17ecbb3

Browse files
committed
Merge branch 'master' of github.com:SHA2017-badge/micropython-esp32
2 parents c96e4f5 + fea2d8e commit 17ecbb3

File tree

7 files changed

+28
-14
lines changed

7 files changed

+28
-14
lines changed

esp32/modugfx.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ uint8_t target_lut;
6262

6363
typedef struct _ugfx_obj_t { mp_obj_base_t base; } ugfx_obj_t;
6464

65+
extern bool ugfx_screen_flipped;
6566
static orientation_t get_orientation(int a){
6667
if (a == 90)
6768
return GDISP_ROTATE_90;
@@ -146,11 +147,19 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(ugfx_get_lut_obj, ugfx_get_lut);
146147
STATIC mp_obj_t ugfx_set_orientation(mp_uint_t n_args, const mp_obj_t *args) {
147148
if (n_args > 0){
148149
int a = mp_obj_get_int(args[0]);
150+
a %= 360;
151+
if (a >= 180) {
152+
ugfx_screen_flipped = true;
153+
a -= 180;
154+
}
149155
gdispSetOrientation(get_orientation(a));
150-
151156
}
152157

153-
return mp_obj_new_int(gdispGetOrientation());
158+
int a = gdispGetOrientation();
159+
if (ugfx_screen_flipped)
160+
a += 180;
161+
a %= 360;
162+
return mp_obj_new_int(a);
154163
}
155164
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ugfx_set_orientation_obj, 0, 1, ugfx_set_orientation);
156165

esp32/modules/badge_event_reminder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def exit(p):
1111
ugfx.string(0, 25+13*2, "some nice numbers and an overview of what all", "Roboto_Regular12", ugfx.BLACK)
1212
ugfx.string(0, 25+13*3, "of you are doing with it.", "Roboto_Regular12", ugfx.BLACK)
1313

14-
ugfx.string(0, 25+13*5, "The events starts now, in room 'No'!", "Roboto_Regular12", ugfx.BLACK)
14+
ugfx.string(0, 25+13*5, "The events starts now, in room 'Pa'!", "Roboto_Regular12", ugfx.BLACK)
1515
ugfx.string(0, ugfx.height()-13, "Press any key to close reminder.", "Roboto_Regular12", ugfx.BLACK)
1616
ugfx.set_lut(ugfx.LUT_FULL)
1717
ugfx.flush()

esp32/modules/easydraw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ def nickname(y = 25, font = "PermanentMarker36", color = ugfx.BLACK):
3939
nick = badge.nvs_get_str("owner", "name", 'Henk de Vries')
4040
ugfx.string_box(0,y,296,38, nick, font, color, ugfx.justifyCenter)
4141

42-
def battery(vUsb, vBatt, charging):
42+
def battery(on_usb, vBatt, charging):
4343
vMin = badge.nvs_get_u16('batt', 'vmin', 3500) # mV
4444
vMax = badge.nvs_get_u16('batt', 'vmax', 4100) # mV
45-
if charging and vUsb>4000:
45+
if charging and on_usb:
4646
try:
4747
badge.eink_png(0,0,'/lib/resources/chrg.png')
4848
except:
4949
ugfx.string(0, 0, "CHRG",'Roboto_Regular12',ugfx.BLACK)
50-
elif vUsb>4000:
50+
elif on_usb:
5151
try:
5252
badge.eink_png(0,0,'/lib/resources/usb.png')
5353
except:

esp32/modules/splash.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ def disp_string_right(y, s):
5050

5151
easydraw.nickname()
5252

53-
vUsb = badge.usb_volt_sense()
53+
on_usb = pm.usb_attached()
5454
vBatt = badge.battery_volt_sense()
5555
vBatt += vDrop
5656
charging = badge.battery_charge_status()
5757

58-
easydraw.battery(vUsb, vBatt, charging)
58+
easydraw.battery(on_usb, vBatt, charging)
5959

6060
if vBatt>500:
6161
ugfx.string(52, 0, str(round(vBatt/1000, 1)) + 'v','Roboto_Regular12',ugfx.BLACK)
@@ -123,7 +123,7 @@ def onSleep(idleTime):
123123
### PROGRAM
124124

125125
# Calibrate battery voltage drop
126-
if badge.battery_charge_status() == False and badge.usb_volt_sense() > 4500 and badge.battery_volt_sense() > 2500:
126+
if badge.battery_charge_status() == False and pm.usb_attached() and badge.battery_volt_sense() > 2500:
127127
badge.nvs_set_u16('splash', 'bat.volt.drop', 5200 - badge.battery_volt_sense()) # mV
128128
print('Set vDrop to: ' + str(4200 - badge.battery_volt_sense()))
129129
vDrop = badge.nvs_get_u16('splash', 'bat.volt.drop', 1000) - 1000 # mV
@@ -174,7 +174,6 @@ def onSleep(idleTime):
174174
easywifi.disable()
175175
gc.collect()
176176

177-
virtualtimers.debug(True)
178177
virtualtimers.activate(25)
179178
pm.callback(onSleep)
180179
pm.feed()

esp32/modules/tasks/badgeeventreminder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import virtualtimers, time, appglue, badge
88

9-
whenToTrigger = 1502196900 - 600
9+
# Tue Aug 8 13:30:00 2017 (CEST)
10+
whenToTrigger = 1502191800 - 600
1011

1112
def ber_task():
1213
global whenToTrigger

esp32/modules/tasks/powermanagement.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111

1212
userResponseTime = badge.nvs_get_u16('splash', 'urt', 5000)
1313

14+
def usb_attached():
15+
return badge.usb_volt_sense() > 4500
16+
1417
def pm_task():
1518
''' The power management task [internal function] '''
1619
global requestedStandbyTime
1720

1821
idleTime = virtualtimers.idle_time()
19-
print("[Power management] Next task wants to run in "+str(idleTime)+" ms.")
20-
21-
if idleTime>30000 and not badge.safe_mode():
22+
#print("[Power management] Next task wants to run in "+str(idleTime)+" ms.")
23+
24+
if idleTime > 30000 and not badge.safe_mode() and not ( usb_attached() and badge.nvs_get_u8('badge', 'usb_stay_awake', 0) != 0 ):
2225
global onSleepCallback
2326
if not onSleepCallback==None:
2427
print("[Power management] Running onSleepCallback...")

unix/modbadge.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,5 @@ const mp_obj_module_t mock_badge_module = {
235235
.base = {&mp_type_module},
236236
.globals = (mp_obj_dict_t *)&mock_badge_module_globals,
237237
};
238+
239+
bool ugfx_screen_flipped = false;

0 commit comments

Comments
 (0)