diff --git a/Controllers/JginYueInternalUSBController/JginYueInternalUSBController.cpp b/Controllers/JginYueInternalUSBController/JginYueInternalUSBController.cpp new file mode 100644 index 00000000..b217d641 --- /dev/null +++ b/Controllers/JginYueInternalUSBController/JginYueInternalUSBController.cpp @@ -0,0 +1,255 @@ +/*-----------------------------------------*\ +| JginYueInternalUSBController.cpp | +| | +| Driver for JginYue internal USB | +| lighting controller | +| | +| Tong R (tcr020) 2023/08/09 | +| | +| Dongguan Yonghang Electronic | +| Technology Co., Ltd | +\*-----------------------------------------*/ +#include +#include +#include + +#include "RGBController.h" +#include "ResourceManager.h" +#include "SettingsManager.h" +#include "JginYueInternalUSBController.h" +#include "dependencies/dmiinfo.h" + +#define JGINYUE_USB_GENERAL_COMMAND_HEADER 0x01 +#define JGINYUE_USB_LED_STRIPE_SET_COMMAND_HEADER 0x05 +#define JGINYUE_USB_MODE_SET_COMMAND_HEADER 0x06 +#define JGINYUE_USB_PER_LED_SET_COMMAND_HEADER 0x04 + +#define JGINYUE_USB_GET_FW_VERSION 0xA0 +#define JGINYUE_USB_GET_FW_REPLY 0x5A +#define JGINYUE_RG_DEFAULT 0x01 +#define JGINYUE_RG_SWAP 0x00 + + +JginYueInternalUSBController::JginYueInternalUSBController(hid_device* dev_handle, const char* path) +{ + DMIInfo dmi; + + dev = dev_handle; + location = path; + device_name = "JGINYUE " + dmi.getMainboard(); + + Init_device(device_config); +} + +JginYueInternalUSBController::~JginYueInternalUSBController() +{ + hid_close(dev); +} +unsigned int JginYueInternalUSBController::GetZoneCount() +{ + return(JGINYUE_MAX_ZONES); +} + +std::string JginYueInternalUSBController::GetDeviceLocation() +{ + return("HID:" + location); +} + +std::string JginYueInternalUSBController::GetDeviceName() +{ + return(device_name); +} + +std::string JginYueInternalUSBController::GetSerialString() +{ + return(""); +} + +std::string JginYueInternalUSBController::GetDeviceFWVirson() +{ + unsigned char usb_buf[16]; + + memset(usb_buf,0x00,sizeof(usb_buf)); + + usb_buf[0x00] = JGINYUE_USB_GENERAL_COMMAND_HEADER; + usb_buf[0x01] = JGINYUE_USB_GET_FW_VERSION; + + hid_write(dev, usb_buf, 16); + hid_read(dev, usb_buf, 16); + + if((usb_buf[0x00]!=JGINYUE_USB_GENERAL_COMMAND_HEADER)||(usb_buf[0x01]!=JGINYUE_USB_GET_FW_REPLY)) + { + return (""); + } + + std::string Major_virson = std::to_string(usb_buf[0x02]); + std::string Minor_virson = std::to_string(usb_buf[0x03]); + + return ("Major_virson " + Major_virson + " Minor_virson " + Minor_virson); + +} + + +void JginYueInternalUSBController::Init_device(AreaConfiguration* ptr_device_cfg) +{ + for(int index_config=1; index_config <=JGINYUE_MAX_ZONES; index_config++) + { + ptr_device_cfg[index_config].Brightness = JGINYUE_USB_BRIGHTNESS_DEFAULT; + ptr_device_cfg[index_config].Color_B = 0xFF; + ptr_device_cfg[index_config].Color_G = 0xFF; + ptr_device_cfg[index_config].Color_R = 0xFF; + ptr_device_cfg[index_config].RG_Swap = JGINYUE_RG_DEFAULT; + ptr_device_cfg[index_config].Speed = JGINYUE_USB_SPEED_DEFAULT; + ptr_device_cfg[index_config].LED_numbers = JGINYUE_ADDRESSABLE_MAX_LEDS; + ptr_device_cfg[index_config].Mode_active = JGINYUE_USB_MODE_STATIC; + } +} + +void JginYueInternalUSBController::WriteZoneMode + ( + unsigned char zone, + unsigned char mode, + RGBColor rgb, + unsigned char speed, + unsigned char brightness, + unsigned char direction + ) +{ + int Active_zone; + unsigned char usb_buf[65]; + switch (zone) + { + case 0x01: + Active_zone=1; + break; + case 0x02: + Active_zone=2; + break; + default: + Active_zone=1; + return; + break; + } + device_config[Active_zone].Mode_active = mode; + device_config[Active_zone].Direct_Mode_control = 0x00; + device_config[Active_zone].Speed = speed; + device_config[Active_zone].Brightness = brightness; + device_config[Active_zone].Direction = direction; + device_config[Active_zone].Color_B = RGBGetBValue(rgb); + device_config[Active_zone].Color_G = RGBGetGValue(rgb); + device_config[Active_zone].Color_R = RGBGetRValue(rgb); + + memset(usb_buf, 0x00, sizeof(usb_buf)); + + usb_buf[0x00] = JGINYUE_USB_LED_STRIPE_SET_COMMAND_HEADER; + usb_buf[0x01] = zone; + usb_buf[0x02] = device_config[Active_zone].LED_numbers; + usb_buf[0x03] = device_config[Active_zone].RG_Swap; + usb_buf[0x04] = device_config[Active_zone].Direction; + usb_buf[0x05] = device_config[Active_zone].Direct_Mode_control; + hid_write(dev, usb_buf ,16); + + memset(usb_buf, 0x00, sizeof(usb_buf)); + + usb_buf[0x00] = JGINYUE_USB_MODE_SET_COMMAND_HEADER; + usb_buf[0x01] = zone; + usb_buf[0x02] = device_config[Active_zone].Mode_active; + usb_buf[0x03] = device_config[Active_zone].Color_R; + usb_buf[0x04] = device_config[Active_zone].Color_G; + usb_buf[0x05] = device_config[Active_zone].Color_B; + usb_buf[0x06] = device_config[Active_zone].Brightness; + usb_buf[0x07] = device_config[Active_zone].Speed; + hid_write(dev, usb_buf ,16); +} + +void JginYueInternalUSBController::DirectLEDControl + ( + RGBColor* colors, + unsigned char zone + ) +{ + int Active_zone; + unsigned char usb_buf[302]; + switch (zone) + { + case 0x01: + Active_zone=1; + break; + case 0x02: + Active_zone=2; + break; + default: + Active_zone=1; + return; + break; + } + device_config[Active_zone].Mode_active=JGINYUE_USB_MODE_DIRECT; + device_config[Active_zone].Direct_Mode_control=0x01; + + memset(usb_buf, 0x00, sizeof(usb_buf)); + + + usb_buf[0x00] = JGINYUE_USB_LED_STRIPE_SET_COMMAND_HEADER; + usb_buf[0x01] = zone; + usb_buf[0x02] = device_config[Active_zone].LED_numbers; + usb_buf[0x03] = device_config[Active_zone].RG_Swap; + usb_buf[0x04] = device_config[Active_zone].Direction; + usb_buf[0x05] = device_config[Active_zone].Direct_Mode_control; + + hid_write(dev, usb_buf ,16); + memset(usb_buf, 0x00, sizeof(usb_buf)); + usb_buf[0x00] = JGINYUE_USB_PER_LED_SET_COMMAND_HEADER; + usb_buf[0x01] = zone; + + for(unsigned int color_idx = 0; color_idx < device_config[Active_zone].LED_numbers; color_idx++) + { + usb_buf[color_idx * 3 + 2] = RGBGetRValue(colors[color_idx]); + usb_buf[color_idx * 3 + 3] = RGBGetGValue(colors[color_idx]); + usb_buf[color_idx * 3 + 4] = RGBGetBValue(colors[color_idx]); + } + hid_send_feature_report(dev,usb_buf,302); +} + + +void JginYueInternalUSBController::Area_resize(unsigned char led_numbers,unsigned char zone) +{ + unsigned char usb_buf[65]; + int Active_zone; + switch (zone) + { + case 0x01: + Active_zone=1; + break; + case 0x02: + Active_zone=2; + break; + default: + Active_zone=1; + return; + break; + } + device_config[Active_zone].LED_numbers=led_numbers; + + memset(usb_buf, 0x00, sizeof(usb_buf)); + + usb_buf[0x00] = JGINYUE_USB_LED_STRIPE_SET_COMMAND_HEADER; + usb_buf[0x01] = zone; + usb_buf[0x02] = device_config[Active_zone].LED_numbers; + usb_buf[0x03] = device_config[Active_zone].RG_Swap; + usb_buf[0x04] = device_config[Active_zone].Direction; + usb_buf[0x05] = device_config[Active_zone].Direct_Mode_control; + hid_write(dev, usb_buf ,16); +} + +void JginYueInternalUSBController::SetRGSwap(unsigned char RGSwap) +{ + if((RGSwap!=0x00)&&(RGSwap!=0x01)) + { + return; + } + + for(int index_config=1; index_config <=JGINYUE_MAX_ZONES; index_config++) + { + device_config[index_config].RG_Swap = RGSwap; + } +} diff --git a/Controllers/JginYueInternalUSBController/JginYueInternalUSBController.h b/Controllers/JginYueInternalUSBController/JginYueInternalUSBController.h new file mode 100644 index 00000000..db908909 --- /dev/null +++ b/Controllers/JginYueInternalUSBController/JginYueInternalUSBController.h @@ -0,0 +1,116 @@ +/*-----------------------------------------*\ +| JginYueInternalUSBController.h | +| | +| Driver for JginYue internal USB | +| lighting controller | +| | +| Tong R (tcr020) 2023/08/09 | +| | +| Dongguan Yonghang Electronic | +| Technology Co., Ltd | +\*-----------------------------------------*/ + +#include "RGBController.h" +#include +#include + +#pragma once +#define JGINYUE_MAX_ZONES 2 +#define JGINYUE_ADDRESSABLE_MAX_LEDS 100 + +enum +{ + JGINYUE_USB_MODE_OFF =0x10, + JGINYUE_USB_MODE_STATIC =0x11, + JGINYUE_USB_MODE_BREATHING =0x12, + JGINYUE_USB_MODE_STROBE =0x13, + JGINYUE_USB_MODE_CYCLING =0x14, + JGINYUE_USB_MODE_RANDOM =0x15, + JGINYUE_USB_MODE_MUSIC =0x16, /*music mode,not support yet */ + JGINYUE_USB_MODE_WAVE =0x17, + JGINYUE_USB_MODE_SPRING =0x18, /*spring mode,not support yet */ + JGINYUE_USB_MODE_WATER =0x19, + JGINYUE_USB_MODE_RAINBOW =0x1A, /*rainbow mode,not support yet */ + JGINYUE_USB_MODE_DIRECT =0x20, /*Not the exact USB protrol - but need a way to differentiate */ +}; + +enum +{ + JGINYUE_USB_SPEED_MAX =0xFF, + JGINYUE_USB_SPEED_MIN =0x00, + JGINYUE_USB_SPEED_DEFAULT =0x80 +}; + +enum +{ + JGINYUE_DIRECTION_RIGHT = 0x00, + JGINYUE_DIRECTION_LEFT = 0x01 +}; + + +enum +{ + JGINYUE_USB_BRIGHTNESS_MAX =0xFF, + JGINYUE_USB_BRIGHTNESS_MIN =0x00, + JGINYUE_USB_BRIGHTNESS_DEFAULT =0xFF +}; + + +struct AreaConfiguration +{ + unsigned char LED_numbers; + unsigned char RG_Swap; + unsigned char Direction; + unsigned char Direct_Mode_control; /*0x00 = Disabled 0x01 = Enabled*/ + unsigned char Mode_active; + unsigned char Color_R; + unsigned char Color_G; + unsigned char Color_B; + unsigned char Brightness; + unsigned char Speed; +}; + + + + +class JginYueInternalUSBController +{ +public: + + JginYueInternalUSBController(hid_device* dev_handle, const char* path); + ~JginYueInternalUSBController(); + + unsigned int GetZoneCount(); + std::string GetDeviceLocation(); + std::string GetDeviceName(); + std::string GetSerialString(); + std::string GetDeviceFWVirson(); + + void WriteZoneMode + ( + unsigned char zone, + unsigned char mode, + RGBColor rgb, + unsigned char speed, + unsigned char brightness, + unsigned char direction + ); + + void DirectLEDControl + ( + RGBColor* colors, + unsigned char zone + ); + + void SetRGSwap(unsigned char RGSwap); + void Init_device(AreaConfiguration* ptr_device_cfg); + void Area_resize(unsigned char led_numbers,unsigned char zone); + + + +private: + AreaConfiguration device_config[8]; + hid_device* dev; + std::string location; + std::string device_name; +}; diff --git a/Controllers/JginYueInternalUSBController/JginYueInternalUSBControllerDetect.cpp b/Controllers/JginYueInternalUSBController/JginYueInternalUSBControllerDetect.cpp new file mode 100644 index 00000000..04489680 --- /dev/null +++ b/Controllers/JginYueInternalUSBController/JginYueInternalUSBControllerDetect.cpp @@ -0,0 +1,34 @@ +#include "RGBController_JginYueInternalUSB.h" +#include "JginYueInternalUSBController.h" +#include "RGBController.h" +#include "Detector.h" +#include "i2c_smbus.h" +#include "pci_ids.h" +#include +#include +#include +#include + +/*---------------------------------------------------------*\ +| JGINYUE vendor ID | +\*---------------------------------------------------------*/ +#define JGINYUE_VID 0x0416 + +/*---------------------------------------------------------*\ +| JGINYUE product ID | +\*---------------------------------------------------------*/ +#define JGINYUE_MOTHERBOARD_PID 0xA125 + +void DetectJginYueInternalUSBController(hid_device_info* info,const std::string& /*name*/) +{ + hid_device* dev = hid_open_path(info->path); + + if(dev) + { + JginYueInternalUSBController* controller =new JginYueInternalUSBController(dev,info->path); + RGBController_JginYueInternalUSB* rgb_controller =new RGBController_JginYueInternalUSB(controller); + ResourceManager::get()->RegisterRGBController(rgb_controller); + } +} + +REGISTER_HID_DETECTOR("JginYue Internal USB Controller",DetectJginYueInternalUSBController,JGINYUE_VID,JGINYUE_MOTHERBOARD_PID); diff --git a/Controllers/JginYueInternalUSBController/RGBController_JginYueInternalUSB.cpp b/Controllers/JginYueInternalUSBController/RGBController_JginYueInternalUSB.cpp new file mode 100644 index 00000000..83a60d8f --- /dev/null +++ b/Controllers/JginYueInternalUSBController/RGBController_JginYueInternalUSB.cpp @@ -0,0 +1,340 @@ +/*------------------------------------------------*\ +| RGBController_JginYueInternalUSB.cpp | +| | +| Generic RGB Interface JginYueInternalUSB Class | +| | +| Tong R (tcr020) 2023/08/09 | +| | +| Dongguan Yonghang Electronic Technology Co., Ltd| +\*------------------------------------------------*/ + +#include "RGBController_JginYueInternalUSB.h" +#include + +#define JGINYUE_MAX_ZONES 2 +#define JGINYUE_ADDRESSABLE_MAX_LEDS 100 +/**------------------------------------------------------------------*\ + @name JginYueInternalUSB + @category MotherBoard + @type USB + @save :x: + @direct :white_check_mark: + @effects :white_check_mark: + @detectors DetectJginYueInternalUSB + @comment Insert multiline JginYueInternalUSB comment here +*/ + +RGBController_JginYueInternalUSB::RGBController_JginYueInternalUSB(JginYueInternalUSBController* controller_ptr) +{ + controller =controller_ptr; + + name =controller->GetDeviceName(); + description ="JGINYUE USB ARGB Device"; + vendor ="JGINYUE"; + type =DEVICE_TYPE_MOTHERBOARD; + location =controller->GetDeviceLocation(); + version =controller->GetDeviceFWVirson(); + + mode Off; + Off.name ="Off"; + Off.value =JGINYUE_USB_MODE_OFF; + Off.flags =0; + Off.color_mode =MODE_COLORS_NONE; + modes.push_back(Off); + + mode Static; + Static.name ="Static"; + Static.value =JGINYUE_USB_MODE_STATIC; + Static.flags =MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; + Static.color_mode =MODE_COLORS_MODE_SPECIFIC; + Static.colors_max =1; + Static.colors_min =1; + Static.colors.resize(1); + modes.push_back(Static); + + mode Breathing; + Breathing.name ="Breathing"; + Breathing.value =JGINYUE_USB_MODE_BREATHING; + Breathing.flags =MODE_FLAG_HAS_MODE_SPECIFIC_COLOR|MODE_FLAG_HAS_SPEED|MODE_FLAG_HAS_BRIGHTNESS; + Breathing.color_mode =MODE_COLORS_MODE_SPECIFIC; + Breathing.colors_max =1; + Breathing.colors_min =1; + Breathing.brightness =JGINYUE_USB_BRIGHTNESS_DEFAULT; + Breathing.brightness_max =JGINYUE_USB_BRIGHTNESS_MAX; + Breathing.brightness_min =JGINYUE_USB_BRIGHTNESS_MIN; + Breathing.speed =JGINYUE_USB_SPEED_DEFAULT; + Breathing.speed_max =JGINYUE_USB_SPEED_MAX; + Breathing.speed_min =JGINYUE_USB_SPEED_MIN; + Breathing.colors.resize(1); + modes.push_back(Breathing); + + mode Strobe; + Strobe.name ="Strobe"; + Strobe.value =JGINYUE_USB_MODE_STROBE; + Strobe.flags =MODE_FLAG_HAS_MODE_SPECIFIC_COLOR|MODE_FLAG_HAS_SPEED|MODE_FLAG_HAS_BRIGHTNESS; + Strobe.color_mode =MODE_COLORS_MODE_SPECIFIC; + Strobe.colors_max =1; + Strobe.colors_min =1; + Strobe.brightness =JGINYUE_USB_BRIGHTNESS_DEFAULT; + Strobe.brightness_max =JGINYUE_USB_BRIGHTNESS_MAX; + Strobe.brightness_min =JGINYUE_USB_BRIGHTNESS_MIN; + Strobe.speed =JGINYUE_USB_SPEED_DEFAULT; + Strobe.speed_max =JGINYUE_USB_SPEED_MAX; + Strobe.speed_min =JGINYUE_USB_SPEED_MIN; + Strobe.colors.resize(1); + modes.push_back(Strobe); + + mode Cycling; + Cycling.name ="Cycling"; + Cycling.value =JGINYUE_USB_MODE_CYCLING; + Cycling.flags =MODE_FLAG_HAS_SPEED|MODE_FLAG_HAS_BRIGHTNESS; + Cycling.color_mode =MODE_COLORS_NONE; + Cycling.brightness =JGINYUE_USB_BRIGHTNESS_DEFAULT; + Cycling.brightness_max =JGINYUE_USB_BRIGHTNESS_MAX; + Cycling.brightness_min =JGINYUE_USB_BRIGHTNESS_MIN; + Cycling.speed =JGINYUE_USB_SPEED_DEFAULT; + Cycling.speed_max =JGINYUE_USB_SPEED_MAX; + Cycling.speed_min =JGINYUE_USB_SPEED_MIN; + modes.push_back(Cycling); + + mode Random; + Random.name ="Random"; + Random.value =JGINYUE_USB_MODE_RANDOM; + Random.flags =MODE_FLAG_HAS_SPEED|MODE_FLAG_HAS_BRIGHTNESS; + Random.color_mode =MODE_COLORS_NONE; + Random.brightness =JGINYUE_USB_BRIGHTNESS_DEFAULT; + Random.brightness_max =JGINYUE_USB_BRIGHTNESS_MAX; + Random.brightness_min =JGINYUE_USB_BRIGHTNESS_MIN; + Random.speed =JGINYUE_USB_SPEED_DEFAULT; + Random.speed_max =JGINYUE_USB_SPEED_MAX; + Random.speed_min =JGINYUE_USB_SPEED_MIN; + modes.push_back(Random); + + mode Wave; + Wave.name ="Wave"; + Wave.value =JGINYUE_USB_MODE_WAVE; + Wave.flags =MODE_FLAG_HAS_SPEED; + Wave.color_mode =MODE_COLORS_NONE; + Wave.speed =JGINYUE_USB_SPEED_DEFAULT; + Wave.speed_max =JGINYUE_USB_SPEED_MAX; + Wave.speed_min =JGINYUE_USB_SPEED_MIN; + modes.push_back(Wave); + + //mode Spring; + //Spring.name ="Spring"; + //Spring.value =JGINYUE_USB_MODE_SPRING; + //Spring.flags =MODE_FLAG_HAS_SPEED|MODE_FLAG_HAS_BRIGHTNESS|MODE_FLAG_HAS_DIRECTION_LR; + //Spring.color_mode =MODE_COLORS_NONE; + //Spring.brightness =JGINYUE_USB_BRIGHTNESS_DEFAULT; + //Spring.brightness_max =JGINYUE_USB_BRIGHTNESS_MAX; + //Spring.brightness_min =JGINYUE_USB_BRIGHTNESS_MIN; + //Spring.speed =JGINYUE_USB_SPEED_DEFAULT; + //Spring.speed_max =JGINYUE_USB_SPEED_MAX; + //Spring.speed_min =JGINYUE_USB_SPEED_MIN; + //Spring.direction =0x00; + //modes.push_back(Spring); + + mode Water; + Water.name ="Water"; + Water.value =JGINYUE_USB_MODE_WATER; + Water.flags =MODE_FLAG_HAS_SPEED|MODE_FLAG_HAS_BRIGHTNESS|MODE_FLAG_HAS_DIRECTION_LR; + Water.color_mode =MODE_COLORS_NONE; + Water.brightness =JGINYUE_USB_BRIGHTNESS_DEFAULT; + Water.brightness_max =JGINYUE_USB_BRIGHTNESS_MAX; + Water.brightness_min =JGINYUE_USB_BRIGHTNESS_MIN; + Water.speed =JGINYUE_USB_SPEED_DEFAULT; + Water.speed_max =JGINYUE_USB_SPEED_MAX; + Water.speed_min =JGINYUE_USB_SPEED_MIN; + Water.direction =MODE_DIRECTION_RIGHT; + modes.push_back(Water); + + //mode Rainbow; + //Rainbow.name ="Rainbow"; + //Rainbow.value =JGINYUE_USB_MODE_RAINBOW; + //Rainbow.flags =MODE_FLAG_HAS_SPEED|MODE_FLAG_HAS_BRIGHTNESS|MODE_FLAG_HAS_DIRECTION_LR; + //Rainbow.color_mode =MODE_COLORS_NONE; + //Rainbow.brightness =JGINYUE_USB_BRIGHTNESS_DEFAULT; + //Rainbow.brightness_max =JGINYUE_USB_BRIGHTNESS_MAX; + //Rainbow.brightness_min =JGINYUE_USB_BRIGHTNESS_MIN; + //Rainbow.speed =JGINYUE_USB_SPEED_DEFAULT; + //Rainbow.speed_max =JGINYUE_USB_SPEED_MAX; + //Rainbow.speed_min =JGINYUE_USB_SPEED_MIN; + //Rainbow.direction =MODE_DIRECTION_RIGHT; + //modes.push_back(Rainbow); + + mode Direct; + Direct.name ="Direct"; + Direct.value =JGINYUE_USB_MODE_DIRECT; + Direct.flags =MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode =MODE_COLORS_PER_LED; + modes.push_back(Direct); + + SetupZones(); +} + + + + +void RGBController_JginYueInternalUSB::SetupZones() +{ + bool first_run = false; + + if(zones.size() == 0) + { + first_run = true; + } + + leds.clear(); + colors.clear(); + zones.resize(JGINYUE_MAX_ZONES); + + + zones[0].name = "ARGB_Header_1"; + zones[0].type = ZONE_TYPE_LINEAR; + zones[0].leds_min = 1; + zones[0].leds_max = 100; + zones[0].matrix_map = NULL; + + zones[1].name = "ARGB_Header_2"; + zones[1].type = ZONE_TYPE_LINEAR; + zones[1].leds_min = 1; + zones[1].leds_max = 100; + zones[1].matrix_map = NULL; + + if(first_run) + { + zones[0].leds_count=100; + zones[1].leds_count=100; + } + + for (unsigned int led_idx = 0 , j=1; led_idx < zones[0].leds_count + zones[1].leds_count ; led_idx++) + { + if(led_idx==zones[0].leds_count) j=1; + + if (led_idxArea_resize(new_size,area); +} + +void RGBController_JginYueInternalUSB::DeviceUpdateLEDs() +{ + for (int i = 0; i < JGINYUE_MAX_ZONES; i++) + { + UpdateZoneLEDs(i); + } + +} + +void RGBController_JginYueInternalUSB::UpdateZoneLEDs(int zone) +{ + unsigned char area; + switch (zone) + { + case 0: + area = 0x01; + break; + case 1: + area = 0x02; + break; + default: + area = 0x01; + break; + } + controller->DirectLEDControl(zones[zone].colors,area); +} + +void RGBController_JginYueInternalUSB::UpdateSingleLED(int led) +{ + int zone; + zone = leds[led].value; + UpdateZoneLEDs(zone); +} + + +void RGBController_JginYueInternalUSB::DeviceUpdateMode() +{ + unsigned char area; + + + if(modes[active_mode].value == JGINYUE_USB_MODE_DIRECT) + { + DeviceUpdateLEDs(); + } + else + { + unsigned char aim_direction = JGINYUE_DIRECTION_RIGHT; + unsigned char aim_speed = JGINYUE_USB_SPEED_DEFAULT; + unsigned char aim_brightness = JGINYUE_USB_BRIGHTNESS_DEFAULT; + RGBColor aim_rgb = 0x00FFFFFF; + + if((modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR) ) + { + aim_direction = modes[active_mode].direction; + } + + if((modes[active_mode].flags & MODE_FLAG_HAS_SPEED) ) + { + aim_speed = modes[active_mode].speed; + } + + if((modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS) ) + { + aim_brightness = modes[active_mode].brightness; + } + + if((modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR) ) + { + aim_rgb = modes[active_mode].colors[0]; + } + for (int zone_index = 0; zone_index < JGINYUE_MAX_ZONES; zone_index++) + { + switch (zone_index) + { + case 0: + area = 0x01; + break; + case 1: + area = 0x02; + break; + default: + area = 0x01; + break; + } + controller->WriteZoneMode(area,modes[active_mode].value,aim_rgb,aim_speed,aim_brightness,aim_direction); + } + } +} diff --git a/Controllers/JginYueInternalUSBController/RGBController_JginYueInternalUSB.h b/Controllers/JginYueInternalUSBController/RGBController_JginYueInternalUSB.h new file mode 100644 index 00000000..c78df693 --- /dev/null +++ b/Controllers/JginYueInternalUSBController/RGBController_JginYueInternalUSB.h @@ -0,0 +1,33 @@ +/*------------------------------------------------*\ +| RGBController_JginYueInternalUSB.h | +| | +| Generic RGB Interface JginYueInternalUSB Class | +| | +| Tong R (tcr020) 2023/08/09 | +| | +| Dongguan Yonghang Electronic Technology Co., Ltd| +\*------------------------------------------------*/ + +#pragma once + +#include "RGBController.h" +#include "JginYueInternalUSBController.h" + +class RGBController_JginYueInternalUSB : public RGBController +{ +public: + RGBController_JginYueInternalUSB(JginYueInternalUSBController* controller_ptr); + + void SetupZones(); + + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void DeviceUpdateMode(); + +private: + JginYueInternalUSBController* controller; +}; diff --git a/OpenRGB.pro b/OpenRGB.pro index e7c16399..2da26de1 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -179,6 +179,7 @@ INCLUDEPATH += Controllers/HYTEMousematController/ \ Controllers/IntelArcA770LEController/ \ Controllers/IonicoController/ \ + Controllers/JginYueInternalUSBController/ \ Controllers/LEDStripController/ \ Controllers/LegoDimensionsToypadBaseController/ \ Controllers/LenovoControllers/ \ @@ -568,6 +569,8 @@ HEADERS += Controllers/IntelArcA770LEController/RGBController_IntelArcA770LE.h \ Controllers/IonicoController/IonicoController.h \ Controllers/IonicoController/RGBController_Ionico.h \ + Controllers/JginYueInternalUSBController/JginYueInternalUSBController.h \ + Controllers/JginYueInternalUSBController/RGBController_JginYueInternalUSB.h \ Controllers/KasaSmartController/KasaSmartController.h \ Controllers/KasaSmartController/RGBController_KasaSmart.h \ Controllers/KeychronKeyboardController/KeychronKeyboardController.h \ @@ -1262,6 +1265,9 @@ SOURCES += Controllers/IonicoController/IonicoControllerDetect.cpp \ Controllers/IonicoController/RGBController_Ionico.cpp \ Controllers/IntelArcA770LEController/RGBController_IntelArcA770LE.cpp \ + Controllers/JginYueInternalUSBController/RGBController_JginYueInternalUSB.cpp \ + Controllers/JginYueInternalUSBController/JginYueInternalUSBController.cpp \ + Controllers/JginYueInternalUSBController/JginYueInternalUSBControllerDetect.cpp \ Controllers/KasaSmartController/KasaSmartController.cpp \ Controllers/KasaSmartController/KasaSmartControllerDetect.cpp \ Controllers/KasaSmartController/RGBController_KasaSmart.cpp \