Legion2 / CorsairLightingProtocol

Control LEDs connected to an Arduino with iCUE, create an unofficial Corsair iCUE compatible Arduino LED controller.
Apache License 2.0
509 stars 64 forks source link

commander pro with 1 analog channel and 1 digital channel #355

Closed saeedbs closed 10 months ago

saeedbs commented 10 months ago

I built a 'commander pro' with Leonardo and 2 channels but one is digital and other one is analog, I mixed two of examples for this : nonaddressable and commander pro and removed some of fan controller codes but most of the time my addressable rgb corsair fans don't work correctly while analog rgb fans work just fine, I think maybe I was wrong somewhere in code pls help me about it when I say not working correctly means sometimes I get correct effect for like 5mins but after that they won't work correctly just flickering red/green! oddly trying find the pattern of it happening but can't figure it looks too random to work correctly

photo_2023-11-10_00-26-37 photo_2023-11-10_00-28-44

#include <CorsairLightingProtocol.h>
#include <FastLED.h>

#include "SimpleFanController.h"
#include "ThermistorTemperatureController.h"

#define DATA_PIN_CHANNEL_1 2

//for channel 2
#define RED_PIN 9
#define GREEN_PIN 10
#define BLUE_PIN 11

#define TEMP_SENSOR_PIN_1 A4
#define TEMP_SENSOR_PIN_2 A5

#define FAN_UPDATE_RATE 500

CorsairLightingFirmwareStorageEEPROM firmwareStorage;
CorsairLightingFirmware firmware(CORSAIR_COMMANDER_PRO, &firmwareStorage);
ThermistorTemperatureController temperatureController;
FastLEDControllerStorageEEPROM storage;
FastLEDController ledController(&storage);
SimpleFanController fanController(&temperatureController, FAN_UPDATE_RATE, EEPROM_ADDRESS + storage.getEEPROMSize());
CorsairLightingProtocolController cLP(&ledController, &temperatureController, &fanController, &firmware);
CorsairLightingProtocolHID cHID(&cLP);

CRGB ledsChannel1[96];
CRGB ledsChannel2[10];

void setup() {
         CLP::disableBuildInLEDs();
    FastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 96);
         ledController.addLEDs(0, ledsChannel1, 96);

        pinMode(RED_PIN, OUTPUT);
    pinMode(GREEN_PIN, OUTPUT);
    pinMode(BLUE_PIN, OUTPUT);
  ledController.addLEDs(1, ledsChannel2, 10);
    ledController.onUpdateHook(0, []() {
        // use color of first LED of the first channel
        set4PinLEDs(ledsChannel2[0]);
    });
        temperatureController.addSensor(0, TEMP_SENSOR_PIN_1);
    temperatureController.addSensor(1, TEMP_SENSOR_PIN_2);
}

void loop() {
    cHID.update();
    if (ledController.updateLEDs()) {
        FastLED.show();
    }
}

void set4PinLEDs(const CRGB& color) {
        analogWrite(RED_PIN, color.r);
    analogWrite(GREEN_PIN, color.g);
    analogWrite(BLUE_PIN, color.b);

}
saeedbs commented 10 months ago

video their odd behavior https://github.com/Legion2/CorsairLightingProtocol/assets/9435467/8e22f233-1ab7-41f0-9b5d-d5dd03f8b5db

Legion2 commented 10 months ago

Hi, your schematic and code looks good. Most often flickering comes from not having a common ground, bad wire connections or faulty LEDs.

github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

saeedbs commented 9 months ago

it seems leonardo is faulty ... after replacing it ...it works with no issue