Уведомления
Очистить все
Страница 8 / 8
Предыдущий
Это цикл для отправки 15-ти байт, никакого отношения к светодиодам не имеет:
for (int l=0; l<15; l++)
SetBit(), ClearBit() - стандартные битовые операции. (0x80 >> bit_position) - это операция сдвиг вправо, упрощенно (0x80 >> 1) = В01000000.
5-й режим:
void loop()
{
LS = 0;
if (flag == 0)
{
if (counter < (N_O_S)) {sector_time--;}
if (counter > (N_O_S)) {sector_time++;}
}
if (counter == N_O_S) {flag = 1;}
if ((counter < (N_O_S - TOL)) || (counter > (N_O_S + TOL))) {flag = 0;}
if (end_time < millis())
{
end_time = millis() + (random(10,20) * 1000);
flag=0;
mode++;
if (mode == 6) {mode = 1;}
}
counter = 0;
if (offset > (N_O_S - 1)) {offset = 0;}
EnableSPI();
while (LS == 0)
{
if (counter < N_O_S) {pointer = counter;} else {pointer = N_O_S - 1;}
pointer = pointer + offset;
if (pointer > (N_O_S - 1)) {pointer = pointer - N_O_S;}
int sector_index = pointer;
if (sector_index == 0)
{
test_counter++;
}
int led_index = test_counter % 20;
if (mode == 5)
{
led_index = 19 - led_index;
}
pointer = pointer * 15;
int cached_bit_1 = GetBit(&test_array[0], 2 * led_index);
int cached_bit_2 = GetBit(&test_array[0], 2 * led_index + 1);
SetBit(&test_array[0], 2 * led_index);
SetBit(&test_array[0], 2 * led_index + 1);
digitalWrite(latchPin, LOW);
switch (mode)
{
case 1:
for (int l=0; l<15; l++){SendRecSPI(bild_01[pointer + l]);}
break;
case 2:
for (int l=0; l<15; l++){SendRecSPI(bild_02[pointer + l]);}
break;
case 3:
for (int l=0; l<15; l++){SendRecSPI(bild_03[pointer + l]);}
break;
case 4:
case 5:
for (int l=0; l<15; l++){SendRecSPI(test_array[l]);}
break;
}
digitalWrite(latchPin, HIGH);
if (cached_bit_1 == 0) ClearBit(&test_array[0], 2 * led_index);
if (cached_bit_2 == 0) ClearBit(&test_array[0], 2 * led_index + 1);
counter++;
unsigned long end_micros = micros() + sector_time;
while ((micros() < end_micros) && (LS == 0)) {}
}
DisableSPI();
offset = offset + v_offset;
}
Размещено : 24.07.2026 11:58
здравствуйте. большое вам спасибо за помощь . мне хватит. здесь огромное поле для творчества. и чтобы все изучить. я очень рада.
Создатель темы Размещено : 26.07.2026 22:08
а еще один маленький вопрос? я правильно поняла что скорость перемещения диодов по кольцу, зависит от скорости вращения конструкции. то есть от прерывания LS.
Создатель темы Размещено : 26.07.2026 22:12
Страница 8 / 8
Предыдущий