Skip to content

Commit 6b2d2ae

Browse files
Reformat code to the style requirements
1 parent 91e389e commit 6b2d2ae

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

APIs_RTOS/Events_ex_1/main.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,30 @@ void handler(int count);
1010
Event<void(int)> event1(&queue, handler);
1111
Event<void(int)> event2(&queue, handler);
1212

13-
14-
void handler(int count)
15-
{
13+
void handler(int count) {
1614
unsigned time_ms = equeue_tick();
1715
printf("Timestamp = %d Event = %d \n", time_ms, count);
1816
return;
1917
}
2018

21-
void post_events(void)
22-
{
19+
void post_events(void) {
2320
// Events can be posted multiple times and enqueue gracefully until
2421
// the dispatch function is called. Each event will be processed
2522
// subject to any delay and period specified. Each time an event has
2623
// been dispatched it will be re-queued ready for the next dispatch
2724
// period.
28-
event1.post(1); // Event1 with a value of 1
29-
event1.post(2); // Event1 with a value of 2
30-
event1.post(3); // Event1 with a value of 3
25+
event1.post(1); // Event1 with a value of 1
26+
event1.post(2); // Event1 with a value of 2
27+
event1.post(3); // Event1 with a value of 3
3128

3229
// Cancel the last event posted ie Event1 with a value of 3
3330
event1.cancel();
3431

35-
event1.post(4); // Event1 with a value of 4
36-
37-
event2.post(5); // Event2 with a value of 5
32+
event1.post(4); // Event1 with a value of 4
3833

34+
event2.post(5); // Event2 with a value of 5
3935
}
4036

41-
4237
// Example demonstrates the following:
4338
// 1. Post 5 different events to a queue
4439
// 2. Configure the event delay and period for each
@@ -76,18 +71,17 @@ void post_events(void)
7671
// Timestamp = 727 Event = 2
7772
// Timestamp = 756 Event = 4
7873

79-
int main()
80-
{
74+
int main() {
8175
// Example 1 Dispatch posted events for a specified period
8276
Thread event_thread;
8377

8478
// The event can be manually configured for special timing requirements
8579
// specified in milliseconds (using Chrono durations)
86-
event1.delay(100ms); // Starting delay - 100 msec
87-
event1.period(200ms); // Delay between each event - 200msec
80+
event1.delay(100ms); // Starting delay - 100 msec
81+
event1.period(200ms); // Delay between each event - 200msec
8882

89-
event2.delay(400ms); // Starting delay - 400 msec
90-
event2.period(non_periodic); // Single non periodic event
83+
event2.delay(400ms); // Starting delay - 400 msec
84+
event2.period(non_periodic); // Single non periodic event
9185

9286
event_thread.start(callback(post_events));
9387

@@ -99,5 +93,4 @@ int main()
9993
queue.dispatch_for(800ms);
10094

10195
event_thread.join();
102-
10396
}

Tutorials_UsingAPIs/Alarm/main.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ LowPowerTicker alarm_event;
1717

1818
std::chrono::hours hour_inc;
1919
std::chrono::minutes min_inc;
20-
std::chrono::microseconds delay;
20+
std::chrono::microseconds delay;
2121

22-
volatile uint8_t select_state = 0;
22+
volatile uint8_t select_state = 0;
2323

2424
// Timer Callbacks
25-
void inc_select(void)
26-
{
25+
void inc_select(void) {
2726
if (select_state < 2) {
2827
select_state++;
2928
} else {
@@ -33,28 +32,25 @@ void inc_select(void)
3332
}
3433
}
3534

36-
void set_time_leds(void)
37-
{
35+
void set_time_leds(void) {
3836
if (select_state == 0) {
3937
hour_led = !hour_led;
4038
} else {
4139
min_led = !min_led;
4240
}
4341
}
4442

45-
void inc_delay(void)
46-
{
43+
void inc_delay(void) {
4744
if (select_state == 0) {
4845
delay += hour_inc++;
4946
hour_led = !hour_led;
5047
} else {
51-
delay =+ min_inc++;
48+
delay = +min_inc++;
5249
min_led = !min_led;
5350
}
5451
}
5552

56-
void trigger_alarm_out(void)
57-
{
53+
void trigger_alarm_out(void) {
5854
alarm_out = 1;
5955
alarm_led = 0;
6056
}
@@ -78,8 +74,7 @@ void trigger_alarm_out(void)
7874
* time.
7975
*/
8076
// Main thread
81-
int main()
82-
{
77+
int main() {
8378
// Configure interrupt in pins (button controls)
8479
sel.rise(inc_select);
8580
inc_time.fall(set_time_leds);

0 commit comments

Comments
 (0)