adjusted timings
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -90,3 +90,9 @@ Thumbs.db
|
|||||||
|
|
||||||
# debug information files
|
# debug information files
|
||||||
*.dwo
|
*.dwo
|
||||||
|
|
||||||
|
# o-files
|
||||||
|
*.o
|
||||||
|
|
||||||
|
# binary
|
||||||
|
*.bin
|
||||||
@@ -15,7 +15,10 @@ board = esp32-c3-devkitm-1
|
|||||||
; board = esp32doit-devkit-v1
|
; board = esp32doit-devkit-v1
|
||||||
framework = arduino
|
framework = arduino
|
||||||
; framework = espidf
|
; framework = espidf
|
||||||
monitor_speed = 9600
|
monitor_speed = 115200
|
||||||
|
monitor_rts = 0
|
||||||
|
monitor_dtr = 0
|
||||||
|
upload_speed = 921600
|
||||||
; upload_port = /dev/ttyACM0
|
; upload_port = /dev/ttyACM0
|
||||||
build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 -Wunused -Wall -Wextra
|
build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 -Wunused -Wall -Wextra
|
||||||
; upload_protocol = espota
|
; upload_protocol = espota
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "MyBLEServer.hpp"
|
#include "MyBLEServer.hpp"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "HWCDC.h"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
|
||||||
#include "tlc.hpp"
|
#include "tlc.hpp"
|
||||||
@@ -32,6 +34,7 @@ MyAlarmCallback::MyAlarmCallback(enum Alarm * alarm, enum Dimmer * dimmer, enum
|
|||||||
}
|
}
|
||||||
void MyAlarmCallback::onWrite(BLECharacteristic * pCharacteristic) {
|
void MyAlarmCallback::onWrite(BLECharacteristic * pCharacteristic) {
|
||||||
String value = pCharacteristic->getValue().c_str();
|
String value = pCharacteristic->getValue().c_str();
|
||||||
|
// Serial.println(value);
|
||||||
|
|
||||||
if (value.compareTo("X") == 0) {
|
if (value.compareTo("X") == 0) {
|
||||||
// Serial.println("found X");
|
// Serial.println("found X");
|
||||||
@@ -62,6 +65,7 @@ void MyAlarmCallback::onWrite(BLECharacteristic * pCharacteristic) {
|
|||||||
*dimmerState = BRIGHTNESS_UP;
|
*dimmerState = BRIGHTNESS_UP;
|
||||||
}
|
}
|
||||||
else if (value.compareTo("darker") == 0) {
|
else if (value.compareTo("darker") == 0) {
|
||||||
|
|
||||||
// Serial.println("found darker");
|
// Serial.println("found darker");
|
||||||
// alarmFired_100m = 1;
|
// alarmFired_100m = 1;
|
||||||
// alarmFired = ALARM_100M;
|
// alarmFired = ALARM_100M;
|
||||||
|
|||||||
17
src/main.cpp
17
src/main.cpp
@@ -105,13 +105,13 @@ void setup() {
|
|||||||
pinMode(DARKER_PIN, INPUT_PULLUP);
|
pinMode(DARKER_PIN, INPUT_PULLUP);
|
||||||
pinMode(GPIO_NUM_10, INPUT); // former Alarm pin
|
pinMode(GPIO_NUM_10, INPUT); // former Alarm pin
|
||||||
|
|
||||||
Serial.begin(9600);
|
Serial.begin(115200);
|
||||||
delay(1000);
|
// delay(1000);
|
||||||
Serial.println("Hallo Welt");
|
// Serial.println("Hallo Welt");
|
||||||
delay(1000);
|
// delay(1000);
|
||||||
Serial.println("Hallo Welt");
|
// Serial.println("Hallo Welt");
|
||||||
delay(1000);
|
// delay(1000);
|
||||||
Serial.println("Hallo Welt");
|
// Serial.println("Hallo Welt");
|
||||||
|
|
||||||
EEPROM.begin(EEPROM_SIZE);
|
EEPROM.begin(EEPROM_SIZE);
|
||||||
#if defined(FIRST_BOOT)
|
#if defined(FIRST_BOOT)
|
||||||
@@ -212,7 +212,6 @@ void loop() {
|
|||||||
// Serial.print("WIFI");
|
// Serial.print("WIFI");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
if (serverCallback->getConnectionState()) {
|
if (serverCallback->getConnectionState()) {
|
||||||
@@ -240,7 +239,7 @@ void loop() {
|
|||||||
// ESP_ERROR_CHECK(rmt_write_items(RMT_CHANNEL_0, cockpit.led_data,
|
// ESP_ERROR_CHECK(rmt_write_items(RMT_CHANNEL_0, cockpit.led_data,
|
||||||
// sizeof(cockpit.led_data) / sizeof(rmt_item32_t), true)); delay(100);
|
// sizeof(cockpit.led_data) / sizeof(rmt_item32_t), true)); delay(100);
|
||||||
// }
|
// }
|
||||||
for (int i = 0; i < 49; i++) {
|
for (int i = 0; i < 48; i++) {
|
||||||
// cockpit.knightRiderAdvanced(red, i);
|
// cockpit.knightRiderAdvanced(red, i);
|
||||||
// cockpit.outToIn(red, i);
|
// cockpit.outToIn(red, i);
|
||||||
cockpit.inToOutMulticolor(c, 12, i);
|
cockpit.inToOutMulticolor(c, 12, i);
|
||||||
|
|||||||
335
src/tlc.cpp
335
src/tlc.cpp
@@ -1,5 +1,7 @@
|
|||||||
#include "tlc.hpp"
|
#include "tlc.hpp"
|
||||||
|
#include "Arduino.h"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
Color Cockpit::ORANGE = {.blue = 0, .red = 255, .green = 0xA5};
|
Color Cockpit::ORANGE = {.blue = 0, .red = 255, .green = 0xA5};
|
||||||
Color Cockpit::RED = {.blue = 0, .red = 255, .green = 0};
|
Color Cockpit::RED = {.blue = 0, .red = 255, .green = 0};
|
||||||
@@ -118,7 +120,7 @@ void Cockpit::outToInMulticolor(Color color[], uint8_t colors, int state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Cockpit::inToOutMulticolor(Color color[], uint8_t colors, int state) {
|
void Cockpit::inToOutMulticolor(Color color[], uint8_t colors, int state) {
|
||||||
uint8_t curColorIndex = state / 4;
|
uint8_t curColorIndex = (state / 4) % colors;
|
||||||
state = state % 4;
|
state = state % 4;
|
||||||
turnOffLeds();
|
turnOffLeds();
|
||||||
|
|
||||||
@@ -191,108 +193,6 @@ void Cockpit::colorfade(int state) {
|
|||||||
this->writeLEDs();
|
this->writeLEDs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void Cockpit::knightRider(int state){
|
|
||||||
// uint8_t color = 1;
|
|
||||||
// this->turnOffLeds();
|
|
||||||
|
|
||||||
// uint8_t brightness = this->brightnessState;
|
|
||||||
// uint8_t dimmedIntensitiy = brightness / 2;
|
|
||||||
// uint8_t heavyDimmedIntensitiy = brightness / 4;
|
|
||||||
|
|
||||||
// int step = state % 13;
|
|
||||||
// switch (step)
|
|
||||||
// {
|
|
||||||
// case 0:
|
|
||||||
// this->stateLEDs[0][color] = brightness;
|
|
||||||
// // step += 1;
|
|
||||||
// break;
|
|
||||||
// case 1:
|
|
||||||
// this->stateLEDs[0][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[1][color] = brightness;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// this->stateLEDs[0][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[1][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[2][color] = brightness;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// this->stateLEDs[0][color] = 0;
|
|
||||||
// this->stateLEDs[1][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[2][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[3][color] = brightness;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// this->stateLEDs[1][color] = 0;
|
|
||||||
// this->stateLEDs[2][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[3][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[4][color] = brightness;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 5:
|
|
||||||
// this->stateLEDs[2][color] = 0;
|
|
||||||
// this->stateLEDs[3][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[4][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[5][color] = brightness;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 6:
|
|
||||||
// this->stateLEDs[3][color] = 0;
|
|
||||||
// this->stateLEDs[4][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[5][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[6][color] = brightness;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 7:
|
|
||||||
// this->stateLEDs[4][color] = 0;
|
|
||||||
// this->stateLEDs[5][color] = brightness;
|
|
||||||
// this->stateLEDs[6][color] = dimmedIntensitiy;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 8:
|
|
||||||
// this->stateLEDs[4][color] = brightness;
|
|
||||||
// this->stateLEDs[5][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[6][color] = heavyDimmedIntensitiy;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 9:
|
|
||||||
// this->stateLEDs[3][color] = brightness;
|
|
||||||
// this->stateLEDs[4][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[5][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[6][color] = 0;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 10:
|
|
||||||
// this->stateLEDs[2][color] = brightness;
|
|
||||||
// this->stateLEDs[3][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[4][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[5][color] = 0;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 11:
|
|
||||||
// this->stateLEDs[1][color] = brightness;
|
|
||||||
// this->stateLEDs[2][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[3][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[4][color] = 0;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
// case 12:
|
|
||||||
// this->stateLEDs[0][color] = brightness;
|
|
||||||
// this->stateLEDs[1][color] = dimmedIntensitiy;
|
|
||||||
// this->stateLEDs[2][color] = heavyDimmedIntensitiy;
|
|
||||||
// this->stateLEDs[3][color] = 0;
|
|
||||||
// // step++;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this->writeLEDs();
|
|
||||||
// }
|
|
||||||
|
|
||||||
void Cockpit::knightRiderAdvanced(Color color, int state) {
|
void Cockpit::knightRiderAdvanced(Color color, int state) {
|
||||||
this->turnOffLeds();
|
this->turnOffLeds();
|
||||||
// 15 states
|
// 15 states
|
||||||
@@ -454,24 +354,62 @@ void Cockpit::writeZero() {
|
|||||||
#if defined(INVERSE_MODE)
|
#if defined(INVERSE_MODE)
|
||||||
|
|
||||||
#if defined(MODE_RMT)
|
#if defined(MODE_RMT)
|
||||||
this->led_data[this->cp].level0 = 0;
|
|
||||||
this->led_data[this->cp].duration0 = 1;
|
// costs 4 cp
|
||||||
this->led_data[this->cp].level1 = 0;
|
|
||||||
this->led_data[this->cp].duration1 = 1;
|
byte pattern = 0b11100000; // should be 0b11000000 <-hardware hack
|
||||||
this->cp++;
|
byte invPattern = ~pattern;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
|
if (invPattern & 0x80) {
|
||||||
|
if (i % 2 == 0) {
|
||||||
this->led_data[this->cp].level0 = 1;
|
this->led_data[this->cp].level0 = 1;
|
||||||
this->led_data[this->cp].duration0 = 1;
|
this->led_data[this->cp].duration0 = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
this->led_data[this->cp].level1 = 1;
|
this->led_data[this->cp].level1 = 1;
|
||||||
this->led_data[this->cp].duration1 = 1;
|
this->led_data[this->cp].duration1 = 1;
|
||||||
this->cp++;
|
this->cp++;
|
||||||
|
}
|
||||||
for (int i = 0; i < 5; i++) {
|
}
|
||||||
this->led_data[this->cp].level0 = this->led_data[this->cp - 1].level0;
|
else {
|
||||||
|
if (i % 2 == 0) {
|
||||||
|
this->led_data[this->cp].level0 = 0;
|
||||||
this->led_data[this->cp].duration0 = 1;
|
this->led_data[this->cp].duration0 = 1;
|
||||||
this->led_data[this->cp].level1 = this->led_data[this->cp - 1].level1;
|
}
|
||||||
|
else {
|
||||||
|
this->led_data[this->cp].level1 = 0;
|
||||||
this->led_data[this->cp].duration1 = 1;
|
this->led_data[this->cp].duration1 = 1;
|
||||||
this->cp++;
|
this->cp++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
invPattern <<= 1;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this->led_data[this->cp].level0 = 0;
|
||||||
|
|
||||||
|
// before
|
||||||
|
// this->led_data[this->cp].level0 = 0;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = 0;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
// this->led_data[this->cp].level0 = 1;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = 1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
|
||||||
|
// for (int i = 0; i < 5; i++) {
|
||||||
|
// this->led_data[this->cp].level0 = this->led_data[this->cp - 1].level0;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = this->led_data[this->cp - 1].level1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
// }
|
||||||
|
// end before
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -522,42 +460,79 @@ void Cockpit::writeOne() {
|
|||||||
// PORTB |= B1; //uno
|
// PORTB |= B1; //uno
|
||||||
#if defined(INVERSE_MODE)
|
#if defined(INVERSE_MODE)
|
||||||
#if defined(MODE_RMT)
|
#if defined(MODE_RMT)
|
||||||
this->led_data[this->cp].level0 = 0;
|
|
||||||
this->led_data[this->cp].duration0 = 1;
|
|
||||||
this->led_data[this->cp].level1 = 0;
|
|
||||||
this->led_data[this->cp].duration1 = 1;
|
|
||||||
this->cp++;
|
|
||||||
this->led_data[this->cp].level0 = 1;
|
|
||||||
this->led_data[this->cp].duration0 = 1;
|
|
||||||
this->led_data[this->cp].level1 = 1;
|
|
||||||
this->led_data[this->cp].duration1 = 1;
|
|
||||||
this->cp++;
|
|
||||||
this->led_data[this->cp].level0 = 0;
|
|
||||||
this->led_data[this->cp].duration0 = 1;
|
|
||||||
this->led_data[this->cp].level1 = 0;
|
|
||||||
this->led_data[this->cp].duration1 = 1;
|
|
||||||
this->cp++;
|
|
||||||
this->led_data[this->cp].level0 = 1;
|
|
||||||
this->led_data[this->cp].duration0 = 1;
|
|
||||||
this->led_data[this->cp].level1 = 1;
|
|
||||||
this->led_data[this->cp].duration1 = 1;
|
|
||||||
this->cp++;
|
|
||||||
|
|
||||||
this->led_data[this->cp].level0 = this->led_data[this->cp - 1].level0;
|
// costs 4 cp
|
||||||
|
|
||||||
|
// byte pattern = 0b11001100; // this is how it should be
|
||||||
|
byte pattern = 0b11101110; // hardware hack, because open collector is slow -> more 1 than 0
|
||||||
|
byte invPattern = ~pattern;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
|
if (invPattern & 0x80) {
|
||||||
|
if (i % 2 == 0) {
|
||||||
|
this->led_data[this->cp].level0 = 1;
|
||||||
this->led_data[this->cp].duration0 = 1;
|
this->led_data[this->cp].duration0 = 1;
|
||||||
this->led_data[this->cp].level1 = this->led_data[this->cp - 1].level1;
|
}
|
||||||
|
else {
|
||||||
|
this->led_data[this->cp].level1 = 1;
|
||||||
this->led_data[this->cp].duration1 = 1;
|
this->led_data[this->cp].duration1 = 1;
|
||||||
this->cp++;
|
this->cp++;
|
||||||
this->led_data[this->cp].level0 = this->led_data[this->cp - 1].level0;
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (i % 2 == 0) {
|
||||||
|
this->led_data[this->cp].level0 = 0;
|
||||||
this->led_data[this->cp].duration0 = 1;
|
this->led_data[this->cp].duration0 = 1;
|
||||||
this->led_data[this->cp].level1 = this->led_data[this->cp - 1].level1;
|
}
|
||||||
this->led_data[this->cp].duration1 = 1;
|
else {
|
||||||
this->cp++;
|
this->led_data[this->cp].level1 = 0;
|
||||||
this->led_data[this->cp].level0 = this->led_data[this->cp - 1].level0;
|
|
||||||
this->led_data[this->cp].duration0 = 1;
|
|
||||||
this->led_data[this->cp].level1 = this->led_data[this->cp - 1].level1;
|
|
||||||
this->led_data[this->cp].duration1 = 1;
|
this->led_data[this->cp].duration1 = 1;
|
||||||
this->cp++;
|
this->cp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
invPattern <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// before
|
||||||
|
|
||||||
|
// this->led_data[this->cp].level0 = 0;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = 0;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
// this->led_data[this->cp].level0 = 1;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = 1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
// this->led_data[this->cp].level0 = 0;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = 0;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
// this->led_data[this->cp].level0 = 1;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = 1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
|
||||||
|
// this->led_data[this->cp].level0 = this->led_data[this->cp - 1].level0;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = this->led_data[this->cp - 1].level1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
// this->led_data[this->cp].level0 = this->led_data[this->cp - 1].level0;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = this->led_data[this->cp - 1].level1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
// this->led_data[this->cp].level0 = this->led_data[this->cp - 1].level0;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = this->led_data[this->cp - 1].level1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
|
||||||
|
// end before
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -614,12 +589,16 @@ void Cockpit::writeOne() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Cockpit::writeCommTimer() {
|
void Cockpit::writeCommTimer() {
|
||||||
// first two zeroes determine the timing (tcycle) after device is powered up or after a GSLAT
|
// first two zeroes determine the timing (tcycle) after device is powered up or after a
|
||||||
|
// GSLAT
|
||||||
|
|
||||||
|
// 8 cp
|
||||||
this->writeZero();
|
this->writeZero();
|
||||||
this->writeZero();
|
this->writeZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cockpit::writeCommand() {
|
void Cockpit::writeCommand() {
|
||||||
|
// cost 32 cp
|
||||||
this->writeZero();
|
this->writeZero();
|
||||||
this->writeZero();
|
this->writeZero();
|
||||||
this->writeOne();
|
this->writeOne();
|
||||||
@@ -637,11 +616,31 @@ void Cockpit::waitEOS() {
|
|||||||
#if defined(INVERSE_MODE)
|
#if defined(INVERSE_MODE)
|
||||||
|
|
||||||
#if defined(MODE_RMT)
|
#if defined(MODE_RMT)
|
||||||
|
|
||||||
|
// costs 16 cp
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < CYCLYTIME * 4; i++) {
|
||||||
|
|
||||||
|
if (i % 2 == 0) {
|
||||||
this->led_data[this->cp].level0 = 1;
|
this->led_data[this->cp].level0 = 1;
|
||||||
this->led_data[this->cp].duration0 = 1;
|
this->led_data[this->cp].duration0 = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
this->led_data[this->cp].level1 = 1;
|
this->led_data[this->cp].level1 = 1;
|
||||||
this->led_data[this->cp].duration1 = 1;
|
this->led_data[this->cp].duration1 = 1;
|
||||||
this->cp++;
|
this->cp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// before
|
||||||
|
// this->led_data[this->cp].level0 = 1;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = 1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp++;
|
||||||
|
|
||||||
|
// end before
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#if defined(MODE_INTERRUPT)
|
#if defined(MODE_INTERRUPT)
|
||||||
this->buffer[this->cp] = 1;
|
this->buffer[this->cp] = 1;
|
||||||
@@ -655,13 +654,15 @@ void Cockpit::waitEOS() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MODE_RMT)
|
#if defined(MODE_RMT)
|
||||||
for (int i = this->cp; i < 24 + this->cp; i++) {
|
// before
|
||||||
this->led_data[i].level0 = this->led_data[i - 1].level0;
|
// for (int i = this->cp; i < 24 + this->cp; i++) {
|
||||||
this->led_data[i].duration0 = 1;
|
// this->led_data[i].level0 = this->led_data[i - 1].level0;
|
||||||
this->led_data[i].level1 = this->led_data[i - 1].level1;
|
// this->led_data[i].duration0 = 1;
|
||||||
this->led_data[i].duration1 = 1;
|
// this->led_data[i].level1 = this->led_data[i - 1].level1;
|
||||||
}
|
// this->led_data[i].duration1 = 1;
|
||||||
this->cp += 24; // tCycle is 6 * pTime
|
// }
|
||||||
|
// this->cp += 24; // tCycle is 6 * pTime
|
||||||
|
// end before
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined(MODE_INTERRUPT)
|
#if defined(MODE_INTERRUPT)
|
||||||
@@ -683,11 +684,28 @@ void Cockpit::waitGSLAT() {
|
|||||||
|
|
||||||
#if defined(MODE_RMT)
|
#if defined(MODE_RMT)
|
||||||
|
|
||||||
|
// cost 32 cp
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < CYCLYTIME * 8; i++) {
|
||||||
|
|
||||||
|
if (i % 2 == 0) {
|
||||||
this->led_data[this->cp].level0 = 1;
|
this->led_data[this->cp].level0 = 1;
|
||||||
this->led_data[this->cp].duration0 = 1;
|
this->led_data[this->cp].duration0 = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
this->led_data[this->cp].level1 = 1;
|
this->led_data[this->cp].level1 = 1;
|
||||||
this->led_data[this->cp].duration1 = 1;
|
this->led_data[this->cp].duration1 = 1;
|
||||||
this->cp += 1;
|
this->cp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->cp = 0;
|
||||||
|
// before
|
||||||
|
// this->led_data[this->cp].level0 = 1;
|
||||||
|
// this->led_data[this->cp].duration0 = 1;
|
||||||
|
// this->led_data[this->cp].level1 = 1;
|
||||||
|
// this->led_data[this->cp].duration1 = 1;
|
||||||
|
// this->cp += 1;
|
||||||
|
// end before
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined(MODE_INTERRUPT)
|
#if defined(MODE_INTERRUPT)
|
||||||
@@ -703,13 +721,16 @@ void Cockpit::waitGSLAT() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MODE_RMT)
|
#if defined(MODE_RMT)
|
||||||
for (int i = this->cp; i < 60 + this->cp; i++) {
|
|
||||||
this->led_data[i].level0 = this->led_data[i - 1].level0;
|
// before
|
||||||
this->led_data[i].duration0 = 1;
|
// for (int i = this->cp; i < 60 + this->cp; i++) {
|
||||||
this->led_data[i].level1 = this->led_data[i - 1].level1;
|
// this->led_data[i].level0 = this->led_data[i - 1].level0;
|
||||||
this->led_data[i].duration1 = 1;
|
// this->led_data[i].duration0 = 1;
|
||||||
}
|
// this->led_data[i].level1 = this->led_data[i - 1].level1;
|
||||||
this->cp = 0; // minimum 8 time tCycle
|
// this->led_data[i].duration1 = 1;
|
||||||
|
// }
|
||||||
|
// this->cp = 0; // minimum 8 time tCycle
|
||||||
|
// end before
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined(MODE_INTERRUPT)
|
#if defined(MODE_INTERRUPT)
|
||||||
|
|||||||
@@ -9,13 +9,15 @@
|
|||||||
#include "driver/rmt.h"
|
#include "driver/rmt.h"
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#define BUFFER_SIZE 1818
|
#define BUFFER_SIZE 1048 // 1818
|
||||||
|
// #define BUFFER_SIZE 1818 // 1818
|
||||||
// #include "config.h"
|
// #include "config.h"
|
||||||
|
|
||||||
// #define MODE_INTERRUPT
|
// #define MODE_INTERRUPT
|
||||||
#define MODE_RMT
|
#define MODE_RMT
|
||||||
#define NUM_LEDS 7
|
#define NUM_LEDS 7
|
||||||
#define COLOR_CHANNELS 3
|
#define COLOR_CHANNELS 3
|
||||||
|
#define CYCLYTIME 8 // us
|
||||||
|
|
||||||
class Cockpit;
|
class Cockpit;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user