Skip to content

Commit

Permalink
Initial PlatformIO migration work
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Enns committed Sep 3, 2021
0 parents commit d39c72d
Show file tree
Hide file tree
Showing 1,264 changed files with 315,019 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
37 changes: 37 additions & 0 deletions _Boards/Atmel/Board_Mega/MFBoards.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef MFBoardMega_h
#define MFBoardMega_h

#define MF_SEGMENT_SUPPORT 1
#define MF_LCD_SUPPORT 1
#define MF_STEPPER_SUPPORT 1
#define MF_SERVO_SUPPORT 1
#define MF_ANALOG_SUPPORT 1
#define MF_SHIFTER_SUPPORT 1
// ALL 26544 (10.5%) / 4247 (51.8%)
// No Segments 24784 (9.8%) / 4102 (50.1%)
// No LCDs 25030 (9.9%) / 4212 (51.4%)
// NO Steppers 21398 (8.4%) / 4177 (51.0%)
// No Servos 24538 (9.7%) / 3827 (46.7%)

#define MODULE_MAX_PINS 69
#define MAX_OUTPUTS 40
#define MAX_BUTTONS 67 // 69 max. numbering, 0/1 for serial
#define MAX_LEDSEGMENTS 4
#define MAX_ENCODERS 20
#define MAX_STEPPERS 10
#define MAX_MFSERVOS 10
#define MAX_MFLCD_I2C 2
#define MAX_ANALOG_INPUTS 5
#define MAX_SHIFTERS 10

#define STEPS 64
#define STEPPER_SPEED 400 // 300 already worked, 467, too?
#define STEPPER_ACCEL 800

#define MOBIFLIGHT_TYPE "MobiFlight Mega"
#define MOBIFLIGHT_SERIAL "1234567890"
#define MEMLEN_NAME "MobiFlight Mega"
#define EEPROM_SIZE 4096 // EEPROMSizeMega
#define MEMLEN_CONFIG 1024

#endif
40 changes: 40 additions & 0 deletions _Boards/Atmel/Board_ProMicro/MFBoards.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef MFBoardMicro_h
#define MFBoardMicro_h

#define MF_SEGMENT_SUPPORT 0
#define MF_LCD_SUPPORT 0
#define MF_STEPPER_SUPPORT 0
#define MF_SERVO_SUPPORT 0
#define MF_ANALOG_SUPPORT 1
#define MF_SHIFTER_SUPPORT 0
#define MF_INPUT_SHIFTER_SUPPORT 1

// ALL 26892 (93.8%) / 1713 (66.9%)
// No Segments 25148 (87.7%) / 1580 (61.7%)
// No LCDs 25308 (88.3%) / 1678 (65.5%)
// NO Steppers 21892 (76.4%) / 1675 (65.4%)
// No Servos 25302 (88.2%) / 1620 (63.3%)

#define MODULE_MAX_PINS 21
#define MAX_OUTPUTS 10
#define MAX_BUTTONS 16
#define MAX_LEDSEGMENTS 1
#define MAX_ENCODERS 4
#define MAX_STEPPERS 2
#define MAX_MFSERVOS 2
#define MAX_MFLCD_I2C 2
#define MAX_ANALOG_INPUTS 2
#define MAX_SHIFTERS 4
#define MAX_INPUT_SHIFTERS 4

#define STEPS 64
#define STEPPER_SPEED 400 // 300 already worked, 467, too?
#define STEPPER_ACCEL 800

#define MOBIFLIGHT_TYPE "MobiFlight Micro"
#define MOBIFLIGHT_SERIAL "0987654321"
#define MEMLEN_NAME "MobiFlight Micro"
#define EEPROM_SIZE 1024 // EEPROMSizeMicro
#define MEMLEN_CONFIG 256

#endif
37 changes: 37 additions & 0 deletions _Boards/Atmel/Board_Uno/MFBoards.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef MFBoardUno_h
#define MFBoardUno_h

#define MF_SEGMENT_SUPPORT 1
#define MF_LCD_SUPPORT 1
#define MF_STEPPER_SUPPORT 1
#define MF_SERVO_SUPPORT 1
#define MF_ANALOG_SUPPORT 0
#define MF_SHIFTER_SUPPORT 0
// ALL 24602 (76.3%) / 1551 (75.7%)
// No Segments 22860 (70.9%) / 1418 (69.2%)
// No LCDs 23072 (71.5%) / 1516 (74.0%)
// NO Steppers 19586 (60.7%) / 1513 (73.9%)
// No Servos 23014 (71.3%) / 1458 (71.2%)

#define MODULE_MAX_PINS 13
#define MAX_OUTPUTS 8
#define MAX_BUTTONS 8
#define MAX_LEDSEGMENTS 1
#define MAX_ENCODERS 2
#define MAX_STEPPERS 2
#define MAX_MFSERVOS 2
#define MAX_MFLCD_I2C 2
#define MAX_ANALOG_INPUTS 0
#define MAX_SHIFTERS 0

#define STEPS 64
#define STEPPER_SPEED 400 // 300 already worked, 467, too?
#define STEPPER_ACCEL 800

#define MOBIFLIGHT_TYPE "MobiFlight Uno"
#define MOBIFLIGHT_SERIAL "0987654321"
#define MEMLEN_NAME "MobiFlight Uno"
#define EEPROM_SIZE 1024 // EEPROMSizeUno
#define MEMLEN_CONFIG 256

#endif
1 change: 1 addition & 0 deletions build/project.checksum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
420cf51f97dfa8a041a6975d8620dc14c29d1fa0
8 changes: 8 additions & 0 deletions firmware_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Import("env")

# my_flags = env.ParseFlags(env['BUILD_FLAGS'])
# defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")}
# print(defines)
# env.Replace(PROGNAME="firmware_%s" % defines.get("VERSION"))

env.Replace(PROGNAME=env.GetProjectOption("firmware_name") + "_" + env.GetProjectOption("firmware_version"))
41 changes: 41 additions & 0 deletions include/MFAnalog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// MFSegments.h
//
/// \mainpage MF MFAnalog module for MobiFlight Framework
/// \par Revision History
/// \version 1.0 Initial release
/// \author Manfred Berry ([email protected]) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS
// Copyright (C) 2021 Manfred Berry

#ifndef MFAnalog_h
#define MFAnalog_h

#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

extern "C"
{
// callback functions
typedef void (*analogEvent) (int, uint8_t, const char *);
};


/////////////////////////////////////////////////////////////////////
/// \class MFAnalog MFAnalog.h <MFAnalog.h>
class MFAnalog
{
public:
MFAnalog(uint8_t pin = 1, analogEvent callback = NULL, const char * name = "Analog Input", uint8_t sensitivity = 2);
void update();
const char * _name;
uint8_t _pin;

private:
int _lastValue;
uint32_t _last;
analogEvent _handler;
uint8_t _sensitivity;
};
#endif
4 changes: 4 additions & 0 deletions include/MFBoardMega.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef MFBoardMega_h
#define MFBoardMega_h

#endif
49 changes: 49 additions & 0 deletions include/MFButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// MFButton.h
//
/// \mainpage MF Button module for MobiFlight Framework
/// \par Revision History
/// \version 1.0 Initial release
/// \author Sebastian Moebius ([email protected]) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS
// Copyright (C) 2013-2014 Sebastian Moebius

#ifndef MFButton_h
#define MFButton_h

#include <stdlib.h>
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#include <wiring.h>
#endif

extern "C"
{
// callback functions always follow the signature: void cmd(void);
typedef void (*buttonEvent) (byte, uint8_t, const char *);
};

enum
{
btnOnPress,
btnOnRelease,
};

/////////////////////////////////////////////////////////////////////
/// \class MFButton MFButton.h <MFButton.h>
class MFButton
{
public:
MFButton(uint8_t pin = 1, const char * name = "Button");
void update();
void trigger();
void attachHandler(byte eventId, buttonEvent newHandler);
const char * _name;
uint8_t _pin;

private:
bool _state;
uint32_t _last;
buttonEvent _handlerList[2];
};
#endif
65 changes: 65 additions & 0 deletions include/MFCore.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef MFCore_H
#define MFCore_H

#include <stdlib.h>
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#include <wiring.h>
#endif

enum
{
kTypeNotSet, // 0
kTypeButton, // 1
kTypeEncoder, // 2
kTypeOutput, // 3
kTypeLedSegment, // 4
kTypeStepper, // 5
kTypeServo, // 6
};

// 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
};



class MFCore
{
public:
MFCore();
void test();
static void CallbackFunction();

private:
bool _state;
};
#endif
67 changes: 67 additions & 0 deletions include/MFEncoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// MFEncoder.h
//
/// \mainpage MF Button module for MobiFlight Framework
/// \par Revision History
/// \version 1.0 Initial release
/// \author Sebastian Moebius ([email protected]) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS
// Copyright (C) 2013-2014 Sebastian Moebius

#ifndef MFEncoder_h
#define MFEncoder_h

#include <stdlib.h>
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#include <wiring.h>
#endif

///#include "../Button/Button.h"
///#include "../TicksPerSecond/TicksPerSecond.h"
///#include "../RotaryEncoderAcelleration/RotaryEncoderAcelleration.h"
#include <RotaryEncoder.h>

extern "C"
{
typedef void (*encoderEvent) (uint8_t, uint8_t, const char *);
};

// this prevents the internal position overflow.
// no need to change this
#define MF_ENC_MAX 8000

// this defines the delta value limit for triggering onFast
// this should work well for all encoder types
#define MF_ENC_FAST_LIMIT 40

enum
{
encLeft,
encLeftFast,
encRight,
encRightFast
};

/////////////////////////////////////////////////////////////////////
/// \class MFEncoder MFEncoder.h <MFEncoder.h>
class MFEncoder
{
public:
MFEncoder();
void attach(uint8_t pin1, uint8_t pin2, uint8_t encoderType, const char * name = "Encoder");
void update();
void attachHandler(uint8_t eventId, encoderEvent newHandler);

private:
uint8_t _pin1;
uint8_t _pin2;
bool _initialized;
RotaryEncoder _encoder;
const char * _name;
long _pos;
encoderEvent _handlerList[4];
uint8_t _encoderType;
uint16_t _fastLimit = MF_ENC_FAST_LIMIT;
};
#endif
Loading

0 comments on commit d39c72d

Please sign in to comment.