Skip to content

Commit f5c6f87

Browse files
Made a simple forward-then-backward loop in option 2
1 parent aedd344 commit f5c6f87

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

src/swsh/swsh.c

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/* Static functions */
1111
static void temporary_control(void);
12-
static void repeat_press_a(void);
12+
static void loop_forward_backward(void);
1313
static void max_raid_menu(void);
1414
static void max_raid_setup(void);
1515
static void light_pillar_setup_with_control(void);
@@ -68,7 +68,7 @@ int main(void)
6868
break;
6969

7070
case 2:
71-
repeat_press_a();
71+
loop_forward_backward();
7272
break;
7373

7474
case 3:
@@ -115,37 +115,27 @@ void temporary_control(void)
115115

116116

117117
/*
118-
* Press A repetitively until the button is pressed.
119-
*/
120-
static void repeat_press_a(void)
118+
* Move forward, then backward, in a loop
119+
*/
120+
static void loop_forward_backward(void)
121121
{
122-
uint8_t count = 0;
123-
while (delay(0, 0, 50) == 0) {
124-
switch (count % 4) {
125-
case 0:
126-
set_leds(NO_LEDS);
127-
break;
128-
case 1:
129-
set_leds(TX_LED);
130-
break;
131-
case 2:
132-
set_leds(BOTH_LEDS);
133-
break;
134-
case 3:
135-
set_leds(RX_LED);
136-
break;
122+
uint16_t cycles = 100;
123+
set_leds(BOTH_LEDS);
124+
for (;;) {
125+
set_leds(RX_LED);
126+
for (uint16_t i = 0 ; i < (cycles / 2) ; i += 1) {
127+
send_update(BT_NONE, DP_NEUTRAL, S_TOP, S_NEUTRAL);
137128
}
138129

139-
send_update(BT_A, DP_NEUTRAL, S_NEUTRAL, S_NEUTRAL);
140-
send_update(BT_NONE, DP_NEUTRAL, S_NEUTRAL, S_NEUTRAL);
130+
set_leds(TX_LED);
131+
for (uint16_t i = 0 ; i < (cycles / 2) ; i += 1) {
132+
send_update(BT_NONE, DP_NEUTRAL, S_BOTTOM, S_NEUTRAL);
133+
}
141134

142-
count += 1;
135+
/* Reset sticks position */
136+
set_leds(NO_LEDS);
137+
pause_automation();
143138
}
144-
145-
set_leds(NO_LEDS);
146-
send_update(BT_NONE, DP_NEUTRAL, S_NEUTRAL, S_NEUTRAL);
147-
148-
_delay_ms(200);
149139
}
150140

151141

0 commit comments

Comments
 (0)