diff --git a/.vscode/settings.json b/.vscode/settings.json index b870cb12..899adfcc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false, AlignConsecutiveAssignments: Consecutive, AlignConsecutiveBitFields: Consecutive, AlignConsecutiveDeclarations: Consecutive, AlignConsecutiveMacros: Consecutive, AlignTrailingComments: true, AllowShortBlocksOnASingleLine: Empty, AllowShortEnumsOnASingleLine: true, AllowShortFunctionsOnASingleLine: Inline, AllowShortIfStatementsOnASingleLine: WithoutElse, BreakInheritanceList: BeforeColon, EmptyLineBeforeAccessModifier: LogicalBlock, SortIncludes: Never }", + "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Linux, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false, AlignConsecutiveAssignments: Consecutive, AlignConsecutiveBitFields: Consecutive, AlignConsecutiveDeclarations: Consecutive, AlignConsecutiveMacros: Consecutive, AlignTrailingComments: true, AllowShortBlocksOnASingleLine: Empty, AllowShortEnumsOnASingleLine: true, AllowShortFunctionsOnASingleLine: Inline, AllowShortIfStatementsOnASingleLine: WithoutElse, BreakInheritanceList: BeforeColon, EmptyLineBeforeAccessModifier: LogicalBlock, SortIncludes: Never }", "[cpp]": { "editor.defaultFormatter": "ms-vscode.cpptools", "editor.formatOnSave": true diff --git a/CustomDevices b/CustomDevices deleted file mode 100644 index e69de29b..00000000 diff --git a/_Boards/Atmel/Board_Mega/MFBoards.h b/_Boards/Atmel/Board_Mega/MFBoards.h deleted file mode 100644 index ba5114df..00000000 --- a/_Boards/Atmel/Board_Mega/MFBoards.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// MFBoards.h (Arduino Mega) -// -// (C) MobiFlight Project 2022 -// - -#ifndef MFBoardMega_h -#define MFBoardMega_h - -#ifndef MF_SEGMENT_SUPPORT -#define MF_SEGMENT_SUPPORT 1 -#endif -#ifndef MF_LCD_SUPPORT -#define MF_LCD_SUPPORT 1 -#endif -#ifndef MF_STEPPER_SUPPORT -#define MF_STEPPER_SUPPORT 1 -#endif -#ifndef MF_SERVO_SUPPORT -#define MF_SERVO_SUPPORT 1 -#endif -#ifndef MF_ANALOG_SUPPORT -#define MF_ANALOG_SUPPORT 1 -#endif -#ifndef MF_OUTPUT_SHIFTER_SUPPORT -#define MF_OUTPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_INPUT_SHIFTER_SUPPORT -#define MF_INPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#endif -#ifndef MF_DIGIN_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#define MF_DIGIN_MUX_SUPPORT 1 -#endif - -#ifndef MOBIFLIGHT_TYPE -#define MOBIFLIGHT_TYPE "MobiFlight Mega" -#endif -#ifndef MOBIFLIGHT_NAME -#define MOBIFLIGHT_NAME "MobiFlight Mega" -#endif -#ifndef MEMLEN_CONFIG -#define MEMLEN_CONFIG 1496 // max. size for config which wil be stored in EEPROM -#endif -#ifndef MEMLEN_NAMES_BUFFER -#define MEMLEN_NAMES_BUFFER 1000 // max. size for configBuffer, contains only names from inputs -#endif -#ifndef MF_MAX_DEVICEMEM -#define MF_MAX_DEVICEMEM 1600 // max. memory size for devices -#endif - -#endif - -// MFBoards.h \ No newline at end of file diff --git a/_Boards/Atmel/Board_Nano/MFBoards.h b/_Boards/Atmel/Board_Nano/MFBoards.h deleted file mode 100644 index aa2afeb8..00000000 --- a/_Boards/Atmel/Board_Nano/MFBoards.h +++ /dev/null @@ -1,56 +0,0 @@ -// -// MFBoards.h (Arduino Uno/Nano) -// -// (C) MobiFlight Project 2022 -// - -#ifndef MFBoardUno_h -#define MFBoardUno_h - -#ifndef MF_SEGMENT_SUPPORT -#define MF_SEGMENT_SUPPORT 1 -#endif -#ifndef MF_LCD_SUPPORT -#define MF_LCD_SUPPORT 1 -#endif -#ifndef MF_STEPPER_SUPPORT -#define MF_STEPPER_SUPPORT 1 -#endif -#ifndef MF_SERVO_SUPPORT -#define MF_SERVO_SUPPORT 1 -#endif -#ifndef MF_ANALOG_SUPPORT -#define MF_ANALOG_SUPPORT 1 -#endif -#ifndef MF_OUTPUT_SHIFTER_SUPPORT -#define MF_OUTPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_INPUT_SHIFTER_SUPPORT -#define MF_INPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#endif -#ifndef MF_DIGIN_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#define MF_DIGIN_MUX_SUPPORT 1 -#endif - -#ifndef MOBIFLIGHT_TYPE -#define MOBIFLIGHT_TYPE "MobiFlight Nano" -#endif -#ifndef MOBIFLIGHT_NAME -#define MOBIFLIGHT_NAME "MobiFlight Nano" -#endif -#ifndef MEMLEN_CONFIG -#define MEMLEN_CONFIG 286 // max. size for config which wil be stored in EEPROM -#endif -#ifndef MEMLEN_NAMES_BUFFER -#define MEMLEN_NAMES_BUFFER 220 // max. size for configBuffer, contains only names from inputs -#endif -#ifndef MF_MAX_DEVICEMEM -#define MF_MAX_DEVICEMEM 420 // max. memory size for devices -#endif -#endif - -// MFBoards.h \ No newline at end of file diff --git a/_Boards/Atmel/Board_ProMicro/MFBoards.h b/_Boards/Atmel/Board_ProMicro/MFBoards.h deleted file mode 100644 index d114f358..00000000 --- a/_Boards/Atmel/Board_ProMicro/MFBoards.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// MFBoards.h (Arduino ProMicro) -// -// (C) MobiFlight Project 2022 -// - -#ifndef MFBoardMicro_h -#define MFBoardMicro_h - -#ifndef MF_SEGMENT_SUPPORT -#define MF_SEGMENT_SUPPORT 1 -#endif -#ifndef MF_LCD_SUPPORT -#define MF_LCD_SUPPORT 1 -#endif -#ifndef MF_STEPPER_SUPPORT -#define MF_STEPPER_SUPPORT 1 -#endif -#ifndef MF_SERVO_SUPPORT -#define MF_SERVO_SUPPORT 1 -#endif -#ifndef MF_ANALOG_SUPPORT -#define MF_ANALOG_SUPPORT 1 -#endif -#ifndef MF_OUTPUT_SHIFTER_SUPPORT -#define MF_OUTPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_INPUT_SHIFTER_SUPPORT -#define MF_INPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#endif -#ifndef MF_DIGIN_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#define MF_DIGIN_MUX_SUPPORT 1 -#endif - -#ifndef MOBIFLIGHT_TYPE -#define MOBIFLIGHT_TYPE "MobiFlight Micro" -#endif -#ifndef MOBIFLIGHT_NAME -#define MOBIFLIGHT_NAME "MobiFlight Micro" -#endif -#ifndef MEMLEN_CONFIG -#define MEMLEN_CONFIG 440 // max. size for config which wil be stored in EEPROM -#endif -#ifndef MEMLEN_NAMES_BUFFER -#define MEMLEN_NAMES_BUFFER 350 // max. size for configBuffer, contains only names from inputs -#endif -#ifndef MF_MAX_DEVICEMEM -#define MF_MAX_DEVICEMEM 470 // max. memory size for devices -#endif - -#endif - -// MFBoards.h diff --git a/_Boards/Atmel/Board_Uno/MFBoards.h b/_Boards/Atmel/Board_Uno/MFBoards.h deleted file mode 100644 index 71a37786..00000000 --- a/_Boards/Atmel/Board_Uno/MFBoards.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// MFBoards.h (Arduino Uno/Nano) -// -// (C) MobiFlight Project 2022 -// - -#ifndef MFBoardUno_h -#define MFBoardUno_h - -#ifndef MF_SEGMENT_SUPPORT -#define MF_SEGMENT_SUPPORT 1 -#endif -#ifndef MF_LCD_SUPPORT -#define MF_LCD_SUPPORT 1 -#endif -#ifndef MF_STEPPER_SUPPORT -#define MF_STEPPER_SUPPORT 1 -#endif -#ifndef MF_SERVO_SUPPORT -#define MF_SERVO_SUPPORT 1 -#endif -#ifndef MF_ANALOG_SUPPORT -#define MF_ANALOG_SUPPORT 1 -#endif -#ifndef MF_OUTPUT_SHIFTER_SUPPORT -#define MF_OUTPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_INPUT_SHIFTER_SUPPORT -#define MF_INPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#endif -#ifndef MF_DIGIN_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#define MF_DIGIN_MUX_SUPPORT 1 -#endif - -#ifndef MOBIFLIGHT_TYPE -#define MOBIFLIGHT_TYPE "MobiFlight Uno" -#endif -#ifndef MOBIFLIGHT_NAME -#define MOBIFLIGHT_NAME "MobiFlight Uno" -#endif -#ifndef MEMLEN_CONFIG -#define MEMLEN_CONFIG 286 // max. size for config which wil be stored in EEPROM -#endif -#ifndef MEMLEN_NAMES_BUFFER -#define MEMLEN_NAMES_BUFFER 220 // max. size for configBuffer, contains only names from inputs -#endif -#ifndef MF_MAX_DEVICEMEM -#define MF_MAX_DEVICEMEM 420 // max. memory size for devices -#endif - -#endif - -// MFBoards.h \ No newline at end of file diff --git a/_Boards/Atmel/Board_Uno/reset.arduino_uno_1_0_2.hex b/_Boards/Atmel/Board_Uno/reset.arduino_uno_1_0_2.hex deleted file mode 100644 index 86408120..00000000 --- a/_Boards/Atmel/Board_Uno/reset.arduino_uno_1_0_2.hex +++ /dev/null @@ -1,134 +0,0 @@ -:100000000C945D000C9485000C9485000C94850084 -:100010000C9485000C9485000C9485000C9485004C -:100020000C9485000C9485000C9485000C9485003C -:100030000C9485000C9485000C9485000C9485002C -:100040000C9437020C9485000C94A7020C94810246 -:100050000C9485000C9485000C9485000C9485000C -:100060000C9485000C9485000000000024002700FB -:100070002A0000000000250028002B0004040404CE -:100080000404040402020202020203030303030342 -:10009000010204081020408001020408102001021F -:1000A00004081020000000080002010000030407FB -:1000B0000000000000000000D90211241FBECFEF95 -:1000C000D8E0DEBFCDBF11E0A0E0B1E0E4E2F8E0AF -:1000D00002C005900D92A231B107D9F721E0A2E14B -:1000E000B1E001C01D92AA3BB207E1F710E0CDE5F7 -:1000F000D0E004C02197FE010E940A04CC35D1074C -:10010000C9F70E940A030C9410040C940000E1EB60 -:10011000F0E02491EDE9F0E09491E9E8F0E0E49179 -:10012000EE23C9F0222339F0233001F1A8F4213065 -:1001300019F1223029F1F0E0EE0FFF1FEE58FF4FCA -:10014000A591B4912FB7F894EC91811126C09095A8 -:100150009E239C932FBF08952730A9F02830C9F023 -:10016000243049F7209180002F7D03C0209180002A -:100170002F7720938000DFCF24B52F7724BDDBCFEE -:1001800024B52F7DFBCF2091B0002F772093B000B6 -:10019000D2CF2091B0002F7DF9CF9E2BDACF3FB781 -:1001A000F8948091170190911801A0911901B091D4 -:1001B0001A0126B5A89B05C02F3F19F00196A11D75 -:1001C000B11D3FBFBA2FA92F982F8827BC01CD01A1 -:1001D000620F711D811D911D42E0660F771F881F00 -:1001E000991F4A95D1F708958F929F92AF92BF922F -:1001F000CF92DF92EF92FF920E94CF004B015C0101 -:1002000088EEC82E83E0D82EE12CF12C0E94CF007E -:10021000681979098A099B09683E7340810591052F -:10022000A8F321E0C21AD108E108F10888EE880E8F -:1002300083E0981EA11CB11CC114D104E104F10497 -:1002400029F7FF90EF90DF90CF90BF90AF909F90F5 -:100250008F900895AF92BF92CF92DF92EF92FF926C -:100260000F931F93CF93DF936C017B018B01040FDE -:10027000151FEB015E01AE18BF08C017D10759F07A -:100280006991D601ED91FC910190F081E02DC601BC -:100290000995892B79F7C501DF91CF911F910F91B6 -:1002A000FF90EF90DF90CF90BF90AF900895FC014A -:1002B000538D448D252F30E0842F90E0821B930BCB -:1002C000541710F0CF96089501970895FC01918D71 -:1002D000828D981761F0A28DAE0FBF2FB11D5D9674 -:1002E0008C91928D9F5F9F73928F90E008958FEF16 -:1002F0009FEF0895FC01918D828D981731F0828DCA -:10030000E80FF11D858D90E008958FEF9FEF089520 -:10031000FC01918D228D892F90E0805C9F4F821B84 -:1003200091098F73992708958BE191E00E948801CC -:1003300021E0892B09F420E0822F089580E090E0ED -:10034000892B29F00E94940181110C9400000895DA -:10035000FC01A48DA80FB92FB11DA35ABF4F2C913A -:10036000848D90E001968F739927848FA689B78931 -:100370002C93A089B1898C91837080648C93938D28 -:10038000848D981306C00288F389E02D80818F7DCB -:1003900080830895EF92FF920F931F93CF93DF9383 -:1003A000EC0181E0888F9B8D8C8D98131AC0E889B1 -:1003B000F989808185FF15C09FB7F894EE89FF8980 -:1003C0006083E889F98980818370806480839FBF1E -:1003D00081E090E0DF91CF911F910F91FF90EF901E -:1003E0000895F62E0B8D10E00F5F1F4F0F7311272E -:1003F000E02E8C8D8E110CC00FB607FCFACFE88969 -:10040000F989808185FFF5CFCE010E94A801F1CF47 -:10041000EB8DEC0FFD2FF11DE35AFF4FF0829FB7DC -:10042000F8940B8FEA89FB8980818062CFCFCF93CC -:10043000DF93EC01888D8823B9F0AA89BB89E8890C -:10044000F9898C9185FD03C0808186FD0DC00FB6B2 -:1004500007FCF7CF8C9185FFF2CF808185FFEDCF30 -:10046000CE010E94A801E9CFDF91CF9108951F929C -:100470000F920FB60F9211242F933F938F939F9358 -:10048000AF93BF938091130190911401A091150136 -:10049000B09116013091120123E0230F2D3758F54A -:1004A0000196A11DB11D2093120180931301909319 -:1004B0001401A0931501B09316018091170190913A -:1004C0001801A0911901B0911A010196A11DB11D49 -:1004D0008093170190931801A0931901B0931A010A -:1004E000BF91AF919F918F913F912F910F900FBE30 -:1004F0000F901F90189526E8230F0296A11DB11D9D -:10050000D2CF1F920F920FB60F9211242F933F93C9 -:100510004F935F936F937F938F939F93AF93BF930B -:10052000EF93FF938BE191E00E94A801FF91EF917F -:10053000BF91AF919F918F917F916F915F914F91FB -:100540003F912F910F900FBE0F901F9018951F9203 -:100550000F920FB60F9211242F938F939F93EF93C7 -:10056000FF93E0912B01F0912C018081E09131010A -:10057000F091320182FD1BC09081809134018F5F28 -:100580008F7320913501821741F0E0913401F0E042 -:10059000E55EFE4F958F80933401FF91EF919F911F -:1005A0008F912F910F900FBE0F901F901895808103 -:1005B000F4CFEBE1F1E01382128288EE93E0A0E049 -:1005C000B0E084839583A683B78384E091E0918330 -:1005D000808385EC90E09587848784EC90E0978712 -:1005E000868780EC90E0918B808B81EC90E0938B00 -:1005F000828B82EC90E0958B848B86EC90E0978BDD -:10060000868B118E128E138E148E1092B901109259 -:10061000B8010895CF93DF93CDB7DEB7789484B552 -:10062000826084BD84B5816084BD85B5826085BDEE -:1006300085B5816085BD80916E00816080936E007C -:10064000109281008091810082608093810080916E -:10065000810081608093810080918000816080931F -:1006600080008091B10084608093B1008091B000DF -:1006700081608093B00080917A00846080937A00DA -:1006800080917A00826080937A0080917A00816004 -:1006900080937A0080917A00806880937A0010922B -:1006A000C1000DB71EB780E094E09093B90180932C -:1006B000B8018DB79EB794500FB6F8949EBF0FBE89 -:1006C0008DBFEDB7FEB731966F01EDE9F0E04491D3 -:1006D000E9E8F0E08491882399F090E0880F991F71 -:1006E000FC01E859FF4FA591B491FC01EE58FF4F72 -:1006F000859194918FB7F894EC91E42BEC938FBF94 -:10070000E0912B01F0912C0182E08083E0912701A0 -:10071000F09128011082E0912901F0912A0180E1F5 -:10072000808310923301E0912F01F091300186E037 -:100730008083E0912D01F0912E0180818061808382 -:10074000E0912D01F0912E01808188608083E091FD -:100750002D01F0912E01808180688083E0912D0130 -:10076000F0912E0180818F7D8083C6019C5FF60110 -:100770002FEF21938E179F07E1F78091B801909199 -:10078000B90181159440A8F0F12CE12CF601B1904B -:100790006F01C7010E94F403B81621F06B2DC70149 -:1007A0000E94FC03FFEFEF1AFF0AE11424E0F206B7 -:1007B00069F70FB6F8941EBF0FBE0DBF00E010E042 -:1007C00081E00E9487000E94F40080E00E94870080 -:1007D0000E94F4000115110599F30E9494018823E9 -:1007E00079F30E940000ECCFF999FECF92BD81BD54 -:1007F000F89A992780B50895262FF999FECF1FBA48 -:1008000092BD81BD20BD0FB6F894FA9AF99A0FBE39 -:1008100001960895EE0FFF1F0590F491E02D0994C5 -:04082000F894FFCF7A -:1008240000000000CA012A0157011702880166016D -:020834007A0147 -:00000001FF diff --git a/_Boards/RaspberryPi/Pico/MFBoards.h b/_Boards/RaspberryPi/Pico/MFBoards.h deleted file mode 100644 index c60cd6ec..00000000 --- a/_Boards/RaspberryPi/Pico/MFBoards.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef MFBoardMicro_h -#define MFBoardMicro_h - -#ifndef MF_SEGMENT_SUPPORT -#define MF_SEGMENT_SUPPORT 1 -#endif -#ifndef MF_LCD_SUPPORT -#define MF_LCD_SUPPORT 1 -#endif -#ifndef MF_STEPPER_SUPPORT -#define MF_STEPPER_SUPPORT 1 -#endif -#ifndef MF_SERVO_SUPPORT -#define MF_SERVO_SUPPORT 1 -#endif -#ifndef MF_ANALOG_SUPPORT -#define MF_ANALOG_SUPPORT 1 -#endif -#ifndef MF_OUTPUT_SHIFTER_SUPPORT -#define MF_OUTPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_INPUT_SHIFTER_SUPPORT -#define MF_INPUT_SHIFTER_SUPPORT 1 -#endif -#ifndef MF_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#endif -#ifndef MF_DIGIN_MUX_SUPPORT -#define MF_MUX_SUPPORT 1 -#define MF_DIGIN_MUX_SUPPORT 1 -#endif - -#ifndef MOBIFLIGHT_TYPE -#define MOBIFLIGHT_TYPE "MobiFlight RaspiPico" -#endif -#ifndef MOBIFLIGHT_NAME -#define MOBIFLIGHT_NAME "MobiFlight RaspiPico" -#endif -#ifndef MEMLEN_CONFIG -#define MEMLEN_CONFIG 1496 // MUST be less than EEPROM_SIZE!! MEM_OFFSET_CONFIG + MEM_LEN_CONFIG <= EEPROM_SIZE, see: eeprom_write_block (MEM_OFFSET_CONFIG, configBuffer, MEM_LEN_CONFIG); -#endif -#ifndef MEMLEN_NAMES_BUFFER -#define MEMLEN_NAMES_BUFFER 1000 // max. size for configBuffer, contains only names from inputs -#endif -#ifndef MF_MAX_DEVICEMEM -#define MF_MAX_DEVICEMEM 1000 // max. memory size for devices -#endif - -#endif diff --git a/_Boards/Atmel/Board_Mega/arduino_mega.board.json b/_Boards/arduino_mega.board.json similarity index 100% rename from _Boards/Atmel/Board_Mega/arduino_mega.board.json rename to _Boards/arduino_mega.board.json diff --git a/_Boards/Atmel/Board_ProMicro/arduino_micro.board.json b/_Boards/arduino_micro.board.json similarity index 100% rename from _Boards/Atmel/Board_ProMicro/arduino_micro.board.json rename to _Boards/arduino_micro.board.json diff --git a/_Boards/Atmel/Board_Nano/arduino_nano.board.json b/_Boards/arduino_nano.board.json similarity index 100% rename from _Boards/Atmel/Board_Nano/arduino_nano.board.json rename to _Boards/arduino_nano.board.json diff --git a/_Boards/Atmel/Board_Uno/arduino_uno.board.json b/_Boards/arduino_uno.board.json similarity index 100% rename from _Boards/Atmel/Board_Uno/arduino_uno.board.json rename to _Boards/arduino_uno.board.json diff --git a/_Boards/Atmel/Board_Mega/mobiflight_mega.png b/_Boards/mobiflight_mega.png similarity index 100% rename from _Boards/Atmel/Board_Mega/mobiflight_mega.png rename to _Boards/mobiflight_mega.png diff --git a/_Boards/Atmel/Board_ProMicro/mobiflight_micro.png b/_Boards/mobiflight_micro.png similarity index 100% rename from _Boards/Atmel/Board_ProMicro/mobiflight_micro.png rename to _Boards/mobiflight_micro.png diff --git a/_Boards/Atmel/Board_Nano/mobiflight_nano.png b/_Boards/mobiflight_nano.png similarity index 100% rename from _Boards/Atmel/Board_Nano/mobiflight_nano.png rename to _Boards/mobiflight_nano.png diff --git a/_Boards/Atmel/Board_Uno/mobiflight_uno.png b/_Boards/mobiflight_uno.png similarity index 100% rename from _Boards/Atmel/Board_Uno/mobiflight_uno.png rename to _Boards/mobiflight_uno.png diff --git a/_Boards/RaspberryPi/Pico/raspberry_pico.png b/_Boards/raspberry_pico.png similarity index 100% rename from _Boards/RaspberryPi/Pico/raspberry_pico.png rename to _Boards/raspberry_pico.png diff --git a/_Boards/RaspberryPi/Pico/raspberrypi_pico.board.json b/_Boards/raspberrypi_pico.board.json similarity index 100% rename from _Boards/RaspberryPi/Pico/raspberrypi_pico.board.json rename to _Boards/raspberrypi_pico.board.json diff --git a/_Boards/Atmel/Board_Mega/reset.arduino_mega_1_0_2.hex b/_Boards/reset.arduino_mega_1_0_2.hex similarity index 100% rename from _Boards/Atmel/Board_Mega/reset.arduino_mega_1_0_2.hex rename to _Boards/reset.arduino_mega_1_0_2.hex diff --git a/_Boards/Atmel/Board_ProMicro/reset.arduino_promicro_1_0_2.hex b/_Boards/reset.arduino_promicro_1_0_2.hex similarity index 100% rename from _Boards/Atmel/Board_ProMicro/reset.arduino_promicro_1_0_2.hex rename to _Boards/reset.arduino_promicro_1_0_2.hex diff --git a/_Boards/Atmel/Board_Nano/reset.arduino_uno_1_0_2.hex b/_Boards/reset.arduino_uno_1_0_2.hex similarity index 100% rename from _Boards/Atmel/Board_Nano/reset.arduino_uno_1_0_2.hex rename to _Boards/reset.arduino_uno_1_0_2.hex diff --git a/_Boards/RaspberryPi/Pico/reset.raspberry_pico_flash_nuke.uf2 b/_Boards/reset.raspberry_pico_flash_nuke.uf2 similarity index 100% rename from _Boards/RaspberryPi/Pico/reset.raspberry_pico_flash_nuke.uf2 rename to _Boards/reset.raspberry_pico_flash_nuke.uf2 diff --git a/copy_fw_files.py b/copy_fw_files.py index 46b434f0..b900edcb 100644 --- a/copy_fw_files.py +++ b/copy_fw_files.py @@ -15,7 +15,7 @@ build_path_fw = build_path / 'firmware' build_path_json = build_path / 'Boards' distrubution_path = './_dist' -board_folder = ['./_Boards/Atmel', './_Boards/RaspberryPi'] +board_folder = ['./_Boards'] def copy_fw_files (source, target, env): fw_file_name=str(target[0]) diff --git a/platformio.ini b/platformio.ini index 301967bc..53af38cf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -35,7 +35,17 @@ build_flags = -DDEFAULT_TIMEOUT=5000 ; -DREVERSED_OUTPUT_OUTPUT ; -DREVERSED_OUTPUT_OUTPUTSHIFTER -; -DDEBUG2CMDMESSENGER=1 +; -DDEBUG2CMDMESSENGER + -DMF_SEGMENT_SUPPORT + -DMF_LCD_SUPPORT + -DMF_STEPPER_SUPPORT + -DMF_SERVO_SUPPORT + -DMF_ANALOG_SUPPORT + -DMF_OUTPUT_SHIFTER_SUPPORT + -DMF_INPUT_SHIFTER_SUPPORT + -DMF_MUX_SUPPORT + -DMF_MUX_SUPPORT + -DMF_DIGIN_MUX_SUPPORT -I./src/MF_Analog -I./src/MF_Button -I./src/MF_Encoder @@ -62,7 +72,13 @@ board = megaatmega2560 framework = arduino build_flags = ${env.build_flags} - -I./_Boards/Atmel/Board_Mega + '-DMOBIFLIGHT_TYPE="MobiFlight Mega"' + '-DMOBIFLIGHT_NAME="MobiFlight Mega"' + -DMEMLEN_CONFIG=1496 ; max. size for config which wil be stored in EEPROM + -DMEMLEN_NAMES_BUFFER=1000 ; max. size for configBuffer, contains only names from inputs + -DMF_MAX_DEVICEMEM=1600 ; max. memory size for devices +build_unflags = + ;-DMF_STEPPER_SUPPORT ; this is just an example how to deactivate a device build_src_filter = ${env.build_src_filter} lib_deps = @@ -79,7 +95,13 @@ board = sparkfun_promicro16 framework = arduino build_flags = ${env.build_flags} - -I./_Boards/Atmel/Board_ProMicro + '-DMOBIFLIGHT_TYPE="MobiFlight Micro"' + '-DMOBIFLIGHT_NAME="MobiFlight Micro"' + -DMEMLEN_CONFIG=440 ; max. size for config which wil be stored in EEPROM + -DMEMLEN_NAMES_BUFFER=350 ; max. size for configBuffer, contains only names from inputs + -DMF_MAX_DEVICEMEM=470 ; max. memory size for devices +build_unflags = + ;-DMF_STEPPER_SUPPORT ; this is just an example how to deactivate a device build_src_filter = ${env.build_src_filter} lib_deps = @@ -97,7 +119,13 @@ board = uno framework = arduino build_flags = ${env.build_flags} - -I./_Boards/Atmel/Board_Uno + '-DMOBIFLIGHT_TYPE="MobiFlight Uno"' + '-DMOBIFLIGHT_NAME="MobiFlight Uno"' + -DMEMLEN_CONFIG=286 ; max. size for config which wil be stored in EEPROM + -DMEMLEN_NAMES_BUFFER=220 ; max. size for configBuffer, contains only names from inputs + -DMF_MAX_DEVICEMEM=420 ; max. memory size for devices +build_unflags = + ;-DMF_STEPPER_SUPPORT ; this is just an example how to deactivate a device build_src_filter = ${env.build_src_filter} lib_deps = @@ -114,7 +142,14 @@ board = nanoatmega328 framework = arduino build_flags = ${env.build_flags} + '-DMOBIFLIGHT_TYPE="MobiFlight Nano"' + '-DMOBIFLIGHT_NAME="MobiFlight Nano"' + -DMEMLEN_CONFIG=286 ; max. size for config which wil be stored in EEPROM + -DMEMLEN_NAMES_BUFFER=220 ; max. size for configBuffer, contains only names from inputs + -DMF_MAX_DEVICEMEM=420 ; max. memory size for devices -I./_Boards/Atmel/Board_Nano +build_unflags = + ;-DMF_STEPPER_SUPPORT ; this is just an example how to deactivate a device build_src_filter = ${env.build_src_filter} lib_deps = @@ -129,14 +164,21 @@ extra_scripts = platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = pico framework = arduino -board_build.core = earlephilhower ; select new core -board_build.filesystem_size = 0M ; configure filesystem size. Default 0 Mbyte. +board_build.core = earlephilhower ; select new core +board_build.filesystem_size = 0M ; configure filesystem size. Default 0 Mbyte. lib_ldf_mode = chain+ -upload_protocol = mbed ; for debugging upoading can be changed to picoprobe -;debug_tool = picoprobe ; and uncomment this for debugging w/ picoprobe +upload_protocol = mbed ; for debugging upoading can be changed to picoprobe +;debug_tool = picoprobe ; and uncomment this for debugging w/ picoprobe build_flags = ${env.build_flags} + '-DMOBIFLIGHT_TYPE="MobiFlight RaspiPico"' + '-DMOBIFLIGHT_NAME="MobiFlight RaspiPico"' + -DMEMLEN_CONFIG=1496 ; max. size for config which wil be stored in EEPROM + -DMEMLEN_NAMES_BUFFER=1000 ; max. size for configBuffer, contains only names from inputs + -DMF_MAX_DEVICEMEM=1000 ; max. memory size for devices -I./_Boards/RaspberryPi/Pico +build_unflags = + ;-DMF_STEPPER_SUPPORT ; this is just an example how to deactivate a device build_src_filter = ${env.build_src_filter} lib_deps = diff --git a/src/CommandMessenger.cpp b/src/CommandMessenger.cpp index 19bdd3b0..8ae5f67f 100644 --- a/src/CommandMessenger.cpp +++ b/src/CommandMessenger.cpp @@ -4,36 +4,36 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" - +#include "commandmessenger.h" +#include "config.h" #include "Button.h" #include "Encoder.h" -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT #include "Analog.h" #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT #include "InputShifter.h" #endif #include "Output.h" -#if MF_SEGMENT_SUPPORT == 1 +#ifdef MF_SEGMENT_SUPPORT #include "LedSegment.h" #endif -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT #include "Stepper.h" #endif -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT #include "Servos.h" #endif -#if MF_LCD_SUPPORT == 1 +#ifdef MF_LCD_SUPPORT #include "LCDDisplay.h" #endif -#if MF_OUTPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_OUTPUT_SHIFTER_SUPPORT #include "OutputShifter.h" #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT #include "DigInMux.h" #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT #include "CustomDevice.h" #endif @@ -50,7 +50,7 @@ void attachCommandCallbacks() // Attach callback methods cmdMessenger.attach(OnUnknownCommand); -#if MF_SEGMENT_SUPPORT == 1 +#ifdef MF_SEGMENT_SUPPORT cmdMessenger.attach(kInitModule, LedSegment::OnInitModule); cmdMessenger.attach(kSetModule, LedSegment::OnSetModule); cmdMessenger.attach(kSetModuleBrightness, LedSegment::OnSetModuleBrightness); @@ -59,14 +59,14 @@ void attachCommandCallbacks() cmdMessenger.attach(kSetPin, Output::OnSet); -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT cmdMessenger.attach(kSetStepper, Stepper::OnSet); cmdMessenger.attach(kResetStepper, Stepper::OnReset); cmdMessenger.attach(kSetZeroStepper, Stepper::OnSetZero); cmdMessenger.attach(kSetStepperSpeedAccel, Stepper::OnSetSpeedAccel); #endif -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT cmdMessenger.attach(kSetServo, Servos::OnSet); #endif @@ -81,15 +81,15 @@ void attachCommandCallbacks() cmdMessenger.attach(kTrigger, OnTrigger); cmdMessenger.attach(kSetPowerSavingMode, OnSetPowerSavingMode); -#if MF_LCD_SUPPORT == 1 +#ifdef MF_LCD_SUPPORT cmdMessenger.attach(kSetLcdDisplayI2C, LCDDisplay::OnSet); #endif -#if MF_OUTPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_OUTPUT_SHIFTER_SUPPORT cmdMessenger.attach(kSetShiftRegisterPins, OutputShifter::OnSet); #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT cmdMessenger.attach(kSetCustomDevice, CustomDevice::OnSet); #endif @@ -138,13 +138,13 @@ uint32_t getLastCommandMillis() void OnTrigger() { Button::OnTrigger(); -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT InputShifter::OnTrigger(); #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT DigInMux::OnTrigger(); #endif -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT Analog::OnTrigger(); #endif } diff --git a/src/Config.cpp b/src/Config.cpp index 0c39a264..b6cfae44 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -4,7 +4,9 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "config.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFEEPROM.h" #include "Button.h" #include "Encoder.h" @@ -13,34 +15,34 @@ #include "ArduinoUniqueID.h" #endif -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT #include "Analog.h" #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT #include "InputShifter.h" #endif -#if MF_SEGMENT_SUPPORT == 1 +#ifdef MF_SEGMENT_SUPPORT #include "LedSegment.h" #endif -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT #include "Stepper.h" #endif -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT #include "Servos.h" #endif -#if MF_LCD_SUPPORT == 1 +#ifdef MF_LCD_SUPPORT #include "LCDDisplay.h" #endif -#if MF_OUTPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_OUTPUT_SHIFTER_SUPPORT #include "OutputShifter.h" #endif -#if MF_MUX_SUPPORT == 1 +#ifdef MF_MUX_SUPPORT #include "MFMuxDriver.h" #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT #include "DigInMux.h" #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT #include "CustomDevice.h" #endif #ifdef HAS_CONFIG_IN_FLASH @@ -67,7 +69,7 @@ const uint8_t MEM_OFFSET_SERIAL = MEM_OFFSET_NAME + MEM_LEN_NAME; const uint8_t MEM_LEN_SERIAL = 11; const uint8_t MEM_OFFSET_CONFIG = MEM_OFFSET_NAME + MEM_LEN_NAME + MEM_LEN_SERIAL; -#if defined(ARDUINO_ARCH_AVR) +#ifdef ARDUINO_ARCH_AVR char serial[11]; // 3 characters for "SN-",7 characters for "xyz-zyx" plus terminating NULL #else char serial[3 + UniqueIDsize * 2 + 1]; // 3 characters for "SN-", UniqueID as HEX String, terminating NULL @@ -171,13 +173,13 @@ void resetConfig() Button::Clear(); Encoder::Clear(); Output::Clear(); -#if MF_SEGMENT_SUPPORT == 1 +#ifdef MF_SEGMENT_SUPPORT LedSegment::Clear(); #endif -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT Servos::Clear(); #endif -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT #if defined(STEPPER_ON_2ND_CORE) && defined(ARDUINO_ARCH_RP2040) Stepper::stopUpdate2ndCore(true); #endif @@ -186,22 +188,22 @@ void resetConfig() Stepper::stopUpdate2ndCore(false); #endif #endif -#if MF_LCD_SUPPORT == 1 +#ifdef MF_LCD_SUPPORT LCDDisplay::Clear(); #endif -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT Analog::Clear(); #endif -#if MF_OUTPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_OUTPUT_SHIFTER_SUPPORT OutputShifter::Clear(); #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT InputShifter::Clear(); #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT DigInMux::Clear(); #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT #if defined(USE_2ND_CORE) && defined(ARDUINO_ARCH_RP2040) CustomDevice::stopUpdate2ndCore(true); #endif @@ -344,41 +346,41 @@ void InitArrays(uint8_t *numberDevices) sendFailureMessage("Button"); if (!Output::setupArray(numberDevices[kTypeOutput])) sendFailureMessage("Output"); -#if MF_SEGMENT_SUPPORT == 1 +#ifdef MF_SEGMENT_SUPPORT if (!LedSegment::setupArray(numberDevices[kTypeLedSegmentDeprecated] + numberDevices[kTypeLedSegmentMulti])) sendFailureMessage("7Segment"); #endif -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT if (!Stepper::setupArray(numberDevices[kTypeStepper] + numberDevices[kTypeStepperDeprecated1] + numberDevices[kTypeStepperDeprecated2])) sendFailureMessage("Stepper"); #endif -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT if (!Servos::setupArray(numberDevices[kTypeServo])) sendFailureMessage("Servo"); #endif if (!Encoder::setupArray(numberDevices[kTypeEncoder] + numberDevices[kTypeEncoderSingleDetent])) sendFailureMessage("Encoders"); -#if MF_LCD_SUPPORT == 1 +#ifdef MF_LCD_SUPPORT if (!LCDDisplay::setupArray(numberDevices[kTypeLcdDisplayI2C])) sendFailureMessage("LCD"); #endif -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT if (!Analog::setupArray(numberDevices[kTypeAnalogInput] + numberDevices[kTypeAnalogInputDeprecated])) sendFailureMessage("AnalogIn"); #endif -#if MF_OUTPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_OUTPUT_SHIFTER_SUPPORT if (!OutputShifter::setupArray(numberDevices[kTypeOutputShifter])) sendFailureMessage("OutputShifter"); #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT if (!InputShifter::setupArray(numberDevices[kTypeInputShifter])) sendFailureMessage("InputShifter"); #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT if (!DigInMux::setupArray(numberDevices[kTypeDigInMux])) sendFailureMessage("DigInMux"); #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT if (!CustomDevice::setupArray(numberDevices[kTypeCustomDevice])) sendFailureMessage("CustomDevice"); #endif @@ -431,7 +433,7 @@ void readConfigFromMemory(bool configFromFlash) copy_success = readEndCommand(&addrMem, ':', configFromFlash); // check EEPROM until end of name break; -#if MF_SEGMENT_SUPPORT == 1 +#ifdef MF_SEGMENT_SUPPORT // this is for backwards compatibility case kTypeLedSegmentDeprecated: // this is the new type @@ -450,7 +452,7 @@ void readConfigFromMemory(bool configFromFlash) break; #endif -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT case kTypeStepperDeprecated1: case kTypeStepperDeprecated2: case kTypeStepper: @@ -482,7 +484,7 @@ void readConfigFromMemory(bool configFromFlash) break; #endif -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT case kTypeServo: params[0] = readUint(&addrMem, configFromFlash); // Pin number Servos::Add(params[0]); @@ -503,7 +505,7 @@ void readConfigFromMemory(bool configFromFlash) copy_success = readName(&addrMem, nameBuffer, &pNameBuffer, configFromFlash); // copy the NULL terminated name to nameBuffer and set to next free memory location break; -#if MF_LCD_SUPPORT == 1 +#ifdef MF_LCD_SUPPORT case kTypeLcdDisplayI2C: params[0] = readUint(&addrMem, configFromFlash); // address params[1] = readUint(&addrMem, configFromFlash); // columns @@ -513,7 +515,7 @@ void readConfigFromMemory(bool configFromFlash) break; #endif -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT case kTypeAnalogInputDeprecated: case kTypeAnalogInput: params[0] = readUint(&addrMem, configFromFlash); // pin number @@ -527,7 +529,7 @@ void readConfigFromMemory(bool configFromFlash) break; #endif -#if MF_OUTPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_OUTPUT_SHIFTER_SUPPORT case kTypeOutputShifter: params[0] = readUint(&addrMem, configFromFlash); // latch Pin params[1] = readUint(&addrMem, configFromFlash); // clock Pin @@ -538,7 +540,7 @@ void readConfigFromMemory(bool configFromFlash) break; #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT case kTypeInputShifter: params[0] = readUint(&addrMem, configFromFlash); // latch Pin params[1] = readUint(&addrMem, configFromFlash); // clock Pin @@ -550,7 +552,7 @@ void readConfigFromMemory(bool configFromFlash) break; #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT case kTypeDigInMux: params[0] = readUint(&addrMem, configFromFlash); // data pin // Mux driver section @@ -567,7 +569,7 @@ void readConfigFromMemory(bool configFromFlash) break; #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT case kTypeCustomDevice: { uint16_t adrType = addrMem; // first location of custom Type in EEPROM copy_success = readEndCommand(&addrMem, '.', configFromFlash); @@ -644,7 +646,7 @@ bool getStatusConfig() // ************************************************************ // Generate a serial number only for AVR's -#if defined(ARDUINO_ARCH_AVR) +#ifdef ARDUINO_ARCH_AVR void generateRandomSerial() { // To have not always the same starting point for the random generator, millis() are @@ -696,7 +698,7 @@ void generateSerial(bool force) if (force) { // A serial number is forced to generate // generate a serial number acc. the old style only for AVR's -#if defined(ARDUINO_ARCH_AVR) +#ifdef ARDUINO_ARCH_AVR generateRandomSerial(); #else // For other boards always the UniqueID is used. @@ -717,7 +719,7 @@ void generateSerial(bool force) return; } -#if defined(ARDUINO_ARCH_AVR) +#ifdef ARDUINO_ARCH_AVR // Coming here no serial number is available (so it's the first start up of an AVR board) // or a uniqueID is already generated and saved to the eeprom // AVR's are forced to roll back to "old style" serial number diff --git a/src/MF_Analog/Analog.cpp b/src/MF_Analog/Analog.cpp index 6e91fc12..27555283 100644 --- a/src/MF_Analog/Analog.cpp +++ b/src/MF_Analog/Analog.cpp @@ -4,11 +4,13 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "config.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFAnalog.h" #include "Analog.h" -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT namespace Analog { MFAnalog *analog; diff --git a/src/MF_Analog/Analog.h b/src/MF_Analog/Analog.h index 32bd05ab..8e6fbf09 100644 --- a/src/MF_Analog/Analog.h +++ b/src/MF_Analog/Analog.h @@ -6,7 +6,8 @@ #pragma once -#include +#include + namespace Analog { bool setupArray(uint16_t count); diff --git a/src/MF_Analog/MFAnalog.cpp b/src/MF_Analog/MFAnalog.cpp index 86f4af96..e4378cef 100644 --- a/src/MF_Analog/MFAnalog.cpp +++ b/src/MF_Analog/MFAnalog.cpp @@ -18,7 +18,7 @@ void MFAnalog::attach(uint8_t pin, const char *name, uint8_t sensitivity, bool d _sensitivity = sensitivity; _pin = pin; _name = name; -#if defined(ARDUINO_AVR_PROMICRO16) +#ifdef ARDUINO_AVR_PROMICRO16 // ProMicro has a special pin assignment for analog pins // therefore reading from A6 and A7 does not work // via "digital" pins. See also pins_arduino.h @@ -36,7 +36,7 @@ void MFAnalog::attach(uint8_t pin, const char *name, uint8_t sensitivity, bool d readBuffer(); } // and set initial value from buffers - _lastValue = ADC_Average_Total >> ADC_MAX_AVERAGE_LOG2; + _lastValue = ADC_Average_Total >> ADC_MAX_AVERAGE_LOG2; _initialized = true; } @@ -71,9 +71,9 @@ void MFAnalog::retrigger() } void MFAnalog::readBuffer() -{ +{ if (!_initialized) - return; // read ADC and calculate floating average, call it every ~10ms + return; // read ADC and calculate floating average, call it every ~10ms ADC_Average_Total -= ADC_Buffer[(ADC_Average_Pointer)]; // subtract oldest value to save the newest value ADC_Buffer[ADC_Average_Pointer] = analogRead(_pin); // store read in, must be subtracted in next loop ADC_Average_Total += ADC_Buffer[ADC_Average_Pointer]; // add read in for floating average diff --git a/src/MF_Button/Button.cpp b/src/MF_Button/Button.cpp index 343b56fc..d4acf1ba 100644 --- a/src/MF_Button/Button.cpp +++ b/src/MF_Button/Button.cpp @@ -4,7 +4,9 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "config.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFButton.h" #include "Button.h" diff --git a/src/MF_Button/Button.h b/src/MF_Button/Button.h index 5dd41673..7403315b 100644 --- a/src/MF_Button/Button.h +++ b/src/MF_Button/Button.h @@ -6,7 +6,7 @@ #pragma once -#include +#include namespace Button { diff --git a/src/MF_CustomDevice/CustomDevice.cpp b/src/MF_CustomDevice/CustomDevice.cpp index e3ccfae2..ab691cf1 100644 --- a/src/MF_CustomDevice/CustomDevice.cpp +++ b/src/MF_CustomDevice/CustomDevice.cpp @@ -1,4 +1,12 @@ -#include "mobiflight.h" +// +// CustomDevice.cpp +// +// (C) MobiFlight Project 2022 +// + +#include "commandmessenger.h" +#include "allocateMem.h" +#include "commandmessenger.h" #include "CustomDevice.h" #include "MFCustomDevice.h" #if defined(USE_2ND_CORE) && defined(ARDUINO_ARCH_RP2040) @@ -17,7 +25,7 @@ namespace CustomDevice MFCustomDevice *customDevice; uint8_t customDeviceRegistered = 0; uint8_t maxCustomDevices = 0; -#if defined(USE_2ND_CORE) +#ifdef USE_2ND_CORE char payload[SERIAL_RX_BUFFER_SIZE]; #endif @@ -169,7 +177,7 @@ void loop1() #ifdef MF_CUSTOMDEVICE_POLL_MS if (millis() - lastMillis >= MF_CUSTOMDEVICE_POLL_MS) { #endif -#if defined(MF_CUSTOMDEVICE_HAS_UPDATE) +#ifdef MF_CUSTOMDEVICE_HAS_UPDATE for (int i = 0; i < CustomDevice::customDeviceRegistered && !stopUpdating; i++) { CustomDevice::customDevice[i].update(); } diff --git a/src/MF_CustomDevice/CustomDevice.h b/src/MF_CustomDevice/CustomDevice.h index 82fe0f51..5cb78a23 100644 --- a/src/MF_CustomDevice/CustomDevice.h +++ b/src/MF_CustomDevice/CustomDevice.h @@ -1,8 +1,16 @@ +// +// CustomDevice.h +// +// (C) MobiFlight Project 2022 +// + #pragma once +#include + namespace CustomDevice { - #define START_STOP_2ND_CORE -1 +#define START_STOP_2ND_CORE -1 bool setupArray(uint16_t count); void Add(uint16_t adrPin, uint16_t adrType, uint16_t adrConfig, bool configFromFlash); diff --git a/src/MF_DigInMux/DigInMux.cpp b/src/MF_DigInMux/DigInMux.cpp index 984bab0b..5931d557 100644 --- a/src/MF_DigInMux/DigInMux.cpp +++ b/src/MF_DigInMux/DigInMux.cpp @@ -4,7 +4,9 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "config.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFDigInMux.h" #include "MFMuxDriver.h" diff --git a/src/MF_DigInMux/DigInMux.h b/src/MF_DigInMux/DigInMux.h index 11409d22..0e1c1be9 100644 --- a/src/MF_DigInMux/DigInMux.h +++ b/src/MF_DigInMux/DigInMux.h @@ -4,9 +4,10 @@ // (C) MobiFlight Project 2022 // + #pragma once -#include -#include "MFDigInMux.h" + +#include namespace DigInMux { diff --git a/src/MF_DigInMux/MFDigInMux.cpp b/src/MF_DigInMux/MFDigInMux.cpp index c82f0883..c36fb51b 100644 --- a/src/MF_DigInMux/MFDigInMux.cpp +++ b/src/MF_DigInMux/MFDigInMux.cpp @@ -4,7 +4,6 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" #include "MFDigInMux.h" #include "MFMuxDriver.h" diff --git a/src/MF_Encoder/Encoder.cpp b/src/MF_Encoder/Encoder.cpp index 49ce2a82..cc5fbfa5 100644 --- a/src/MF_Encoder/Encoder.cpp +++ b/src/MF_Encoder/Encoder.cpp @@ -4,7 +4,9 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "config.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFEncoder.h" #include "Encoder.h" @@ -14,7 +16,7 @@ namespace Encoder uint8_t encodersRegistered = 0; uint8_t maxEncoders = 0; - void handlerOnEncoder(uint8_t eventId, const char *name) + void handlerOnEncoder(uint8_t eventId, const char *name) { if (!getBoardReady()) return; diff --git a/src/MF_Encoder/Encoder.h b/src/MF_Encoder/Encoder.h index 52b54894..fac599e3 100644 --- a/src/MF_Encoder/Encoder.h +++ b/src/MF_Encoder/Encoder.h @@ -5,7 +5,8 @@ // #pragma once -#include + +#include namespace Encoder { diff --git a/src/MF_Encoder/MFEncoder.h b/src/MF_Encoder/MFEncoder.h index 6ad8a80b..c30853dc 100644 --- a/src/MF_Encoder/MFEncoder.h +++ b/src/MF_Encoder/MFEncoder.h @@ -38,7 +38,7 @@ enum { typedef struct { // Detent positions in the quadrature (by value, not position) - bool detents[4]; + bool detents[4]; // Bit shift to apply given the detent resolution of this encoder. // @@ -56,11 +56,11 @@ class MFEncoder void attach(uint8_t pin1, uint8_t pin2, uint8_t TypeEncoder, const char *name = "Encoder"); void update(); // call this function every some milliseconds or by using an interrupt for handling state changes of the rotary encoder. - void tick(void); + void tick(void); // retrieve the current position - int16_t getPosition(); + int16_t getPosition(); // adjust the current position - void setPosition(int16_t newPosition); + void setPosition(int16_t newPosition); private: static encoderEvent _handler; diff --git a/src/MF_InputShifter/InputShifter.cpp b/src/MF_InputShifter/InputShifter.cpp index 20a7b1fe..3d9d46c9 100644 --- a/src/MF_InputShifter/InputShifter.cpp +++ b/src/MF_InputShifter/InputShifter.cpp @@ -4,7 +4,9 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "config.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFInputShifter.h" #include "InputShifter.h" diff --git a/src/MF_InputShifter/InputShifter.h b/src/MF_InputShifter/InputShifter.h index 0efb1c7c..b88cbc28 100644 --- a/src/MF_InputShifter/InputShifter.h +++ b/src/MF_InputShifter/InputShifter.h @@ -6,6 +6,8 @@ #pragma once +#include + namespace InputShifter { bool setupArray(uint16_t count); diff --git a/src/MF_LCDDisplay/LCDDisplay.cpp b/src/MF_LCDDisplay/LCDDisplay.cpp index e1601625..86d731cf 100644 --- a/src/MF_LCDDisplay/LCDDisplay.cpp +++ b/src/MF_LCDDisplay/LCDDisplay.cpp @@ -4,7 +4,8 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFLCDDisplay.h" #include "LCDDisplay.h" diff --git a/src/MF_LCDDisplay/LCDDisplay.h b/src/MF_LCDDisplay/LCDDisplay.h index 6d8ba5e9..3e31ee5b 100644 --- a/src/MF_LCDDisplay/LCDDisplay.h +++ b/src/MF_LCDDisplay/LCDDisplay.h @@ -5,7 +5,8 @@ // #pragma once -#include + +#include namespace LCDDisplay { diff --git a/src/MF_LCDDisplay/MFLCDDisplay.cpp b/src/MF_LCDDisplay/MFLCDDisplay.cpp index 1e45531c..bc760931 100644 --- a/src/MF_LCDDisplay/MFLCDDisplay.cpp +++ b/src/MF_LCDDisplay/MFLCDDisplay.cpp @@ -45,8 +45,7 @@ void MFLCDDisplay::powerSavingMode(bool state) if (state) { _lcdDisplay.noBacklight(); _lcdDisplay.noDisplay(); - } - else { + } else { _lcdDisplay.backlight(); _lcdDisplay.display(); } diff --git a/src/MF_LCDDisplay/MFLCDDisplay.h b/src/MF_LCDDisplay/MFLCDDisplay.h index 2084fa94..eb7ae819 100644 --- a/src/MF_LCDDisplay/MFLCDDisplay.h +++ b/src/MF_LCDDisplay/MFLCDDisplay.h @@ -26,7 +26,7 @@ class MFLCDDisplay byte _cols; byte _lines; - void _printCentered(const char *str, uint8_t line); + void _printCentered(const char *str, uint8_t line); }; // MFLCDDisplay.h \ No newline at end of file diff --git a/src/MF_Modules/MFEEPROM.cpp b/src/MF_Modules/MFEEPROM.cpp index 3bf8808a..1fad7d09 100644 --- a/src/MF_Modules/MFEEPROM.cpp +++ b/src/MF_Modules/MFEEPROM.cpp @@ -4,9 +4,7 @@ // (C) MobiFlight Project 2022 // -#include #include "MFEEPROM.h" -#include "MFBoards.h" MFEEPROM::MFEEPROM() {} diff --git a/src/MF_Modules/MFEEPROM.h b/src/MF_Modules/MFEEPROM.h index af298f07..a4b00b39 100644 --- a/src/MF_Modules/MFEEPROM.h +++ b/src/MF_Modules/MFEEPROM.h @@ -6,6 +6,7 @@ #pragma once +#include #include class MFEEPROM @@ -17,9 +18,10 @@ class MFEEPROM MFEEPROM(); void init(void); uint16_t get_length(void); - uint8_t read_byte(uint16_t adr); - bool write_byte(uint16_t adr, const uint8_t data); - void commit() { + uint8_t read_byte(uint16_t adr); + bool write_byte(uint16_t adr, const uint8_t data); + void commit() + { #if !defined(ARDUINO_ARCH_AVR) EEPROM.commit(); #endif @@ -37,7 +39,7 @@ class MFEEPROM bool read_block(uint16_t adr, T &t, uint16_t len) { if (adr + len > _eepromLength) return false; - uint8_t *ptr = (uint8_t*) &t; + uint8_t *ptr = (uint8_t *)&t; for (uint16_t i = 0; i < len; i++) { *ptr++ = EEPROM.read(adr + i); } diff --git a/src/MF_Modules/MFMuxDriver.cpp b/src/MF_Modules/MFMuxDriver.cpp index 2e73e358..dc12ca45 100644 --- a/src/MF_Modules/MFMuxDriver.cpp +++ b/src/MF_Modules/MFMuxDriver.cpp @@ -4,7 +4,8 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFMuxDriver.h" MFMuxDriver::MFMuxDriver(void) diff --git a/src/MF_Modules/MFMuxDriver.h b/src/MF_Modules/MFMuxDriver.h index 4cd39971..327329e0 100644 --- a/src/MF_Modules/MFMuxDriver.h +++ b/src/MF_Modules/MFMuxDriver.h @@ -16,8 +16,8 @@ class MFMuxDriver { public: MFMuxDriver(void); - void attach(uint8_t Sel0Pin, uint8_t Sel1Pin, uint8_t Sel2Pin, uint8_t Sel3Pin); - void detach(); + void attach(uint8_t Sel0Pin, uint8_t Sel1Pin, uint8_t Sel2Pin, uint8_t Sel3Pin); + void detach(); // void setChannelOpt(uint8_t mode); void setChannel(uint8_t value); diff --git a/src/MF_Output/MFOutput.cpp b/src/MF_Output/MFOutput.cpp index 6dbd3203..7010bb9b 100644 --- a/src/MF_Output/MFOutput.cpp +++ b/src/MF_Output/MFOutput.cpp @@ -13,8 +13,8 @@ MFOutput::MFOutput() void MFOutput::attach(uint8_t pin) { - _pin = pin; -#if defined(ARDUINO_ARCH_RP2040) + _pin = pin; +#ifdef ARDUINO_ARCH_RP2040 pinMode(_pin, OUTPUT_12MA); #else pinMode(_pin, OUTPUT); diff --git a/src/MF_Output/MFOutput.h b/src/MF_Output/MFOutput.h index ac386b06..e64dfb69 100644 --- a/src/MF_Output/MFOutput.h +++ b/src/MF_Output/MFOutput.h @@ -9,11 +9,11 @@ #include #ifdef REVERSED_OUTPUT_OUTPUT - #define MF_HIGH LOW - #define MF_LOW HIGH +#define MF_HIGH LOW +#define MF_LOW HIGH #else - #define MF_HIGH HIGH - #define MF_LOW LOW +#define MF_HIGH HIGH +#define MF_LOW LOW #endif class MFOutput { diff --git a/src/MF_Output/Output.cpp b/src/MF_Output/Output.cpp index 865643df..d2abb4ad 100644 --- a/src/MF_Output/Output.cpp +++ b/src/MF_Output/Output.cpp @@ -4,7 +4,8 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFOutput.h" #include "Output.h" diff --git a/src/MF_Output/Output.h b/src/MF_Output/Output.h index 813ebe30..a53ac83f 100644 --- a/src/MF_Output/Output.h +++ b/src/MF_Output/Output.h @@ -6,6 +6,8 @@ #pragma once +#include + namespace Output { bool setupArray(uint16_t count); diff --git a/src/MF_OutputShifter/MFOutputShifter.h b/src/MF_OutputShifter/MFOutputShifter.h index 1720a416..0517bccc 100644 --- a/src/MF_OutputShifter/MFOutputShifter.h +++ b/src/MF_OutputShifter/MFOutputShifter.h @@ -9,11 +9,11 @@ #include #ifdef REVERSED_OUTPUT_OUTPUTSHIFTER - #define MF_HIGH LOW - #define MF_LOW HIGH +#define MF_HIGH LOW +#define MF_LOW HIGH #else - #define MF_HIGH HIGH - #define MF_LOW LOW +#define MF_HIGH HIGH +#define MF_LOW LOW #endif class MFOutputShifter @@ -29,12 +29,12 @@ class MFOutputShifter void powerSavingMode(bool state); private: - uint8_t _latchPin; // Latch pin - uint8_t _clockPin; // Clock pin - uint8_t _dataPin; // Data/SI pin - uint8_t _moduleCount; // Number of 8 bit modules in series. For a shift register with 16 bit one needs to select 2 modules a 8...... + uint8_t _latchPin; // Latch pin + uint8_t _clockPin; // Clock pin + uint8_t _dataPin; // Data/SI pin + uint8_t _moduleCount; // Number of 8 bit modules in series. For a shift register with 16 bit one needs to select 2 modules a 8...... uint8_t *_lastState; - bool _initialized = false; + bool _initialized = false; }; // MFOutputShifter.h diff --git a/src/MF_OutputShifter/OutputShifter.cpp b/src/MF_OutputShifter/OutputShifter.cpp index 3d3282df..7985dac2 100644 --- a/src/MF_OutputShifter/OutputShifter.cpp +++ b/src/MF_OutputShifter/OutputShifter.cpp @@ -4,7 +4,8 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFOutputShifter.h" #include "OutputShifter.h" @@ -18,7 +19,7 @@ namespace OutputShifter { if (!FitInMemory(sizeof(MFOutputShifter) * count)) return false; - outputShifter = new (allocateMemory(sizeof(MFOutputShifter) * count)) MFOutputShifter; + outputShifter = new (allocateMemory(sizeof(MFOutputShifter) * count)) MFOutputShifter; maxOutputShifter = count; return true; } @@ -28,8 +29,7 @@ namespace OutputShifter if (outputShifterRegistered == maxOutputShifter) return; outputShifter[outputShifterRegistered] = MFOutputShifter(); - if (!outputShifter[outputShifterRegistered].attach(latchPin, clockPin, dataPin, modules)) - { + if (!outputShifter[outputShifterRegistered].attach(latchPin, clockPin, dataPin, modules)) { cmdMessenger.sendCmd(kStatus, F("OutputShifter array does not fit into Memory")); return; } diff --git a/src/MF_OutputShifter/OutputShifter.h b/src/MF_OutputShifter/OutputShifter.h index b3917029..d2f8df08 100644 --- a/src/MF_OutputShifter/OutputShifter.h +++ b/src/MF_OutputShifter/OutputShifter.h @@ -6,6 +6,8 @@ #pragma once +#include + namespace OutputShifter { bool setupArray(uint16_t count); diff --git a/src/MF_Segment/LedControl_dual.cpp b/src/MF_Segment/LedControl_dual.cpp index 269f5110..2a9aab6c 100644 --- a/src/MF_Segment/LedControl_dual.cpp +++ b/src/MF_Segment/LedControl_dual.cpp @@ -151,7 +151,7 @@ bool LedControl::begin(uint8_t type, uint8_t dataPin, uint8_t clkPin, uint8_t cs if (!FitInMemory(sizeof(uint8_t) * numDevices * 8)) return false; digitBuffer = new (allocateMemory(sizeof(uint8_t) * numDevices * 8)) uint8_t; - maxUnits = numDevices; + maxUnits = numDevices; pinMode(_dataPin, OUTPUT); pinMode(_clkPin, OUTPUT); pinMode(_csPin, OUTPUT); @@ -252,15 +252,15 @@ void LedControl::setChar(uint8_t addr, uint8_t digit, char value, bool dp, bool void LedControl::setSingleSegment(uint8_t subModule, uint8_t segment, uint8_t value, bool sendNow) { - uint8_t digit = segment >> 3; + uint8_t digit = segment >> 3; uint8_t bitPosition = segment % 8; - uint8_t offset = subModule * 8; + uint8_t offset = subModule * 8; if (isMAX()) { if (subModule >= maxUnits) return; if (segment > 63) return; if (value) { - digitBuffer[offset + digit] |= (1 << bitPosition); + digitBuffer[offset + digit] |= (1 << bitPosition); } else { digitBuffer[offset + digit] &= ~(1 << bitPosition); } @@ -275,7 +275,7 @@ void LedControl::setSingleSegment(uint8_t subModule, uint8_t segment, uint8_t va if (bitPosition == 8) bitPosition = 0; if (value) { - rawdata[(maxUnits - 1) - digit] |= (1 << bitPosition); + rawdata[(maxUnits - 1) - digit] |= (1 << bitPosition); } else { rawdata[(maxUnits - 1) - digit] &= ~(1 << bitPosition); } diff --git a/src/MF_Segment/LedControl_dual.h b/src/MF_Segment/LedControl_dual.h index 4f9734e9..886b9da6 100644 --- a/src/MF_Segment/LedControl_dual.h +++ b/src/MF_Segment/LedControl_dual.h @@ -22,8 +22,7 @@ // non-relevant arguments (particularly: for TM's) are ignored. // A few methods (mostly for internal use) have been added. -#ifndef __LEDCONTROL_DUAL__H__ -#define __LEDCONTROL_DUAL__H__ +#pragma once // This constant reduces buffer usage: a single (static) 16-byte buffer // is used for all objects. However, for TM1637s, data is written @@ -34,8 +33,6 @@ // (as opposite to writing individual chars). #define LEDCONTROL_EXTENDED -#include -// #include #include #include @@ -80,9 +77,9 @@ class LedControl void setPattern(uint8_t addr, uint8_t digit, uint8_t value, bool sendNow = true); // MAX-specific - uint8_t *digitBuffer; // each digit must be stored in a buffer to be able to set single segments - void setScanLimit(uint8_t addr, uint8_t limit); - void spiTransfer(uint8_t addr, uint8_t opcode, uint8_t data); + uint8_t *digitBuffer; // each digit must be stored in a buffer to be able to set single segments + void setScanLimit(uint8_t addr, uint8_t limit); + void spiTransfer(uint8_t addr, uint8_t opcode, uint8_t data); // TM-specific // uint8_t dpSet = 0; @@ -100,7 +97,7 @@ class LedControl #endif public: - LedControl(){}; + LedControl() {}; bool begin(uint8_t type, uint8_t dataPin, uint8_t clkPin, uint8_t csPin, uint8_t numDevices = 1); @@ -185,5 +182,3 @@ class LedControl #endif }; - -#endif //!__LEDCONTROL_DUAL__H__ diff --git a/src/MF_Segment/LedSegment.cpp b/src/MF_Segment/LedSegment.cpp index 00715997..c19963e2 100644 --- a/src/MF_Segment/LedSegment.cpp +++ b/src/MF_Segment/LedSegment.cpp @@ -4,7 +4,8 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFSegments.h" #include "LedSegment.h" @@ -30,8 +31,7 @@ namespace LedSegment ledSegments[ledSegmentsRegistered] = MFSegments(); - if (!ledSegments[ledSegmentsRegistered].attach(type, dataPin, csPin, clkPin, numDevices, brightness)) - { + if (!ledSegments[ledSegmentsRegistered].attach(type, dataPin, csPin, clkPin, numDevices, brightness)) { cmdMessenger.sendCmd(kStatus, F("Led Segment array does not fit into Memory")); return; } @@ -88,10 +88,10 @@ namespace LedSegment void OnSetModuleSingleSegment() { - uint8_t module = (uint8_t)cmdMessenger.readInt16Arg(); - uint8_t subModule = (uint8_t)cmdMessenger.readInt16Arg(); - char *segment = cmdMessenger.readStringArg(); // 0 to 63, multiple segments deliminited by '|' - uint8_t on_off = (uint8_t)cmdMessenger.readInt16Arg(); // 0 or 1 + uint8_t module = (uint8_t)cmdMessenger.readInt16Arg(); + uint8_t subModule = (uint8_t)cmdMessenger.readInt16Arg(); + char *segment = cmdMessenger.readStringArg(); // 0 to 63, multiple segments deliminited by '|' + uint8_t on_off = (uint8_t)cmdMessenger.readInt16Arg(); // 0 or 1 char *pinTokens = strtok(segment, "|"); while (pinTokens != 0) { @@ -100,7 +100,7 @@ namespace LedSegment pinTokens = strtok(0, "|"); } } - + } // namespace // LedSegment.cpp diff --git a/src/MF_Segment/LedSegment.h b/src/MF_Segment/LedSegment.h index 914ef0c6..5c8add58 100644 --- a/src/MF_Segment/LedSegment.h +++ b/src/MF_Segment/LedSegment.h @@ -6,8 +6,10 @@ #pragma once +#include + namespace LedSegment -{ +{ enum { TYPE_MAX72XX = 0, TYPE_TM1637_4DIGITS = 0xFD, diff --git a/src/MF_Segment/MFSegments.cpp b/src/MF_Segment/MFSegments.cpp index a3351465..a7d4771e 100644 --- a/src/MF_Segment/MFSegments.cpp +++ b/src/MF_Segment/MFSegments.cpp @@ -31,9 +31,8 @@ void MFSegments::setSingleSegment(uint8_t module, uint8_t segment, uint8_t on_of { if (_moduleCount == 0) return; - - _ledControl.setSingleSegment(module, segment, on_off); + _ledControl.setSingleSegment(module, segment, on_off); } void MFSegments::setBrightness(uint8_t module, uint8_t value) diff --git a/src/MF_Segment/MFSegments.h b/src/MF_Segment/MFSegments.h index a33c5a47..9b87c746 100644 --- a/src/MF_Segment/MFSegments.h +++ b/src/MF_Segment/MFSegments.h @@ -23,7 +23,7 @@ class MFSegments private: LedControl _ledControl; - uint8_t _moduleCount; + uint8_t _moduleCount; }; // MFSegments.h diff --git a/src/MF_Servo/MFServo.cpp b/src/MF_Servo/MFServo.cpp index 3c624d02..6a3bc040 100644 --- a/src/MF_Servo/MFServo.cpp +++ b/src/MF_Servo/MFServo.cpp @@ -12,7 +12,7 @@ void MFServo::moveTo(int absolute) if (_targetPos != newValue) { _targetPos = newValue; if (!_initialized) { -#if defined(ARDUINO_ARCH_RP2040) +#ifdef ARDUINO_ARCH_RP2040 _servo.attach(_pin, 544, 2400); #else _servo.attach(_pin); diff --git a/src/MF_Servo/Servos.cpp b/src/MF_Servo/Servos.cpp index 507a2749..c96b6e7a 100644 --- a/src/MF_Servo/Servos.cpp +++ b/src/MF_Servo/Servos.cpp @@ -4,7 +4,8 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFServo.h" #include "Servos.h" diff --git a/src/MF_Servo/Servos.h b/src/MF_Servo/Servos.h index fc1de28b..c5b6c68a 100644 --- a/src/MF_Servo/Servos.h +++ b/src/MF_Servo/Servos.h @@ -6,6 +6,8 @@ #pragma once +#include + namespace Servos { bool setupArray(uint16_t count); diff --git a/src/MF_Stepper/MFStepper.cpp b/src/MF_Stepper/MFStepper.cpp index e29b7687..bd5bb910 100644 --- a/src/MF_Stepper/MFStepper.cpp +++ b/src/MF_Stepper/MFStepper.cpp @@ -4,7 +4,8 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "allocateMem.h" +#include "commandmessenger.h" #include "MFStepper.h" enum { // enumeration for stepper mode @@ -97,7 +98,7 @@ void MFStepper::moveTo(long newPosition) _inMove = MOVE_CCW; if (_inMove == MOVE_CCW && newPosition > currentPosition && newPosition > _targetPos) _inMove = MOVE_CW; - + _stepper->moveTo(newPosition + _backlash * _inMove); _targetPos = newPosition; } diff --git a/src/MF_Stepper/MFStepper.h b/src/MF_Stepper/MFStepper.h index 02f44ec1..702a7b6c 100644 --- a/src/MF_Stepper/MFStepper.h +++ b/src/MF_Stepper/MFStepper.h @@ -16,15 +16,15 @@ class MFStepper public: MFStepper(); - void attach(uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4, uint8_t btnPin1, uint8_t mode, int8_t backlash, bool deactivateOutput); - void detach(); - void update(); - void reset(); - void moveTo(long absolute); - void setMaxSpeed(uint16_t speed); - void setAcceleration(uint16_t acceleration); - void setZero(); - void powerSavingMode(bool state); + void attach(uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4, uint8_t btnPin1, uint8_t mode, int8_t backlash, bool deactivateOutput); + void detach(); + void update(); + void reset(); + void moveTo(long absolute); + void setMaxSpeed(uint16_t speed); + void setAcceleration(uint16_t acceleration); + void setZero(); + void powerSavingMode(bool state); private: bool _initialized; diff --git a/src/MF_Stepper/Stepper.cpp b/src/MF_Stepper/Stepper.cpp index e6988f52..48834afa 100644 --- a/src/MF_Stepper/Stepper.cpp +++ b/src/MF_Stepper/Stepper.cpp @@ -4,7 +4,8 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "commandmessenger.h" +#include "allocateMem.h" #include "MFStepper.h" #include "Stepper.h" #if defined(STEPPER_ON_2ND_CORE) && defined(ARDUINO_ARCH_RP2040) @@ -16,7 +17,7 @@ namespace Stepper MFStepper *steppers; uint8_t steppersRegistered = 0; uint8_t maxSteppers = 0; -#if defined(STEPPER_ON_2ND_CORE) +#ifdef STEPPER_ON_2ND_CORE enum { FUNC_MOVETO = 1, FUNC_ZETZERO, diff --git a/src/MF_Stepper/Stepper.h b/src/MF_Stepper/Stepper.h index 59da4822..3058a260 100644 --- a/src/MF_Stepper/Stepper.h +++ b/src/MF_Stepper/Stepper.h @@ -6,6 +6,8 @@ #pragma once +#include + namespace Stepper { bool setupArray(uint16_t count); diff --git a/src/allocateMem.cpp b/src/allocateMem.cpp index 0e2c3789..e8e953fa 100644 --- a/src/allocateMem.cpp +++ b/src/allocateMem.cpp @@ -4,20 +4,21 @@ // (C) MobiFlight Project 2022 // -#include "mobiflight.h" +#include "allocateMem.h" +#include "commandmessenger.h" -#if defined (ARDUINO_ARCH_AVR) -uint8_t deviceBuffer[MF_MAX_DEVICEMEM] = {0}; +#ifdef ARDUINO_ARCH_AVR +uint8_t deviceBuffer[MF_MAX_DEVICEMEM] = {0}; #else -std::size_t deviceBuffer[MF_MAX_DEVICEMEM] = {0}; +std::size_t deviceBuffer[MF_MAX_DEVICEMEM] = {0}; #endif -uint16_t nextPointer = 0; +uint16_t nextPointer = 0; -#if defined (ARDUINO_ARCH_AVR) -uint8_t *allocateMemory(uint16_t size) +#ifdef ARDUINO_ARCH_AVR +uint8_t *allocateMemory(uint16_t size) #else -std::size_t *allocateMemory(uint16_t size) +std::size_t *allocateMemory(uint16_t size) #endif { uint16_t actualPointer = nextPointer; diff --git a/src/allocateMem.h b/src/allocateMem.h index 4ffb3e04..19e89a51 100644 --- a/src/allocateMem.h +++ b/src/allocateMem.h @@ -6,16 +6,17 @@ #pragma once +#include #include -#if defined (ARDUINO_ARCH_AVR) -uint8_t *allocateMemory(uint16_t size); +#ifdef ARDUINO_ARCH_AVR +uint8_t *allocateMemory(uint16_t size); #else -std::size_t *allocateMemory(uint16_t size); +std::size_t *allocateMemory(uint16_t size); #endif -void ClearMemory(); -uint16_t GetAvailableMemory(); -bool FitInMemory(uint16_t size); +void ClearMemory(); +uint16_t GetAvailableMemory(); +bool FitInMemory(uint16_t size); // allocatemem.h diff --git a/src/commandmessenger.h b/src/commandmessenger.h index 19580b38..98282784 100644 --- a/src/commandmessenger.h +++ b/src/commandmessenger.h @@ -6,51 +6,51 @@ #pragma once +#include #include // This is the list of recognized commands. These can be commands that can either be sent or received. // In order to receive, attach a callback function to these events enum { - kInitModule, // 0 - kSetModule, // 1 - kSetPin, // 2 - kSetStepper, // 3 - kSetServo, // 4 - kStatus, // 5, Command to report status - kEncoderChange, // 6 - kButtonChange, // 7 - kStepperChange, // 8 - kGetInfo, // 9 - kInfo, // 10 - kSetConfig, // 11 - kGetConfig, // 12 - kResetConfig, // 13 - kSaveConfig, // 14 - kConfigSaved, // 15 - kActivateConfig, // 16 - kConfigActivated, // 17 - kSetPowerSavingMode, // 18 - kSetName, // 19 - kGenNewSerial, // 20 - kResetStepper, // 21 - kSetZeroStepper, // 22 - kTrigger, // 23 - kResetBoard, // 24 - kSetLcdDisplayI2C, // 25 - kSetModuleBrightness, // 26 - kSetShiftRegisterPins, // 27 - kAnalogChange, // 28 - kInputShifterChange, // 29 - kDigInMuxChange, // 30 - kSetStepperSpeedAccel, // 31 - kSetCustomDevice, // 32 + kInitModule, // 0 + kSetModule, // 1 + kSetPin, // 2 + kSetStepper, // 3 + kSetServo, // 4 + kStatus, // 5, Command to report status + kEncoderChange, // 6 + kButtonChange, // 7 + kStepperChange, // 8 + kGetInfo, // 9 + kInfo, // 10 + kSetConfig, // 11 + kGetConfig, // 12 + kResetConfig, // 13 + kSaveConfig, // 14 + kConfigSaved, // 15 + kActivateConfig, // 16 + kConfigActivated, // 17 + kSetPowerSavingMode, // 18 + kSetName, // 19 + kGenNewSerial, // 20 + kResetStepper, // 21 + kSetZeroStepper, // 22 + kTrigger, // 23 + kResetBoard, // 24 + kSetLcdDisplayI2C, // 25 + kSetModuleBrightness, // 26 + kSetShiftRegisterPins, // 27 + kAnalogChange, // 28 + kInputShifterChange, // 29 + kDigInMuxChange, // 30 + kSetStepperSpeedAccel, // 31 + kSetCustomDevice, // 32 kSetModuleSingleSegment, // 33 - kDebug = 0xFF // 255 + kDebug = 0xFF // 255 }; void attachCommandCallbacks(); uint32_t getLastCommandMillis(); -void setLastCommandMillis(); extern CmdMessenger cmdMessenger; \ No newline at end of file diff --git a/src/config.h b/src/config.h index 7ef7dd71..6e7fbf79 100644 --- a/src/config.h +++ b/src/config.h @@ -6,6 +6,8 @@ #pragma once +#include + enum { kTypeNotSet, // 0 kTypeButton, // 1 diff --git a/src/mobiflight.cpp b/src/mobiflight.cpp index 33fc8f76..6f09884d 100644 --- a/src/mobiflight.cpp +++ b/src/mobiflight.cpp @@ -5,36 +5,39 @@ // #include -#include "mobiflight.h" +#include "config.h" +#include "allocateMem.h" +#include "commandmessenger.h" #include "Button.h" #include "Encoder.h" #include "MFEEPROM.h" -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT #include "Analog.h" #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT #include "InputShifter.h" #endif #include "Output.h" -#if MF_SEGMENT_SUPPORT == 1 +#ifdef MF_SEGMENT_SUPPORT #include "LedSegment.h" #endif -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT #include "Stepper.h" #endif -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT #include "Servos.h" #endif -#if MF_LCD_SUPPORT == 1 +#ifdef MF_LCD_SUPPORT #include "LCDDisplay.h" #endif -#if MF_OUTPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_OUTPUT_SHIFTER_SUPPORT #include "OutputShifter.h" #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT #include "DigInMux.h" +#include "MFDigInMux.h" #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT #include "CustomDevice.h" #endif @@ -59,20 +62,20 @@ MFMuxDriver MUX; typedef struct { uint32_t Buttons = 0; uint32_t Encoders = 0; -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT uint32_t Servos = 0; #endif -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT uint32_t AnalogAverage = 0; uint32_t Analog = 0; #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT uint32_t InputShifters = 0; #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT uint32_t DigInMux = 0; #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT uint32_t CustomDevice = 0; #endif } lastUpdate_t; @@ -86,17 +89,17 @@ void initPollIntervals(void) // Init Time Gap between Inputs, do not read at the same loop lastUpdate.Buttons = millis(); lastUpdate.Encoders = millis(); -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT lastUpdate.Servos = millis() + 2; #endif -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT lastUpdate.AnalogAverage = millis() + 4; lastUpdate.Analog = millis() + 4; #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT lastUpdate.InputShifters = millis() + 6; #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT lastUpdate.DigInMux = millis() + 8; #endif } @@ -117,19 +120,19 @@ void SetPowerSavingMode(bool state) // disable the lights ;) powerSavingMode = state; Output::PowerSave(state); -#if MF_SEGMENT_SUPPORT == 1 +#ifdef MF_SEGMENT_SUPPORT LedSegment::PowerSave(state); #endif -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT Stepper::PowerSave(state); #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 +#ifdef MF_CUSTOMDEVICE_SUPPORT CustomDevice::PowerSave(state); #endif -#if MF_OUTPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_OUTPUT_SHIFTER_SUPPORT OutputShifter::PowerSave(state); #endif -#if MF_LCD_SUPPORT == 1 +#ifdef MF_LCD_SUPPORT LCDDisplay::PowerSave(state); #endif @@ -192,28 +195,28 @@ void loop() timedUpdate(Encoder::read, &lastUpdate.Encoders, MF_ENCODER_DEBOUNCE_MS); -#if MF_STEPPER_SUPPORT == 1 +#ifdef MF_STEPPER_SUPPORT Stepper::update(); #endif -#if MF_SERVO_SUPPORT == 1 +#ifdef MF_SERVO_SUPPORT timedUpdate(Servos::update, &lastUpdate.Servos, MF_SERVO_DELAY_MS); #endif -#if MF_ANALOG_SUPPORT == 1 +#ifdef MF_ANALOG_SUPPORT timedUpdate(Analog::read, &lastUpdate.Analog, MF_ANALOGREAD_DELAY_MS); timedUpdate(Analog::readAverage, &lastUpdate.AnalogAverage, MF_ANALOGAVERAGE_DELAY_MS); #endif -#if MF_INPUT_SHIFTER_SUPPORT == 1 +#ifdef MF_INPUT_SHIFTER_SUPPORT timedUpdate(InputShifter::read, &lastUpdate.InputShifters, MF_INSHIFTER_POLL_MS); #endif -#if MF_DIGIN_MUX_SUPPORT == 1 +#ifdef MF_DIGIN_MUX_SUPPORT timedUpdate(DigInMux::read, &lastUpdate.DigInMux, MF_INMUX_POLL_MS); #endif -#if MF_CUSTOMDEVICE_SUPPORT == 1 && defined(MF_CUSTOMDEVICE_HAS_UPDATE) +#if defined(MF_CUSTOMDEVICE_SUPPORT) && defined(MF_CUSTOMDEVICE_HAS_UPDATE) #ifdef MF_CUSTOMDEVICE_POLL_MS timedUpdate(CustomDevice::update, &lastUpdate.CustomDevice, MF_CUSTOMDEVICE_POLL_MS); #else diff --git a/src/mobiflight.h b/src/mobiflight.h deleted file mode 100644 index 3a38f3af..00000000 --- a/src/mobiflight.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// mobiflight.h -// -// (C) MobiFlight Project 2022 -// - -#pragma once - -#include -#include "MFBoards.h" -#include "config.h" -#include "allocateMem.h" -#include "commandmessenger.h" - -// mobiflight.h \ No newline at end of file