Clear fan data works
This commit is contained in:
parent
822845cc7a
commit
b8d19731ad
@ -38,7 +38,7 @@ void parse_command(uint8_t command[], uint8_t command_len) {
|
||||
context.command = WRITE_CONFIG;
|
||||
break;
|
||||
case 0x22: // Clear stored fan speed data
|
||||
context.command = READ_BULK_FAN_SPEED;
|
||||
context.command = CLEAR_BULK_FAN_SPEED;
|
||||
break;
|
||||
default: // Unrecognized command
|
||||
context.command = UNKNOWN_COMMAND;
|
||||
@ -89,7 +89,6 @@ void parse_command(uint8_t command[], uint8_t command_len) {
|
||||
case 0x14: // Read current fan speed
|
||||
case 0x15: // Read bulk fan speed
|
||||
case 0x22: // Clear stored fan speed data
|
||||
context.command = READ_BULK_FAN_SPEED;
|
||||
if (param == 0x01) {
|
||||
context.fan = FAN1;
|
||||
} else if (param == 0x02) {
|
||||
@ -193,6 +192,14 @@ uint8_t route_command(int pos) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case CLEAR_BULK_FAN_SPEED:
|
||||
// Overwrite the content of the desired fan array with zeroes
|
||||
if (context.fan == FAN1) {
|
||||
memset(fan1_history, 0, sizeof(fan1_history));
|
||||
} else if (context.fan == FAN2) {
|
||||
memset(fan2_history, 0, sizeof(fan2_history));
|
||||
}
|
||||
break;
|
||||
case UNKNOWN_COMMAND:
|
||||
default:
|
||||
return 0xFF;
|
||||
|
||||
@ -21,14 +21,14 @@ extern "C" {
|
||||
|
||||
// Enum of all valid command types
|
||||
typedef enum {
|
||||
WRITE_CONFIG, // Change the configuration
|
||||
READ_CONFIG, // Read, and print the current configuration
|
||||
READ_VOLTAGE, // Read, and print a voltage
|
||||
READ_TERMPERATURE, // Read, and print the temperature
|
||||
READ_FAN_SPEED, // Read, and print the current fan speed
|
||||
READ_BULK_FAN_SPEED, // Read, and print the stored back fan speed data
|
||||
CLEAR_BULK_FAN_SPEED, // Clear the buffer of stored fan speed data
|
||||
UNKNOWN_COMMAND // An unrecognized command has been sent
|
||||
WRITE_CONFIG = 0x21, // Change the configuration
|
||||
READ_CONFIG = 0x11, // Read, and print the current configuration
|
||||
READ_VOLTAGE = 0x12, // Read, and print a voltage
|
||||
READ_TERMPERATURE = 0x13, // Read, and print the temperature
|
||||
READ_FAN_SPEED = 0x14, // Read, and print the current fan speed
|
||||
READ_BULK_FAN_SPEED = 0x15, // Read, and print the stored back fan speed data
|
||||
CLEAR_BULK_FAN_SPEED = 0x22, // Clear the buffer of stored fan speed data
|
||||
UNKNOWN_COMMAND // An unrecognized command has been sent
|
||||
} command_t;
|
||||
|
||||
// Enum of all valid voltage sources
|
||||
|
||||
@ -67,7 +67,23 @@ void i2c_stop_handler() {
|
||||
if (last_action_write) {
|
||||
// Parse the received command data
|
||||
parse_command(i2c_recv, i2c_recv_len);
|
||||
|
||||
if (i2c_recv[0] == 0x22) {
|
||||
route_command(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write only commands need to be routed now
|
||||
switch (i2c_recv[0]) {
|
||||
WRITE_CONFIG:
|
||||
CLEAR_BULK_FAN_SPEED:
|
||||
route_command(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
// Reset the buffer for future transmissions
|
||||
i2c_reset_recv();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user