led driver
This commit is contained in:
parent
aede43f0b5
commit
c7af67df36
@ -11,7 +11,27 @@
|
||||
extern led_strip_handle_t leds;
|
||||
|
||||
typedef enum {
|
||||
|
||||
shape1 = 0,
|
||||
shape2 = 1,
|
||||
shape3 = 2,
|
||||
shape4 = 3,
|
||||
module_sseg = 4,
|
||||
game_sseg = 5,
|
||||
tft = 6,
|
||||
mic = 7,
|
||||
ir_led = 8,
|
||||
speaker = 9,
|
||||
rfid = 10,
|
||||
keypad = 11,
|
||||
char_lcd = 12,
|
||||
s4 = 13,
|
||||
s3 = 14,
|
||||
s2 = 15,
|
||||
s1 = 16,
|
||||
b1 = 17,
|
||||
b2 = 18,
|
||||
b3 = 19,
|
||||
b4 = 20,
|
||||
} Led;
|
||||
|
||||
void init_leds(void);
|
||||
|
||||
@ -70,6 +70,7 @@ bool get_button_released(void) {
|
||||
}
|
||||
|
||||
void strike(char* reason) {
|
||||
ESP_LOGW("strike!", "%s", reason);
|
||||
uint8_t reg = 6;
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_to_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, ®, 1, (100 / portTICK_PERIOD_MS)));
|
||||
}
|
||||
|
||||
@ -28,8 +28,10 @@ void step6(void) {
|
||||
|
||||
for (int i = 0; i < NUM_WIRES; i++) {
|
||||
if (just_cut_wires & (1<<i)) {
|
||||
// ESP_LOGI(STEP6_TAG, "Wire %d cut", i);
|
||||
if (solution[i]) {
|
||||
xTaskCreate(correct_wire_task, "correct_wire", 4096, NULL, 5, NULL);
|
||||
// ESP_LOGI(STEP6_TAG, "correct wire");
|
||||
} else {
|
||||
strike("Cut wrong wire");
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
if (list_pos_len[i] == max_len) {
|
||||
int idx = list_pos[i][1];
|
||||
out_cut[idx] = true;
|
||||
ESP_LOGI(TAG, "1. cutting %d", idx);
|
||||
// ESP_LOGI(TAG, "1. cutting %d", idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,14 +191,14 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
// 2. cut the first wire if it is green or white
|
||||
if (wires[0] == WireColor::green || wires[0] == WireColor::white) {
|
||||
out_cut[0] = true;
|
||||
ESP_LOGI(TAG, "2. cutting %d", 0);
|
||||
// ESP_LOGI(TAG, "2. cutting %d", 0);
|
||||
}
|
||||
|
||||
// 3. cut blue wires in even positions (odd indexes)
|
||||
for (int i = 1; i < NUM_WIRES; i += 2) {
|
||||
if (wires[i] == WireColor::blue) {
|
||||
out_cut[i] = true;
|
||||
ESP_LOGI(TAG, "3. cutting %d", i);
|
||||
// ESP_LOGI(TAG, "3. cutting %d", i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
) {
|
||||
out_cut[i] = true;
|
||||
out_cut[i+1] = true;
|
||||
ESP_LOGI(TAG, "4. cutting %d, %d", i, i+1);
|
||||
// ESP_LOGI(TAG, "4. cutting %d, %d", i, i+1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
wires[pos+1] == WireColor::white
|
||||
) {
|
||||
out_cut[pos] = true;
|
||||
ESP_LOGI(TAG, "5. cutting %d", pos);
|
||||
// ESP_LOGI(TAG, "5. cutting %d", pos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -233,14 +233,14 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
if (wires[4] == WireColor::red) {
|
||||
for (int white_idx = 0; white_idx < white_pos_len; white_idx++) {
|
||||
out_cut[white_pos[white_idx]] = true;
|
||||
ESP_LOGI(TAG, "6. cutting %d", white_pos[white_idx]);
|
||||
// ESP_LOGI(TAG, "6. cutting %d", white_pos[white_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
// 7. cut the first black wire if there are more white wires than green wires
|
||||
if (white_pos_len > green_pos_len && black_pos_len > 0) {
|
||||
out_cut[black_pos[0]] = true;
|
||||
ESP_LOGI(TAG, "7. cutting %d", black_pos[0]);
|
||||
// ESP_LOGI(TAG, "7. cutting %d", black_pos[0]);
|
||||
}
|
||||
|
||||
// 8. cut all wires in an alternating pattern of 2 colors at least 4 wires long
|
||||
@ -254,7 +254,7 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
out_cut[i+1] = true;
|
||||
out_cut[i+2] = true;
|
||||
out_cut[i+3] = true;
|
||||
ESP_LOGI(TAG, "8. cutting %d, %d, %d, %d", i, i+1, i+2, i+3);
|
||||
// ESP_LOGI(TAG, "8. cutting %d, %d, %d, %d", i, i+1, i+2, i+3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
for (int i = 0; i < NUM_WIRES; i++) {
|
||||
if (color_name_len[wires[i]] == i+1) {
|
||||
out_cut[i] = true;
|
||||
ESP_LOGI(TAG, "9. cutting %d", i);
|
||||
// ESP_LOGI(TAG, "9. cutting %d", i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,14 +270,14 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
if (max_len <= 2) {
|
||||
for (int i = 0; i < red_pos_len; i++) {
|
||||
out_cut[red_pos[i]] = true;
|
||||
ESP_LOGI(TAG, "10. cutting %d", red_pos[i]);
|
||||
// ESP_LOGI(TAG, "10. cutting %d", red_pos[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// 11. cut the last wire if it is the same color as the first wire
|
||||
if (wires[0] == wires[NUM_WIRES-1]) {
|
||||
out_cut[NUM_WIRES-1] = true;
|
||||
ESP_LOGI(TAG, "11. cutting %d", NUM_WIRES-1);
|
||||
// ESP_LOGI(TAG, "11. cutting %d", NUM_WIRES-1);
|
||||
}
|
||||
|
||||
// 12. cut any wire adjacent to both a yellow and blue wire
|
||||
@ -287,7 +287,7 @@ void solve_wires(WireColor* wires, bool* out_cut) {
|
||||
(wires[i] == WireColor::blue && wires[i+2] == WireColor::white)
|
||||
) {
|
||||
out_cut[i+1] = true;
|
||||
ESP_LOGI(TAG, "12. cutting %d", i+1);
|
||||
// ESP_LOGI(TAG, "12. cutting %d", i+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user