Browse Source

initial commit

split-pipe
Hendrik Langer 4 years ago
parent
commit
20834ef5b1
  1. 2
      LICENSE
  2. 5
      raspberry/.gitignore
  3. 6
      raspberry/requirements.py
  4. 10
      raspberry/roberto.py
  5. 57
      raspberry/roberto/__init__.py
  6. BIN
      raspberry/roberto/camera/1.jpg
  7. BIN
      raspberry/roberto/camera/2.jpg
  8. BIN
      raspberry/roberto/camera/3.jpg
  9. 1
      raspberry/roberto/camera/__init__.py
  10. 105
      raspberry/roberto/camera/base_camera.py
  11. 15
      raspberry/roberto/camera/camera.py
  12. 30
      raspberry/roberto/camera/camera_opencv.py
  13. 24
      raspberry/roberto/camera/camera_pi.py
  14. 36
      raspberry/roberto/camera/camera_v4l2.py
  15. 0
      raspberry/roberto/config.py
  16. 3
      raspberry/roberto/model.py
  17. 1
      raspberry/roberto/static/css/bootstrap.min.css
  18. 1
      raspberry/roberto/static/js/bootstrap.min.js
  19. 1
      raspberry/roberto/static/js/jquery.min.js
  20. 8
      raspberry/roberto/views/frontend/__init__.py
  21. 27
      raspberry/roberto/views/frontend/routes.py
  22. 17
      raspberry/roberto/views/frontend/templates/index.html
  23. 79
      send.py
  24. 1
      trigorilla/.gitignore
  25. 67
      trigorilla/.travis.yml
  26. 39
      trigorilla/include/README
  27. 39
      trigorilla/platformio.ini
  28. 177
      trigorilla/src/main.cpp
  29. 358
      trigorilla/src/pins/boards.h
  30. 479
      trigorilla/src/pins/macros.h
  31. 713
      trigorilla/src/pins/pins_RAMPS.h
  32. 122
      trigorilla/src/pins/pins_TRIGORILLA_14.h
  33. 138
      trigorilla/src/stepper.h
  34. 11
      trigorilla/test/README

2
LICENSE

@ -1,4 +1,4 @@
MIT License Copyright (c) <year> <copyright holders>
MIT License Copyright (c) 2020 Hendrik <hendrik+dev@xd0.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

5
raspberry/.gitignore

@ -0,0 +1,5 @@
__pycache__/
*.py[cod]
# Flask
instance/

6
raspberry/requirements.py

@ -0,0 +1,6 @@
python3-flask
python3-serial
python3-opencv
python3-imaging
libjs-jquery
libjs-bootstrap

10
raspberry/roberto.py

@ -0,0 +1,10 @@
#!/usr/bin/env python3
from roberto import create_app
# Call the Application Factory function to construct a Flask application instance
# using the standard configuration defined in /instance/flask.cfg
app = create_app('config.py')
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=False, threaded=True)

57
raspberry/roberto/__init__.py

@ -0,0 +1,57 @@
import os
from flask import Flask
from flask_login import LoginManager
#######################
#### Configuration ####
#######################
# Create the instances of the Flask extensions (flask-sqlalchemy, flask-login, etc.) in
# the global scope, but without any arguments passed in. These instances are not attached
# to the application at this point.
login = LoginManager()
login.login_view = "users.login"
#from roberto.camera.camera_opencv import Camera
######################################
#### Application Factory Function ####
######################################
def create_app(config_filename=None):
app = Flask(__name__)
app.config.from_mapping(
SECRET_KEY=os.urandom(24),
DATABASE=os.path.join(app.instance_path, 'roberto.sqlite'),
)
if config_filename is None:
app.config.from_pyfile('config.py')
else:
app.config.from_pyfile(config_filename)
initialize_extensions(app)
register_blueprints(app)
# ensure the instance folder exists
try:
os.makedirs(app.instance_path)
except OSError:
pass
return app
def initialize_extensions(app):
# Since the application instance is now created, pass it to each Flask
# extension instance to bind it to the Flask application instance (app)
from roberto.model import db
db.init_app(app)
#login.init_app(app)
pass
def register_blueprints(app):
# Since the application instance is now created, register each Blueprint
# with the Flask application instance (app)
from roberto.views.frontend import frontend_blueprint
app.register_blueprint(frontend_blueprint)

BIN
raspberry/roberto/camera/1.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
raspberry/roberto/camera/2.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
raspberry/roberto/camera/3.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

1
raspberry/roberto/camera/__init__.py

@ -0,0 +1 @@
# https://blog.miguelgrinberg.com/post/flask-video-streaming-revisited

105
raspberry/roberto/camera/base_camera.py

@ -0,0 +1,105 @@
import time
import threading
try:
from greenlet import getcurrent as get_ident
except ImportError:
try:
from thread import get_ident
except ImportError:
from _thread import get_ident
class CameraEvent(object):
"""An Event-like class that signals all active clients when a new frame is
available.
"""
def __init__(self):
self.events = {}
def wait(self):
"""Invoked from each client's thread to wait for the next frame."""
ident = get_ident()
if ident not in self.events:
# this is a new client
# add an entry for it in the self.events dict
# each entry has two elements, a threading.Event() and a timestamp
self.events[ident] = [threading.Event(), time.time()]
return self.events[ident][0].wait()
def set(self):
"""Invoked by the camera thread when a new frame is available."""
now = time.time()
remove = None
for ident, event in self.events.items():
if not event[0].isSet():
# if this client's event is not set, then set it
# also update the last set timestamp to now
event[0].set()
event[1] = now
else:
# if the client's event is already set, it means the client
# did not process a previous frame
# if the event stays set for more than 5 seconds, then assume
# the client is gone and remove it
if now - event[1] > 5:
remove = ident
if remove:
del self.events[remove]
def clear(self):
"""Invoked from each client's thread after a frame was processed."""
self.events[get_ident()][0].clear()
class BaseCamera(object):
thread = None # background thread that reads frames from camera
frame = None # current frame is stored here by background thread
last_access = 0 # time of last client access to the camera
event = CameraEvent()
def __init__(self):
"""Start the background camera thread if it isn't running yet."""
if BaseCamera.thread is None:
BaseCamera.last_access = time.time()
# start background frame thread
BaseCamera.thread = threading.Thread(target=self._thread)
BaseCamera.thread.start()
# wait until frames are available
while self.get_frame() is None:
time.sleep(0)
def get_frame(self):
"""Return the current camera frame."""
BaseCamera.last_access = time.time()
# wait for a signal from the camera thread
BaseCamera.event.wait()
BaseCamera.event.clear()
return BaseCamera.frame
@staticmethod
def frames():
""""Generator that returns frames from the camera."""
raise RuntimeError('Must be implemented by subclasses.')
@classmethod
def _thread(cls):
"""Camera background thread."""
print('Starting camera thread.')
frames_iterator = cls.frames()
for frame in frames_iterator:
BaseCamera.frame = frame
BaseCamera.event.set() # send signal to clients
time.sleep(0)
# if there hasn't been any clients asking for frames in
# the last 10 seconds then stop the thread
if time.time() - BaseCamera.last_access > 10:
frames_iterator.close()
print('Stopping camera thread due to inactivity.')
break
BaseCamera.thread = None

15
raspberry/roberto/camera/camera.py

@ -0,0 +1,15 @@
import time
from .base_camera import BaseCamera
class Camera(BaseCamera):
"""An emulated camera implementation that streams a repeated sequence of
files 1.jpg, 2.jpg and 3.jpg at a rate of one frame per second."""
imgs = [open(f + '.jpg', 'rb').read() for f in ['1', '2', '3']]
@staticmethod
def frames():
while True:
time.sleep(1)
yield Camera.imgs[int(time.time()) % 3]

30
raspberry/roberto/camera/camera_opencv.py

@ -0,0 +1,30 @@
import os
import cv2
from .base_camera import BaseCamera
class Camera(BaseCamera):
video_source = 0
def __init__(self):
if os.environ.get('OPENCV_CAMERA_SOURCE'):
Camera.set_video_source(int(os.environ['OPENCV_CAMERA_SOURCE']))
super(Camera, self).__init__()
@staticmethod
def set_video_source(source):
Camera.video_source = source
@staticmethod
def frames():
camera = cv2.VideoCapture(Camera.video_source)
if not camera.isOpened():
raise RuntimeError('Could not start camera.')
while True:
# read current frame
_, img = camera.read()
# encode as a jpeg image and return it
yield cv2.imencode('.jpg', img)[1].tobytes()

24
raspberry/roberto/camera/camera_pi.py

@ -0,0 +1,24 @@
import io
import time
import picamera
from .base_camera import BaseCamera
class Camera(BaseCamera):
@staticmethod
def frames():
with picamera.PiCamera() as camera:
# let camera warm up
time.sleep(2)
stream = io.BytesIO()
for _ in camera.capture_continuous(stream, 'jpeg',
use_video_port=True):
# return current frame
stream.seek(0)
yield stream.read()
# reset stream for next frame
stream.seek(0)
stream.truncate()

36
raspberry/roberto/camera/camera_v4l2.py

@ -0,0 +1,36 @@
import io
from PIL import Image
import select
import v4l2capture
from .base_camera import BaseCamera
class Camera(BaseCamera):
"""Requires python-v4l2capture module: https://github.com/gebart/python-v4l2capture"""
video_source = "/dev/video0"
@staticmethod
def frames():
video = v4l2capture.Video_device(Camera.video_source)
# Suggest an image size. The device may choose and return another if unsupported
size_x = 640
size_y = 480
size_x, size_y = video.set_format(size_x, size_y)
video.create_buffers(1)
video.queue_all_buffers()
video.start()
bio = io.BytesIO()
try:
while True:
select.select((video,), (), ()) # Wait for the device to fill the buffer.
image_data = video.read_and_queue()
image = Image.frombytes("RGB", (size_x, size_y), image_data)
image.save(bio, format="jpeg")
yield bio.getvalue()
bio.seek(0)
bio.truncate()
finally:
video.close()

0
raspberry/roberto/config.py

3
raspberry/roberto/model.py

@ -0,0 +1,3 @@
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()

1
raspberry/roberto/static/css/bootstrap.min.css

@ -0,0 +1 @@
/usr/share/javascript/bootstrap/css/bootstrap.min.css

1
raspberry/roberto/static/js/bootstrap.min.js

@ -0,0 +1 @@
/usr/share/javascript/bootstrap/js/bootstrap.min.js

1
raspberry/roberto/static/js/jquery.min.js

@ -0,0 +1 @@
/usr/share/javascript/jquery/jquery.min.js

8
raspberry/roberto/views/frontend/__init__.py

@ -0,0 +1,8 @@
"""
The frontend blueprint handles the webui.
"""
from flask import Blueprint
frontend_blueprint = Blueprint('frontend', __name__, template_folder='templates')
from . import routes

27
raspberry/roberto/views/frontend/routes.py

@ -0,0 +1,27 @@
from . import frontend_blueprint
from flask import current_app, render_template
from flask import Response
################
#### routes ####
################
@frontend_blueprint.route('/')
def index():
return render_template('index.html')
def gen(camera):
"""Video streaming generator function."""
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@frontend_blueprint.route('/video_feed')
def video_feed():
"""Video streaming route. Put this in the src attribute of an img tag."""
from roberto.camera.camera_opencv import Camera
return Response(gen(Camera()),
mimetype='multipart/x-mixed-replace; boundary=frame')

17
raspberry/roberto/views/frontend/templates/index.html

@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Video Streaming Demonstration</title>
<!-- Bootstrap -->
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
</head>
<body>
<h1>Video Streaming Demonstration</h1>
<img src="{{ url_for('frontend.video_feed') }}">
<!-- jQuery and Bootstrap -->
<script src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
</body>
</html>

79
send.py

@ -0,0 +1,79 @@
#!/usr/bin/env python3
import sys, argparse
import time
import threading
import serial
import pygame
def serialreceive(ser):
print("Serial running")
while ser:
try:
if ser.in_waiting > 0:
line = ser.read(ser.in_waiting)
print(line)
except Exception:
pass
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('-P', '--serialport', help="serial port to open", default="/dev/ttyUSB0")
parser.add_argument('--delay', help="add delay before startup", type=int, default=1)
args = parser.parse_args()
pygame.init()
pygame.joystick.init()
joysticks = [pygame.joystick.Joystick(x) for x in range(pygame.joystick.get_count())]
for joystick in joysticks:
joystick.init()
name = joystick.get_name()
print("Found joystick: ")
print(name)
with serial.Serial(args.serialport, 115200, timeout=12) as ser:
receivethread = threading.Thread(target=serialreceive, args=(ser,))
receivethread.daemon = True
receivethread.start()
time.sleep(args.delay)
axis_data = {0:0,1:0,2:0,3:0,4:0}
try:
while True:
for event in pygame.event.get():
if event.type == pygame.JOYAXISMOTION:
axis_data[event.axis] = round(event.value,2)
if abs(axis_data[event.axis]) <= 0.15:
axis_data[event.axis] = 0;
print(axis_data)
x = axis_data[0]
y = axis_data[1]
r = axis_data[3]
m0 = +y - x - r
m1 = +y + x - r
m2 = -y + x - r
m3 = -y - x - r
m0 *= 4000
m1 *= 4000
m2 *= 4000
m3 *= 4000
command = 'S '+str(int(m0))+','+str(int(m1))+','+str(int(m2))+','+str(int(m3))+'\n'
ser.write(bytes(command, "utf8"))
#ser.flush()
#time.sleep(0.05)
print(command)
except KeyboardInterrupt:
print("KeyboardInterrupt. Exiting")
#ser.write(b'S 800,800,-800,-800\n')
#time.sleep(2)
ser.write(b'DISABLE')
print("serial closed")
if __name__ == "__main__":
main(sys.argv[1:])

1
trigorilla/.gitignore

@ -0,0 +1 @@
.pio

67
trigorilla/.travis.yml

@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
#
#
# Please choose one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#
#
# Template #1: General project. Test it using existing `platformio.ini`.
#
# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# install:
# - pip install -U platformio
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be used as a library with examples.
#
# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# env:
# - PLATFORMIO_CI_SRC=path/to/test/file.c
# - PLATFORMIO_CI_SRC=examples/file.ino
# - PLATFORMIO_CI_SRC=path/to/test/directory
#
# install:
# - pip install -U platformio
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

39
trigorilla/include/README

@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

39
trigorilla/platformio.ini

@ -0,0 +1,39 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = megaatmega2560
#default_envs = nano
[common]
lib_deps =
ToneLibrary
# TimerOne
# AccelStepper
# SpeedyStepper
[env]
framework = arduino
build_flags = -O2
#build_flags = ${common.build_flags}
lib_deps = ${common.lib_deps}
monitor_speed = 115200
[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
board_build.f_cpu = 16000000L
lib_deps = ${common.lib_deps}
[env:nano]
platform = atmelavr
board = nanoatmega328
board_build.f_cpu = 16000000L
lib_deps = ${common.lib_deps}

177
trigorilla/src/main.cpp

@ -0,0 +1,177 @@
/*
* Blink
* Turns on an LED on for one second,
* then off for one second, repeatedly.
*/
#include <Arduino.h>
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#include "pins/pins_TRIGORILLA_14.h"
#elif defined(__AVR_ATmega328P__)
#define LED_PIN LED_BUILTIN
#define X_DIR_PIN PD2
#define X_STEP_PIN PD3
#define X_ENABLE_PIN A0
#define Y_DIR_PIN PD4
#define Y_STEP_PIN PD5
#define Y_ENABLE_PIN A1
#define Z_DIR_PIN PD6
#define Z_STEP_PIN PD7
#define Z_ENABLE_PIN A2
#define E0_DIR_PIN PB0
#define E0_STEP_PIN PB1
#define E0_ENABLE_PIN A3
#define E1_DIR_PIN PB2
#define E1_STEP_PIN PB3
#define E1_ENABLE_PIN A4
#endif
#include "stepper.h"
const int NUM_STEPPER = 5;
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
TimerStepper stepper[NUM_STEPPER];
#elif defined(__AVR_ATmega328P__)
LoopStepper stepper[NUM_STEPPER];
#endif
unsigned long lastMillis = 0;
unsigned long lastCommand = 0;
const long interval = 1000; // interval at which to blink (milliseconds)
int enable_pin[NUM_STEPPER] = {X_ENABLE_PIN, Y_ENABLE_PIN, Z_ENABLE_PIN, E0_ENABLE_PIN, E1_ENABLE_PIN};
void setup()
{
Serial.begin(115200);
/* delay(500);
Serial.println("##########");
Serial.println("MIDI");
Serial.println("##########");
Serial.flush();
*/
// initialize LED digital pin as an output.
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
pinMode(TRIGORILLA_HEATER_0_PIN, OUTPUT);
digitalWrite(TRIGORILLA_HEATER_0_PIN, HIGH);
stepper[0].begin( X_DIR_PIN, X_STEP_PIN, X_ENABLE_PIN);
stepper[1].begin( Y_DIR_PIN, Y_STEP_PIN, Y_ENABLE_PIN);
stepper[2].begin( Z_DIR_PIN, Z_STEP_PIN, Z_ENABLE_PIN);
stepper[3].begin(E0_DIR_PIN, E0_STEP_PIN, E0_ENABLE_PIN);
stepper[4].begin(E1_DIR_PIN, E1_STEP_PIN, E1_ENABLE_PIN);
for (int i = 0; i < NUM_STEPPER; i++) {
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
stepper[i].setMaxSpeed(8000);
#elif defined(__AVR_ATmega328P__)
stepper[i].setMaxSpeed(1400);
#endif
stepper[i].setAcceleration(4000);
}
// Timer0 is already used for millis() - we'll just interrupt somewhere
// in the middle and call the "Compare A" function below
OCR0A = 0xAF;
TIMSK0 |= _BV(OCIE0A);
}
// Interrupt is called once a millisecond,
ISR(TIMER0_COMPA_vect) {
for (int i=0; i<NUM_STEPPER; i++) stepper[i].loop();
}
bool parseCmd(char* buf, int values[4]) {
char cmd;
int n = sscanf(buf, "%c %d,%d,%d,%d", &cmd, &values[0], &values[1], &values[2], &values[3]);
if (n == 5) return true;
else return false;
}
void loop()
{
unsigned long currentMillis = millis();
if(Serial.available()) {
String command = Serial.readStringUntil('\n');
lastCommand = millis();
if (command.equals("ENABLE")) {
stepper[0].enable();
stepper[1].enable();
stepper[2].enable();
stepper[3].enable();
//Serial.println("## ENABLE");
} else if (command.equals("DISABLE")) {
stepper[0].disable();
stepper[1].disable();
stepper[2].disable();
stepper[3].disable();
//Serial.println("## DISABLE");
} else if (command.charAt(0) == 'A') {
int values[4];
char* buf = command.c_str();
bool success = parseCmd(buf, values);
if (success) {
stepper[0].setAcceleration(values[0]);
stepper[1].setAcceleration(values[1]);
stepper[2].setAcceleration(values[2]);
stepper[3].setAcceleration(values[3]);
}
} else if (command.charAt(0) == 'S') {
int values[4];
char* buf = command.c_str();
bool success = parseCmd(buf, values);
if (success) {
stepper[0].setSpeedDirect(values[0]);
stepper[1].setSpeedDirect(values[1]);
stepper[2].setSpeedDirect(values[2]);
stepper[3].setSpeedDirect(values[3]);
Serial.print("Motor Speeds: ");
Serial.print(values[0]); Serial.print(", ");
Serial.print(values[1]); Serial.print(", ");
Serial.print(values[2]); Serial.print(", ");
Serial.print(values[3]); Serial.print("\n");
}
}
}
if (millis() - lastCommand > 5000) {
stepper[0].disable();
stepper[1].disable();
stepper[2].disable();
stepper[3].disable();
}
/*
stepper[0].setSpeed(-4000);
stepper[1].setSpeed(-4000);
stepper[2].setSpeed(4000);
stepper[3].setSpeed(4000);
delay(2000);
stepper[0].setSpeed(0);
stepper[1].setSpeed(0);
stepper[2].setSpeed(0);
stepper[3].setSpeed(0);
while (stepper[0].isAccelerating() || stepper[1].isAccelerating() || stepper[2].isAccelerating() || stepper[3].isAccelerating()) {
delay(20);
}
stepper[0].setSpeed(2400);
stepper[1].setSpeed(2400);
stepper[2].setSpeed(2400);
stepper[3].setSpeed(2400);
delay(4200);
stepper[0].setSpeed(0);
stepper[1].setSpeed(0);
stepper[2].setSpeed(0);
stepper[3].setSpeed(0);
while (stepper[0].isAccelerating() || stepper[1].isAccelerating() || stepper[2].isAccelerating() || stepper[3].isAccelerating()) {
delay(20);
}
// for (int i=0; i<NUM_STEPPER; i++) {
// stepper[i].disable();
// }
// delay(2000);
*/
}

358
trigorilla/src/pins/boards.h

@ -0,0 +1,358 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "macros.h"
#define BOARD_UNKNOWN -1
//
// RAMPS 1.3 / 1.4 - ATmega1280, ATmega2560
//
#define BOARD_RAMPS_OLD 1000 // MEGA/RAMPS up to 1.2
#define BOARD_RAMPS_13_EFB 1010 // RAMPS 1.3 (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_13_EEB 1011 // RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_13_EFF 1012 // RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_13_EEF 1013 // RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_13_SF 1014 // RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
#define BOARD_RAMPS_14_EFB 1020 // RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_14_EEB 1021 // RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_14_EFF 1022 // RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_14_EEF 1023 // RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_14_SF 1024 // RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
#define BOARD_RAMPS_PLUS_EFB 1030 // RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_PLUS_EEB 1031 // RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_PLUS_EFF 1032 // RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_PLUS_EEF 1033 // RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_PLUS_SF 1034 // RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
//
// RAMPS Derivatives - ATmega1280, ATmega2560
//
#define BOARD_3DRAG 1100 // 3Drag Controller
#define BOARD_K8200 1101 // Velleman K8200 Controller (derived from 3Drag Controller)
#define BOARD_K8400 1102 // Velleman K8400 Controller (derived from 3Drag Controller)
#define BOARD_BAM_DICE 1103 // 2PrintBeta BAM&DICE with STK drivers
#define BOARD_BAM_DICE_DUE 1104 // 2PrintBeta BAM&DICE Due with STK drivers
#define BOARD_MKS_BASE 1105 // MKS BASE v1.0
#define BOARD_MKS_BASE_14 1106 // MKS BASE v1.4 with Allegro A4982 stepper drivers
#define BOARD_MKS_BASE_15 1107 // MKS BASE v1.5 with Allegro A4982 stepper drivers
#define BOARD_MKS_BASE_16 1108 // MKS BASE v1.6 with Allegro A4982 stepper drivers
#define BOARD_MKS_BASE_HEROIC 1109 // MKS BASE 1.0 with Heroic HR4982 stepper drivers
#define BOARD_MKS_GEN_13 1110 // MKS GEN v1.3 or 1.4
#define BOARD_MKS_GEN_L 1111 // MKS GEN L
#define BOARD_KFB_2 1112 // BigTreeTech or BIQU KFB2.0
#define BOARD_ZRIB_V20 1113 // zrib V2.0 control board (Chinese knock off RAMPS replica)
#define BOARD_FELIX2 1114 // Felix 2.0+ Electronics Board (RAMPS like)
#define BOARD_RIGIDBOARD 1115 // Invent-A-Part RigidBoard
#define BOARD_RIGIDBOARD_V2 1116 // Invent-A-Part RigidBoard V2
#define BOARD_SAINSMART_2IN1 1117 // Sainsmart 2-in-1 board
#define BOARD_ULTIMAKER 1118 // Ultimaker
#define BOARD_ULTIMAKER_OLD 1119 // Ultimaker (Older electronics. Pre 1.5.4. This is rare)
#define BOARD_AZTEEG_X3 1120 // Azteeg X3
#define BOARD_AZTEEG_X3_PRO 1121 // Azteeg X3 Pro
#define BOARD_ULTIMAIN_2 1122 // Ultimainboard 2.x (Uses TEMP_SENSOR 20)
#define BOARD_RUMBA 1123 // Rumba
#define BOARD_RUMBA_RAISE3D 1124 // Raise3D N series Rumba derivative
#define BOARD_RL200 1125 // Rapide Lite 200 (v1, low-cost RUMBA clone with drv)
#define BOARD_FORMBOT_TREX2PLUS 1126 // Formbot T-Rex 2 Plus
#define BOARD_FORMBOT_TREX3 1127 // Formbot T-Rex 3
#define BOARD_FORMBOT_RAPTOR 1128 // Formbot Raptor
#define BOARD_FORMBOT_RAPTOR2 1129 // Formbot Raptor 2
#define BOARD_BQ_ZUM_MEGA_3D 1130 // bq ZUM Mega 3D
#define BOARD_MAKEBOARD_MINI 1131 // MakeBoard Mini v2.1.2 is a control board sold by MicroMake
#define BOARD_TRIGORILLA_13 1132 // TriGorilla Anycubic version 1.3-based on RAMPS EFB
#define BOARD_TRIGORILLA_14 1133 // ... Ver 1.4
#define BOARD_TRIGORILLA_14_11 1134 // ... Rev 1.1 (new servo pin order)
#define BOARD_RAMPS_ENDER_4 1135 // Creality: Ender-4, CR-8
#define BOARD_RAMPS_CREALITY 1136 // Creality: CR10S, CR20, CR-X
#define BOARD_RAMPS_DAGOMA 1137 // Dagoma F5
#define BOARD_FYSETC_F6_13 1138 // FYSETC F6 1.3
#define BOARD_FYSETC_F6_14 1139 // FYSETC F6 1.4
#define BOARD_DUPLICATOR_I3_PLUS 1140 // Wanhao Duplicator i3 Plus
#define BOARD_VORON 1141 // VORON Design
#define BOARD_TRONXY_V3_1_0 1142 // Tronxy TRONXY-V3-1.0
#define BOARD_Z_BOLT_X_SERIES 1143 // Z-Bolt X Series
#define BOARD_TT_OSCAR 1144 // TT OSCAR
#define BOARD_OVERLORD 1145 // Overlord/Overlord Pro
#define BOARD_HJC2560C_REV1 1146 // ADIMLab Gantry v1
#define BOARD_HJC2560C_REV2 1147 // ADIMLab Gantry v2
#define BOARD_TANGO 1148 // BIQU Tango V1
#define BOARD_MKS_GEN_L_V2 1149 // MKS GEN L V2
//
// RAMBo and derivatives
//
#define BOARD_RAMBO 1200 // Rambo
#define BOARD_MINIRAMBO 1201 // Mini-Rambo
#define BOARD_MINIRAMBO_10A 1202 // Mini-Rambo 1.0a
#define BOARD_EINSY_RAMBO 1203 // Einsy Rambo
#define BOARD_EINSY_RETRO 1204 // Einsy Retro
#define BOARD_SCOOVO_X9H 1205 // abee Scoovo X9H
//
// Other ATmega1280, ATmega2560
//
#define BOARD_CNCONTROLS_11 1300 // Cartesio CN Controls V11
#define BOARD_CNCONTROLS_12 1301 // Cartesio CN Controls V12
#define BOARD_CNCONTROLS_15 1302 // Cartesio CN Controls V15
#define BOARD_CHEAPTRONIC 1303 // Cheaptronic v1.0
#define BOARD_CHEAPTRONIC_V2 1304 // Cheaptronic v2.0
#define BOARD_MIGHTYBOARD_REVE 1305 // Makerbot Mightyboard Revision E
#define BOARD_MEGATRONICS 1306 // Megatronics
#define BOARD_MEGATRONICS_2 1307 // Megatronics v2.0
#define BOARD_MEGATRONICS_3 1308 // Megatronics v3.0
#define BOARD_MEGATRONICS_31 1309 // Megatronics v3.1
#define BOARD_MEGATRONICS_32 1310 // Megatronics v3.2
#define BOARD_ELEFU_3 1311 // Elefu Ra Board (v3)
#define BOARD_LEAPFROG 1312 // Leapfrog
#define BOARD_MEGACONTROLLER 1313 // Mega controller
#define BOARD_GT2560_REV_A 1314 // Geeetech GT2560 Rev. A
#define BOARD_GT2560_REV_A_PLUS 1315 // Geeetech GT2560 Rev. A+ (with auto level probe)
#define BOARD_GT2560_V3 1316 // Geeetech GT2560 Rev B for A10(M/D)
#define BOARD_GT2560_V3_MC2 1317 // Geeetech GT2560 Rev B for Mecreator2
#define BOARD_GT2560_V3_A20 1318 // Geeetech GT2560 Rev B for A20(M/D)
#define BOARD_EINSTART_S 1319 // Einstart retrofit
#define BOARD_WANHAO_ONEPLUS 1320 // Wanhao 0ne+ i3 Mini
#define BOARD_LEAPFROG_XEED2015 1321 // Leapfrog Xeed 2015
#define BOARD_PICA_REVB 1322 // PICA Shield (original version)
#define BOARD_PICA 1323 // PICA Shield (rev C or later)
//
// ATmega1281, ATmega2561
//
#define BOARD_MINITRONICS 1400 // Minitronics v1.0/1.1
#define BOARD_SILVER_GATE 1401 // Silvergate v1.0
//
// Sanguinololu and Derivatives - ATmega644P, ATmega1284P
//
#define BOARD_SANGUINOLOLU_11 1500 // Sanguinololu < 1.2
#define BOARD_SANGUINOLOLU_12 1501 // Sanguinololu 1.2 and above
#define BOARD_MELZI 1502 // Melzi
#define BOARD_MELZI_MAKR3D 1503 // Melzi with ATmega1284 (MaKr3d version)
#define BOARD_MELZI_CREALITY 1504 // Melzi Creality3D board (for CR-10 etc)
#define BOARD_MELZI_MALYAN 1505 // Melzi Malyan M150 board
#define BOARD_MELZI_TRONXY 1506 // Tronxy X5S
#define BOARD_STB_11 1507 // STB V1.1
#define BOARD_AZTEEG_X1 1508 // Azteeg X1
#define BOARD_ANET_10 1509 // Anet 1.0 (Melzi clone)
//
// Other ATmega644P, ATmega644, ATmega1284P
//
#define BOARD_GEN3_MONOLITHIC 1600 // Gen3 Monolithic Electronics
#define BOARD_GEN3_PLUS 1601 // Gen3+
#define BOARD_GEN6 1602 // Gen6
#define BOARD_GEN6_DELUXE 1603 // Gen6 deluxe
#define BOARD_GEN7_CUSTOM 1604 // Gen7 custom (Alfons3 Version) "https://github.com/Alfons3/Generation_7_Electronics"
#define BOARD_GEN7_12 1605 // Gen7 v1.1, v1.2
#define BOARD_GEN7_13 1606 // Gen7 v1.3
#define BOARD_GEN7_14 1607 // Gen7 v1.4
#define BOARD_OMCA_A 1608 // Alpha OMCA board
#define BOARD_OMCA 1609 // Final OMCA board
#define BOARD_SETHI 1610 // Sethi 3D_1
//
// Teensyduino - AT90USB1286, AT90USB1286P
//
#define BOARD_TEENSYLU 1700 // Teensylu
#define BOARD_PRINTRBOARD 1701 // Printrboard (AT90USB1286)
#define BOARD_PRINTRBOARD_REVF 1702 // Printrboard Revision F (AT90USB1286)
#define BOARD_BRAINWAVE 1703 // Brainwave (AT90USB646)
#define BOARD_BRAINWAVE_PRO 1704 // Brainwave Pro (AT90USB1286)
#define BOARD_SAV_MKI 1705 // SAV Mk-I (AT90USB1286)
#define BOARD_TEENSY2 1706 // Teensy++2.0 (AT90USB1286)
#define BOARD_5DPRINT 1707 // 5DPrint D8 Driver Board
//
// LPC1768 ARM Cortex M3
//
#define BOARD_RAMPS_14_RE_ARM_EFB 2000 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_14_RE_ARM_EEB 2001 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_14_RE_ARM_EFF 2002 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_14_RE_ARM_EEF 2003 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_14_RE_ARM_SF 2004 // Re-ARM with RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
#define BOARD_MKS_SBASE 2005 // MKS-Sbase (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_AZSMZ_MINI 2006 // AZSMZ Mini
#define BOARD_BIQU_BQ111_A4 2007 // BIQU BQ111-A4 (Power outputs: Hotend, Fan, Bed)
#define BOARD_SELENA_COMPACT 2008 // Selena Compact (Power outputs: Hotend0, Hotend1, Bed0, Bed1, Fan0, Fan1)
#define BOARD_BIQU_B300_V1_0 2009 // BIQU B300_V1.0 (Power outputs: Hotend0, Fan, Bed, SPI Driver)
#define BOARD_MKS_SGEN_L 2010 // MKS-SGen-L (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_GMARSH_X6_REV1 2011 // GMARSH X6 board, revision 1 prototype
#define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed)
//
// LPC1769 ARM Cortex M3
//
#define BOARD_MKS_SGEN 2500 // MKS-SGen (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_AZTEEG_X5_GT 2501 // Azteeg X5 GT (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_AZTEEG_X5_MINI 2502 // Azteeg X5 Mini (Power outputs: Hotend0, Bed, Fan)
#define BOARD_AZTEEG_X5_MINI_WIFI 2503 // Azteeg X5 Mini Wifi (Power outputs: Hotend0, Bed, Fan)
#define BOARD_COHESION3D_REMIX 2504 // Cohesion3D ReMix
#define BOARD_COHESION3D_MINI 2505 // Cohesion3D Mini
#define BOARD_SMOOTHIEBOARD 2506 // Smoothieboard
#define BOARD_TH3D_EZBOARD 2507 // TH3D EZBoard v1.0
#define BOARD_BTT_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO (Power outputs: Hotend0, Hotend1, Fan, Bed)
//
// SAM3X8E ARM Cortex M3
//
#define BOARD_DUE3DOM 3000 // DUE3DOM for Arduino DUE
#define BOARD_DUE3DOM_MINI 3001 // DUE3DOM MINI for Arduino DUE
#define BOARD_RADDS 3002 // RADDS
#define BOARD_RAMPS_FD_V1 3003 // RAMPS-FD v1
#define BOARD_RAMPS_FD_V2 3004 // RAMPS-FD v2
#define BOARD_RAMPS_SMART_EFB 3005 // RAMPS-SMART (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_SMART_EEB 3006 // RAMPS-SMART (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_SMART_EFF 3007 // RAMPS-SMART (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_SMART_EEF 3008 // RAMPS-SMART (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_SMART_SF 3009 // RAMPS-SMART (Power outputs: Spindle, Controller Fan)
#define BOARD_RAMPS_DUO_EFB 3010 // RAMPS Duo (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_DUO_EEB 3011 // RAMPS Duo (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_DUO_EFF 3012 // RAMPS Duo (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS_DUO_EEF 3013 // RAMPS Duo (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_DUO_SF 3014 // RAMPS Duo (Power outputs: Spindle, Controller Fan)
#define BOARD_RAMPS4DUE_EFB 3015 // RAMPS4DUE (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS4DUE_EEB 3016 // RAMPS4DUE (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS4DUE_EFF 3017 // RAMPS4DUE (Power outputs: Hotend, Fan0, Fan1)
#define BOARD_RAMPS4DUE_EEF 3018 // RAMPS4DUE (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS4DUE_SF 3019 // RAMPS4DUE (Power outputs: Spindle, Controller Fan)
#define BOARD_RURAMPS4D_11 3020 // RuRAMPS4Duo v1.1 (Power outputs: Hotend0, Hotend1, Hotend2, Fan0, Fan1, Bed)
#define BOARD_RURAMPS4D_13 3021 // RuRAMPS4Duo v1.3 (Power outputs: Hotend0, Hotend1, Hotend2, Fan0, Fan1, Bed)
#define BOARD_ULTRATRONICS_PRO 3022 // ReprapWorld Ultratronics Pro V1.0
#define BOARD_ARCHIM1 3023 // UltiMachine Archim1 (with DRV8825 drivers)
#define BOARD_ARCHIM2 3024 // UltiMachine Archim2 (with TMC2130 drivers)
#define BOARD_ALLIGATOR 3025 // Alligator Board R2
#define BOARD_CNCONTROLS_15D 3026 // Cartesio CN Controls V15 on DUE
//
// SAM3X8C ARM Cortex M3
//
#define BOARD_PRINTRBOARD_G2 3100 // PRINTRBOARD G2
#define BOARD_ADSK 3101 // Arduino DUE Shield Kit (ADSK)
//
// STM32 ARM Cortex-M3
//
#define BOARD_STM32F103RE 4000 // STM32F103RE Libmaple-based STM32F1 controller
#define BOARD_MALYAN_M200 4001 // STM32C8T6 Libmaple-based STM32F1 controller
#define BOARD_STM3R_MINI 4002 // STM32F103RE Libmaple-based STM32F1 controller
#define BOARD_GTM32_PRO_VB 4003 // STM32F103VET6 controller
#define BOARD_MORPHEUS 4004 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller
#define BOARD_CHITU3D 4005 // Chitu3D (STM32F103RET6)
#define BOARD_MKS_ROBIN 4006 // MKS Robin (STM32F103ZET6)
#define BOARD_MKS_ROBIN_MINI 4007 // MKS Robin Mini (STM32F103VET6)
#define BOARD_MKS_ROBIN_NANO 4008 // MKS Robin Nano (STM32F103VET6)
#define BOARD_MKS_ROBIN_LITE 4009 // MKS Robin Lite/Lite2 (STM32F103RCT6)
#define BOARD_MKS_ROBIN_LITE3 4010 // MKS Robin Lite3 (STM32F103RCT6)
#define BOARD_MKS_ROBIN_PRO 4011 // MKS Robin Pro (STM32F103ZET6)
#define BOARD_BTT_SKR_MINI_V1_1 4012 // BigTreeTech SKR Mini v1.1 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V1_0 4013 // BigTreeTech SKR Mini E3 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V1_2 4014 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
#define BOARD_BTT_SKR_E3_DIP 4015 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
#define BOARD_JGAURORA_A5S_A1 4016 // JGAurora A5S A1 (STM32F103ZET6)
#define BOARD_FYSETC_AIO_II 4017 // FYSETC AIO_II
#define BOARD_FYSETC_CHEETAH 4018 // FYSETC Cheetah
#define BOARD_FYSETC_CHEETAH_V12 4019 // FYSETC Cheetah V1.2
#define BOARD_LONGER3D_LK 4020 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
#define BOARD_GTM32_MINI 4021 // STM32F103VET6 controller
#define BOARD_GTM32_MINI_A30 4022 // STM32F103VET6 controller
#define BOARD_GTM32_REV_B 4023 // STM32F103VET6 controller
//
// ARM Cortex-M4F
//
#define BOARD_TEENSY31_32 4100 // Teensy3.1 and Teensy3.2
#define BOARD_TEENSY35_36 4101 // Teensy3.5 and Teensy3.6
//
// STM32 ARM Cortex-M4F
//
#define BOARD_BEAST 4200 // STM32F4xxVxT6 Libmaple-based STM32F4 controller
#define BOARD_GENERIC_STM32F4 4201 // STM32 STM32GENERIC-based STM32F4 controller
#define BOARD_ARMED 4202 // Arm'ed STM32F4-based controller
#define BOARD_RUMBA32_AUS3D 4203 // RUMBA32 STM32F446VET6 based controller from Aus3D
#define BOARD_RUMBA32_MKS 4204 // RUMBA32 STM32F446VET6 based controller from Makerbase
#define BOARD_BLACK_STM32F407VE 4205 // BLACK_STM32F407VE
#define BOARD_BLACK_STM32F407ZE 4206 // BLACK_STM32F407ZE
#define BOARD_STEVAL_3DP001V1 4207 // STEVAL-3DP001V1 3D PRINTER BOARD
#define BOARD_BTT_SKR_PRO_V1_1 4208 // BigTreeTech SKR Pro v1.1 (STM32F407ZG)
#define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VE)
#define BOARD_BTT_GTR_V1_0 4210 // BigTreeTech GTR v1.0 (STM32F407IGT)
#define BOARD_LERDGE_K 4211 // Lerdge K (STM32F407ZG)
#define BOARD_LERDGE_X 4212 // Lerdge X (STM32F407VE)
#define BOARD_VAKE403D 4213 // VAkE 403D (STM32F446VET6)
#define BOARD_FYSETC_S6 4214 // FYSETC S6 board
#define BOARD_FLYF407ZG 4215 // FLYF407ZG board (STM32F407ZG)
#define BOARD_MKS_ROBIN2 4216 // MKS_ROBIN2 (STM32F407ZE)
//
// ARM Cortex M7
//
#define BOARD_THE_BORG 5000 // THE-BORG (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_REMRAM_V1 5001 // RemRam v1
//
// Espressif ESP32 WiFi
//
#define BOARD_ESPRESSIF_ESP32 6000 // Generic ESP32
#define BOARD_MRR_ESPA 6001 // MRR ESPA board based on ESP32 (native pins only)
#define BOARD_MRR_ESPE 6002 // MRR ESPE board based on ESP32 (with I2S stepper stream)
#define BOARD_E4D_BOX 6003 // E4d@BOX
//
// SAMD51 ARM Cortex M4
//
#define BOARD_AGCM4_RAMPS_144 6100 // RAMPS 1.4.4
//
// Simulations
//
#define BOARD_LINUX_RAMPS 9999
#define _MB_1(B) (defined(BOARD_##B) && MOTHERBOARD==BOARD_##B)
#define MB(V...) DO(MB,||,V)
#define IS_MELZI MB(MELZI, MELZI_CREALITY, MELZI_MAKR3D, MELZI_MALYAN, MELZI_TRONXY)

479
trigorilla/src/pins/macros.h

@ -0,0 +1,479 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#define ABCE 4
#define XYZE 4
#define ABC 3
#define XYZ 3
#define XY 2
#define _AXIS(A) (A##_AXIS)
#define _XMIN_ 100
#define _YMIN_ 200
#define _ZMIN_ 300
#define _XMAX_ 101
#define _YMAX_ 201
#define _ZMAX_ 301
#define _XDIAG_ 102
#define _YDIAG_ 202
#define _ZDIAG_ 302
#define _E0DIAG_ 400
#define _E1DIAG_ 401
#define _E2DIAG_ 402
#define _E3DIAG_ 403
#define _E4DIAG_ 404
#define _E5DIAG_ 405
#define _E6DIAG_ 406
#define _E7DIAG_ 407
#define _FORCE_INLINE_ __attribute__((__always_inline__)) __inline__
#define FORCE_INLINE __attribute__((always_inline)) inline
#define _UNUSED __attribute__((unused))
#define _O0 __attribute__((optimize("O0")))
#define _Os __attribute__((optimize("Os")))
#define _O1 __attribute__((optimize("O1")))
#define _O2 __attribute__((optimize("O2")))
#define _O3 __attribute__((optimize("O3")))
#ifndef UNUSED
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#define UNUSED(X) (void)X
#else
#define UNUSED(x) ((void)(x))
#endif
#endif
// Clock speed factors
#if !defined(CYCLES_PER_MICROSECOND) && !defined(__STM32F1__)
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000UL) // 16 or 20 on AVR
#endif
// Nanoseconds per cycle
#define NANOSECONDS_PER_CYCLE (1000000000.0 / F_CPU)
// Macros to make sprintf_P read from PROGMEM (AVR extension)
#ifdef __AVR__
#define S_FMT "%S"
#else
#define S_FMT "%s"
#endif
// Macros to make a string from a macro
#define STRINGIFY_(M) #M
#define STRINGIFY(M) STRINGIFY_(M)
#define A(CODE) " " CODE "\n\t"
#define L(CODE) CODE ":\n\t"
// Macros for bit masks
#undef _BV
#define _BV(n) (1<<(n))
#define TEST(n,b) (!!((n)&_BV(b)))
#define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0)
#ifndef SBI
#define SBI(A,B) (A |= (1 << (B)))
#endif
#ifndef CBI
#define CBI(A,B) (A &= ~(1 << (B)))
#endif
#define _BV32(b) (1UL << (b))
#define TEST32(n,b) !!((n)&_BV32(b))
#define SBI32(n,b) (n |= _BV32(b))
#define CBI32(n,b) (n &= ~_BV32(b))
#define cu(x) ((x)*(x)*(x))
#define RADIANS(d) ((d)*float(M_PI)/180.0f)
#define DEGREES(r) ((r)*180.0f/float(M_PI))
#define HYPOT2(x,y) (sq(x)+sq(y))
#define CIRCLE_AREA(R) (float(M_PI) * sq(float(R)))
#define CIRCLE_CIRC(R) (2 * float(M_PI) * float(R))
#define SIGN(a) ((a>0)-(a<0))
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
// Macros to constrain values
#ifdef __cplusplus
// C++11 solution that is standards compliant.
template <class V, class N> static inline constexpr void NOLESS(V& v, const N n) {
if (n > v) v = n;
}
template <class V, class N> static inline constexpr void NOMORE(V& v, const N n) {
if (n < v) v = n;
}
template <class V, class N1, class N2> static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
if (n1 > v) v = n1;
else if (n2 < v) v = n2;
}
#else
// Using GCC extensions, but Travis GCC version does not like it and gives
// "error: statement-expressions are not allowed outside functions nor in template-argument lists"
#define NOLESS(v, n) \
do{ \
__typeof__(n) _n = (n); \
if (_n > v) v = _n; \
}while(0)
#define NOMORE(v, n) \
do{ \
__typeof__(n) _n = (n); \
if (_n < v) v = _n; \
}while(0)
#define LIMIT(v, n1, n2) \
do{ \
__typeof__(n1) _n1 = (n1); \
__typeof__(n2) _n2 = (n2); \
if (_n1 > v) v = _n1; \
else if (_n2 < v) v = _n2; \
}while(0)
#endif
// Macros to chain up to 12 conditions
#define _DO_1(W,C,A) (_##W##_1(A))
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))
#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V))
#define _DO_4(W,C,A,V...) (_##W##_1(A) C _DO_3(W,C,V))
#define _DO_5(W,C,A,V...) (_##W##_1(A) C _DO_4(W,C,V))
#define _DO_6(W,C,A,V...) (_##W##_1(A) C _DO_5(W,C,V))
#define _DO_7(W,C,A,V...) (_##W##_1(A) C _DO_6(W,C,V))
#define _DO_8(W,C,A,V...) (_##W##_1(A) C _DO_7(W,C,V))
#define _DO_9(W,C,A,V...) (_##W##_1(A) C _DO_8(W,C,V))
#define _DO_10(W,C,A,V...) (_##W##_1(A) C _DO_9(W,C,V))
#define _DO_11(W,C,A,V...) (_##W##_1(A) C _DO_10(W,C,V))
#define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V))
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
#define DO(W,C,V...) _DO_N(W,C,NUM_ARGS(V),V)
// Macros to support option testing
#define _CAT(a,V...) a##V
#define CAT(a,V...) _CAT(a,V)
#define SWITCH_ENABLED_false 0
#define SWITCH_ENABLED_true 1
#define SWITCH_ENABLED_0 0
#define SWITCH_ENABLED_1 1
#define SWITCH_ENABLED_0x0 0
#define SWITCH_ENABLED_0x1 1
#define SWITCH_ENABLED_ 1
#define _ENA_1(O) _CAT(SWITCH_ENABLED_, O)
#define _DIS_1(O) !_ENA_1(O)
#define ENABLED(V...) DO(ENA,&&,V)
#define DISABLED(V...) DO(DIS,&&,V)
#define ANY(V...) !DISABLED(V)
#define NONE(V...) DISABLED(V)
#define ALL(V...) ENABLED(V)
#define BOTH(V1,V2) ALL(V1,V2)
#define EITHER(V1,V2) ANY(V1,V2)
// Macros to support pins/buttons exist testing
#define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
#define _PINEX_1 PIN_EXISTS
#define PINS_EXIST(V...) DO(PINEX,&&,V)
#define ANY_PIN(V...) DO(PINEX,||,V)
#define BUTTON_EXISTS(BN) (defined(BTN_##BN) && BTN_##BN >= 0)
#define _BTNEX_1 BUTTON_EXISTS
#define BUTTONS_EXIST(V...) DO(BTNEX,&&,V)
#define ANY_BUTTON(V...) DO(BTNEX,||,V)
#define WITHIN(N,L,H) ((N) >= (L) && (N) <= (H))
#define NUMERIC(a) WITHIN(a, '0', '9')
#define DECIMAL(a) (NUMERIC(a) || a == '.')
#define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-' || (a) == '+')
#define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+')
#define COUNT(a) (sizeof(a)/sizeof(*a))
#define ZERO(a) memset(a,0,sizeof(a))
#define COPY(a,b) do{ \
static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
}while(0)
// Macros for initializing arrays
#define LIST_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P
#define LIST_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O
#define LIST_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N
#define LIST_13(A,B,C,D,E,F,G,H,I,J,K,L,M,...) A,B,C,D,E,F,G,H,I,J,K,L,M
#define LIST_12(A,B,C,D,E,F,G,H,I,J,K,L,...) A,B,C,D,E,F,G,H,I,J,K,L
#define LIST_11(A,B,C,D,E,F,G,H,I,J,K,...) A,B,C,D,E,F,G,H,I,J,K
#define LIST_10(A,B,C,D,E,F,G,H,I,J,...) A,B,C,D,E,F,G,H,I,J
#define LIST_9( A,B,C,D,E,F,G,H,I,...) A,B,C,D,E,F,G,H,I
#define LIST_8( A,B,C,D,E,F,G,H,...) A,B,C,D,E,F,G,H
#define LIST_7( A,B,C,D,E,F,G,...) A,B,C,D,E,F,G
#define LIST_6( A,B,C,D,E,F,...) A,B,C,D,E,F
#define LIST_5( A,B,C,D,E,...) A,B,C,D,E
#define LIST_4( A,B,C,D,...) A,B,C,D
#define LIST_3( A,B,C,...) A,B,C
#define LIST_2( A,B,...) A,B
#define LIST_1( A,...) A
#define _LIST_N(N,V...) LIST_##N(V)
#define LIST_N(N,V...) _LIST_N(N,V)
#define ARRAY_N(N,V...) { _LIST_N(N,V) }
#define _JOIN_1(O) (O)
#define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V)))
#define NOOP (void(0))
#define CEILING(x,y) (((x) + (y) - 1) / (y))
#undef ABS
#ifdef __cplusplus
template <class T> static inline constexpr const T ABS(const T v) { return v >= 0 ? v : -v; }
#else
#define ABS(a) ({__typeof__(a) _a = (a); _a >= 0 ? _a : -_a;})
#endif
#define UNEAR_ZERO(x) ((x) < 0.000001f)
#define NEAR_ZERO(x) WITHIN(x, -0.000001f, 0.000001f)
#define NEAR(x,y) NEAR_ZERO((x)-(y))
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x)))
#define FIXFLOAT(f) (f + (f < 0 ? -0.00005f : 0.00005f))
//
// Maths macros that can be overridden by HAL
//
#define ACOS(x) acosf(x)
#define ATAN2(y, x) atan2f(y, x)
#define POW(x, y) powf(x, y)
#define SQRT(x) sqrtf(x)
#define RSQRT(x) (1.0f / sqrtf(x))
#define CEIL(x) ceilf(x)
#define FLOOR(x) floorf(x)
#define LROUND(x) lroundf(x)
#define FMOD(x, y) fmodf(x, y)
#define HYPOT(x,y) SQRT(HYPOT2(x,y))
#ifdef TARGET_LPC1768
#define I2C_ADDRESS(A) ((A) << 1)
#else
#define I2C_ADDRESS(A) A
#endif
// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
#define _NUM_ARGS(_,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT
#define NUM_ARGS(V...) _NUM_ARGS(0,V,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
#ifdef __cplusplus
#ifndef _MINMAX_H_
#define _MINMAX_H_
extern "C++" {
// C++11 solution that is standards compliant. Return type is deduced automatically
template <class L, class R> static inline constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
return lhs < rhs ? lhs : rhs;
}
template <class L, class R> static inline constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
return lhs > rhs ? lhs : rhs;
}
template<class T, class ... Ts> static inline constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); }
template<class T, class ... Ts> static inline constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); }
}
#endif
#else
#define MIN_2(a,b) ((a)<(b)?(a):(b))
#define MIN_3(a,V...) MIN_2(a,MIN_2(V))
#define MIN_4(a,V...) MIN_2(a,MIN_3(V))
#define MIN_5(a,V...) MIN_2(a,MIN_4(V))
#define MIN_6(a,V...) MIN_2(a,MIN_5(V))
#define MIN_7(a,V...) MIN_2(a,MIN_6(V))
#define MIN_8(a,V...) MIN_2(a,MIN_7(V))
#define MIN_9(a,V...) MIN_2(a,MIN_8(V))
#define MIN_10(a,V...) MIN_2(a,MIN_9(V))
#define __MIN_N(N,V...) MIN_##N(V)
#define _MIN_N(N,V...) __MIN_N(N,V)
#define _MIN(V...) _MIN_N(NUM_ARGS(V), V)
#define MAX_2(a,b) ((a)>(b)?(a):(b))
#define MAX_3(a,V...) MAX_2(a,MAX_2(V))
#define MAX_4(a,V...) MAX_2(a,MAX_3(V))
#define MAX_5(a,V...) MAX_2(a,MAX_4(V))
#define MAX_6(a,V...) MAX_2(a,MAX_5(V))
#define MAX_7(a,V...) MAX_2(a,MAX_6(V))
#define MAX_8(a,V...) MAX_2(a,MAX_7(V))
#define MAX_9(a,V...) MAX_2(a,MAX_8(V))
#define MAX_10(a,V...) MAX_2(a,MAX_9(V))
#define __MAX_N(N,V...) MAX_##N(V)
#define _MAX_N(N,V...) __MAX_N(N,V)
#define _MAX(V...) _MAX_N(NUM_ARGS(V), V)
#endif
// Macros for adding
#define INC_0 1
#define INC_1 2
#define INC_2 3
#define INC_3 4
#define INC_4 5
#define INC_5 6
#define INC_6 7
#define INC_7 8
#define INC_8 9
#define INCREMENT_(n) INC_##n
#define INCREMENT(n) INCREMENT_(n)
#define ADD0(N) N
#define ADD1(N) INCREMENT_(N)
#define ADD2(N) ADD1(ADD1(N))
#define ADD3(N) ADD1(ADD2(N))
#define ADD4(N) ADD2(ADD2(N))
#define ADD5(N) ADD2(ADD3(N))
#define ADD6(N) ADD3(ADD3(N))
#define ADD7(N) ADD3(ADD4(N))
#define ADD8(N) ADD4(ADD4(N))
#define ADD9(N) ADD4(ADD5(N))
#define ADD10(N) ADD5(ADD5(N))
// Macros for subtracting
#define DEC_0 0
#define DEC_1 0
#define DEC_2 1
#define DEC_3 2
#define DEC_4 3
#define DEC_5 4
#define DEC_6 5
#define DEC_7 6
#define DEC_8 7
#define DEC_9 8
#define DECREMENT_(n) DEC_##n
#define DECREMENT(n) DECREMENT_(n)
#define SUB0(N) N
#define SUB1(N) DECREMENT_(N)
#define SUB2(N) SUB1(SUB1(N))
#define SUB3(N) SUB1(SUB2(N))
#define SUB4(N) SUB2(SUB2(N))
#define SUB5(N) SUB2(SUB3(N))
#define SUB6(N) SUB3(SUB3(N))
#define SUB7(N) SUB3(SUB4(N))
#define SUB8(N) SUB4(SUB4(N))
#define SUB9(N) SUB4(SUB5(N))
#define SUB10(N) SUB5(SUB5(N))
//
// Primitives supporting precompiler REPEAT
//
#define FIRST(a,...) a
#define SECOND(a,b,...) b
// Defer expansion
#define EMPTY()
#define DEFER(M) M EMPTY()
#define DEFER2(M) M EMPTY EMPTY()()
#define DEFER3(M) M EMPTY EMPTY EMPTY()()()
#define DEFER4(M) M EMPTY EMPTY EMPTY EMPTY()()()()
// Force define expansion
#define EVAL(V...) EVAL16(V)
#define EVAL1024(V...) EVAL512(EVAL512(V))
#define EVAL512(V...) EVAL256(EVAL256(V))
#define EVAL256(V...) EVAL128(EVAL128(V))
#define EVAL128(V...) EVAL64(EVAL64(V))
#define EVAL64(V...) EVAL32(EVAL32(V))
#define EVAL32(V...) EVAL16(EVAL16(V))
#define EVAL16(V...) EVAL8(EVAL8(V))
#define EVAL8(V...) EVAL4(EVAL4(V))
#define EVAL4(V...) EVAL2(EVAL2(V))
#define EVAL2(V...) EVAL1(EVAL1(V))
#define EVAL1(V...) V
#define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0
#define PROBE() ~, 1 // Second item will be 1 if this is passed
#define _NOT_0 PROBE()
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
#define _BOOL(x) NOT(NOT(x)) // NOT('0') gets '0'. Anything else gets '1'.
#define IF_ELSE(TF) _IF_ELSE(_BOOL(TF))
#define _IF_ELSE(TF) _CAT(_IF_, TF)
#define _IF_1(V...) V _IF_1_ELSE
#define _IF_0(...) _IF_0_ELSE
#define _IF_1_ELSE(...)
#define _IF_0_ELSE(V...) V
#define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
#define _END_OF_ARGUMENTS_() 0
//
// REPEAT core macros. Recurse N times with ascending I.
//
// Call OP(I) N times with ascending counter.
#define _REPEAT(_RPT_I,_RPT_N,_RPT_OP) \
_RPT_OP(_RPT_I) \
IF_ELSE(SUB1(_RPT_N)) \
( DEFER2(__REPEAT)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
( /* Do nothing */ )
#define __REPEAT() _REPEAT
// Call OP(I, ...) N times with ascending counter.
#define _REPEAT2(_RPT_I,_RPT_N,_RPT_OP,V...) \
_RPT_OP(_RPT_I,V) \
IF_ELSE(SUB1(_RPT_N)) \
( DEFER2(__REPEAT2)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP,V) ) \
( /* Do nothing */ )
#define __REPEAT2() _REPEAT2
// Repeat a macro passing S...N-1.
#define REPEAT_S(S,N,OP) EVAL(_REPEAT(S,SUB##S(N),OP))
#define REPEAT(N,OP) REPEAT_S(0,N,OP)
// Repeat a macro passing 0...N-1 plus additional arguments.
#define REPEAT2_S(S,N,OP,V...) EVAL(_REPEAT2(S,SUB##S(N),OP,V))
#define REPEAT2(N,OP,V...) REPEAT2_S(0,N,OP,V)
// Use RREPEAT macros with REPEAT macros for nesting
#define _RREPEAT(_RPT_I,_RPT_N,_RPT_OP) \
_RPT_OP(_RPT_I) \
IF_ELSE(SUB1(_RPT_N)) \
( DEFER2(__RREPEAT)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
( /* Do nothing */ )
#define __RREPEAT() _RREPEAT
#define _RREPEAT2(_RPT_I,_RPT_N,_RPT_OP,V...) \
_RPT_OP(_RPT_I,V) \
IF_ELSE(SUB1(_RPT_N)) \
( DEFER2(__RREPEAT2)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP,V) ) \
( /* Do nothing */ )
#define __RREPEAT2() _RREPEAT2
#define RREPEAT_S(S,N,OP) EVAL(_RREPEAT(S,SUB##S(N),OP))
#define RREPEAT(N,OP) RREPEAT_S(0,N,OP)
#define RREPEAT2_S(S,N,OP,V...) EVAL(_RREPEAT2(S,SUB##S(N),OP,V))
#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V)

713
trigorilla/src/pins/pins_RAMPS.h

@ -0,0 +1,713 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Arduino Mega with RAMPS v1.4 (or v1.3) pin assignments
*
* Applies to the following boards:
*
* RAMPS_14_EFB (Hotend, Fan, Bed)
* RAMPS_14_EEB (Hotend0, Hotend1, Bed)
* RAMPS_14_EFF (Hotend, Fan0, Fan1)
* RAMPS_14_EEF (Hotend0, Hotend1, Fan)
* RAMPS_14_SF (Spindle, Controller Fan)
*
* RAMPS_13_EFB (Hotend, Fan, Bed)
* RAMPS_13_EEB (Hotend0, Hotend1, Bed)
* RAMPS_13_EFF (Hotend, Fan0, Fan1)
* RAMPS_13_EEF (Hotend0, Hotend1, Fan)
* RAMPS_13_SF (Spindle, Controller Fan)
*
* Other pins_MYBOARD.h files may override these defaults
*
* Differences between
* RAMPS_13 | RAMPS_14
* 7 | 11
*/
#ifdef TARGET_LPC1768
#error "Oops! Set MOTHERBOARD to an LPC1768-based board when building for LPC1768."
#elif defined(__STM32F1__)
#error "Oops! Set MOTHERBOARD to an STM32F1-based board when building for STM32F1."
#endif
#if NONE(IS_RAMPS_SMART, IS_RAMPS_DUO, IS_RAMPS4DUE, TARGET_LPC1768)
#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__)
#error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'"
#endif
#endif
#ifndef BOARD_INFO_NAME
#define BOARD_INFO_NAME "RAMPS 1.4"
#endif
//
// Servos
//
#ifndef SERVO0_PIN
#ifdef IS_RAMPS_13
#define SERVO0_PIN 7
#else
#define SERVO0_PIN 11
#endif
#endif
#ifndef SERVO1_PIN
#define SERVO1_PIN 6
#endif
#ifndef SERVO2_PIN
#define SERVO2_PIN 5
#endif
#ifndef SERVO3_PIN
#define SERVO3_PIN 4
#endif
//
// Limit Switches
//
#ifndef X_STOP_PIN
#ifndef X_MIN_PIN
#define X_MIN_PIN 3
#endif
#ifndef X_MAX_PIN
#define X_MAX_PIN 2
#endif
#endif
#ifndef Y_STOP_PIN
#ifndef Y_MIN_PIN
#define Y_MIN_PIN 14
#endif
#ifndef Y_MAX_PIN
#define Y_MAX_PIN 15
#endif
#endif
#ifndef Z_STOP_PIN
#ifndef Z_MIN_PIN
#define Z_MIN_PIN 18
#endif
#ifndef Z_MAX_PIN
#define Z_MAX_PIN 19
#endif
#endif
//
// Z Probe (when not Z_MIN_PIN)
//
#ifndef Z_MIN_PROBE_PIN
#define Z_MIN_PROBE_PIN 32
#endif
//
// Steppers
//
#define X_STEP_PIN 54
#define X_DIR_PIN 55
#define X_ENABLE_PIN 38
#ifndef X_CS_PIN
#define X_CS_PIN 53
#endif
#define Y_STEP_PIN 60
#define Y_DIR_PIN 61
#define Y_ENABLE_PIN 56
#ifndef Y_CS_PIN
#define Y_CS_PIN 49
#endif
#define Z_STEP_PIN 46
#define Z_DIR_PIN 48
#define Z_ENABLE_PIN 62
#ifndef Z_CS_PIN
#define Z_CS_PIN 40
#endif
#define E0_STEP_PIN 26
#define E0_DIR_PIN 28
#define E0_ENABLE_PIN 24
#ifndef E0_CS_PIN
#define E0_CS_PIN 42
#endif
#define E1_STEP_PIN 36
#define E1_DIR_PIN 34
#define E1_ENABLE_PIN 30
#ifndef E1_CS_PIN
#define E1_CS_PIN 44
#endif
//
// Temperature Sensors
//
#ifndef TEMP_0_PIN
#define TEMP_0_PIN 13 // Analog Input
#endif
#ifndef TEMP_1_PIN
#define TEMP_1_PIN 15 // Analog Input
#endif
#ifndef TEMP_BED_PIN
#define TEMP_BED_PIN 14 // Analog Input
#endif
// SPI for Max6675 or Max31855 Thermocouple
#if DISABLED(SDSUPPORT)
#define MAX6675_SS_PIN 66 // Don't use 53 if using Display/SD card
#else
#define MAX6675_SS_PIN 66 // Don't use 49 (SD_DETECT_PIN)
#endif
//
// Augmentation for auto-assigning RAMPS plugs
//
#if NONE(IS_RAMPS_EEB, IS_RAMPS_EEF, IS_RAMPS_EFB, IS_RAMPS_EFF, IS_RAMPS_SF) && !PIN_EXISTS(MOSFET_D)
#if HOTENDS > 1
#if TEMP_SENSOR_BED
#define IS_RAMPS_EEB
#else
#define IS_RAMPS_EEF
#endif
#elif TEMP_SENSOR_BED
#define IS_RAMPS_EFB
#else
#define IS_RAMPS_EFF
#endif
#endif
//
// Heaters / Fans
//
#ifndef MOSFET_D_PIN
#define MOSFET_D_PIN -1
#endif
#ifndef RAMPS_D8_PIN
#define RAMPS_D8_PIN 8
#endif
#ifndef RAMPS_D9_PIN
#define RAMPS_D9_PIN 9
#endif
#ifndef RAMPS_D10_PIN
#define RAMPS_D10_PIN 10
#endif
#define HEATER_0_PIN RAMPS_D10_PIN
#if ENABLED(IS_RAMPS_EFB) // Hotend, Fan, Bed
#define HEATER_BED_PIN RAMPS_D8_PIN
#elif ENABLED(IS_RAMPS_EEF) // Hotend, Hotend, Fan
#define HEATER_1_PIN RAMPS_D9_PIN
#elif ENABLED(IS_RAMPS_EEB) // Hotend, Hotend, Bed
#define HEATER_1_PIN RAMPS_D9_PIN
#define HEATER_BED_PIN RAMPS_D8_PIN
#elif ENABLED(IS_RAMPS_EFF) // Hotend, Fan, Fan
#define FAN1_PIN RAMPS_D8_PIN
#elif DISABLED(IS_RAMPS_SF) // Not Spindle, Fan (i.e., "EFBF" or "EFBE")
#define HEATER_BED_PIN RAMPS_D8_PIN
#if HOTENDS == 1
#define FAN1_PIN MOSFET_D_PIN
#else
#define HEATER_1_PIN MOSFET_D_PIN
#endif
#endif
#ifndef FAN_PIN
#if EITHER(IS_RAMPS_EFB, IS_RAMPS_EFF) // Hotend, Fan, Bed or Hotend, Fan, Fan
#define FAN_PIN RAMPS_D9_PIN
#elif EITHER(IS_RAMPS_EEF, IS_RAMPS_SF) // Hotend, Hotend, Fan or Spindle, Fan
#define FAN_PIN RAMPS_D8_PIN
#elif ENABLED(IS_RAMPS_EEB) // Hotend, Hotend, Bed
#define FAN_PIN 4 // IO pin. Buffer needed
#else // Non-specific are "EFB" (i.e., "EFBF" or "EFBE")
#define FAN_PIN RAMPS_D9_PIN
#endif
#endif
//
// Misc. Functions
//
#define SDSS 53
#define LED_PIN 13
#ifndef FILWIDTH_PIN
#define FILWIDTH_PIN 5 // Analog Input on AUX2
#endif
// RAMPS 1.4 DIO 4 on the servos connector
#ifndef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN 4
#endif
#ifndef PS_ON_PIN
#define PS_ON_PIN 12
#endif
#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN)
#if NUM_SERVOS <= 1 // Prefer the servo connector
#define CASE_LIGHT_PIN 6 // Hardware PWM
#elif HAS_FREE_AUX2_PINS
#define CASE_LIGHT_PIN 44 // Hardware PWM
#endif
#endif
//
// M3/M4/M5 - Spindle/Laser Control
//
#if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN)
#if !NUM_SERVOS // Use servo connector if possible
#define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown!
#define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM
#define SPINDLE_DIR_PIN 5
#elif HAS_FREE_AUX2_PINS
#define SPINDLE_LASER_ENA_PIN 40 // Pullup or pulldown!
#define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM
#define SPINDLE_DIR_PIN 65
#else
#error "No auto-assignable Spindle/Laser pins available."
#endif
#endif
//
// TMC software SPI
//
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI 66
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO 44
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK 64
#endif
#endif
#if HAS_TMC220x
/**
* TMC2208/TMC2209 stepper drivers
*
* Hardware serial communication ports.
* If undefined software serial is used according to the pins below
*/
//#define X_HARDWARE_SERIAL Serial1
//#define X2_HARDWARE_SERIAL Serial1
//#define Y_HARDWARE_SERIAL Serial1
//#define Y2_HARDWARE_SERIAL Serial1
//#define Z_HARDWARE_SERIAL Serial1
//#define Z2_HARDWARE_SERIAL Serial1
//#define E0_HARDWARE_SERIAL Serial1
//#define E1_HARDWARE_SERIAL Serial1
//#define E2_HARDWARE_SERIAL Serial1
//#define E3_HARDWARE_SERIAL Serial1
//#define E4_HARDWARE_SERIAL Serial1
//
// Software serial
//
#ifndef X_SERIAL_TX_PIN
#define X_SERIAL_TX_PIN 40
#endif
#ifndef X_SERIAL_RX_PIN
#define X_SERIAL_RX_PIN 63
#endif
#ifndef X2_SERIAL_TX_PIN
#define X2_SERIAL_TX_PIN -1
#endif
#ifndef X2_SERIAL_RX_PIN
#define X2_SERIAL_RX_PIN -1
#endif
#ifndef Y_SERIAL_TX_PIN
#define Y_SERIAL_TX_PIN 59
#endif
#ifndef Y_SERIAL_RX_PIN
#define Y_SERIAL_RX_PIN 64
#endif
#ifndef Y2_SERIAL_TX_PIN
#define Y2_SERIAL_TX_PIN -1
#endif
#ifndef Y2_SERIAL_RX_PIN
#define Y2_SERIAL_RX_PIN -1
#endif
#ifndef Z_SERIAL_TX_PIN
#define Z_SERIAL_TX_PIN 42
#endif
#ifndef Z_SERIAL_RX_PIN
#define Z_SERIAL_RX_PIN 65
#endif
#ifndef Z2_SERIAL_TX_PIN
#define Z2_SERIAL_TX_PIN -1
#endif
#ifndef Z2_SERIAL_RX_PIN
#define Z2_SERIAL_RX_PIN -1
#endif
#ifndef E0_SERIAL_TX_PIN
#define E0_SERIAL_TX_PIN 44
#endif
#ifndef E0_SERIAL_RX_PIN
#define E0_SERIAL_RX_PIN 66
#endif
#ifndef E1_SERIAL_TX_PIN
#define E1_SERIAL_TX_PIN -1
#endif
#ifndef E1_SERIAL_RX_PIN
#define E1_SERIAL_RX_PIN -1
#endif
#ifndef E2_SERIAL_TX_PIN
#define E2_SERIAL_TX_PIN -1
#endif
#ifndef E2_SERIAL_RX_PIN
#define E2_SERIAL_RX_PIN -1
#endif
#ifndef E3_SERIAL_TX_PIN
#define E3_SERIAL_TX_PIN -1
#endif
#ifndef E3_SERIAL_RX_PIN
#define E3_SERIAL_RX_PIN -1
#endif
#ifndef E4_SERIAL_TX_PIN
#define E4_SERIAL_TX_PIN -1
#endif
#ifndef E4_SERIAL_RX_PIN
#define E4_SERIAL_RX_PIN -1
#endif
#ifndef E5_SERIAL_TX_PIN
#define E5_SERIAL_TX_PIN -1
#endif
#ifndef E5_SERIAL_RX_PIN
#define E5_SERIAL_RX_PIN -1
#endif
#ifndef E6_SERIAL_TX_PIN
#define E6_SERIAL_TX_PIN -1
#endif
#ifndef E6_SERIAL_RX_PIN
#define E6_SERIAL_RX_PIN -1
#endif
#ifndef E7_SERIAL_TX_PIN
#define E7_SERIAL_TX_PIN -1
#endif
#ifndef E7_SERIAL_RX_PIN
#define E7_SERIAL_RX_PIN -1
#endif
#endif
//
// Průša i3 MK2 Multiplexer Support
//
#ifndef E_MUX0_PIN
#define E_MUX0_PIN 40 // Z_CS_PIN
#endif
#ifndef E_MUX1_PIN
#define E_MUX1_PIN 42 // E0_CS_PIN
#endif
#ifndef E_MUX2_PIN
#define E_MUX2_PIN 44 // E1_CS_PIN
#endif
//////////////////////////
// LCDs and Controllers //
//////////////////////////
#if HAS_SPI_LCD
//
// LCD Display output pins
//
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define LCD_PINS_RS 49 // CS chip select /SS chip slave select
#define LCD_PINS_ENABLE 51 // SID (MOSI)
#define LCD_PINS_D4 52 // SCK (CLK) clock
#elif BOTH(NEWPANEL, PANEL_ONE)
#define LCD_PINS_RS 40
#define LCD_PINS_ENABLE 42
#define LCD_PINS_D4 65
#define LCD_PINS_D5 66
#define LCD_PINS_D6 44
#define LCD_PINS_D7 64
#else
#if ENABLED(CR10_STOCKDISPLAY)
#define LCD_PINS_RS 27
#define LCD_PINS_ENABLE 29
#define LCD_PINS_D4 25
#if DISABLED(NEWPANEL)
#define BEEPER_PIN 37
#endif
#elif ENABLED(ZONESTAR_LCD)
#define LCD_PINS_RS 64
#define LCD_PINS_ENABLE 44
#define LCD_PINS_D4 63
#define LCD_PINS_D5 40
#define LCD_PINS_D6 42
#define LCD_PINS_D7 65
#else
#if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306)
#define LCD_PINS_DC 25 // Set as output on init
#define LCD_PINS_RS 27 // Pull low for 1s to init
// DOGM SPI LCD Support
#define DOGLCD_CS 16
#define DOGLCD_MOSI 17
#define DOGLCD_SCK 23
#define DOGLCD_A0 LCD_PINS_DC
#else
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#endif
#define LCD_PINS_D7 29
#if DISABLED(NEWPANEL)
#define BEEPER_PIN 33
#endif
#endif
#if DISABLED(NEWPANEL)
// Buttons attached to a shift register
// Not wired yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#endif
#endif
//
// LCD Display input pins
//
#if ENABLED(NEWPANEL)
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
#define BEEPER_PIN 37
#if ENABLED(CR10_STOCKDISPLAY)
#define BTN_EN1 17
#define BTN_EN2 23
#else
#define BTN_EN1 31
#define BTN_EN2 33
#endif
#define BTN_ENC 35
#ifndef SD_DETECT_PIN
#define SD_DETECT_PIN 49
#endif
#ifndef KILL_PIN
#define KILL_PIN 41
#endif
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
#define LCD_BACKLIGHT_PIN 39
#endif
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define BTN_EN1 64
#define BTN_EN2 59
#define BTN_ENC 63
#define SD_DETECT_PIN 42
#elif ENABLED(LCD_I2C_PANELOLU2)
#define BTN_EN1 47
#define BTN_EN2 43
#define BTN_ENC 32
#define LCD_SDSS SDSS
#define KILL_PIN 41
#elif ENABLED(LCD_I2C_VIKI)
#define BTN_EN1 40 // http://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42.
#define BTN_EN2 42
#define BTN_ENC -1
#define LCD_SDSS SDSS
#define SD_DETECT_PIN 49
#elif ANY(VIKI2, miniVIKI)
#define DOGLCD_CS 45
#define DOGLCD_A0 44
#define LCD_SCREEN_ROT_180
#define BEEPER_PIN 33
#define STAT_LED_RED_PIN 32
#define STAT_LED_BLUE_PIN 35
#define BTN_EN1 22
#define BTN_EN2 7
#define BTN_ENC 39
#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board
#define KILL_PIN 31
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define DOGLCD_CS 29
#define DOGLCD_A0 27
#define BEEPER_PIN 23
#define LCD_BACKLIGHT_PIN 33
#define BTN_EN1 35
#define BTN_EN2 37
#define BTN_ENC 31
#define LCD_SDSS SDSS
#define SD_DETECT_PIN 49
#define KILL_PIN 41
#elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864)
#define BEEPER_PIN 37
#define BTN_ENC 35
#define SD_DETECT_PIN 49
#ifndef KILL_PIN
#define KILL_PIN 41
#endif
#if ENABLED(MKS_MINI_12864) // Added in Marlin 1.1.6
#define DOGLCD_A0 27
#define DOGLCD_CS 25
// GLCD features
// Uncomment screen orientation
//#define LCD_SCREEN_ROT_90
//#define LCD_SCREEN_ROT_180
//#define LCD_SCREEN_ROT_270
// not connected to a pin
#define LCD_BACKLIGHT_PIN -1 // 65 (MKS mini12864 can't adjust backlight by software!)
#define BTN_EN1 31
#define BTN_EN2 33
#elif ENABLED(FYSETC_MINI_12864)
// From https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8
#define DOGLCD_A0 16
#define DOGLCD_CS 17
#define BTN_EN1 33
#define BTN_EN2 31
//#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems
// results in LCD soft SPI mode 3, SD soft SPI mode 0
#define LCD_RESET_PIN 23 // Must be high or open for LCD to operate normally.
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
#ifndef RGB_LED_R_PIN
#define RGB_LED_R_PIN 25
#endif
#ifndef RGB_LED_G_PIN
#define RGB_LED_G_PIN 27
#endif
#ifndef RGB_LED_B_PIN
#define RGB_LED_B_PIN 29
#endif
#elif ENABLED(FYSETC_MINI_12864_2_1)
#define NEOPIXEL_PIN 25
#endif
#endif
#elif ENABLED(MINIPANEL)
#define BEEPER_PIN 42
// not connected to a pin
#define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65
#define DOGLCD_A0 44
#define DOGLCD_CS 66
// GLCD features
// Uncomment screen orientation
//#define LCD_SCREEN_ROT_90
//#define LCD_SCREEN_ROT_180
//#define LCD_SCREEN_ROT_270
#define BTN_EN1 40
#define BTN_EN2 63
#define BTN_ENC 59
#define SD_DETECT_PIN 49
#define KILL_PIN 64
#elif ENABLED(ZONESTAR_LCD)
#define ADC_KEYPAD_PIN 12
#elif ENABLED(AZSMZ_12864)
// Pins only defined for RAMPS_SMART currently
#else
// Beeper on AUX-4
#define BEEPER_PIN 33
// Buttons are directly attached to AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define SHIFT_OUT 40
#define SHIFT_CLK 44
#define SHIFT_LD 42
#define BTN_EN1 64
#define BTN_EN2 59
#define BTN_ENC 63
#elif ENABLED(PANEL_ONE)
#define BTN_EN1 59 // AUX2 PIN 3
#define BTN_EN2 63 // AUX2 PIN 4
#define BTN_ENC 49 // AUX3 PIN 7
#else
#define BTN_EN1 37
#define BTN_EN2 35
#define BTN_ENC 31
#endif
#if ENABLED(G3D_PANEL)
#define SD_DETECT_PIN 49
#define KILL_PIN 41
#endif
#endif
#endif // NEWPANEL
#endif // HAS_SPI_LCD

122
trigorilla/src/pins/pins_TRIGORILLA_14.h

@ -0,0 +1,122 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "boards.h"
/**
* Arduino Mega with RAMPS v1.4 for Anycubic
*/
#define BOARD_INFO_NAME "Anycubic RAMPS 1.4"
//
// Servos
//
#if MB(TRIGORILLA_14_11)
#define SERVO0_PIN 5
#define SERVO1_PIN 4
#define SERVO2_PIN 11
#define SERVO3_PIN 6
#endif
//
// Custom Limit Switches
//
//#define ANYCUBIC_4_MAX_PRO_ENDSTOPS
#if ENABLED(ANYCUBIC_4_MAX_PRO_ENDSTOPS)
#define X_MAX_PIN 43
#define Y_MIN_PIN 19
#endif
// Labeled pins
#define TRIGORILLA_HEATER_BED_PIN 8
#define TRIGORILLA_HEATER_0_PIN 10
#define TRIGORILLA_HEATER_1_PIN 45 // Anycubic Kossel: Unused
#define TRIGORILLA_FAN0_PIN 9 // Anycubic Kossel: Usually the part cooling fan
#define TRIGORILLA_FAN1_PIN 7 // Anycubic Kossel: Unused
#define TRIGORILLA_FAN2_PIN 44 // Anycubic Kossel: Hotend fan
// Remap MOSFET pins to common usages:
#define RAMPS_D10_PIN TRIGORILLA_HEATER_0_PIN // HEATER_0_PIN is always RAMPS_D10_PIN in pins_RAMPS.h
#if HOTENDS > 1 // EEF and EEB
#define RAMPS_D9_PIN TRIGORILLA_HEATER_1_PIN
#if !TEMP_SENSOR_BED
// EEF
#define RAMPS_D8_PIN TRIGORILLA_FAN0_PIN
#else
// EEB
#define RAMPS_D8_PIN TRIGORILLA_HEATER_BED_PIN
#define FAN_PIN TRIGORILLA_FAN0_PIN // Override pin 4 in pins_RAMPS.h
#endif
#elif TEMP_SENSOR_BED
// EFB (Anycubic Kossel default)
#define RAMPS_D9_PIN TRIGORILLA_FAN0_PIN
#define RAMPS_D8_PIN TRIGORILLA_HEATER_BED_PIN
#else
// EFF
#define RAMPS_D9_PIN TRIGORILLA_FAN1_PIN
#define RAMPS_D8_PIN TRIGORILLA_FAN0_PIN
#endif
#if HOTENDS > 1 || TEMP_SENSOR_BED // EEF, EEB, EFB
#define FAN1_PIN TRIGORILLA_FAN1_PIN
#endif
#define FAN2_PIN TRIGORILLA_FAN2_PIN
#define ORIG_E0_AUTO_FAN_PIN TRIGORILLA_FAN2_PIN // Used in Anycubic Kossel example config
#include "pins_RAMPS.h"
//
// AnyCubic made the following changes to 1.1.0-RC8
// If these are appropriate for your LCD let us know.
//
#if 0 && HAS_SPI_LCD
// LCD Display output pins
#if BOTH(NEWPANEL, PANEL_ONE)
#undef LCD_PINS_D6
#define LCD_PINS_D6 57
#endif
// LCD Display input pins
#if ENABLED(NEWPANEL)
#if ANY(VIKI2, miniVIKI)
#undef DOGLCD_A0
#define DOGLCD_A0 23
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#undef BEEPER_PIN
#define BEEPER_PIN 33
#undef LCD_BACKLIGHT_PIN
#define LCD_BACKLIGHT_PIN 67
#endif
#elif ENABLED(MINIPANEL)
#undef BEEPER_PIN
#define BEEPER_PIN 33
#undef DOGLCD_A0
#define DOGLCD_A0 42
#endif
#endif // HAS_SPI_LCD

138
trigorilla/src/stepper.h

@ -0,0 +1,138 @@
#ifndef _STEPPER_H
#define _STEPPER_H
#include <Arduino.h>
#include <Tone.h>
//#include <TimerOne.h>
class Stepper {
public:
virtual void begin(int dir_pin, int step_pin, int enable_pin);
virtual void writeSpeed(uint16_t freq, bool dir) = 0;
virtual void loop();
virtual void stop() = 0;
void enable();
void disable();
void setSpeed(int16_t speed);
virtual void setSpeedDirect(int16_t speed);
void setMaxSpeed(uint16_t max_speed);
void setAcceleration(uint16_t accel);
bool isAccelerating();
protected:
int dir_pin;
int step_pin;
int enable_pin;
uint16_t maxSpeed = 4000;
uint16_t acceleration = 2000;
int16_t targetSpeed = 0;
int16_t currentSpeed = 0;
unsigned long lastAccelMillis = 0;
};
class TimerStepper : public Stepper {
public:
void begin(int dir_pin, int step_pin, int enable_pin) override;
void writeSpeed(uint16_t freq, bool dir) override;
void setSpeedDirect(int16_t speed) override;
void stop() override;
void loop() override;
private:
Tone tone;
};
void Stepper::begin(int dir_pin, int step_pin, int enable_pin) {
this->dir_pin = dir_pin;
this->step_pin = step_pin;
this->enable_pin = enable_pin;
pinMode(dir_pin, OUTPUT);
pinMode(step_pin, OUTPUT);
pinMode(enable_pin, OUTPUT);
disable();
}
void Stepper::enable() {
digitalWrite(enable_pin, LOW);
}
void Stepper::disable() {
stop();
digitalWrite(enable_pin, HIGH);
}
void Stepper::setSpeed(int16_t speed) {
if ((speed > 0) && (speed > maxSpeed)) speed = maxSpeed;
else if ((speed < 0) && (-speed > maxSpeed)) speed = -maxSpeed;
else targetSpeed = speed;
}
void Stepper::setMaxSpeed(uint16_t max_speed) {
maxSpeed = max_speed;
}
void Stepper::setAcceleration(uint16_t accel) {
acceleration = accel;
}
bool Stepper::isAccelerating() {
if (currentSpeed != targetSpeed) return true;
else return false;
}
void TimerStepper::begin(int dir_pin, int step_pin, int enable_pin) {
Stepper::begin(dir_pin, step_pin, enable_pin);
tone.begin(step_pin);
}
void TimerStepper::writeSpeed(uint16_t freq, bool dir) {
enable();
digitalWrite(dir_pin, dir ? HIGH : LOW);
if (freq > 0) tone.play(freq);
else tone.stop();
}
void TimerStepper::setSpeedDirect(int16_t speed) {
uint16_t freq = abs(speed);
bool dir = (speed < 0);
writeSpeed(freq, dir);
}
void TimerStepper::stop() {
targetSpeed = 0;
currentSpeed = 0;
tone.stop();
}
void TimerStepper::loop() {
int16_t speedDiff = targetSpeed - currentSpeed;
int16_t increment = acceleration / 1000;
if (speedDiff == 0) return;
else if ( (speedDiff > 0) && ( speedDiff > increment)) currentSpeed += increment;
else if ( (speedDiff < 0) && (-speedDiff > increment)) currentSpeed -= increment;
else currentSpeed = targetSpeed;
/*
int16_t accelDelta = (millis()-lastAccelMillis)*acceleration/1000;
lastAccelMillis = millis();
if (accelDelta > ACCEL_CAP_PER_STEP) accelDelta = ACCEL_CAP_PER_STEP;
if (speedDiff > accelDelta) speedDiff = accelDelta;
else if (speedDiff < -accelDelta) speedDiff = -accelDelta;
currentSpeed += speedDiff;
*/
uint16_t freq = abs(currentSpeed);
bool dir = (currentSpeed < 0);
writeSpeed(freq, dir);
}
#endif /* _STEPPER_H */

11
trigorilla/test/README

@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html
Loading…
Cancel
Save