void setup() { Serial.begin(19200); delay(250); while(Serial.available()) Serial.read(); } // setup void loop() { if(!lcd_updatetime) lcd_update(); my_delay(100); // --------------- serial in --------------- if (Serial.available() > 0) { char incomingByte = (char)Serial.read(); if(incomingByte == 13) // Wenn das Enter ankommt { strcpy(serial_in_command, serial_in_buff); memset(&serial_in_buff[0], 0, sizeof(serial_in_buff)); // 30.554 Bytes chr_cnt = 0; } else // Falls kein Enter kommt muss der Text gespeichert werden in dem inText Array { if(isprint(incomingByte)) { if(chr_cnt<(MAXBUFFER-2)) serial_in_buff[chr_cnt++] = incomingByte; else { Serial.println(F("serBUF ov-> DEL")); memset(&serial_in_buff[0], 0, sizeof(serial_in_buff)); // 30.554 Bytes memset(&serial_in_command[0], 0, sizeof(serial_in_command)); // 30.554 Bytes chr_cnt=0; } // if(chr_cnt<(MAXBUFFER-1)) } // if(isprint(incomingByte)) } // if !(incomingByte == 13) } // if (Serial.available() > 0) if(strlen(serial_in_command)) { Serial.println(); Serial.print(serial_in_command); Serial.println(F("->erkannt")); // 30.608 Bytes if( strstr(serial_in_command, "help") || ( strstr(serial_in_command, "?") && strlen(serial_in_command)==1 ) ) { // help screen Serial.println(F("\ncommands:\n")); Serial.println(F("up")); Serial.println(F("reset")); Serial.println(F("")); } else if( strstr(serial_in_command, "up") ) { if( strlen(serial_in_command) == 2 && !faehrt ) { *serial_in_command=0; alle_fahren(1); } // if( strlen(serial_in_command) == 2 && !faehrt ) else if( strstr(serial_in_command, "up?") ) { sprintf_P(s_out_str, PSTR("up %s Uhr"), MY_EEP_VAR.fenster_up_time_str); Serial.println(s_out_str); } else if( strlen(serial_in_command) >= 7 ) { uint8_t hh=atoi(strncpy(serial_in_buff, &serial_in_command[2], 2)); if( 0 <= hh && hh <= 12) { uint8_t mm = atoi(strncpy(serial_in_buff, &serial_in_command[5], 2)); if( 0 <= mm && mm < 60) { if( strcmp(MY_EEP_VAR.fenster_up_time_str, MY_EEP_VAR.sonnenaufgang_time_str) || !strcmp(MY_EEP_VAR.fenster_up_time_str, MY_EEP_VAR.sonnenaufgang_time_str) ) sprintf( MY_EEP_VAR.fenster_up_time_str, "%02d:%02d", hh, mm); else Serial.println(F("up unveraendert")); Serial.print(F("up_time: ")); Serial.println(MY_EEP_VAR.fenster_up_time_str); my_i2c_eeprom_write_buffer( sizeof(jar_str), (char*)&MY_EEP_VAR, sizeof(MY_EEP_VAR) ); Serial.println(F("EEP_W")); } // if( 0 <= mm && mm < 60) else DEBUG_PRINTLN(F("ERROR mm Fehler uptime nicht gestellt !")); } // if( 0 <= hh && hh <= 12) else DEBUG_PRINTLN(F("ERROR hh Fehler uptime nicht gestellt !")); } // else if( strlen(serial_in_command) >= 7 ) } // if( strstr(serial_in_command, "up") ) else if( !strcmp(serial_in_command, "reset") ) { // "reset" delay(250); {asm("ldi r30,0"); asm("ldi r31,0"); asm("ijmp");} } // if( !strcmp(serial_in_command, "reset") ) *serial_in_command=0; } // if(strlen(serial_in_command)) } // loop()