Skip to content

Commit c6a283a

Browse files
committed
Auto updates for circuit 1 working
1 parent bca70bf commit c6a283a

4 files changed

Lines changed: 134 additions & 85 deletions

File tree

src/products/espaper/fw/esphome/schedules/circuit11.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/products/espaper/fw/esphome/schedules/circuit12.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/products/espaper/fw/esphome/schedules/circuit13.yaml renamed to src/products/espaper/fw/esphome/schedules/circuit_unified.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@ layout:
1313
pad_column: 8
1414
widgets:
1515
- label:
16-
text: "Circuit 1 Workout 2"
16+
id: workout_title
17+
text: "Circuit 1 Workout"
1718
grid_cell_column_span: 2
1819
- label:
1920
text: "Narayan\nIoannis"
2021
- label:
21-
text: "Lateral Raise + Split Squat"
22+
id: workout_1
23+
text: "Overhead Press + Pull Up"
2224
- label:
2325
text: "Nick\nSam"
2426
- label:
25-
text: "Overhead Press + Pull Up"
27+
id: workout_2
28+
text: "Row + Push Up"
2629
- label:
2730
text: "Ray"
2831
- label:
29-
text: "Row + Push Up"
32+
id: workout_3
33+
text: "Lateral Raise + Split Squat"

src/products/espaper/fw/esphome/workout.yaml

Lines changed: 126 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,84 @@ esphome:
33
on_boot:
44
then:
55
- lvgl.page.show: clock_page
6-
6+
- delay: 2s
7+
- script.execute: time_update
8+
- script.execute: update_workout_display
9+
- delay: 1s
710

811
esp32:
912
board: esp32-c3-devkitm-1
1013
framework:
1114
type: esp-idf
1215

1316
logger:
17+
level: DEBUG
18+
19+
globals:
20+
- id: fake_hour
21+
type: int
22+
initial_value: '9'
23+
- id: fake_minute
24+
type: int
25+
initial_value: '29'
26+
- id: fake_second
27+
type: int
28+
initial_value: '0'
29+
- id: fake_day_of_week
30+
type: int
31+
initial_value: '1'
32+
- id: fake_month
33+
type: int
34+
initial_value: '1'
35+
- id: fake_day_of_month
36+
type: int
37+
initial_value: '1'
38+
- id: current_workout_idx
39+
type: int
40+
initial_value: '0'
41+
1442

1543
api:
1644
password: ""
1745

1846
ota:
1947
- platform: esphome
2048
password: ""
49+
port: 3232
50+
51+
safe_mode:
52+
reboot_timeout: 10min
2153

2254
wifi:
2355
ssid: "atopile"
2456
password: "code2pcb"
57+
fast_connect: true
58+
reboot_timeout: 15min
59+
power_save_mode: none
60+
61+
on_connect:
62+
then:
63+
- logger.log: "WiFi connected successfully"
64+
on_disconnect:
65+
then:
66+
- logger.log: "WiFi disconnected"
2567

2668
ap:
2769
ssid: "Workout Fallback Hotspot"
2870
password: "QuxGYPMmHAe1"
2971

3072
captive_portal:
3173

74+
# WiFi status monitoring
75+
text_sensor:
76+
- platform: wifi_info
77+
ip_address:
78+
name: "WiFi IP"
79+
ssid:
80+
name: "WiFi SSID"
81+
mac_address:
82+
name: "WiFi MAC"
83+
3284

3385
font:
3486
- file: 'fonts/Roboto-Regular.ttf'
@@ -53,11 +105,7 @@ display:
53105
inverted: true
54106
reset_pin: 3
55107
model: 7.50inV2
56-
# full_update_every: 30
57-
# lambda: |-
58-
# it.print(0, 0, id(font1), "Hello World!");
59-
update_interval: 10s
60-
# full_update_every: 2
108+
update_interval: 2s
61109
auto_clear_enabled: false
62110

63111
color:
@@ -143,42 +191,97 @@ lvgl:
143191
- label:
144192
id: date_label
145193
y: 30
146-
- obj: !include schedules/circuit11.yaml
194+
- obj: !include schedules/circuit_unified.yaml
147195

148-
time:
149-
- platform: homeassistant
150-
id: time_comp
151-
on_time_sync:
152-
- script.execute: time_update
153-
on_time:
154-
- minutes: '*'
155-
seconds: 0
156-
then:
157-
- script.execute: time_update
196+
interval:
197+
- id: time_interval
198+
interval: 1s
199+
then:
200+
- script.execute: fake_time_update
158201

159202
script:
203+
- id: fake_time_update
204+
then:
205+
- logger.log: "Fake time update executing"
206+
- globals.set:
207+
id: fake_second
208+
value: !lambda |-
209+
// Add 8 minutes (480 seconds) to simulate time passage
210+
int total_seconds = id(fake_second) + 480;
211+
int new_hour = id(fake_hour) + (total_seconds / 3600);
212+
int new_minute = id(fake_minute) + ((total_seconds % 3600) / 60);
213+
int new_second = total_seconds % 60;
214+
215+
// Normalize time
216+
new_minute += new_second / 60;
217+
new_second %= 60;
218+
new_hour += new_minute / 60;
219+
new_minute %= 60;
220+
new_hour %= 24;
221+
222+
id(fake_hour) = new_hour;
223+
id(fake_minute) = new_minute;
224+
return new_second;
225+
- globals.set:
226+
id: current_workout_idx
227+
value: !lambda |-
228+
int hour = id(fake_hour);
229+
int minute = id(fake_minute);
230+
if (hour < 10 || (hour == 10 && minute < 30)) return 0;
231+
if (hour < 11 || (hour == 11 && minute < 30)) return 1;
232+
return 2;
233+
- script.execute: time_update
234+
- script.execute: update_workout_display
235+
- logger.log: "Fake time update completed"
160236
- id: time_update
161237
then:
162238
- lvgl.indicator.update:
163239
id: minute_hand
164240
value: !lambda |-
165-
return id(time_comp).now().minute;
241+
return id(fake_minute);
166242
- lvgl.indicator.update:
167243
id: hour_hand
168244
value: !lambda |-
169-
auto now = id(time_comp).now();
170-
return std::fmod(now.hour, 12) * 60 + now.minute;
245+
return (id(fake_hour) % 12) * 60 + id(fake_minute);
171246
- lvgl.label.update:
172247
id: date_label
173248
text: !lambda |-
174249
static const char * const mon_names[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
175250
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
176251
static char date_buf[8];
177-
auto now = id(time_comp).now();
178-
snprintf(date_buf, sizeof(date_buf), "%s %2d", mon_names[now.month-1], now.day_of_month);
252+
snprintf(date_buf, sizeof(date_buf), "%s %2d", mon_names[id(fake_month)-1], id(fake_day_of_month));
179253
return date_buf;
180254
- lvgl.label.update:
181255
id: day_label
182256
text: !lambda |-
183257
static const char * const day_names[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
184-
return day_names[id(time_comp).now().day_of_week - 1];
258+
return day_names[id(fake_day_of_week) - 1];
259+
- id: update_workout_display
260+
then:
261+
- lvgl.label.update:
262+
id: workout_title
263+
text: !lambda |-
264+
static char title_buf[32];
265+
snprintf(title_buf, sizeof(title_buf), "Circuit 1 Workout %d", id(current_workout_idx) + 1);
266+
return title_buf;
267+
- lvgl.label.update:
268+
id: workout_1
269+
text: !lambda |-
270+
static const char * const workouts[] = {
271+
"Overhead Press + Pull Up", "Row + Push Up", "Lateral Raise + Split Squat"
272+
};
273+
return workouts[id(current_workout_idx)];
274+
- lvgl.label.update:
275+
id: workout_2
276+
text: !lambda |-
277+
static const char * const workouts[] = {
278+
"Row + Push Up", "Lateral Raise + Split Squat", "Overhead Press + Pull Up"
279+
};
280+
return workouts[id(current_workout_idx)];
281+
- lvgl.label.update:
282+
id: workout_3
283+
text: !lambda |-
284+
static const char * const workouts[] = {
285+
"Lateral Raise + Split Squat", "Overhead Press + Pull Up", "Row + Push Up"
286+
};
287+
return workouts[id(current_workout_idx)];

0 commit comments

Comments
 (0)