proj: switching to ESP32C6
This commit is contained in:
+30
-28
@@ -117,28 +117,33 @@ void LightingTask() {
|
||||
ESP_LOGI(TAG, "Start Lighting");
|
||||
|
||||
static I2cMaster master(I2C_NUM_0,
|
||||
/*sda=*/ GPIO_NUM_0,
|
||||
/*scl=*/ GPIO_NUM_4);
|
||||
/*sda=*/ GPIO_NUM_10,
|
||||
/*scl=*/ GPIO_NUM_11);
|
||||
// static PmwExpanderPca9685 pca9685(master);
|
||||
static PmwExpanderPca9685 ledDriver1(master, /*iverted=*/ true);
|
||||
static PmwExpanderPca9685 ledDriver2(master, /*iverted=*/ true, 0x41);
|
||||
static PmwExpanderPca9685 ledDriver1(master, /*iverted=*/ false);
|
||||
static PmwExpanderPca9685 ledDriver2(master, /*iverted=*/ false, 0x41);
|
||||
PmwExpanderPca9685::GrayValues values[2];
|
||||
|
||||
while (true) {
|
||||
ESP_LOGI("Light", "Tick");
|
||||
OutputPort pwmEnable(GPIO_NUM_5, GpioPort::Logic::Inverted);
|
||||
pwmEnable.write(true);
|
||||
|
||||
int idx = 0;
|
||||
while (true) {
|
||||
values[0].fill(0);
|
||||
values[1].fill(0);
|
||||
|
||||
values[0][12] = 0x100;
|
||||
values[0][15] = 0x100;
|
||||
// values[x][4] = 0x200; // Actually first
|
||||
values[0][idx] = 0x200;
|
||||
ledDriver1.sendImage(values[0]);
|
||||
|
||||
values[1][1] = 0x100;
|
||||
values[1][2] = 0x100;
|
||||
// values[1][4] = 0x100; // Actually first
|
||||
values[1][idx] = 0x400;
|
||||
ledDriver2.sendImage(values[1]);
|
||||
|
||||
fos::Task::delayMs(1000);
|
||||
if (++idx >= 16 ) {
|
||||
idx = 0;
|
||||
}
|
||||
fos::Task::delayMs(100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,14 +153,20 @@ void MovementTask() {
|
||||
StepperDriverDrv8833::Pins stepperPins{
|
||||
LEDC_TIMER_0,
|
||||
{LEDC_CHANNEL_0, LEDC_CHANNEL_1, LEDC_CHANNEL_2, LEDC_CHANNEL_3},
|
||||
{GPIO_NUM_16, GPIO_NUM_15, GPIO_NUM_14, GPIO_NUM_13},
|
||||
{GPIO_NUM_23, GPIO_NUM_22, GPIO_NUM_21, GPIO_NUM_20},
|
||||
};
|
||||
StepperDriverDrv8833 stepperDriver(stepperPins, MicroSteps);
|
||||
stepperDriver.setPos(0);
|
||||
|
||||
StepperMotor::Config stepperCfg{1.8F, MicroSteps};
|
||||
InputPort initSens(GPIO_NUM_33);
|
||||
initSens.setLogic(GpioPort::Logic::Inverted);
|
||||
InputPort initSens(GPIO_NUM_18);
|
||||
|
||||
InputPort motorFault(GPIO_NUM_8);
|
||||
motorFault.setLogic(GpioPort::Logic::Inverted);
|
||||
|
||||
OutputPort motorSleep(GPIO_NUM_15, GpioPort::Logic::Inverted);
|
||||
motorSleep.write(false);
|
||||
|
||||
StepperMotor stepper(stepperCfg, stepperDriver, initSens);
|
||||
|
||||
int i = 0;
|
||||
@@ -178,21 +189,13 @@ void MovementTask() {
|
||||
void IoTest()
|
||||
{
|
||||
ESP_LOGI(TAG, "Start IO");
|
||||
InputPort in2(GPIO_NUM_32);
|
||||
InputPort mFault(GPIO_NUM_35);
|
||||
|
||||
OutputPort nEnable(GPIO_NUM_2);
|
||||
OutputPort nReset(GPIO_NUM_5);
|
||||
InputPort in2(GPIO_NUM_19);
|
||||
OutputPort nReset(GPIO_NUM_9);
|
||||
|
||||
while (true) {
|
||||
ESP_LOGI("Light", "InValues %i %i", in2.read(), mFault.read());
|
||||
nEnable.write(true);
|
||||
nReset.write(true);
|
||||
fos::Task::delayMs(500);
|
||||
nEnable.write(false);
|
||||
nReset.write(false);
|
||||
fos::Task::delayMs(500);
|
||||
}
|
||||
nReset.write(in2.read());
|
||||
fos::Task::delayMs(100);
|
||||
}
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
@@ -203,7 +206,6 @@ void app_main(void)
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
// ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
initialize_ethernet();
|
||||
static fos::Task lightingTask(LightingTask, "Lights", 0x4000uL);
|
||||
static fos::Task movementTask(MovementTask, "Motor", 0x4000uL);
|
||||
|
||||
Reference in New Issue
Block a user