diff --git a/prosjekt.X/command-handler.c b/prosjekt.X/command-handler.c index 1de3001..347043c 100644 --- a/prosjekt.X/command-handler.c +++ b/prosjekt.X/command-handler.c @@ -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 // not fulfilled. return unknown command. Second parameter is u16, thus two bytes. - if (command_len < 5) { + if (command_len < 4) { context.command = UNKNOWN_COMMAND; return; } @@ -161,7 +161,16 @@ void parse_command(uint8_t command[], uint8_t command_len) { uint8_t route_command(int pos) { switch (context.command) { 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: { switch (context.conf) { diff --git a/prosjekt.X/main.c b/prosjekt.X/main.c index 57d6a81..35b71c9 100644 --- a/prosjekt.X/main.c +++ b/prosjekt.X/main.c @@ -40,8 +40,7 @@ int main() { stdout = &USART_stream; // Read the stored config struct - //config = read_struct_from_EEPROM(); - config.ms_fanspeed_sample_rate = 500; + config = read_struct_from_EEPROM(); PORTB.DIRSET = PIN3_bm;