Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 2 additions & 140 deletions include/logic/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,8 @@
#include <getopt.h>
#include <stdint.h>

struct color {
uint8_t red;
uint8_t green;
uint8_t blue;
};

struct led_temperatures {
uint8_t temp1;
uint8_t temp2;
uint8_t temp3;
};

enum led_modes {
STATIC = 0,
BLINK = 1,
PULSE = 2,
SHIFT = 3,
RAINBOW = 4,
TEMPERATURE = 5,
};

struct temp_speed_pair {
/** temperature */
int8_t temperature;

/** fan speed PWM */
int8_t speed;
};

enum motor_modes {
PWM = 0,
RPM = 1,
DEFAULT = 2,
QUIET = 3,
BALANCED = 4,
PERFORMANCE = 5,
CUSTOM = 6,
UNDEFINED = 7,
};
#include "logic/support.h"
#include "logic/suboptions.h"

struct option_flags {
// flags
Expand All @@ -73,47 +36,6 @@ struct option_flags {
unsigned int set_pump : 1;
};

struct led_control {
uint8_t channel;
enum led_modes mode;
struct color led_colors[7];
uint16_t temperatures[3];
uint8_t speed;
uint8_t count;
uint8_t led_type; // commanderpro
uint8_t direction; // commanderpro
uint8_t change_style; // commanderpro
};

struct fan_control {
uint8_t channel;
enum motor_modes mode;
struct temp_speed_pair table[7];

// data returns
uint8_t fan_count;
uint8_t fan_type;
uint8_t temp_sensor_id;
uint16_t data;
uint16_t speed;
uint8_t speed_pwm;
uint16_t speed_rpm;
uint16_t max_speed;
char mode_string[64];
};

struct pump_control {
uint8_t channel;
enum motor_modes mode;
struct temp_speed_pair table[6];

// data returns
uint16_t speed;
uint8_t speed_pwm;
uint16_t speed_rpm;
uint16_t max_speed;
};

struct option_parse_return {
struct led_control led_ctrl;
struct fan_control fan_ctrl;
Expand Down Expand Up @@ -177,66 +99,6 @@ static struct option long_options[] = {
xx[6].green = 0x00; \
xx[6].blue = 0xff;

enum {
SUBOPTION_FAN_CHANNEL = 0,
SUBOPTION_FAN_MODE,
SUBOPTION_FAN_PWM,
SUBOPTION_FAN_RPM,
SUBOPTION_FAN_TEMPERATURES,
SUBOPTION_FAN_SPEEDS,
SUBOPTION_FAN_LIST_END,
};

enum {
SUBOPTION_LED_CHANNEL = 0,
SUBOPTION_LED_MODE,
SUBOPTION_LED_SPEED,
SUBOPTION_LED_COLORS,
SUBOPTION_LED_WARN,
SUBOPTION_LED_TEMPERATURES,
SUBOPTION_LED_LIST_END,
};

enum {
SUBOPTION_PUMP_MODE = 0,
SUBOPTION_PUMP_PWM,
SUBOPTION_PUMP_RPM,
SUBOPTION_PUMP_TEMPERATURES,
SUBOPTION_PUMP_SPEEDS,
SUBOPTION_PUMP_LIST_END,
};

static char *fan_options[] = {[SUBOPTION_FAN_CHANNEL] = "channel",
[SUBOPTION_FAN_MODE] = "mode",
[SUBOPTION_FAN_PWM] = "pwm",
[SUBOPTION_FAN_RPM] = "rpm",
[SUBOPTION_FAN_TEMPERATURES] = "temps",
[SUBOPTION_FAN_SPEEDS] = "speeds",
[SUBOPTION_FAN_LIST_END] = 0};

static char *led_options[] = {[SUBOPTION_LED_CHANNEL] = "channel",
[SUBOPTION_LED_MODE] = "mode",
[SUBOPTION_LED_SPEED] = "speed",
[SUBOPTION_LED_COLORS] = "colors",
[SUBOPTION_LED_WARN] = "warning_color",
[SUBOPTION_LED_TEMPERATURES] = "temps",
[SUBOPTION_LED_LIST_END] = 0};

static char *pump_options[] = {[SUBOPTION_PUMP_MODE] = "mode",
[SUBOPTION_PUMP_PWM] = "pwm",
[SUBOPTION_PUMP_RPM] = "rpm",
[SUBOPTION_PUMP_TEMPERATURES] = "temps",
[SUBOPTION_PUMP_SPEEDS] = "speeds",
[SUBOPTION_PUMP_LIST_END] = 0};

void fan_suboptions_parse(char *subopts, struct fan_control *settings);
void led_suboptions_parse(char *subopts, struct led_control *settings);
void pump_suboptions_parse(char *subopts, struct pump_control *settings);

void fan_control_init(struct fan_control *settings);
void led_control_init(struct led_control *settings);
void pump_control_init(struct pump_control *settings);

void options_print(void);

int options_parse(int argc, char **argv, struct option_flags *flags,
Expand Down
120 changes: 120 additions & 0 deletions include/logic/suboptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* This file is part of OpenCorsairLink.
* Copyright (C) 2017-2019 Sean Nelson <audiohacked@gmail.com>

* OpenCorsairLink is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.

* OpenCorsairLink is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _SUBOPTIONS_H
#define _SUBOPTIONS_H

enum {
SUBOPTION_FAN_CHANNEL = 0,
SUBOPTION_FAN_MODE,
SUBOPTION_FAN_PWM,
SUBOPTION_FAN_RPM,
SUBOPTION_FAN_TEMPERATURES,
SUBOPTION_FAN_SPEEDS,
SUBOPTION_FAN_LIST_END,
};

enum {
SUBOPTION_LED_CHANNEL = 0,
SUBOPTION_LED_MODE,
SUBOPTION_LED_SPEED,
SUBOPTION_LED_COLORS,
SUBOPTION_LED_WARN,
SUBOPTION_LED_TEMPERATURES,
SUBOPTION_LED_LIST_END,
};

enum {
SUBOPTION_PUMP_MODE = 0,
SUBOPTION_PUMP_PWM,
SUBOPTION_PUMP_RPM,
SUBOPTION_PUMP_TEMPERATURES,
SUBOPTION_PUMP_SPEEDS,
SUBOPTION_PUMP_LIST_END,
};

struct led_control {
uint8_t channel;
enum led_modes mode;
struct color led_colors[7];
uint16_t temperatures[3];
uint8_t speed;
uint8_t count;
};

struct fan_control {
uint8_t channel;
enum motor_modes mode;
struct temp_speed_pair table[7];

// data returns
uint8_t fan_count;
uint8_t fan_type;
uint8_t temp_sensor_id;
uint16_t data;
uint16_t speed;
uint8_t speed_pwm;
uint16_t speed_rpm;
uint16_t max_speed;
char mode_string[64];
};

struct pump_control {
uint8_t channel;
enum motor_modes mode;
struct temp_speed_pair table[6];

// data returns
uint16_t speed;
uint8_t speed_pwm;
uint16_t speed_rpm;
uint16_t max_speed;
};

static char *fan_options[] = {[SUBOPTION_FAN_CHANNEL] = "channel",
[SUBOPTION_FAN_MODE] = "mode",
[SUBOPTION_FAN_PWM] = "pwm",
[SUBOPTION_FAN_RPM] = "rpm",
[SUBOPTION_FAN_TEMPERATURES] = "temps",
[SUBOPTION_FAN_SPEEDS] = "speeds",
[SUBOPTION_FAN_LIST_END] = 0};

static char *led_options[] = {[SUBOPTION_LED_CHANNEL] = "channel",
[SUBOPTION_LED_MODE] = "mode",
[SUBOPTION_LED_SPEED] = "speed",
[SUBOPTION_LED_COLORS] = "colors",
[SUBOPTION_LED_WARN] = "warning_color",
[SUBOPTION_LED_TEMPERATURES] = "temps",
[SUBOPTION_LED_LIST_END] = 0};

static char *pump_options[] = {[SUBOPTION_PUMP_MODE] = "mode",
[SUBOPTION_PUMP_PWM] = "pwm",
[SUBOPTION_PUMP_RPM] = "rpm",
[SUBOPTION_PUMP_TEMPERATURES] = "temps",
[SUBOPTION_PUMP_SPEEDS] = "speeds",
[SUBOPTION_PUMP_LIST_END] = 0};

void fan_suboptions_parse(char *subopts, struct fan_control *settings);
void led_suboptions_parse(char *subopts, struct led_control *settings);
void pump_suboptions_parse(char *subopts, struct pump_control *settings);

void fan_control_init(struct fan_control *settings);
void led_control_init(struct led_control *settings);
void pump_control_init(struct pump_control *settings);

#endif
95 changes: 95 additions & 0 deletions include/logic/support.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* This file is part of OpenCorsairLink.
* Copyright (C) 2017-2019 Sean Nelson <audiohacked@gmail.com>

* OpenCorsairLink is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.

* OpenCorsairLink is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _SUPPORT_H
#define _SUPPORT_H

struct color {
uint8_t red;
uint8_t green;
uint8_t blue;
};

struct led_temperatures {
uint8_t temp1;
uint8_t temp2;
uint8_t temp3;
};

enum led_modes {
STATIC = 0,
BLINK = 1,
PULSE = 2,
SHIFT = 3,
RAINBOW = 4,
TEMPERATURE = 5,
};

struct temp_speed_pair {
/** temperature */
int8_t temperature;

/** fan speed PWM */
int8_t speed;
};

enum motor_modes {
PWM = 0,
RPM = 1,
DEFAULT = 2,
QUIET = 3,
BALANCED = 4,
PERFORMANCE = 5,
CUSTOM = 6,
UNDEFINED = 7,
};

#define INIT_WARNING_LED(xx) \
xx.red = 0xFF; \
xx.green = 0x00; \
xx.blue = 0x00;

#define INIT_DEFAULT_LED(xx) \
xx.red = 0xFF; \
xx.green = 0xFF; \
xx.blue = 0x00;

#define INIT_RAINBOW_LED(xx) \
xx[0].red = 0xff; \
xx[0].green = 0x00; \
xx[0].blue = 0x00; \
xx[1].red = 0xff; \
xx[1].green = 0x80; \
xx[1].blue = 0x00; \
xx[2].red = 0xff; \
xx[2].green = 0xff; \
xx[2].blue = 0x00; \
xx[3].red = 0x00; \
xx[3].green = 0xff; \
xx[3].blue = 0x00; \
xx[4].red = 0x00; \
xx[4].green = 0x00; \
xx[4].blue = 0xff; \
xx[5].red = 0x4b; \
xx[5].green = 0x00; \
xx[5].blue = 0x82; \
xx[6].red = 0x7f; \
xx[6].green = 0x00; \
xx[6].blue = 0xff;

#endif
3 changes: 2 additions & 1 deletion logic/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

#include "common.h"
// #include "logic/support.h"
// #include "logic/suboptions.h"
#include "logic/options.h"
#include "logic/print.h"

Expand Down
Loading