Merge I2C command handler into main #18

Merged
sebgab merged 15 commits from output-fan-data-over-i2c into main 2024-04-30 08:37:29 +00:00
2 changed files with 12 additions and 4 deletions
Showing only changes of commit ae1c50ee09 - Show all commits

View File

@ -137,7 +137,7 @@ void parse_command(uint8_t command[], uint8_t command_len) {
// Validate that we have a fourth parameter, else requirements for command are // Validate that we have a fourth parameter, else requirements for command are
// not fulfilled. return unknown command. Second parameter is u16, thus two bytes. // not fulfilled. return unknown command. Second parameter is u16, thus two bytes.
if (command_len < 5) { if (command_len < 4) {
context.command = UNKNOWN_COMMAND; context.command = UNKNOWN_COMMAND;
return; return;
} }
@ -161,7 +161,16 @@ void parse_command(uint8_t command[], uint8_t command_len) {
uint8_t route_command(int pos) { uint8_t route_command(int pos) {
switch (context.command) { switch (context.command) {
case WRITE_CONFIG: case WRITE_CONFIG:
return WRITE_CONFIG; switch (context.conf) {
case SAMPLE_TIME:
// Overwrite the config value
config.ms_fanspeed_sample_rate = context.conf_val;
// Set the flag to store it in the EEPROM
store_config = true;
break;
}
break;
case READ_CONFIG: case READ_CONFIG:
{ {
switch (context.conf) { switch (context.conf) {

View File

@ -40,8 +40,7 @@ int main() {
stdout = &USART_stream; stdout = &USART_stream;
// Read the stored config struct // Read the stored config struct
//config = read_struct_from_EEPROM(); config = read_struct_from_EEPROM();
config.ms_fanspeed_sample_rate = 500;
PORTB.DIRSET = PIN3_bm; PORTB.DIRSET = PIN3_bm;