@@ -835,64 +835,61 @@ void ExecGunModeDocked()
835835
836836 unsigned long tempChecked = millis ();
837837 unsigned long aStickChecked = millis ();
838- uint8_t aStickDirPrev;
839-
840- {
841- char buf[64 ];
842- int pos = sprintf (&buf[0 ], " %.1f"
843- #ifdef GIT_HASH
844- " -%s"
845- #endif // GIT_HASH
846- , OPENFIRE_VERSION
847- #ifdef GIT_HASH
848- , GIT_HASH
849- #endif // GIT_HASH
850- );
838+ unsigned long currentMillis = millis ();
839+
840+ char buf[64 ];
841+ int pos = sprintf (&buf[0 ], " %.1f"
842+ #ifdef GIT_HASH
843+ " -%s"
844+ #endif // GIT_HASH
845+ , OPENFIRE_VERSION
846+ #ifdef GIT_HASH
847+ , GIT_HASH
848+ #endif // GIT_HASH
849+ );
850+ buf[pos++] = OF_Const::serialTerminator;
851+ pos += sprintf (&buf[pos], " %s" , OPENFIRE_BOARD);
852+ buf[pos++] = OF_Const::serialTerminator;
853+ memcpy (&buf[pos], &OF_Prefs::usb, sizeof (OF_Prefs::USBMap_t));
854+ pos += sizeof (OF_Prefs::USBMap_t);
855+ if (FW_Common::camNotAvailable) {
851856 buf[pos++] = OF_Const::serialTerminator;
852- pos += sprintf (&buf[pos], " %s" , OPENFIRE_BOARD);
853- buf[pos++] = OF_Const::serialTerminator;
854- memcpy (&buf[pos], &OF_Prefs::usb, sizeof (OF_Prefs::USBMap_t));
855- pos += sizeof (OF_Prefs::USBMap_t);
856- if (FW_Common::camNotAvailable) {
857- buf[pos++] = OF_Const::serialTerminator;
858- buf[pos++] = OF_Const::sError ;
859- }
860- Serial.write (buf, pos);
861- Serial.flush ();
857+ buf[pos++] = OF_Const::sError ;
862858 }
859+ Serial.write (buf, pos);
860+ Serial.flush ();
863861
864862 for (;;) {
865863 FW_Common::buttons.Poll (1 );
864+ currentMillis = millis ();
866865
867866 if (!FW_Common::dockedSaving) {
868867 if (FW_Common::buttons.pressed ) {
869868 for (uint i = 0 ; i < ButtonCount; ++i)
870869 if (bitRead (FW_Common::buttons.pressed , i)) {
871- const char buf[] = { OF_Const::sBtnPressed , ( uint8_t )i} ;
870+ buf[0 ] = OF_Const::sBtnPressed , buf[ 1 ] = i ;
872871 Serial.write (buf, 2 );
873872 }
874873 }
875874
876875 if (FW_Common::buttons.released ) {
877876 for (uint i = 0 ; i < ButtonCount; ++i)
878877 if (bitRead (FW_Common::buttons.released , i)) {
879- const char buf[] = { OF_Const::sBtnReleased , ( uint8_t )i} ;
878+ buf[0 ] = OF_Const::sBtnReleased , buf[ 1 ] = i ;
880879 Serial.write (buf, 2 );
881880 }
882881 }
883882
884883 #ifdef USES_TEMP
885- if (OF_Prefs::pins[OF_Const::tempPin] > -1 )
884+ if (OF_Prefs::pins[OF_Const::tempPin] > -1 ) {
886885 OF_FFB::TemperatureUpdate ();
887886
888- unsigned long currentMillis = millis ();
889- if (currentMillis - tempChecked >= 1000 ) {
890- if (OF_Prefs::pins[OF_Const::tempPin] >= 0 ) {
891- const char buf[] = {OF_Const::sTemperatureUpd , (uint8_t )OF_FFB::temperatureCurrent};
887+ if (currentMillis - tempChecked >= 1000 ) {
888+ buf[0 ] = OF_Const::sTemperatureUpd , buf[1 ] = OF_FFB::temperatureCurrent;
892889 Serial.write (buf, 2 );
893- }
894890
895- tempChecked = currentMillis;
891+ tempChecked = currentMillis;
892+ }
896893 }
897894 #endif // USES_TEMP
898895
@@ -903,10 +900,10 @@ void ExecGunModeDocked()
903900 uint16_t analogValueX = analogRead (OF_Prefs::pins[OF_Const::analogX]);
904901 uint16_t analogValueY = analogRead (OF_Prefs::pins[OF_Const::analogY]);
905902
906- char buf[5 ] = { OF_Const::sAnalogPosUpd } ;
903+ buf[0 ] = OF_Const::sAnalogPosUpd ;
907904 memcpy (&buf[1 ], (uint8_t *)&analogValueX, sizeof (uint16_t ));
908905 memcpy (&buf[3 ], (uint8_t *)&analogValueY, sizeof (uint16_t ));
909- Serial.write (buf, sizeof (buf) );
906+ Serial.write (buf, 5 );
910907 }
911908 #endif // USES_ANALOG
912909 }
0 commit comments