id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,537,764
|
optimiser.cpp
|
GenericMadScientist_CHOpt/src/optimiser.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2022, 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <cstdint>
#include <iterator>
#include <stdexcept>
#include "optimiser.hpp"
Optimiser::Optimiser(const ProcessedSong* song,
const std::atomic<bool>* terminate, int speed,
SightRead::Second whammy_delay)
: m_song {song}
, m_terminate {terminate}
, m_drum_fill_delay {BASE_DRUM_FILL_DELAY / speed}
, m_whammy_delay {whammy_delay}
{
if (m_song == nullptr || m_terminate == nullptr) {
throw std::invalid_argument(
"Optimiser ctor's arguments must be non-null");
}
const auto& points = m_song->points();
const auto& sp_data = m_song->sp_data();
const auto capacity = std::distance(points.cbegin(), points.cend()) + 1;
m_next_candidate_points.reserve(static_cast<std::size_t>(capacity));
int count = 0;
for (auto p = points.cbegin(); p < points.cend(); ++p) {
++count;
if (p->is_sp_granting_note
|| (p->is_hold_point
&& sp_data.is_in_whammy_ranges(p->position.beat))) {
for (int i = 0; i < count; ++i) {
m_next_candidate_points.push_back(p);
}
count = 0;
}
}
++count;
for (int i = 0; i < count; ++i) {
m_next_candidate_points.push_back(points.cend());
}
}
PointPtr Optimiser::next_candidate_point(PointPtr point) const
{
const auto index = std::distance(m_song->points().cbegin(), point);
return m_next_candidate_points[static_cast<std::size_t>(index)];
}
Optimiser::CacheKey Optimiser::advance_cache_key(CacheKey key) const
{
key.point = next_candidate_point(key.point);
if (key.point == m_song->points().cend()) {
return key;
}
key = add_whammy_delay(key);
auto pos = key.point->hit_window_start;
if (key.point != m_song->points().cbegin()) {
pos = std::prev(key.point)->hit_window_start;
}
if (pos.beat >= key.position.beat) {
key.position = pos;
}
return key;
}
Optimiser::CacheKey Optimiser::add_whammy_delay(CacheKey key) const
{
auto seconds = m_song->sp_time_map().to_seconds(key.position.beat);
seconds += m_whammy_delay;
key.position.beat = m_song->sp_time_map().to_beats(seconds);
key.position.sp_measure
= m_song->sp_time_map().to_sp_measures(key.position.beat);
return key;
}
int Optimiser::get_partial_path(CacheKey key, Cache& cache) const
{
if (key.point == m_song->points().cend()) {
return 0;
}
if (cache.paths.find(key) == cache.paths.end()) {
if (m_terminate->load()) {
throw std::runtime_error("Thread halted");
}
auto best_path = find_best_subpaths(key, cache, false);
cache.paths.emplace(key, best_path);
return best_path.score_boost;
}
return cache.paths.at(key).score_boost;
}
int Optimiser::get_partial_full_sp_path(PointPtr point, Cache& cache) const
{
if (cache.full_sp_paths.find(point) != cache.full_sp_paths.end()) {
return cache.full_sp_paths.at(point).score_boost;
}
// We only call this from find_best_subpath in a situaiton where we know
// point is not m_points.cend(), so we may assume point is a real Point.
CacheKey key {point, std::prev(point)->hit_window_start};
auto best_path = find_best_subpaths(key, cache, true);
cache.full_sp_paths.emplace(point, best_path);
return best_path.score_boost;
}
// This function is an optimisation for the case where key.point is a tick in
// the middle of an SP granting sustain. It is often the case that adjacent
// ticks have the same optimal subpath, and at any rate the optimal subpath
// can't be better than the optimal subpath for the previous point, so we try it
// first. If it works, we return the result, else we return an empty optional.
std::optional<Optimiser::CacheValue>
Optimiser::try_previous_best_subpaths(CacheKey key, const Cache& cache,
bool has_full_sp) const
{
if (has_full_sp || !key.point->is_hold_point) {
return std::nullopt;
}
if (key.point != m_song->points().cbegin()
&& !std::prev(key.point)->is_hold_point) {
return std::nullopt;
}
auto prev_key_iter = cache.paths.lower_bound(key);
if (prev_key_iter == cache.paths.begin()) {
return std::nullopt;
}
prev_key_iter = std::prev(prev_key_iter);
if (std::distance(prev_key_iter->first.point, key.point) > 1) {
return std::nullopt;
}
const auto& acts = prev_key_iter->second.possible_next_acts;
std::vector<std::tuple<ProtoActivation, CacheKey>> next_acts;
for (const auto& act : acts) {
auto [p, q] = std::get<0>(act);
const auto& [sp_bar, starting_pos]
= m_song->total_available_sp_with_earliest_pos(
key.position.beat, key.point, p,
std::prev(p)->hit_window_start);
ActivationCandidate candidate {p, q, starting_pos, sp_bar};
auto candidate_result = m_song->is_candidate_valid(candidate);
if (candidate_result.validity == ActValidity::success
&& candidate_result.ending_position.beat
<= std::get<1>(act).position.beat) {
next_acts.push_back(act);
}
}
if (next_acts.empty()) {
return std::nullopt;
}
const auto score_boost = prev_key_iter->second.score_boost;
return {{next_acts, score_boost}};
}
// This function takes some information and completes the optimal subpaths from
// it.
void Optimiser::complete_subpath(
PointPtr p, SpPosition starting_pos, SpBar sp_bar,
PointPtrRangeSet& attained_act_ends, Cache& cache, int& best_score_boost,
std::vector<std::tuple<ProtoActivation, CacheKey>>& acts) const
{
for (auto q = attained_act_ends.lowest_absent_element();
q < m_song->points().cend();) {
if (attained_act_ends.contains(q)) {
++q;
continue;
}
ActivationCandidate candidate {p, q, starting_pos, sp_bar};
const auto candidate_result = m_song->is_candidate_valid(candidate);
if (candidate_result.validity != ActValidity::insufficient_sp) {
attained_act_ends.add(q);
} else if (!q->is_hold_point) {
// We cannot hit any later points if q is not a hold point, so
// we are done.
q = m_song->points().cend();
continue;
} else {
// We cannot hit any subsequent hold point, so go straight to
// the next non-hold point.
q = m_song->points().next_non_hold_point(q);
continue;
}
if (candidate_result.validity != ActValidity::success) {
++q;
continue;
}
const auto act_score = m_song->points().range_score(p, std::next(q));
CacheKey next_key {m_song->points().first_after_current_phrase(q),
candidate_result.ending_position};
next_key = advance_cache_key(next_key);
const auto rest_of_path_score_boost = get_partial_path(next_key, cache);
const auto score = act_score + rest_of_path_score_boost;
if (score > best_score_boost) {
best_score_boost = score;
acts.clear();
acts.push_back({{p, q}, next_key});
} else if (score == best_score_boost) {
acts.push_back({{p, q}, next_key});
}
++q;
}
}
SightRead::Second Optimiser::earliest_fill_appearance(CacheKey key,
bool has_full_sp) const
{
if (!m_song->is_drums() || has_full_sp) {
return SightRead::Second(0.0);
}
int sp_count = 0;
for (auto p = key.point; p < m_song->points().cend(); ++p) {
if (p->is_sp_granting_note) {
++sp_count;
if (sp_count == 2) {
return m_song->sp_time_map().to_seconds(
p->hit_window_start.beat)
+ m_drum_fill_delay;
}
}
}
return SightRead::Second(0.0);
}
Optimiser::CacheValue Optimiser::find_best_subpaths(CacheKey key, Cache& cache,
bool has_full_sp) const
{
const auto subpath_from_prev
= try_previous_best_subpaths(key, cache, has_full_sp);
if (subpath_from_prev) {
return *subpath_from_prev;
}
const auto early_act_bound = earliest_fill_appearance(key, has_full_sp);
std::vector<std::tuple<ProtoActivation, CacheKey>> acts;
PointPtrRangeSet attained_act_ends {key.point, m_song->points().cend()};
auto lower_bound_set = false;
auto best_score_boost = 0;
for (auto p = key.point; p < m_song->points().cend(); ++p) {
if (m_song->is_drums()
&& (!p->fill_start.has_value()
|| p->fill_start < early_act_bound)) {
continue;
}
SpBar sp_bar {1.0, 1.0};
SpPosition starting_pos {SightRead::Beat {NEG_INF},
SpMeasure {NEG_INF}};
if (p != m_song->points().cbegin()) {
starting_pos = std::prev(p)->hit_window_start;
}
if (!has_full_sp) {
const auto& [new_sp, new_pos]
= m_song->total_available_sp_with_earliest_pos(
key.position.beat, key.point, p, starting_pos);
sp_bar = new_sp;
starting_pos = new_pos;
}
if (m_song->is_drums()) {
starting_pos.beat
= std::max(starting_pos.beat, p->hit_window_start.beat);
starting_pos.sp_measure = std::max(starting_pos.sp_measure,
p->hit_window_start.sp_measure);
}
if (!sp_bar.full_enough_to_activate(m_song->minimum_sp_to_activate())) {
continue;
}
if (p != key.point && sp_bar.min() == 1.0
&& std::prev(p)->is_sp_granting_note) {
get_partial_full_sp_path(p, cache);
auto cache_value = cache.full_sp_paths.at(p);
if (cache_value.score_boost > best_score_boost) {
return cache_value;
}
if (cache_value.score_boost == best_score_boost) {
const auto& next_acts = cache_value.possible_next_acts;
acts.insert(acts.end(), next_acts.cbegin(), next_acts.cend());
}
break;
}
// This skips some points that are too early to be an act end for the
// earliest possible activation.
if (!lower_bound_set) {
const SpMeasure act_length {
8.0 * std::max(sp_bar.min(), m_song->minimum_sp_to_activate())};
const auto earliest_act_end = starting_pos.sp_measure + act_length;
auto earliest_pt_end = std::find_if_not(
std::next(p), m_song->points().cend(), [&](const auto& pt) {
return pt.hit_window_end.sp_measure <= earliest_act_end;
});
--earliest_pt_end;
attained_act_ends
= PointPtrRangeSet {earliest_pt_end, m_song->points().cend()};
lower_bound_set = true;
}
complete_subpath(p, starting_pos, sp_bar, attained_act_ends, cache,
best_score_boost, acts);
}
return {acts, best_score_boost};
}
Path Optimiser::optimal_path() const
{
Cache cache;
CacheKey start_key {m_song->points().cbegin(),
{SightRead::Beat(NEG_INF), SpMeasure(NEG_INF)}};
start_key = advance_cache_key(start_key);
const auto best_score_boost = get_partial_path(start_key, cache);
Path path {{}, best_score_boost};
while (start_key.point != m_song->points().cend()) {
const auto& acts = cache.paths.at(start_key).possible_next_acts;
// We can get here if the song ends in say ES1.
if (acts.empty()) {
break;
}
auto best_proto_act = std::get<0>(acts[0]);
auto best_next_key = std::get<1>(acts[0]);
auto best_sqz_level = act_squeeze_level(best_proto_act, start_key);
for (auto i = 1U; i < acts.size(); ++i) {
const auto [proto_act, next_key] = acts[i];
const auto sqz_level = act_squeeze_level(proto_act, start_key);
if (sqz_level < best_sqz_level) {
best_proto_act = std::get<0>(acts[i]);
best_next_key = std::get<1>(acts[i]);
best_sqz_level = sqz_level;
}
}
const auto min_whammy_force
= forced_whammy_end(best_proto_act, start_key, best_sqz_level);
const auto [start_pos, end_pos] = act_duration(
best_proto_act, start_key, best_sqz_level, min_whammy_force);
Activation act {best_proto_act.act_start, best_proto_act.act_end,
min_whammy_force.beat, start_pos, end_pos};
path.activations.push_back(act);
start_key = best_next_key;
}
return path;
}
double Optimiser::act_squeeze_level(ProtoActivation act, CacheKey key) const
{
constexpr double THRESHOLD = 0.01;
auto min_sqz = 0.0;
auto max_sqz = 1.0;
// Determines what point controls how early we can go: the previous point on
// guitar and the current point on drums.
const auto start_bound_point
= m_song->is_drums() ? act.act_start : std::prev(act.act_start);
while (max_sqz - min_sqz > THRESHOLD) {
auto trial_sqz = (min_sqz + max_sqz) / 2;
auto start_pos
= m_song->adjusted_hit_window_start(start_bound_point, trial_sqz);
if (start_pos.beat < key.position.beat) {
start_pos = key.position;
}
const auto& [sp_bar, new_pos]
= m_song->total_available_sp_with_earliest_pos(
key.position.beat, key.point, act.act_start, start_pos);
start_pos = new_pos;
ActivationCandidate candidate {act.act_start, act.act_end, start_pos,
sp_bar};
if (m_song->is_candidate_valid(candidate, trial_sqz).validity
== ActValidity::success) {
max_sqz = trial_sqz;
} else {
min_sqz = trial_sqz;
}
}
return max_sqz;
}
SpPosition Optimiser::forced_whammy_end(ProtoActivation act, CacheKey key,
double sqz_level) const
{
constexpr double POS_INF = std::numeric_limits<double>::infinity();
constexpr double THRESHOLD = 0.01;
auto next_point = std::next(act.act_end);
if (next_point == m_song->points().cend()) {
return {SightRead::Beat {POS_INF}, SpMeasure {POS_INF}};
}
auto prev_point = std::prev(act.act_start);
auto min_whammy_force = key.position;
auto max_whammy_force = next_point->hit_window_end;
auto start_pos = m_song->adjusted_hit_window_start(prev_point, sqz_level);
while ((max_whammy_force.beat - min_whammy_force.beat).value()
> THRESHOLD) {
auto mid_beat
= (min_whammy_force.beat + max_whammy_force.beat) * (1.0 / 2);
auto mid_meas = m_song->sp_time_map().to_sp_measures(mid_beat);
SpPosition mid_pos {mid_beat, mid_meas};
auto sp_bar = m_song->total_available_sp(key.position.beat, key.point,
act.act_start, mid_beat);
ActivationCandidate candidate {act.act_start, act.act_end, start_pos,
sp_bar};
auto result = m_song->is_candidate_valid(candidate, sqz_level, mid_pos);
if (result.validity == ActValidity::success) {
min_whammy_force = mid_pos;
} else {
max_whammy_force = mid_pos;
}
}
return min_whammy_force;
}
std::tuple<SightRead::Beat, SightRead::Beat>
Optimiser::act_duration(ProtoActivation act, CacheKey key, double sqz_level,
SpPosition min_whammy_force) const
{
constexpr double THRESHOLD = 0.01;
// Determines what point controls how early we can go: the previous point on
// guitar and the current point on drums.
const auto start_bound_point
= m_song->is_drums() ? act.act_start : std::prev(act.act_start);
auto min_pos
= m_song->adjusted_hit_window_start(start_bound_point, sqz_level);
auto max_pos = m_song->adjusted_hit_window_end(act.act_start, sqz_level);
auto sp_bar = m_song->total_available_sp(
key.position.beat, key.point, act.act_start, min_whammy_force.beat);
while ((max_pos.beat - min_pos.beat).value() > THRESHOLD) {
auto trial_beat = (min_pos.beat + max_pos.beat) * (1.0 / 2);
auto trial_meas = m_song->sp_time_map().to_sp_measures(trial_beat);
SpPosition trial_pos {trial_beat, trial_meas};
ActivationCandidate candidate {act.act_start, act.act_end, trial_pos,
sp_bar};
if (m_song->is_candidate_valid(candidate, sqz_level, min_whammy_force)
.validity
== ActValidity::success) {
min_pos = trial_pos;
} else {
max_pos = trial_pos;
}
}
ActivationCandidate candidate {act.act_start, act.act_end, min_pos, sp_bar};
auto result
= m_song->is_candidate_valid(candidate, sqz_level, min_whammy_force);
assert(result.validity == ActValidity::success); // NOLINT
return {min_pos.beat, result.ending_position.beat};
}
| 18,233
|
C++
|
.cpp
| 432
| 33.340278
| 80
| 0.593141
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,765
|
sp.cpp
|
GenericMadScientist_CHOpt/src/sp.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <cassert>
#include <iterator>
#include <utility>
#include "sp.hpp"
namespace {
bool phrase_contains_pos(const SightRead::StarPower& phrase,
SightRead::Tick position)
{
if (position < phrase.position) {
return false;
}
return position < (phrase.position + phrase.length);
}
double sp_deduction(SpPosition start, SpPosition end)
{
constexpr double MEASURES_PER_BAR = 8.0;
const auto meas_diff = end.sp_measure - start.sp_measure;
return meas_diff.value() / MEASURES_PER_BAR;
}
std::vector<std::tuple<SightRead::Tick, SightRead::Tick, SightRead::Second>>
note_spans(const SightRead::NoteTrack& track, double early_whammy,
const Engine& engine)
{
const auto& tempo_map = track.global_data().tempo_map();
std::vector<std::tuple<SightRead::Tick, SightRead::Tick, SightRead::Second>>
spans;
for (auto note = track.notes().cbegin(); note < track.notes().cend();
++note) {
auto early_gap = std::numeric_limits<double>::infinity();
auto late_gap = std::numeric_limits<double>::infinity();
const auto current_note_time
= tempo_map.to_seconds(note->position).value();
if (note != track.notes().cbegin()) {
early_gap = current_note_time
- tempo_map.to_seconds(std::prev(note)->position).value();
}
if (std::next(note) < track.notes().cend()) {
late_gap = tempo_map.to_seconds(std::next(note)->position).value()
- current_note_time;
}
for (auto length : note->lengths) {
if (length != SightRead::Tick {-1}) {
spans.emplace_back(
note->position, length,
SightRead::Second {
engine.early_timing_window(early_gap, late_gap)}
* early_whammy);
}
}
}
return spans;
}
}
std::vector<SpData::BeatRate>
SpData::form_beat_rates(const SightRead::TempoMap& tempo_map,
const std::vector<SightRead::Tick>& od_beats,
const Engine& engine)
{
constexpr double DEFAULT_BEAT_RATE = 4.0;
std::vector<BeatRate> beat_rates;
if (engine.sp_mode() == SpMode::Measure) {
beat_rates.reserve(tempo_map.time_sigs().size());
for (const auto& ts : tempo_map.time_sigs()) {
const auto pos = tempo_map.to_beats(ts.position);
const auto measure_rate
= ts.numerator * DEFAULT_BEAT_RATE / ts.denominator;
const auto drain_rate
= engine.sp_gain_rate() - 1 / (MEASURES_PER_BAR * measure_rate);
beat_rates.push_back({pos, drain_rate});
}
} else if (!od_beats.empty()) {
beat_rates.reserve(od_beats.size() - 1);
for (auto i = 0U; i < od_beats.size() - 1; ++i) {
const auto pos = tempo_map.to_beats(od_beats[i]);
const auto next_marker = tempo_map.to_beats(od_beats[i + 1]);
const auto drain_rate = engine.sp_gain_rate()
- 1 / (DEFAULT_BEATS_PER_BAR * (next_marker - pos).value());
beat_rates.push_back({pos, drain_rate});
}
} else {
beat_rates.push_back(
{SightRead::Beat(0.0),
engine.sp_gain_rate() - 1 / DEFAULT_BEATS_PER_BAR});
}
return beat_rates;
}
SpData::SpData(const SightRead::NoteTrack& track, SpTimeMap time_map,
const std::vector<SightRead::Tick>& od_beats,
const SqueezeSettings& squeeze_settings, const Engine& engine)
: m_time_map {std::move(time_map)}
, m_beat_rates {form_beat_rates(track.global_data().tempo_map(), od_beats,
engine)}
, m_sp_gain_rate {engine.sp_gain_rate()}
, m_default_net_sp_gain_rate {m_sp_gain_rate - 1 / DEFAULT_BEATS_PER_BAR}
{
// Elements are (whammy start, whammy end, note).
std::vector<std::tuple<SightRead::Beat, SightRead::Beat, SightRead::Beat>>
ranges;
for (const auto& [position, length, early_timing_window] :
note_spans(track, squeeze_settings.early_whammy, engine)) {
if (length == SightRead::Tick {0}) {
continue;
}
const auto pos_copy = position;
const auto phrase = std::find_if(
track.sp_phrases().cbegin(), track.sp_phrases().cend(),
[&](const auto& p) { return phrase_contains_pos(p, pos_copy); });
if (phrase == track.sp_phrases().cend()) {
continue;
}
const auto note = m_time_map.to_beats(position);
auto second_start = m_time_map.to_seconds(note);
second_start -= early_timing_window;
second_start += squeeze_settings.lazy_whammy;
second_start += squeeze_settings.video_lag;
const auto beat_start = m_time_map.to_beats(second_start);
auto beat_end = m_time_map.to_beats(position + length);
if (beat_start < beat_end) {
ranges.emplace_back(beat_start, beat_end, note);
}
}
if (ranges.empty()) {
return;
}
std::sort(ranges.begin(), ranges.end());
std::vector<std::tuple<SightRead::Beat, SightRead::Beat, SightRead::Beat>>
merged_ranges;
auto pair = ranges[0];
for (auto p = std::next(ranges.cbegin()); p < ranges.cend(); ++p) {
if (std::get<0>(*p) <= std::get<1>(pair)) {
std::get<1>(pair) = std::max(std::get<1>(pair), std::get<1>(*p));
} else {
merged_ranges.push_back(pair);
pair = *p;
}
}
merged_ranges.push_back(pair);
for (auto [start, end, note] : merged_ranges) {
const auto start_meas = m_time_map.to_sp_measures(start);
const auto end_meas = m_time_map.to_sp_measures(end);
m_whammy_ranges.push_back({{start, start_meas}, {end, end_meas}, note});
}
if (m_whammy_ranges.empty()) {
return;
}
m_last_whammy_point = m_whammy_ranges.back().end.beat;
auto p = m_whammy_ranges.cbegin();
for (auto pos = 0; pos < m_last_whammy_point.value(); ++pos) {
p = std::find_if_not(p, m_whammy_ranges.cend(), [=](const auto& x) {
return x.end.beat.value() <= pos;
});
m_initial_guesses.push_back(p);
}
}
std::vector<SpData::WhammyRange>::const_iterator
SpData::first_whammy_range_after(SightRead::Beat pos) const
{
if (m_last_whammy_point <= pos) {
return m_whammy_ranges.cend();
}
const auto index = static_cast<std::size_t>(pos.value());
const auto begin = (pos < SightRead::Beat(0.0)) ? m_whammy_ranges.cbegin()
: m_initial_guesses[index];
return std::find_if_not(begin, m_whammy_ranges.cend(),
[=](const auto& x) { return x.end.beat <= pos; });
}
SpData::WhammyPropagationState
SpData::initial_whammy_prop_state(SightRead::Beat start, SightRead::Beat end,
double sp_bar_amount) const
{
auto p = std::lower_bound(
m_beat_rates.cbegin(), m_beat_rates.cend(), start,
[](const auto& ts, const auto& y) { return ts.position < y; });
if (p != m_beat_rates.cbegin()) {
--p;
} else {
const auto subrange_end = std::min(end, p->position);
const auto sp_gain
= (subrange_end - start).value() * m_default_net_sp_gain_rate;
sp_bar_amount += sp_gain;
sp_bar_amount = std::min(sp_bar_amount, 1.0);
start = subrange_end;
}
return {p, start, sp_bar_amount};
}
double SpData::propagate_sp_over_whammy_max(SpPosition start, SpPosition end,
double sp) const
{
assert(start.beat <= end.beat); // NOLINT
auto p = first_whammy_range_after(start.beat);
while ((p != m_whammy_ranges.cend()) && (p->start.beat < end.beat)) {
if (p->start.beat > start.beat) {
const auto meas_diff = p->start.sp_measure - start.sp_measure;
sp -= meas_diff.value() / MEASURES_PER_BAR;
if (sp < 0.0) {
return sp;
}
start = p->start;
}
const auto range_end = std::min(end.beat, p->end.beat);
sp = propagate_over_whammy_range(start.beat, range_end, sp);
if (sp < 0.0 || p->end.beat >= end.beat) {
return sp;
}
start = p->end;
++p;
}
const auto meas_diff = end.sp_measure - start.sp_measure;
sp -= meas_diff.value() / MEASURES_PER_BAR;
return sp;
}
double
SpData::propagate_sp_over_whammy_min(SpPosition start, SpPosition end,
double sp,
SpPosition required_whammy_end) const
{
assert(start.beat <= end.beat); // NOLINT
if (required_whammy_end.beat > start.beat) {
auto whammy_end = end;
if (required_whammy_end.beat < end.beat) {
whammy_end = required_whammy_end;
}
sp = propagate_sp_over_whammy_max(start, whammy_end, sp);
start = required_whammy_end;
}
if (start.beat < end.beat) {
const auto meas_diff = end.sp_measure - start.sp_measure;
sp -= meas_diff.value() / MEASURES_PER_BAR;
}
sp = std::max(sp, 0.0);
return sp;
}
double SpData::propagate_over_whammy_range(SightRead::Beat start,
SightRead::Beat end,
double sp_bar_amount) const
{
auto state = initial_whammy_prop_state(start, end, sp_bar_amount);
while (state.current_position < end) {
auto subrange_end = end;
if (std::next(state.current_beat_rate) != m_beat_rates.cend()) {
subrange_end
= std::min(end, std::next(state.current_beat_rate)->position);
}
state.current_sp += (subrange_end - state.current_position).value()
* state.current_beat_rate->net_sp_gain_rate;
if (state.current_sp < 0.0) {
return -1.0;
}
state.current_sp = std::min(state.current_sp, 1.0);
state.current_position = subrange_end;
++state.current_beat_rate;
}
return state.current_sp;
}
bool SpData::is_in_whammy_ranges(SightRead::Beat beat) const
{
const auto p = first_whammy_range_after(beat);
if (p == m_whammy_ranges.cend()) {
return false;
}
return p->start.beat <= beat;
}
double SpData::available_whammy(SightRead::Beat start,
SightRead::Beat end) const
{
double total_whammy {0.0};
for (auto p = first_whammy_range_after(start); p < m_whammy_ranges.cend();
++p) {
if (p->start.beat >= end) {
break;
}
const auto whammy_start = std::max(p->start.beat, start);
const auto whammy_end = std::min(p->end.beat, end);
total_whammy += (whammy_end - whammy_start).value() * m_sp_gain_rate;
}
return total_whammy;
}
double SpData::available_whammy(SightRead::Beat start, SightRead::Beat end,
SightRead::Beat note_pos) const
{
double total_whammy {0.0};
for (auto p = first_whammy_range_after(start); p < m_whammy_ranges.cend();
++p) {
if (p->start.beat >= end || p->note >= note_pos) {
break;
}
auto whammy_start = std::max(p->start.beat, start);
auto whammy_end = std::min(p->end.beat, end);
total_whammy += (whammy_end - whammy_start).value() * m_sp_gain_rate;
}
return total_whammy;
}
SpPosition SpData::sp_drain_end_point(SpPosition start,
double sp_bar_amount) const
{
const auto end_meas
= start.sp_measure + SpMeasure(sp_bar_amount * MEASURES_PER_BAR);
const auto end_beat = m_time_map.to_beats(end_meas);
return {end_beat, end_meas};
}
SpPosition SpData::activation_end_point(SpPosition start, SpPosition end,
double sp_bar_amount) const
{
auto p = first_whammy_range_after(start.beat);
while ((p != m_whammy_ranges.cend()) && (p->start.beat < end.beat)) {
if (p->start.beat > start.beat) {
const auto sp_drop = sp_deduction(start, p->start);
if (sp_bar_amount < sp_drop) {
return sp_drain_end_point(start, sp_bar_amount);
}
sp_bar_amount -= sp_drop;
start = p->start;
}
const auto range_end = std::min(end.beat, p->end.beat);
const auto new_sp_bar_amount
= propagate_over_whammy_range(start.beat, range_end, sp_bar_amount);
if (new_sp_bar_amount < 0.0) {
const auto end_beat = whammy_propagation_endpoint(
start.beat, end.beat, sp_bar_amount);
const auto end_meas = m_time_map.to_sp_measures(end_beat);
return {end_beat, end_meas};
}
sp_bar_amount = new_sp_bar_amount;
if (p->end.beat >= end.beat) {
return end;
}
start = p->end;
++p;
}
const auto sp_drop = sp_deduction(start, end);
if (sp_bar_amount < sp_drop) {
return sp_drain_end_point(start, sp_bar_amount);
}
return end;
}
// Return the point whammy runs out if all of the range [start, end) is
// whammied.
SightRead::Beat SpData::whammy_propagation_endpoint(SightRead::Beat start,
SightRead::Beat end,
double sp_bar_amount) const
{
auto state = initial_whammy_prop_state(start, end, sp_bar_amount);
while (state.current_position < end) {
auto subrange_end = end;
if (std::next(state.current_beat_rate) != m_beat_rates.cend()) {
subrange_end
= std::min(end, std::next(state.current_beat_rate)->position);
}
auto sp_gain = (subrange_end - state.current_position).value()
* state.current_beat_rate->net_sp_gain_rate;
if (state.current_sp + sp_gain < 0.0) {
return state.current_position
+ SightRead::Beat(-state.current_sp
/ state.current_beat_rate->net_sp_gain_rate);
}
state.current_sp += sp_gain;
state.current_sp = std::min(state.current_sp, 1.0);
state.current_position = subrange_end;
++state.current_beat_rate;
}
return end;
}
| 15,242
|
C++
|
.cpp
| 379
| 31.277045
| 80
| 0.577953
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,766
|
processed.cpp
|
GenericMadScientist_CHOpt/src/processed.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2022, 2023, 2024 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <sstream>
#include "processed.hpp"
#include "stringutil.hpp"
namespace {
int bre_boost(const SightRead::NoteTrack& track, const Engine& engine)
{
constexpr int INITIAL_BRE_VALUE = 750;
constexpr int BRE_VALUE_PER_SECOND = 500;
const auto bre = track.bre();
if (!engine.has_bres() || !bre.has_value()) {
return 0;
}
const auto& tempo_map = track.global_data().tempo_map();
const auto seconds_start = tempo_map.to_seconds(bre->start);
const auto seconds_end = tempo_map.to_seconds(bre->end);
const auto seconds_gap = seconds_end - seconds_start;
return static_cast<int>(INITIAL_BRE_VALUE
+ BRE_VALUE_PER_SECOND * seconds_gap.value());
}
}
SpBar ProcessedSong::sp_from_phrases(PointPtr begin, PointPtr end) const
{
SpBar sp_bar {0.0, 0.0};
for (auto p = m_points.next_sp_granting_note(begin); p < end;
p = m_points.next_sp_granting_note(std::next(p))) {
sp_bar.add_phrase();
if (p->is_unison_sp_granting_note) {
sp_bar.add_phrase();
}
}
return sp_bar;
}
ProcessedSong::ProcessedSong(const SightRead::NoteTrack& track,
SpTimeMap time_map,
const SqueezeSettings& squeeze_settings,
const SightRead::DrumSettings& drum_settings,
const Engine& engine,
const std::vector<SightRead::Tick>& od_beats,
const std::vector<SightRead::Tick>& unison_phrases)
: m_time_map {std::move(time_map)}
, m_points {track, m_time_map, unison_phrases, squeeze_settings,
drum_settings, engine}
, m_sp_data {track, m_time_map, od_beats, squeeze_settings, engine}
, m_minimum_sp_to_activate {engine.minimum_sp_to_activate()}
, m_total_bre_boost {bre_boost(track, engine)}
, m_base_score {track.base_score(drum_settings)}
, m_ignore_average_multiplier {engine.ignore_average_multiplier()}
, m_is_drums {track.track_type() == SightRead::TrackType::Drums}
, m_overlaps {engine.overlaps()}
{
const auto solos = track.solos(drum_settings);
m_total_solo_boost = std::accumulate(
solos.cbegin(), solos.cend(), 0,
[](const auto x, const auto& y) { return x + y.value; });
}
SpBar ProcessedSong::total_available_sp(
SightRead::Beat start, PointPtr first_point, PointPtr act_start,
SightRead::Beat required_whammy_end) const
{
auto sp_bar = sp_from_phrases(first_point, act_start);
if (start >= required_whammy_end) {
sp_bar.max()
+= m_sp_data.available_whammy(start, act_start->position.beat);
sp_bar.max() = std::min(sp_bar.max(), 1.0);
} else if (required_whammy_end >= act_start->position.beat) {
sp_bar.min()
+= m_sp_data.available_whammy(start, act_start->position.beat);
sp_bar.min() = std::min(sp_bar.min(), 1.0);
sp_bar.max() = sp_bar.min();
} else {
sp_bar.min() += m_sp_data.available_whammy(start, required_whammy_end);
sp_bar.min() = std::min(sp_bar.min(), 1.0);
sp_bar.max() = sp_bar.min();
sp_bar.max() += m_sp_data.available_whammy(required_whammy_end,
act_start->position.beat);
sp_bar.max() = std::min(sp_bar.max(), 1.0);
}
return sp_bar;
}
std::tuple<SpBar, SpPosition>
ProcessedSong::total_available_sp_with_earliest_pos(
SightRead::Beat start, PointPtr first_point, PointPtr act_start,
SpPosition earliest_potential_pos) const
{
const SightRead::Beat BEAT_EPSILON {0.0001};
auto sp_bar = sp_from_phrases(first_point, act_start);
sp_bar.max() += m_sp_data.available_whammy(
start, earliest_potential_pos.beat, act_start->position.beat);
sp_bar.max() = std::min(sp_bar.max(), 1.0);
if (sp_bar.full_enough_to_activate(m_minimum_sp_to_activate)) {
return {sp_bar, earliest_potential_pos};
}
const auto extra_sp_required = m_minimum_sp_to_activate - sp_bar.max();
auto first_beat = earliest_potential_pos.beat;
auto last_beat = act_start->position.beat;
if (m_sp_data.available_whammy(first_beat, last_beat,
act_start->position.beat)
< extra_sp_required) {
return {sp_bar, earliest_potential_pos};
}
while (last_beat - first_beat > BEAT_EPSILON) {
const auto mid_beat = (first_beat + last_beat) * 0.5;
if (m_sp_data.available_whammy(earliest_potential_pos.beat, mid_beat,
act_start->position.beat)
< extra_sp_required) {
first_beat = mid_beat;
} else {
last_beat = mid_beat;
}
}
sp_bar.max() += m_sp_data.available_whammy(
earliest_potential_pos.beat, last_beat, act_start->position.beat);
sp_bar.max() = std::min(sp_bar.max(), 1.0);
return {sp_bar,
SpPosition {last_beat, m_time_map.to_sp_measures(last_beat)}};
}
SpPosition ProcessedSong::adjusted_hit_window_start(PointPtr point,
double squeeze) const
{
assert((0.0 <= squeeze) && (squeeze <= 1.0)); // NOLINT
if (squeeze == 1.0) {
return point->hit_window_start;
}
auto start = m_time_map.to_seconds(point->hit_window_start.beat);
auto mid = m_time_map.to_seconds(point->position.beat);
auto adj_start_s = start + (mid - start) * (1.0 - squeeze);
auto adj_start_b = m_time_map.to_beats(adj_start_s);
auto adj_start_m = m_time_map.to_sp_measures(adj_start_b);
return {adj_start_b, adj_start_m};
}
SpPosition ProcessedSong::adjusted_hit_window_end(PointPtr point,
double squeeze) const
{
assert((0.0 <= squeeze) && (squeeze <= 1.0)); // NOLINT
if (squeeze == 1.0) {
return point->hit_window_end;
}
auto mid = m_time_map.to_seconds(point->position.beat);
auto end = m_time_map.to_seconds(point->hit_window_end.beat);
auto adj_end_s = mid + (end - mid) * squeeze;
auto adj_end_b = m_time_map.to_beats(adj_end_s);
auto adj_end_m = m_time_map.to_sp_measures(adj_end_b);
return {adj_end_b, adj_end_m};
}
class SpStatus {
private:
SpPosition m_position;
double m_sp;
bool m_overlap_engine;
static constexpr double MEASURES_PER_BAR = 8.0;
public:
SpStatus(SpPosition position, double sp, bool overlap_engine)
: m_position {position}
, m_sp {sp}
, m_overlap_engine {overlap_engine}
{
}
[[nodiscard]] SpPosition position() const { return m_position; }
[[nodiscard]] double sp() const { return m_sp; }
void add_phrase()
{
constexpr double SP_PHRASE_AMOUNT = 0.25;
m_sp += SP_PHRASE_AMOUNT;
m_sp = std::min(m_sp, 1.0);
}
void advance_whammy_max(SpPosition end_position, const SpData& sp_data,
bool does_overlap)
{
if (does_overlap) {
m_sp = sp_data.propagate_sp_over_whammy_max(m_position,
end_position, m_sp);
} else {
m_sp -= (end_position.sp_measure - m_position.sp_measure).value()
/ MEASURES_PER_BAR;
}
m_position = end_position;
}
void update_early_end(SpPosition sp_note_start, const SpData& sp_data,
SpPosition required_whammy_end)
{
if (!m_overlap_engine) {
required_whammy_end = {SightRead::Beat {0.0}, SpMeasure {0.0}};
}
m_sp = sp_data.propagate_sp_over_whammy_min(m_position, sp_note_start,
m_sp, required_whammy_end);
if (sp_note_start.beat > m_position.beat) {
m_position = sp_note_start;
}
}
void update_late_end(SpPosition sp_note_start, SpPosition sp_note_end,
const SpData& sp_data, bool does_overlap)
{
if (sp_note_start.beat < m_position.beat) {
sp_note_start = m_position;
}
advance_whammy_max(sp_note_start, sp_data, does_overlap);
if (m_sp < 0.0) {
return;
}
// We might run out of SP between sp_note_start and sp_note_end. In this
// case we just hit the note as early as possible.
if (does_overlap) {
const auto new_sp = sp_data.propagate_sp_over_whammy_max(
sp_note_start, sp_note_end, m_sp);
if (new_sp >= 0.0) {
m_sp = new_sp;
m_position = sp_note_end;
}
}
}
};
ActResult
ProcessedSong::is_candidate_valid(const ActivationCandidate& activation,
double squeeze,
SpPosition required_whammy_end) const
{
static constexpr double MEASURES_PER_BAR = 8.0;
const SpPosition null_position {SightRead::Beat(0.0), SpMeasure(0.0)};
if (!activation.sp_bar.full_enough_to_activate(m_minimum_sp_to_activate)) {
return {null_position, ActValidity::insufficient_sp};
}
auto ending_pos = adjusted_hit_window_start(activation.act_end, squeeze);
if (ending_pos.beat < activation.earliest_activation_point.beat) {
ending_pos = activation.earliest_activation_point;
}
auto late_end_position
= adjusted_hit_window_end(activation.act_start, squeeze);
// This conditional can be taken if, for example, the first and last point
// are the same.
if (late_end_position.beat > ending_pos.beat) {
late_end_position = ending_pos;
}
auto late_end_sp = activation.sp_bar.max();
late_end_sp
+= m_sp_data.available_whammy(activation.earliest_activation_point.beat,
activation.act_start->position.beat);
late_end_sp = std::min(late_end_sp, 1.0);
SpStatus status_for_early_end {
activation.earliest_activation_point,
std::max(activation.sp_bar.min(), m_minimum_sp_to_activate),
m_overlaps};
SpStatus status_for_late_end {late_end_position, late_end_sp, m_overlaps};
for (auto p = m_points.next_sp_granting_note(activation.act_start);
p < activation.act_end;
p = m_points.next_sp_granting_note(std::next(p))) {
auto p_start = adjusted_hit_window_start(p, squeeze);
if (p_start.beat < activation.earliest_activation_point.beat) {
p_start = activation.earliest_activation_point;
}
auto p_end = adjusted_hit_window_end(p, squeeze);
if (p_end.beat > ending_pos.beat) {
p_end = ending_pos;
}
status_for_late_end.update_late_end(p_start, p_end, m_sp_data,
m_overlaps);
if (status_for_late_end.sp() < 0.0) {
return {null_position, ActValidity::insufficient_sp};
}
status_for_early_end.update_early_end(p_start, m_sp_data,
required_whammy_end);
if (m_overlaps) {
status_for_early_end.add_phrase();
status_for_late_end.add_phrase();
if (p->is_unison_sp_granting_note) {
status_for_early_end.add_phrase();
status_for_late_end.add_phrase();
}
}
}
status_for_late_end.advance_whammy_max(ending_pos, m_sp_data, m_overlaps);
if (status_for_late_end.sp() < 0.0) {
return {null_position, ActValidity::insufficient_sp};
}
status_for_early_end.update_early_end(ending_pos, m_sp_data,
required_whammy_end);
if (m_overlaps && activation.act_end->is_sp_granting_note) {
status_for_early_end.add_phrase();
if (activation.act_end->is_unison_sp_granting_note) {
status_for_early_end.add_phrase();
}
}
const auto end_meas = status_for_early_end.position().sp_measure
+ SpMeasure(status_for_early_end.sp() * MEASURES_PER_BAR);
const auto next_point = std::next(activation.act_end);
if (next_point != m_points.cend()
&& end_meas
>= adjusted_hit_window_end(next_point, squeeze).sp_measure) {
return {null_position, ActValidity::surplus_sp};
}
const auto end_beat = m_time_map.to_beats(end_meas);
return {{end_beat, end_meas}, ActValidity::success};
}
void ProcessedSong::append_activation(std::stringstream& stream,
const Activation& activation,
const std::string& act_summary) const
{
stream << '\n' << act_summary.substr(0, act_summary.find('-')) << ": ";
if (act_summary[0] == '0') {
stream << "See image";
return;
}
const auto act_start = activation.act_start;
auto previous_sp_note = std::prev(act_start);
while (!previous_sp_note->is_sp_granting_note) {
--previous_sp_note;
}
const auto count
= std::count_if(std::next(previous_sp_note), std::next(act_start),
[](const auto& p) { return !p.is_hold_point; });
if (act_start->is_hold_point) {
auto starting_note = act_start;
while (starting_note->is_hold_point) {
--starting_note;
}
const auto beat_gap
= act_start->position.beat - starting_note->position.beat;
if (count > 0) {
stream << beat_gap.value() << " beats after ";
} else {
stream << "After " << beat_gap.value() << " beats";
}
}
if (count > 1) {
auto previous_note = act_start;
while (previous_note->is_hold_point) {
--previous_note;
}
const auto colour = m_points.colour_set(previous_note);
auto same_colour_count = 1;
for (auto p = std::next(previous_sp_note); p < previous_note; ++p) {
if (p->is_hold_point) {
continue;
}
if (m_points.colour_set(p) == colour) {
++same_colour_count;
}
}
stream << to_ordinal(same_colour_count) << ' ' << colour;
} else if (count == 1) {
stream << "NN";
}
const auto act_end = activation.act_end;
if (!act_end->is_hold_point) {
stream << " (" << m_points.colour_set(act_end) << ")";
}
}
std::vector<std::string> ProcessedSong::act_summaries(const Path& path) const
{
using namespace std::literals::string_literals;
std::vector<std::string> activation_summaries;
auto start_point = m_points.cbegin();
for (const auto& act : path.activations) {
const auto sp_before
= std::count_if(start_point, act.act_start, [](const auto& p) {
return p.is_sp_granting_note;
});
const auto sp_during = std::count_if(
act.act_start, std::next(act.act_end),
[](const auto& p) { return p.is_sp_granting_note; });
auto summary = std::to_string(sp_before);
if (sp_during != 0) {
if (m_overlaps) {
summary += "(+"s + std::to_string(sp_during) + ')';
} else {
summary += "-S"s + std::to_string(sp_during);
}
}
activation_summaries.push_back(summary);
start_point = std::next(act.act_end);
}
const auto spare_sp
= std::count_if(start_point, m_points.cend(),
[](const auto& p) { return p.is_sp_granting_note; });
if (spare_sp != 0) {
activation_summaries.push_back(std::string("ES")
+ std::to_string(spare_sp));
}
return activation_summaries;
}
std::vector<std::string>
ProcessedSong::drum_act_summaries(const Path& path) const
{
std::vector<std::string> activation_summaries;
auto start_point = m_points.cbegin();
for (const auto& act : path.activations) {
int sp_count = 0;
while (sp_count < 2) {
if (start_point->is_sp_granting_note) {
++sp_count;
}
++start_point;
}
const auto early_fill_point
= m_time_map.to_seconds(
std::prev(start_point)->hit_window_start.beat)
+ SightRead::Second(2.0);
const auto late_fill_point
= m_time_map.to_seconds(std::prev(start_point)->hit_window_end.beat)
+ SightRead::Second(2.0);
const auto skipped_fills
= std::count_if(start_point, act.act_start, [&](const auto& p) {
return p.fill_start.has_value()
&& *p.fill_start >= early_fill_point;
});
const auto act_start_fill_start = act.act_start->fill_start;
assert(act_start_fill_start.has_value()); // NOLINT
if (skipped_fills == 0 && late_fill_point > *act_start_fill_start) {
activation_summaries.emplace_back("0(E)");
} else if (skipped_fills > 0) {
while (!start_point->fill_start.has_value()) {
++start_point;
}
const auto fill_start = start_point->fill_start;
assert(fill_start.has_value()); // NOLINT
if (late_fill_point > *fill_start
&& early_fill_point < *fill_start) {
activation_summaries.push_back(std::to_string(skipped_fills - 1)
+ "(L)");
} else {
activation_summaries.push_back(std::to_string(skipped_fills));
}
} else {
activation_summaries.push_back(std::to_string(skipped_fills));
}
start_point = std::next(act.act_end);
}
return activation_summaries;
}
std::string ProcessedSong::path_summary(const Path& path) const
{
constexpr double AVG_MULT_PRECISION = 1000.0;
// We use std::stringstream instead of std::string for better formating of
// floats (average multiplier and mid-sustain activation positions).
std::stringstream stream;
stream << "Path: ";
const auto activation_summaries
= m_is_drums ? drum_act_summaries(path) : act_summaries(path);
if (activation_summaries.empty()) {
stream << "None";
} else {
stream << activation_summaries[0];
for (std::size_t i = 1; i < activation_summaries.size(); ++i) {
stream << '-' << activation_summaries[i];
}
}
auto no_sp_score = std::accumulate(
m_points.cbegin(), m_points.cend(), 0,
[](const auto x, const auto& y) { return x + y.value; });
no_sp_score += m_total_solo_boost;
no_sp_score += m_total_bre_boost;
stream << "\nNo SP score: " << no_sp_score;
const auto total_score = no_sp_score + path.score_boost;
stream << "\nTotal score: " << total_score;
if (!m_ignore_average_multiplier) {
double avg_mult = 0;
if (m_base_score != 0) {
auto int_avg_mult = 0;
auto stars_score = total_score - m_total_solo_boost;
for (auto i = 0; i < 4; ++i) {
int_avg_mult *= 10; // NOLINT
int_avg_mult += (stars_score / m_base_score);
stars_score %= m_base_score;
stars_score *= 10; // NOLINT
}
avg_mult = static_cast<double>(int_avg_mult) / AVG_MULT_PRECISION;
}
stream.setf(std::ios_base::fixed, std::ios_base::floatfield);
stream << std::setprecision(3);
stream << "\nAverage multiplier: " << avg_mult << 'x';
}
if (!m_is_drums) {
stream << std::setprecision(2);
for (std::size_t i = 0; i < path.activations.size(); ++i) {
append_activation(stream, path.activations[i],
activation_summaries[i]);
}
}
return stream.str();
}
| 20,781
|
C++
|
.cpp
| 500
| 32.224
| 80
| 0.579051
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,767
|
ini.cpp
|
GenericMadScientist_CHOpt/src/ini.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include <stdexcept>
#include "ini.hpp"
#include "stringutil.hpp"
SightRead::Metadata parse_ini(std::string_view data)
{
constexpr auto ARTIST_SIZE = 6;
constexpr auto CHARTER_SIZE = 7;
constexpr auto FRETS_SIZE = 5;
constexpr auto NAME_SIZE = 4;
std::string u8_string = to_utf8_string(data);
data = u8_string;
SightRead::Metadata metadata;
metadata.name = "Unknown Song";
metadata.artist = "Unknown Artist";
metadata.charter = "Unknown Charter";
while (!data.empty()) {
const auto line = break_off_newline(data);
if (line.starts_with("name")) {
auto value = skip_whitespace(line.substr(NAME_SIZE));
if (value[0] != '=') {
continue;
}
value = skip_whitespace(value.substr(1));
metadata.name = value;
} else if (line.starts_with("artist")) {
auto value = skip_whitespace(line.substr(ARTIST_SIZE));
if (value[0] != '=') {
continue;
}
value = skip_whitespace(value.substr(1));
metadata.artist = value;
} else if (line.starts_with("charter")) {
auto value = skip_whitespace(line.substr(CHARTER_SIZE));
if (value[0] != '=') {
continue;
}
value = skip_whitespace(value.substr(1));
if (!value.empty()) {
metadata.charter = value;
}
} else if (line.starts_with("frets")) {
auto value = skip_whitespace(line.substr(FRETS_SIZE));
if (value[0] != '=') {
continue;
}
value = skip_whitespace(value.substr(1));
if (!value.empty()) {
metadata.charter = value;
}
}
}
return metadata;
}
| 2,610
|
C++
|
.cpp
| 71
| 28.971831
| 73
| 0.601263
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,768
|
points.cpp
|
GenericMadScientist_CHOpt/src/points.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2022, 2023, 2024 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iterator>
#include <type_traits>
#include "points.hpp"
namespace {
bool phrase_contains_pos(const SightRead::StarPower& phrase,
SightRead::Tick position)
{
if (position < phrase.position) {
return false;
}
return position < (phrase.position + phrase.length);
}
double song_tick_gap(int resolution, const Engine& engine)
{
double quotient
= resolution / static_cast<double>(engine.sust_points_per_beat());
if (engine.round_tick_gap()) {
quotient = std::floor(quotient);
}
return std::max(quotient, 1.0);
}
template <typename OutputIt>
void append_sustain_point(OutputIt points, SightRead::Beat beat,
SpMeasure measure, int value)
{
*points++ = {{beat, measure},
{beat, measure},
{beat, measure},
{},
value,
value,
true,
false,
false};
}
template <typename OutputIt>
void append_sustain_points(OutputIt points, SightRead::Tick position,
SightRead::Tick sust_length, int resolution,
int chord_size, const SpTimeMap& time_map,
const Engine& engine)
{
constexpr double HALF_RES_OFFSET = 0.5;
const double float_res = resolution;
double float_pos = position.value();
double tick_gap = song_tick_gap(resolution, engine);
switch (engine.sustain_ticks_metric()) {
case SustainTicksMetric::Beat: {
double float_sust_len = sust_length.value();
auto float_sust_ticks = sust_length.value() / tick_gap;
switch (engine.sustain_rounding()) {
case SustainRoundingPolicy::RoundUp:
float_sust_ticks = std::ceil(float_sust_ticks);
break;
case SustainRoundingPolicy::RoundToNearest:
float_sust_ticks = std::round(float_sust_ticks);
break;
}
auto sust_ticks = static_cast<int>(float_sust_ticks);
if (engine.chords_multiply_sustains()) {
tick_gap /= chord_size;
sust_ticks *= chord_size;
}
while (float_sust_len > engine.burst_size() * resolution
&& sust_ticks > 0) {
float_pos += tick_gap;
float_sust_len -= tick_gap;
const SightRead::Beat beat {(float_pos - HALF_RES_OFFSET)
/ float_res};
const auto meas = time_map.to_sp_measures(beat);
--sust_ticks;
append_sustain_point(points, beat, meas, 1);
}
if (sust_ticks > 0) {
const SightRead::Beat beat {(float_pos + HALF_RES_OFFSET)
/ float_res};
const auto meas = time_map.to_sp_measures(beat);
append_sustain_point(points, beat, meas, sust_ticks);
}
break;
}
case SustainTicksMetric::OdBeat:
constexpr double SP_BEATS_PER_MEASURE = 4.0;
const double sustain_end = (position + sust_length).value();
tick_gap /= SP_BEATS_PER_MEASURE * resolution;
if (engine.chords_multiply_sustains()) {
tick_gap /= chord_size;
}
while (float_pos + HALF_RES_OFFSET < sustain_end) {
const SightRead::Beat old_beat {float_pos / float_res};
auto meas = time_map.to_sp_measures(old_beat);
meas += SpMeasure {tick_gap};
const auto beat = time_map.to_beats(meas);
float_pos = beat.value() * float_res;
append_sustain_point(points, beat, meas, 1);
}
break;
}
}
int get_chord_size(const SightRead::Note& note,
const SightRead::DrumSettings& drum_settings)
{
if (note.is_skipped_kick(drum_settings)) {
return 0;
}
int note_count = 0;
for (auto length : note.lengths) {
if (length != SightRead::Tick {-1}) {
++note_count;
}
}
return note_count;
}
template <typename OutputIt>
void append_note_points(std::vector<SightRead::Note>::const_iterator note,
const std::vector<SightRead::Note>& notes,
OutputIt points, const SpTimeMap& time_map,
int resolution, bool is_note_sp_ender,
bool is_unison_sp_ender, double squeeze,
const Engine& engine,
const SightRead::DrumSettings& drum_settings)
{
auto note_value = engine.base_note_value();
if (note->flags & SightRead::FLAGS_DRUMS) {
if (note->flags & SightRead::FLAGS_CYMBAL) {
note_value = engine.base_cymbal_value();
}
if (note->flags & (SightRead::FLAGS_GHOST | SightRead::FLAGS_ACCENT)) {
note_value *= 2;
}
}
const auto chord_size = get_chord_size(*note, drum_settings);
const auto pos = note->position;
const auto beat = time_map.to_beats(pos);
const auto meas = time_map.to_sp_measures(beat);
const auto note_seconds = time_map.to_seconds(beat);
auto early_gap = std::numeric_limits<double>::infinity();
if (note != notes.cbegin()) {
const auto prev_note_beat
= time_map.to_beats(std::prev(note)->position);
const auto prev_note_seconds = time_map.to_seconds(prev_note_beat);
early_gap = (note_seconds - prev_note_seconds).value();
}
auto late_gap = std::numeric_limits<double>::infinity();
if (std::next(note) != notes.cend()) {
const auto next_note_beat
= time_map.to_beats(std::next(note)->position);
const auto next_note_seconds = time_map.to_seconds(next_note_beat);
late_gap = (next_note_seconds - note_seconds).value();
}
const SightRead::Second early_window {
engine.early_timing_window(early_gap, late_gap) * squeeze};
const SightRead::Second late_window {
engine.late_timing_window(early_gap, late_gap) * squeeze};
const auto early_beat = time_map.to_beats(note_seconds - early_window);
const auto early_meas = time_map.to_sp_measures(early_beat);
const auto late_beat = time_map.to_beats(note_seconds + late_window);
const auto late_meas = time_map.to_sp_measures(late_beat);
*points++
= {{beat, meas}, {early_beat, early_meas}, {late_beat, late_meas},
{}, note_value * chord_size, note_value * chord_size,
false, is_note_sp_ender, is_unison_sp_ender};
SightRead::Tick min_length {std::numeric_limits<int>::max()};
SightRead::Tick max_length {0};
for (auto length : note->lengths) {
if (length == SightRead::Tick {-1}) {
continue;
}
min_length = std::min(length, min_length);
max_length = std::max(length, max_length);
}
if (min_length == max_length || engine.merge_uneven_sustains()) {
append_sustain_points(points, pos, min_length, resolution, chord_size,
time_map, engine);
} else {
for (auto length : note->lengths) {
if (length != SightRead::Tick {-1}) {
append_sustain_points(points, pos, length, resolution,
chord_size, time_map, engine);
}
}
}
}
std::vector<Point>::iterator closest_point(std::vector<Point>& points,
SightRead::Beat fill_end)
{
assert(!points.empty()); // NOLINT
auto nearest = points.begin();
auto best_gap = std::abs((nearest->position.beat - fill_end).value());
for (auto p = std::next(points.begin()); p < points.end(); ++p) {
if (p->position.beat <= nearest->position.beat) {
continue;
}
const auto new_gap = std::abs((p->position.beat - fill_end).value());
if (new_gap > best_gap) {
break;
}
nearest = p;
best_gap = new_gap;
}
return nearest;
}
void add_drum_activation_points(const SightRead::NoteTrack& track,
std::vector<Point>& points)
{
if (points.empty()) {
return;
}
const auto& tempo_map = track.global_data().tempo_map();
for (auto fill : track.drum_fills()) {
const auto fill_start = tempo_map.to_beats(fill.position);
const auto fill_end = tempo_map.to_beats(fill.position + fill.length);
const auto best_point = closest_point(points, fill_end);
best_point->fill_start = tempo_map.to_seconds(fill_start);
}
}
void shift_points_by_video_lag(std::vector<Point>& points,
const SpTimeMap& time_map,
SightRead::Second video_lag)
{
const auto add_video_lag = [&](auto& position) {
auto seconds = time_map.to_seconds(position.beat);
seconds += video_lag;
position.beat = time_map.to_beats(seconds);
position.sp_measure = time_map.to_sp_measures(position.beat);
};
for (auto& point : points) {
if (point.is_hold_point) {
continue;
}
add_video_lag(point.position);
add_video_lag(point.hit_window_start);
add_video_lag(point.hit_window_end);
}
}
template <typename P>
std::vector<PointPtr> next_matching_vector(const std::vector<Point>& points,
P predicate)
{
if (points.empty()) {
return {};
}
std::vector<PointPtr> next_matching_points;
auto next_matching_point = points.cend();
for (auto p = std::prev(points.cend());; --p) {
if (predicate(*p)) {
next_matching_point = p;
}
next_matching_points.push_back(next_matching_point);
// We can't have the loop condition be p >= points.cbegin() because
// decrementing past .begin() is undefined behaviour.
if (p == points.cbegin()) {
break;
}
}
std::reverse(next_matching_points.begin(), next_matching_points.end());
return next_matching_points;
}
template <typename T>
std::string to_guitar_colour_string(
const std::vector<T>& colours,
const std::vector<std::tuple<T, std::string>>& colour_names)
{
std::string colour_string;
for (const auto& [colour, string] : colour_names) {
if (std::find(colours.cbegin(), colours.cend(), colour)
!= colours.cend()) {
colour_string += string;
}
}
return colour_string;
}
void apply_multiplier(std::vector<Point>& points, const Engine& engine)
{
constexpr int COMBO_PER_MULTIPLIER_LEVEL = 10;
auto combo = 0;
for (auto& point : points) {
if (!point.is_hold_point) {
++combo;
}
auto multiplier = std::min(combo / COMBO_PER_MULTIPLIER_LEVEL + 1,
engine.max_multiplier());
if (!point.is_hold_point && engine.delayed_multiplier()) {
multiplier = std::min((combo - 1) / COMBO_PER_MULTIPLIER_LEVEL + 1,
engine.max_multiplier());
}
point.value *= multiplier;
}
}
bool has_split_notes(SightRead::TrackType track_type)
{
return track_type == SightRead::TrackType::Drums
|| track_type == SightRead::TrackType::FortniteFestival;
}
bool is_note_skippable(const SightRead::Note& starting_note,
const SightRead::Note& note_to_test,
SightRead::TrackType track_type,
const SightRead::DrumSettings& drum_settings)
{
if (track_type == SightRead::TrackType::Drums) {
return note_to_test.is_skipped_kick(drum_settings);
}
if (track_type == SightRead::TrackType::FortniteFestival) {
return false;
}
return starting_note.position == note_to_test.position;
}
std::vector<Point> unmultiplied_points(
const SightRead::NoteTrack& track, const SpTimeMap& time_map,
const std::vector<SightRead::Tick>& unison_phrases,
const SqueezeSettings& squeeze_settings,
const SightRead::DrumSettings& drum_settings, const Engine& engine)
{
const auto& notes = track.notes();
const auto bre = track.bre();
std::vector<Point> points;
auto current_phrase = track.sp_phrases().cbegin();
for (auto p = notes.cbegin(); p != notes.cend();) {
if (track.track_type() == SightRead::TrackType::Drums) {
if (p->is_skipped_kick(drum_settings)) {
++p;
continue;
}
}
if (engine.has_bres() && bre.has_value() && p->position >= bre->start) {
break;
}
const auto search_start
= has_split_notes(track.track_type()) ? std::next(p) : p;
const auto q = std::find_if_not(
search_start, notes.cend(), [=](const auto& note) {
return is_note_skippable(*p, note, track.track_type(),
drum_settings);
});
auto is_note_sp_ender = false;
auto is_unison_sp_ender = false;
if (current_phrase != track.sp_phrases().cend()
&& phrase_contains_pos(*current_phrase, p->position)
&& ((q == notes.cend())
|| !phrase_contains_pos(*current_phrase, q->position))) {
is_note_sp_ender = true;
if (engine.has_unison_bonuses()
&& std::find(unison_phrases.cbegin(), unison_phrases.cend(),
current_phrase->position)
!= unison_phrases.cend()) {
is_unison_sp_ender = true;
}
++current_phrase;
}
append_note_points(p, notes, std::back_inserter(points), time_map,
track.global_data().resolution(), is_note_sp_ender,
is_unison_sp_ender, squeeze_settings.squeeze, engine,
drum_settings);
p = q;
}
std::stable_sort(points.begin(), points.end(),
[](const auto& x, const auto& y) {
return x.position.beat < y.position.beat;
});
return points;
}
std::vector<Point>
non_drum_points(const SightRead::NoteTrack& track, const SpTimeMap& time_map,
const std::vector<SightRead::Tick>& unison_phrases,
const SqueezeSettings& squeeze_settings, const Engine& engine)
{
auto points = unmultiplied_points(
track, time_map, unison_phrases, squeeze_settings,
SightRead::DrumSettings::default_settings(), engine);
apply_multiplier(points, engine);
shift_points_by_video_lag(points, time_map, squeeze_settings.video_lag);
return points;
}
std::string colours_string(const SightRead::Note& note)
{
std::string colours;
if ((note.flags & SightRead::FLAGS_FIVE_FRET_GUITAR) != 0U) {
const std::array<std::string, 6> COLOUR_NAMES {"G", "R", "Y",
"B", "O", "open"};
for (auto i = 0U; i < COLOUR_NAMES.size(); ++i) {
if (note.lengths.at(i) != SightRead::Tick {-1}) {
colours += COLOUR_NAMES.at(i);
}
}
return colours;
}
if ((note.flags & SightRead::FLAGS_SIX_FRET_GUITAR) != 0U) {
const std::array<std::string, 7> COLOUR_NAMES {"W1", "W2", "W3", "B1",
"B2", "B3", "open"};
for (auto i = 0U; i < COLOUR_NAMES.size(); ++i) {
if (note.lengths.at(i) != SightRead::Tick {-1}) {
colours += COLOUR_NAMES.at(i);
}
}
}
if ((note.flags & SightRead::FLAGS_DRUMS) != 0U) {
const std::array<std::string, 6> COLOUR_NAMES {"R", "Y", "B",
"G", "kick", "kick"};
for (auto i = 0U; i < COLOUR_NAMES.size(); ++i) {
if (note.lengths.at(i) != SightRead::Tick {-1}) {
colours += COLOUR_NAMES.at(i);
}
}
if ((note.flags & SightRead::FLAGS_GHOST) != 0U) {
colours += " ghost";
}
if ((note.flags & SightRead::FLAGS_ACCENT) != 0U) {
colours += " accent";
}
if ((note.flags & SightRead::FLAGS_CYMBAL) != 0U) {
colours += " cymbal";
}
}
return colours;
}
std::vector<PointPtr>
first_after_current_sp_vector(const std::vector<Point>& points,
const SightRead::NoteTrack& track,
const Engine& engine)
{
std::vector<PointPtr> results;
const auto& tempo_map = track.global_data().tempo_map();
auto current_sp = track.sp_phrases().cbegin();
for (auto p = points.cbegin(); p < points.cend();) {
current_sp
= std::find_if(current_sp, track.sp_phrases().cend(), [&](auto sp) {
return tempo_map.to_beats(sp.position + sp.length)
> p->position.beat;
});
SightRead::Beat sp_start {std::numeric_limits<double>::infinity()};
SightRead::Beat sp_end {std::numeric_limits<double>::infinity()};
if (current_sp != track.sp_phrases().cend()) {
sp_start = tempo_map.to_beats(current_sp->position);
sp_end
= tempo_map.to_beats(current_sp->position + current_sp->length);
}
if (p->position.beat < sp_start || engine.overlaps()) {
results.push_back(++p);
continue;
}
const auto q = std::find_if(std::next(p), points.cend(), [&](auto pt) {
return pt.position.beat >= sp_end;
});
while (p < q) {
results.push_back(q);
++p;
}
}
return results;
}
std::vector<std::string> note_colours(const std::vector<SightRead::Note>& notes,
const std::vector<Point>& points)
{
std::vector<std::string> colours;
colours.reserve(points.size());
auto note_ptr = notes.cbegin();
for (const auto& p : points) {
if (p.is_hold_point) {
colours.emplace_back("");
continue;
}
colours.push_back(colours_string(*note_ptr));
++note_ptr;
}
return colours;
}
std::vector<Point>
points_from_track(const SightRead::NoteTrack& track, const SpTimeMap& time_map,
const std::vector<SightRead::Tick>& unison_phrases,
const SqueezeSettings& squeeze_settings,
const SightRead::DrumSettings& drum_settings,
const Engine& engine)
{
if (track.track_type() != SightRead::TrackType::Drums) {
return non_drum_points(track, time_map, unison_phrases,
squeeze_settings, engine);
}
auto points = unmultiplied_points(track, time_map, unison_phrases,
squeeze_settings, drum_settings, engine);
add_drum_activation_points(track, points);
apply_multiplier(points, engine);
shift_points_by_video_lag(points, time_map, squeeze_settings.video_lag);
return points;
}
std::vector<PointPtr> next_non_hold_vector(const std::vector<Point>& points)
{
return next_matching_vector(points,
[](const auto& p) { return !p.is_hold_point; });
}
std::vector<PointPtr> next_sp_note_vector(const std::vector<Point>& points)
{
return next_matching_vector(
points, [](const auto& p) { return p.is_sp_granting_note; });
}
std::vector<int> score_totals(const std::vector<Point>& points)
{
std::vector<int> scores;
scores.reserve(points.size() + 1);
scores.push_back(0);
auto sum = 0;
for (const auto& p : points) {
sum += p.value;
scores.push_back(sum);
}
return scores;
}
std::vector<std::tuple<SpPosition, int>>
solo_boosts_from_solos(const std::vector<SightRead::Solo>& solos,
const SpTimeMap& time_map)
{
std::vector<std::tuple<SpPosition, int>> solo_boosts;
solo_boosts.reserve(solos.size());
for (const auto& solo : solos) {
const auto end_beat = time_map.to_beats(solo.end);
const SpMeasure end_meas = time_map.to_sp_measures(end_beat);
const SpPosition end_pos {end_beat, end_meas};
solo_boosts.emplace_back(end_pos, solo.value);
}
return solo_boosts;
}
}
PointSet::PointSet(const SightRead::NoteTrack& track, const SpTimeMap& time_map,
const std::vector<SightRead::Tick>& unison_phrases,
const SqueezeSettings& squeeze_settings,
const SightRead::DrumSettings& drum_settings,
const Engine& engine)
: m_points {points_from_track(track, time_map, unison_phrases,
squeeze_settings, drum_settings, engine)}
, m_first_after_current_sp {first_after_current_sp_vector(m_points, track,
engine)}
, m_next_non_hold_point {next_non_hold_vector(m_points)}
, m_next_sp_granting_note {next_sp_note_vector(m_points)}
, m_solo_boosts {solo_boosts_from_solos(track.solos(drum_settings),
time_map)}
, m_cumulative_score_totals {score_totals(m_points)}
, m_video_lag {squeeze_settings.video_lag}
, m_colours {note_colours(track.notes(), m_points)}
{
}
PointPtr PointSet::first_after_current_phrase(PointPtr point) const
{
const auto index
= static_cast<std::size_t>(std::distance(m_points.cbegin(), point));
return m_first_after_current_sp[index];
}
PointPtr PointSet::next_non_hold_point(PointPtr point) const
{
const auto index
= static_cast<std::size_t>(std::distance(m_points.cbegin(), point));
return m_next_non_hold_point[index];
}
PointPtr PointSet::next_sp_granting_note(PointPtr point) const
{
const auto index
= static_cast<std::size_t>(std::distance(m_points.cbegin(), point));
return m_next_sp_granting_note[index];
}
int PointSet::range_score(PointPtr start, PointPtr end) const
{
const auto start_index
= static_cast<std::size_t>(std::distance(m_points.cbegin(), start));
const auto end_index
= static_cast<std::size_t>(std::distance(m_points.cbegin(), end));
return m_cumulative_score_totals[end_index]
- m_cumulative_score_totals[start_index];
}
| 23,306
|
C++
|
.cpp
| 587
| 30.446337
| 80
| 0.580264
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,769
|
sptimemap.cpp
|
GenericMadScientist_CHOpt/src/sptimemap.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include "sptimemap.hpp"
SightRead::Beat SpTimeMap::to_beats(SightRead::Second seconds) const
{
return m_tempo_map.to_beats(seconds);
}
SightRead::Beat SpTimeMap::to_beats(SpMeasure measures) const
{
switch (m_sp_mode) {
case SpMode::Measure:
return m_tempo_map.to_beats(SightRead::Measure {measures.value()});
case SpMode::OdBeat:
return m_tempo_map.to_beats(SightRead::OdBeat {measures.value()});
default:
throw std::runtime_error("Invalid SpMode value");
}
}
SightRead::Beat SpTimeMap::to_beats(SightRead::Tick ticks) const
{
return m_tempo_map.to_beats(ticks);
}
SightRead::Second SpTimeMap::to_seconds(SightRead::Beat beats) const
{
return m_tempo_map.to_seconds(beats);
}
SightRead::Second SpTimeMap::to_seconds(SpMeasure sp_measures) const
{
return to_seconds(to_beats(sp_measures));
}
SpMeasure SpTimeMap::to_sp_measures(SightRead::Beat beats) const
{
switch (m_sp_mode) {
case SpMode::Measure:
return SpMeasure {m_tempo_map.to_measures(beats).value()};
case SpMode::OdBeat:
return SpMeasure {m_tempo_map.to_od_beats(beats).value()};
default:
throw std::runtime_error("Invalid SpMode value");
}
}
SpMeasure SpTimeMap::to_sp_measures(SightRead::Second seconds) const
{
return to_sp_measures(m_tempo_map.to_beats(seconds));
}
| 2,110
|
C++
|
.cpp
| 61
| 31.42623
| 75
| 0.731994
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,771
|
mainwindow.cpp
|
GenericMadScientist_CHOpt/gui/mainwindow.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2022, 2023, 2024 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include <QDebug>
#include <QDesktopServices>
#include <QDragEnterEvent>
#include <QFileDialog>
#include <QMimeData>
#include <QUrl>
#include "image.hpp"
#include "json_settings.hpp"
#include "mainwindow.hpp"
#include "optimiser.hpp"
#include "ui_mainwindow.h"
class ParserThread : public QThread {
Q_OBJECT
private:
QString m_file_name;
static std::set<Game> song_file_games(const SongFile& song_file)
{
const std::set<Game> all_games {Game::CloneHero, Game::FortniteFestival,
Game::GuitarHeroOne, Game::RockBand,
Game::RockBandThree};
std::set<Game> supported_games;
for (const auto game : all_games) {
try {
song_file.load_song(game);
supported_games.insert(game);
} catch (const std::exception&) {
qDebug() << "Skipping game " << static_cast<int>(game);
}
}
return supported_games;
}
public:
explicit ParserThread(QObject* parent = nullptr)
: QThread(parent)
{
}
void run() override
{
try {
SongFile song_file {m_file_name.toStdString()};
auto games = song_file_games(song_file);
if (games.empty()) {
emit parsing_failed(m_file_name);
}
emit result_ready(std::move(song_file), std::move(games),
m_file_name);
} catch (const std::exception&) {
emit parsing_failed(m_file_name);
}
}
void set_file_name(const QString& file_name) { m_file_name = file_name; }
signals:
void parsing_failed(const QString& file_name);
void result_ready(SongFile loaded_file, std::set<Game> games,
const QString& file_name);
};
class OptimiserThread : public QThread {
Q_OBJECT
private:
std::atomic<bool> m_terminate = false;
Settings m_settings;
std::optional<SightRead::Song> m_song;
QString m_file_name;
public:
explicit OptimiserThread(QObject* parent = nullptr)
: QThread(parent)
{
}
void run() override
{
if (!m_song.has_value()) {
throw std::runtime_error("m_song missing value");
}
try {
const auto& track
= m_song->track(m_settings.instrument, m_settings.difficulty);
const auto builder = make_builder(
*m_song, track, m_settings,
[&](const QString& text) { emit write_text(text); },
&m_terminate);
emit write_text("Saving image...");
const Image image {builder};
image.save(m_file_name.toStdString().c_str());
emit write_text("Image saved");
QDesktopServices::openUrl(QUrl::fromLocalFile(m_file_name));
} catch (const std::runtime_error&) {
qDebug() << "Breaking out of computation";
}
}
void set_data(Settings settings, SightRead::Song song,
const QString& file_name)
{
m_settings = std::move(settings);
m_song = std::move(song);
m_file_name = file_name;
}
void end_thread() { m_terminate = true; }
signals:
void write_text(const QString& text);
};
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, m_ui {std::make_unique<Ui::MainWindow>()}
{
// This is the maximum for our validators instead of MAX_INT because
// with MAX_INT the user can enter 9,999,999,999 which causes an
// overflow.
constexpr auto MAX_DIGITS_INT = 999999999;
constexpr auto MIN_LABEL_WIDTH = 30;
m_ui->setupUi(this);
m_ui->instrumentComboBox->setEnabled(false);
m_ui->difficultyComboBox->setEnabled(false);
m_ui->engineComboBox->setEnabled(false);
m_ui->findPathButton->setEnabled(false);
m_ui->lazyWhammyLineEdit->setValidator(
new QIntValidator(0, MAX_DIGITS_INT, m_ui->lazyWhammyLineEdit));
m_ui->whammyDelayLineEdit->setValidator(
new QIntValidator(0, MAX_DIGITS_INT, m_ui->whammyDelayLineEdit));
m_ui->speedLineEdit->setValidator(
new QIntValidator(MIN_SPEED, MAX_SPEED, m_ui->speedLineEdit));
m_ui->squeezeLabel->setMinimumWidth(MIN_LABEL_WIDTH);
m_ui->earlyWhammyLabel->setMinimumWidth(MIN_LABEL_WIDTH);
m_ui->videoLagLabel->setMinimumWidth(MIN_LABEL_WIDTH);
m_ui->opacityLabel->setMinimumWidth(MIN_LABEL_WIDTH);
const auto settings = load_saved_settings(
QCoreApplication::applicationDirPath().toStdString());
m_ui->squeezeSlider->setValue(settings.squeeze);
m_ui->earlyWhammySlider->setValue(settings.early_whammy);
m_ui->lazyWhammyLineEdit->setText(QString::number(settings.lazy_whammy));
m_ui->whammyDelayLineEdit->setText(QString::number(settings.whammy_delay));
m_ui->videoLagSlider->setValue(settings.video_lag);
m_ui->leftyCheckBox->setChecked(settings.is_lefty_flip);
setAcceptDrops(true);
}
MainWindow::~MainWindow()
{
constexpr auto DELAY_IN_MS = 5000;
JsonSettings settings {};
settings.squeeze = m_ui->squeezeSlider->value();
settings.early_whammy = m_ui->earlyWhammySlider->value();
settings.video_lag = m_ui->videoLagSlider->value();
settings.is_lefty_flip = m_ui->leftyCheckBox->isChecked();
auto ok = false;
const auto lazy_whammy_text = m_ui->lazyWhammyLineEdit->text();
const auto lazy_whammy_ms = lazy_whammy_text.toInt(&ok);
if (ok) {
settings.lazy_whammy = lazy_whammy_ms;
} else {
settings.lazy_whammy = 0;
}
const auto whammy_delay_text = m_ui->whammyDelayLineEdit->text();
const auto whammy_delay_ms = whammy_delay_text.toInt(&ok);
if (ok) {
settings.whammy_delay = whammy_delay_ms;
} else {
settings.whammy_delay = 0;
}
save_settings(settings,
QCoreApplication::applicationDirPath().toStdString());
if (m_thread != nullptr) {
auto* opt_thread = dynamic_cast<OptimiserThread*>(m_thread.get());
if (opt_thread != nullptr) {
opt_thread->end_thread();
}
m_thread->quit();
// We give the thread 5 seconds to obey, then kill it. Although all
// the thread does apart from CPU-bound work is write to a file at
// the very end, so the call to terminate is not so bad.
if (!m_thread->wait(DELAY_IN_MS)) {
m_thread->terminate();
m_thread->wait();
}
}
}
void MainWindow::dragEnterEvent(QDragEnterEvent* event)
{
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
}
void MainWindow::dropEvent(QDropEvent* event)
{
const auto urls = event->mimeData()->urls();
if (urls.size() != 1) {
write_message("Only one file may be dragged and dropped");
return;
}
load_file(urls[0].toLocalFile());
}
void MainWindow::write_message(const QString& message)
{
m_ui->messageBox->append(message);
}
Settings MainWindow::get_settings() const
{
constexpr auto DEFAULT_SPEED = 100;
constexpr auto MS_IN_SECOND = 1000.0;
constexpr auto PERCENTAGE_IN_UNIT = 100.0;
Settings settings;
settings.blank = m_ui->blankPathCheckBox->isChecked();
settings.draw_bpms = m_ui->drawBpmsCheckBox->isChecked();
settings.draw_solos = m_ui->drawSolosCheckBox->isChecked();
settings.draw_time_sigs = m_ui->drawTsesCheckBox->isChecked();
settings.drum_settings.enable_double_kick
= m_ui->doubleKickCheckBox->isChecked();
settings.drum_settings.disable_kick = m_ui->noKickCheckBox->isChecked();
settings.drum_settings.pro_drums = m_ui->proDrumsCheckBox->isChecked();
settings.drum_settings.enable_dynamics
= m_ui->dynamicsCheckBox->isChecked();
settings.difficulty = m_ui->difficultyComboBox->currentData()
.value<SightRead::Difficulty>();
settings.instrument = m_ui->instrumentComboBox->currentData()
.value<SightRead::Instrument>();
settings.squeeze_settings.squeeze
= m_ui->squeezeSlider->value() / PERCENTAGE_IN_UNIT;
settings.squeeze_settings.early_whammy
= m_ui->earlyWhammySlider->value() / PERCENTAGE_IN_UNIT;
settings.squeeze_settings.video_lag
= SightRead::Second {m_ui->videoLagSlider->value() / MS_IN_SECOND};
settings.game = m_ui->engineComboBox->currentData().value<Game>();
const auto precision_mode = m_ui->precisionModeCheckBox->isChecked();
settings.engine
= game_to_engine(settings.game, settings.instrument, precision_mode);
settings.is_lefty_flip = m_ui->leftyCheckBox->isChecked();
settings.opacity
= static_cast<float>(m_ui->opacitySlider->value() / PERCENTAGE_IN_UNIT);
const auto lazy_whammy_text = m_ui->lazyWhammyLineEdit->text();
auto ok = false;
auto lazy_whammy_ms = lazy_whammy_text.toInt(&ok);
if (ok) {
settings.squeeze_settings.lazy_whammy
= SightRead::Second {lazy_whammy_ms / MS_IN_SECOND};
} else {
settings.squeeze_settings.lazy_whammy = SightRead::Second {0.0};
}
const auto whammy_delay_text = m_ui->whammyDelayLineEdit->text();
auto whammy_delay_ms = whammy_delay_text.toInt(&ok);
if (ok) {
settings.squeeze_settings.whammy_delay
= SightRead::Second {whammy_delay_ms / MS_IN_SECOND};
} else {
settings.squeeze_settings.whammy_delay = SightRead::Second {0.0};
}
const auto speed_text = m_ui->speedLineEdit->text();
auto speed = speed_text.toInt(&ok);
if (ok) {
settings.speed = speed;
} else {
settings.speed = DEFAULT_SPEED;
}
return settings;
}
void MainWindow::on_selectFileButton_clicked()
{
const auto file_name = QFileDialog::getOpenFileName(
this, "Open song", "../", "Song charts (*.chart *.mid)");
if (file_name.isEmpty()) {
return;
}
load_file(file_name);
}
void MainWindow::clear_worker_thread() { m_thread.reset(); }
void MainWindow::load_file(const QString& file_name)
{
if (!file_name.endsWith(".chart") && !file_name.endsWith(".mid")) {
write_message("File must be .chart or .mid");
return;
}
m_ui->selectFileButton->setEnabled(false);
setAcceptDrops(false);
auto worker_thread = std::make_unique<ParserThread>(this);
worker_thread->set_file_name(file_name);
connect(worker_thread.get(), &ParserThread::result_ready, this,
&MainWindow::song_read);
connect(worker_thread.get(), &ParserThread::parsing_failed, this,
&MainWindow::parsing_failed);
connect(worker_thread.get(), &ParserThread::finished, this,
&MainWindow::clear_worker_thread);
m_thread = std::move(worker_thread);
m_thread->start();
}
void MainWindow::populate_games(const std::set<Game>& games)
{
m_ui->engineComboBox->clear();
const std::array<std::pair<Game, QString>, 5> full_game_set {
{{Game::CloneHero, "Clone Hero"},
{Game::FortniteFestival, "Fortnite Festival"},
{Game::GuitarHeroOne, "Guitar Hero 1"},
{Game::RockBand, "Rock Band"},
{Game::RockBandThree, "Rock Band 3"}}};
for (const auto& [game, name] : full_game_set) {
if (games.contains(game)) {
m_ui->engineComboBox->addItem(name, QVariant::fromValue(game));
}
}
m_ui->engineComboBox->setCurrentIndex(0);
}
void MainWindow::on_findPathButton_clicked()
{
constexpr auto SPEED_INCREMENT = 5;
const auto speed_text = m_ui->speedLineEdit->text();
auto ok = false;
const auto speed = speed_text.toInt(&ok);
if (!ok || speed < MIN_SPEED || speed > MAX_SPEED
|| speed % SPEED_INCREMENT != 0) {
write_message("Speed not supported by Clone Hero");
return;
}
const auto file_name = QFileDialog::getSaveFileName(this, "Save image", ".",
"Images (*.png *.bmp)");
if (file_name.isEmpty()) {
return;
}
if (!file_name.endsWith(".bmp") && !file_name.endsWith(".png")) {
write_message("Not a valid image file");
return;
}
m_ui->selectFileButton->setEnabled(false);
m_ui->findPathButton->setEnabled(false);
auto settings = get_settings();
auto song = m_loaded_file->load_song(settings.game);
auto worker_thread = std::make_unique<OptimiserThread>(this);
worker_thread->set_data(std::move(settings), std::move(song), file_name);
connect(worker_thread.get(), &OptimiserThread::write_text, this,
&MainWindow::write_message);
connect(worker_thread.get(), &OptimiserThread::finished, this,
&MainWindow::path_found);
connect(worker_thread.get(), &OptimiserThread::finished, this,
&MainWindow::clear_worker_thread);
m_thread = std::move(worker_thread);
m_thread->start();
}
void MainWindow::parsing_failed(const QString& file_name)
{
m_thread.reset();
write_message(file_name + " invalid");
m_ui->selectFileButton->setEnabled(true);
}
void MainWindow::song_read(SongFile loaded_file, const std::set<Game>& games,
const QString& file_name)
{
m_thread.reset();
m_loaded_file = std::move(loaded_file);
populate_games(games);
write_message(file_name + " loaded");
m_ui->findPathButton->setEnabled(true);
m_ui->instrumentComboBox->setEnabled(true);
m_ui->difficultyComboBox->setEnabled(true);
m_ui->engineComboBox->setEnabled(true);
m_ui->selectFileButton->setEnabled(true);
setAcceptDrops(true);
}
void MainWindow::path_found()
{
m_thread.reset();
m_ui->selectFileButton->setEnabled(true);
m_ui->findPathButton->setEnabled(true);
}
void MainWindow::on_engineComboBox_currentIndexChanged(int index)
{
if (!m_loaded_file.has_value()) {
throw std::runtime_error("No loaded file");
}
m_ui->instrumentComboBox->clear();
if (index == -1) {
return;
}
const std::map<SightRead::Instrument, QString> INST_NAMES {
{SightRead::Instrument::Guitar, "Guitar"},
{SightRead::Instrument::GuitarCoop, "Guitar Co-op"},
{SightRead::Instrument::Bass, "Bass"},
{SightRead::Instrument::Rhythm, "Rhythm"},
{SightRead::Instrument::Keys, "Keys"},
{SightRead::Instrument::GHLGuitar, "GHL Guitar"},
{SightRead::Instrument::GHLBass, "GHL Bass"},
{SightRead::Instrument::GHLRhythm, "GHL Rhythm"},
{SightRead::Instrument::GHLGuitarCoop, "GHL Guitar Co-op"},
{SightRead::Instrument::Drums, "Drums"},
{SightRead::Instrument::FortniteGuitar, "Guitar"},
{SightRead::Instrument::FortniteBass, "Bass"},
{SightRead::Instrument::FortniteDrums, "Drums"},
{SightRead::Instrument::FortniteVocals, "Vocals"},
{SightRead::Instrument::FortniteProGuitar, "Pro Guitar"},
{SightRead::Instrument::FortniteProBass, "Pro Bass"}};
const auto game = m_ui->engineComboBox->currentData().value<Game>();
for (auto inst : m_loaded_file->load_song(game).instruments()) {
m_ui->instrumentComboBox->addItem(INST_NAMES.at(inst),
QVariant::fromValue(inst));
}
m_ui->instrumentComboBox->setCurrentIndex(0);
}
void MainWindow::on_instrumentComboBox_currentIndexChanged(int index)
{
if (!m_loaded_file.has_value()) {
throw std::runtime_error("No loaded file");
}
m_ui->difficultyComboBox->clear();
if (index == -1) {
return;
}
const std::map<SightRead::Difficulty, QString> DIFF_NAMES {
{SightRead::Difficulty::Easy, "Easy"},
{SightRead::Difficulty::Medium, "Medium"},
{SightRead::Difficulty::Hard, "Hard"},
{SightRead::Difficulty::Expert, "Expert"}};
const auto inst = m_ui->instrumentComboBox->currentData()
.value<SightRead::Instrument>();
const auto game = m_ui->engineComboBox->currentData().value<Game>();
for (auto diff : m_loaded_file->load_song(game).difficulties(inst)) {
m_ui->difficultyComboBox->addItem(DIFF_NAMES.at(diff),
QVariant::fromValue(diff));
}
const auto count = m_ui->difficultyComboBox->count();
m_ui->difficultyComboBox->setCurrentIndex(count - 1);
}
void MainWindow::on_squeezeSlider_valueChanged(int value)
{
m_ui->squeezeLabel->setText(QString::number(value));
}
void MainWindow::on_earlyWhammySlider_valueChanged(int value)
{
m_ui->earlyWhammyLabel->setText(QString::number(value));
}
void MainWindow::on_videoLagSlider_valueChanged(int value)
{
m_ui->videoLagLabel->setText(QString::number(value));
}
void MainWindow::on_opacitySlider_valueChanged(int value)
{
constexpr auto PERCENTAGE_IN_UNIT = 100.0;
const auto text = QString::number(value / PERCENTAGE_IN_UNIT, 'f', 2);
m_ui->opacityLabel->setText(text);
}
#include "mainwindow.moc"
| 17,790
|
C++
|
.cpp
| 452
| 32.634956
| 80
| 0.649467
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,772
|
json_settings.cpp
|
GenericMadScientist_CHOpt/gui/json_settings.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2022, 2024 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <filesystem>
#include <QFile>
#include <QJsonDocument>
#include <QJsonObject>
#include <QString>
#include "json_settings.hpp"
namespace {
struct IntRange {
int min;
int max;
};
int read_value(const QJsonObject& settings, const QString& name, IntRange range,
int default_value)
{
const auto value = settings.value(name).toInt(default_value);
if (value >= range.min && value <= range.max) {
return value;
}
return default_value;
}
bool read_json_bool(const QJsonObject& settings, const QString& name,
bool default_value)
{
return settings.value(name).toBool(default_value);
}
QString settings_path(std::string_view application_dir)
{
const auto path = std::filesystem::path(application_dir) / "settings.json";
return QString::fromStdString(path.string());
}
}
JsonSettings load_saved_settings(std::string_view application_dir)
{
constexpr int MAX_LINE_EDIT_INT = 999999999;
constexpr int MAX_PERCENT = 100;
constexpr int MAX_VIDEO_LAG = 200;
constexpr int MIN_VIDEO_LAG = -200;
JsonSettings settings {};
settings.squeeze = MAX_PERCENT;
settings.early_whammy = MAX_PERCENT;
settings.lazy_whammy = 0;
settings.whammy_delay = 0;
settings.video_lag = 0;
settings.is_lefty_flip = false;
QFile settings_file {settings_path(application_dir)};
if (!settings_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return settings;
}
const auto settings_file_bytes = settings_file.readAll();
const auto jv = QJsonDocument::fromJson(settings_file_bytes);
if (jv.isNull() || !jv.isObject()) {
return settings;
}
const auto obj = jv.object();
settings.squeeze
= read_value(obj, "squeeze", {0, MAX_PERCENT}, MAX_PERCENT);
settings.early_whammy
= read_value(obj, "early_whammy", {0, MAX_PERCENT}, MAX_PERCENT);
settings.lazy_whammy
= read_value(obj, "lazy_whammy", {0, MAX_LINE_EDIT_INT}, 0);
settings.whammy_delay
= read_value(obj, "whammy_delay", {0, MAX_LINE_EDIT_INT}, 0);
settings.video_lag
= read_value(obj, "video_lag", {MIN_VIDEO_LAG, MAX_VIDEO_LAG}, 0);
settings.is_lefty_flip = read_json_bool(obj, "lefty_flip", false);
return settings;
}
void save_settings(const JsonSettings& settings,
std::string_view application_dir)
{
const QJsonObject obj = {{"squeeze", settings.squeeze},
{"early_whammy", settings.early_whammy},
{"lazy_whammy", settings.lazy_whammy},
{"whammy_delay", settings.whammy_delay},
{"video_lag", settings.video_lag},
{"lefty_flip", settings.is_lefty_flip}};
QFile settings_file {settings_path(application_dir)};
if (settings_file.open(QIODevice::WriteOnly)) {
settings_file.write(QJsonDocument(obj).toJson());
}
}
| 3,720
|
C++
|
.cpp
| 98
| 32.295918
| 80
| 0.671286
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,773
|
chart_fuzzer.cpp
|
GenericMadScientist_CHOpt/fuzzing_targets/chart_fuzzer.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2021 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <cstddef>
#include <sightread/chart.hpp>
#include <sightread/songparts.hpp>
extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size)
{
const std::string_view input {data, size};
try {
parse_chart(input);
return 0;
} catch (const ParseError&) {
return 0;
}
}
| 1,063
|
C++
|
.cpp
| 30
| 32.466667
| 73
| 0.730097
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,774
|
chart_song_fuzzer.cpp
|
GenericMadScientist_CHOpt/fuzzing_targets/chart_song_fuzzer.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2021 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <cstddef>
#include <sightread/songparts.hpp>
#include "song.hpp"
extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size)
{
const std::string_view input {data, size};
try {
Song::from_chart(parse_chart(input), {});
return 0;
} catch (const ParseError&) {
return 0;
}
}
| 1,075
|
C++
|
.cpp
| 30
| 32.833333
| 73
| 0.725264
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,775
|
midi_fuzzer.cpp
|
GenericMadScientist_CHOpt/fuzzing_targets/midi_fuzzer.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2021 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <cstddef>
#include <sightread/songparts.hpp>
#include "midi.hpp"
extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size)
{
const std::vector<std::uint8_t> input {data, data + size};
try {
SightRead::Detail::parse_midi(input);
return 0;
} catch (const ParseError&) {
return 0;
}
}
| 1,087
|
C++
|
.cpp
| 30
| 33.233333
| 73
| 0.726496
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,776
|
midi_song_fuzzer.cpp
|
GenericMadScientist_CHOpt/fuzzing_targets/midi_song_fuzzer.cpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2021 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include <cstddef>
#include <sightread/songparts.hpp>
#include "song.hpp"
extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size)
{
const std::vector<std::uint8_t> input {data, data + size};
try {
Song::from_midi(parse_midi(input), {});
return 0;
} catch (const ParseError&) {
return 0;
}
}
| 1,089
|
C++
|
.cpp
| 30
| 33.3
| 73
| 0.722275
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,777
|
engine.hpp
|
GenericMadScientist_CHOpt/include/engine.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2021, 2022, 2023, 2024 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_ENGINE_HPP
#define CHOPT_ENGINE_HPP
#include <algorithm>
#include <sightread/time.hpp>
#include "sptimemap.hpp"
enum class SustainRoundingPolicy { RoundUp, RoundToNearest };
enum class SustainTicksMetric { Beat, OdBeat };
class Engine {
public:
virtual int base_note_value() const = 0;
virtual int base_cymbal_value() const { return base_note_value(); }
virtual double burst_size() const = 0;
virtual bool chords_multiply_sustains() const = 0;
virtual bool delayed_multiplier() const = 0;
virtual double early_timing_window(double early_gap, double late_gap) const
= 0;
virtual bool has_bres() const = 0;
virtual bool has_unison_bonuses() const = 0;
virtual bool is_rock_band() const = 0;
virtual bool ignore_average_multiplier() const = 0;
virtual double late_timing_window(double early_gap, double late_gap) const
= 0;
virtual int max_multiplier() const = 0;
virtual bool merge_uneven_sustains() const = 0;
virtual double minimum_sp_to_activate() const = 0;
virtual bool overlaps() const = 0;
virtual bool round_tick_gap() const = 0;
virtual SightRead::Tick snap_gap() const = 0;
virtual SpMode sp_mode() const = 0;
virtual double sp_gain_rate() const = 0;
virtual int sust_points_per_beat() const = 0;
virtual SustainRoundingPolicy sustain_rounding() const = 0;
virtual SustainTicksMetric sustain_ticks_metric() const = 0;
virtual ~Engine() = default;
};
class BaseChEngine : public Engine {
protected:
virtual double timing_window(double early_gap, double late_gap) const = 0;
public:
int base_cymbal_value() const override { return 65; }
int base_note_value() const override { return 50; }
double burst_size() const override { return 0.25; }
bool chords_multiply_sustains() const override { return false; }
bool delayed_multiplier() const override { return false; }
double early_timing_window(double early_gap, double late_gap) const override
{
return timing_window(early_gap, late_gap);
}
bool has_bres() const override { return false; }
bool has_unison_bonuses() const override { return false; }
bool ignore_average_multiplier() const override { return false; }
bool is_rock_band() const override { return false; }
double late_timing_window(double early_gap, double late_gap) const override
{
return timing_window(early_gap, late_gap);
}
int max_multiplier() const override { return 4; }
bool merge_uneven_sustains() const override { return false; }
double minimum_sp_to_activate() const override { return 0.5; }
bool overlaps() const override { return true; }
bool round_tick_gap() const override { return true; }
SightRead::Tick snap_gap() const override { return SightRead::Tick {0}; }
double sp_gain_rate() const override { return 1 / 30.0; }
SpMode sp_mode() const override { return SpMode::Measure; }
int sust_points_per_beat() const override { return 25; }
SustainRoundingPolicy sustain_rounding() const override
{
return SustainRoundingPolicy::RoundUp;
}
SustainTicksMetric sustain_ticks_metric() const override
{
return SustainTicksMetric::Beat;
}
};
class ChGuitarEngine final : public BaseChEngine {
protected:
double timing_window(double early_gap, double late_gap) const override
{
(void)early_gap;
(void)late_gap;
return 0.07;
}
};
class ChPrecisionGuitarEngine final : public BaseChEngine {
protected:
double timing_window(double early_gap, double late_gap) const override
{
early_gap = std::clamp(early_gap, 0.0, 0.0525);
late_gap = std::clamp(late_gap, 0.0, 0.0525);
const auto total_gap = early_gap + late_gap;
return 0.27619 * total_gap + 0.021;
}
};
class ChDrumEngine final : public BaseChEngine {
protected:
double timing_window(double early_gap, double late_gap) const override
{
early_gap = std::clamp(early_gap, 0.0375, 0.085);
late_gap = std::clamp(late_gap, 0.0375, 0.085);
const auto total_gap = early_gap + late_gap;
return -2.23425815 * total_gap * total_gap
+ 0.9428571428571415 * total_gap - 0.01;
}
};
class ChPrecisionDrumEngine final : public BaseChEngine {
protected:
double timing_window(double early_gap, double late_gap) const override
{
early_gap = std::clamp(early_gap, 0.025, 0.04);
late_gap = std::clamp(late_gap, 0.025, 0.04);
const auto total_gap = early_gap + late_gap;
return 2.4961183 * total_gap * total_gap + 0.24961183 * total_gap
+ 0.0065;
}
};
class BaseFortniteEngine : public Engine {
public:
int base_note_value() const override { return 36; };
double burst_size() const override { return 0.0; };
bool chords_multiply_sustains() const override { return true; };
bool delayed_multiplier() const override { return true; };
double early_timing_window(double early_gap, double late_gap) const override
{
(void)early_gap;
(void)late_gap;
return 0.1;
}
bool has_bres() const override { return false; };
bool has_unison_bonuses() const override { return false; }
bool is_rock_band() const override { return false; };
bool ignore_average_multiplier() const override { return true; };
double late_timing_window(double early_gap, double late_gap) const override
{
(void)early_gap;
(void)late_gap;
return 0.1;
}
bool merge_uneven_sustains() const override { return true; };
double minimum_sp_to_activate() const override { return 0.25; }
bool overlaps() const override { return true; };
bool round_tick_gap() const override { return false; };
SightRead::Tick snap_gap() const override { return SightRead::Tick {0}; };
SpMode sp_mode() const override { return SpMode::OdBeat; };
double sp_gain_rate() const override { return 0.0; };
SustainRoundingPolicy sustain_rounding() const override
{
return SustainRoundingPolicy::RoundToNearest;
}
SustainTicksMetric sustain_ticks_metric() const override
{
return SustainTicksMetric::OdBeat;
}
};
class FortniteGuitarEngine final : public BaseFortniteEngine {
int max_multiplier() const override { return 4; };
int sust_points_per_beat() const override { return 12; };
};
class FortniteBassEngine final : public BaseFortniteEngine {
int max_multiplier() const override { return 6; };
int sust_points_per_beat() const override { return 12; };
};
class FortniteVocalsEngine final : public BaseFortniteEngine {
int max_multiplier() const override { return 6; };
int sust_points_per_beat() const override { return 25; };
};
class Gh1Engine final : public Engine {
private:
static constexpr double FUDGE_EPSILON = 0.0001;
public:
int base_note_value() const override { return 50; }
double burst_size() const override { return 0.0; }
bool chords_multiply_sustains() const override { return true; }
bool delayed_multiplier() const override { return true; }
double early_timing_window(double early_gap, double late_gap) const override
{
(void)late_gap;
// The division by a number greater than 2 is a fudge so standard
// doubles are not shown as possible without EHW.
return std::min(0.1, early_gap / (2.0 + FUDGE_EPSILON));
}
bool has_bres() const override { return false; }
bool has_unison_bonuses() const override { return false; }
bool ignore_average_multiplier() const override { return true; }
bool is_rock_band() const override { return false; }
double late_timing_window(double early_gap, double late_gap) const override
{
(void)early_gap;
return std::min(0.1, late_gap / (2.0 + FUDGE_EPSILON));
}
int max_multiplier() const override { return 4; }
bool merge_uneven_sustains() const override { return true; }
double minimum_sp_to_activate() const override { return 0.5; }
bool overlaps() const override { return false; }
bool round_tick_gap() const override { return false; }
SightRead::Tick snap_gap() const override { return SightRead::Tick {2}; }
double sp_gain_rate() const override { return 0.034; }
SpMode sp_mode() const override { return SpMode::Measure; }
int sust_points_per_beat() const override { return 25; }
SustainRoundingPolicy sustain_rounding() const override
{
return SustainRoundingPolicy::RoundToNearest;
}
SustainTicksMetric sustain_ticks_metric() const override
{
return SustainTicksMetric::Beat;
}
};
class BaseRbEngine : public Engine {
protected:
virtual double base_timing_window() const = 0;
public:
int base_note_value() const override { return 25; }
double burst_size() const override { return 0.0; }
bool chords_multiply_sustains() const override { return true; }
bool delayed_multiplier() const override { return false; }
double early_timing_window(double early_gap, double late_gap) const override
{
(void)early_gap;
(void)late_gap;
return base_timing_window();
}
bool has_bres() const override { return true; }
bool ignore_average_multiplier() const override { return true; }
bool is_rock_band() const override { return true; }
double late_timing_window(double early_gap, double late_gap) const override
{
(void)early_gap;
return std::min(base_timing_window(), late_gap / 2);
}
bool merge_uneven_sustains() const override { return true; }
double minimum_sp_to_activate() const override { return 0.5; }
bool overlaps() const override { return true; }
bool round_tick_gap() const override { return false; }
SightRead::Tick snap_gap() const override { return SightRead::Tick {2}; }
double sp_gain_rate() const override { return 0.034; }
SpMode sp_mode() const override { return SpMode::OdBeat; }
int sust_points_per_beat() const override { return 12; }
SustainRoundingPolicy sustain_rounding() const override
{
return SustainRoundingPolicy::RoundToNearest;
}
SustainTicksMetric sustain_ticks_metric() const override
{
return SustainTicksMetric::Beat;
}
};
class RbEngine final : public BaseRbEngine {
protected:
double base_timing_window() const override { return 0.1; }
public:
bool has_unison_bonuses() const override { return false; }
int max_multiplier() const override { return 4; }
};
class RbBassEngine final : public BaseRbEngine {
protected:
double base_timing_window() const override { return 0.1; }
public:
bool has_unison_bonuses() const override { return false; }
int max_multiplier() const override { return 6; }
};
class Rb3Engine final : public BaseRbEngine {
protected:
double base_timing_window() const override { return 0.105; }
public:
bool has_unison_bonuses() const override { return true; }
int max_multiplier() const override { return 4; }
};
class Rb3BassEngine final : public BaseRbEngine {
protected:
double base_timing_window() const override { return 0.105; }
public:
bool has_unison_bonuses() const override { return true; }
int max_multiplier() const override { return 6; }
};
#endif
| 12,094
|
C++
|
.h
| 292
| 36.657534
| 80
| 0.695973
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,778
|
songfile.hpp
|
GenericMadScientist_CHOpt/include/songfile.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_SONGFILE_HPP
#define CHOPT_SONGFILE_HPP
#include <cstdint>
#include <string>
#include <vector>
#include <sightread/metadata.hpp>
#include <sightread/song.hpp>
#include "settings.hpp"
class SongFile {
private:
enum class FileType { Chart, Midi };
std::vector<std::uint8_t> m_loaded_file;
SightRead::Metadata m_metadata;
FileType m_file_type;
public:
explicit SongFile(const std::string& filename);
SightRead::Song load_song(Game game) const;
};
#endif
| 1,238
|
C++
|
.h
| 36
| 32.055556
| 73
| 0.755444
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,779
|
points.hpp
|
GenericMadScientist_CHOpt/include/points.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2022, 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_POINTS_HPP
#define CHOPT_POINTS_HPP
#include <limits>
#include <optional>
#include <string>
#include <tuple>
#include <vector>
#include <sightread/drumsettings.hpp>
#include <sightread/songparts.hpp>
#include <sightread/time.hpp>
#include "engine.hpp"
#include "settings.hpp"
#include "sptimemap.hpp"
// fill_start is used for Drums, giving the start of the fill that makes a point
// an activation note if it is one, or nullopt otherwise.
struct Point {
SpPosition position;
SpPosition hit_window_start;
SpPosition hit_window_end;
std::optional<SightRead::Second> fill_start;
int value;
int base_value;
bool is_hold_point;
bool is_sp_granting_note;
bool is_unison_sp_granting_note;
};
using PointPtr = std::vector<Point>::const_iterator;
class PointSet {
private:
std::vector<Point> m_points;
std::vector<PointPtr> m_first_after_current_sp;
std::vector<PointPtr> m_next_non_hold_point;
std::vector<PointPtr> m_next_sp_granting_note;
std::vector<std::tuple<SpPosition, int>> m_solo_boosts;
std::vector<int> m_cumulative_score_totals;
SightRead::Second m_video_lag;
std::vector<std::string> m_colours;
public:
PointSet(const SightRead::NoteTrack& track, const SpTimeMap& time_map,
const std::vector<SightRead::Tick>& unison_phrases,
const SqueezeSettings& squeeze_settings,
const SightRead::DrumSettings& drum_settings,
const Engine& engine);
[[nodiscard]] PointPtr cbegin() const { return m_points.cbegin(); }
[[nodiscard]] PointPtr cend() const { return m_points.cend(); }
// Designed for engines without SP overlap, so the next activation is not
// using part of the given phrase. If the point is not part of a phrase, or
// the engine supports overlap, then this just returns the next point.
[[nodiscard]] PointPtr first_after_current_phrase(PointPtr point) const;
[[nodiscard]] PointPtr next_non_hold_point(PointPtr point) const;
[[nodiscard]] PointPtr next_sp_granting_note(PointPtr point) const;
[[nodiscard]] std::string colour_set(PointPtr point) const
{
return m_colours[static_cast<std::size_t>(
std::distance(m_points.cbegin(), point))];
}
// Get the combined score of all points that are >= start and < end.
[[nodiscard]] int range_score(PointPtr start, PointPtr end) const;
[[nodiscard]] const std::vector<std::tuple<SpPosition, int>>&
solo_boosts() const
{
return m_solo_boosts;
}
[[nodiscard]] SightRead::Second video_lag() const { return m_video_lag; }
};
#endif
| 3,385
|
C++
|
.h
| 83
| 36.783133
| 80
| 0.716975
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,780
|
cimg_wrapper.hpp
|
GenericMadScientist_CHOpt/include/cimg_wrapper.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2022 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
// The entire purpose of this header is to include CImg with warnings
// disabled. On GCC and Clang this can be dealt with by using -Isystem, and the
// MSVC equivalent seems to be to use /external:I (see
// https://devblogs.microsoft.com/cppblog/broken-warnings-theory/). However,
// clang-cl seems to not have this available yet so this hack will have to do.
#ifndef CHOPT_CIMG_WRAPPER_HPP
#define CHOPT_CIMG_WRAPPER_HPP
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#elif defined(__GNUG__)
#pragma GCC system_header
#elif defined(_MSC_VER)
#pragma warning(push, 0)
#endif
#define cimg_display 0 // NOLINT
#define cimg_use_png
#include "CImg.h"
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif
| 1,565
|
C++
|
.h
| 41
| 36.658537
| 79
| 0.764977
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,781
|
ini.hpp
|
GenericMadScientist_CHOpt/include/ini.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_INI_HPP
#define CHOPT_INI_HPP
#include <string_view>
#include <sightread/metadata.hpp>
SightRead::Metadata parse_ini(std::string_view data);
#endif
| 908
|
C++
|
.h
| 23
| 37.565217
| 73
| 0.765909
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,782
|
processed.hpp
|
GenericMadScientist_CHOpt/include/processed.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2022, 2023, 2024 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_PROCESSED_HPP
#define CHOPT_PROCESSED_HPP
#include <limits>
#include <numeric>
#include <string>
#include <tuple>
#include <vector>
#include <sightread/drumsettings.hpp>
#include <sightread/songparts.hpp>
#include <sightread/tempomap.hpp>
#include <sightread/time.hpp>
#include "points.hpp"
#include "settings.hpp"
#include "sp.hpp"
#include "sptimemap.hpp"
struct ActivationCandidate {
PointPtr act_start;
PointPtr act_end;
SpPosition earliest_activation_point {SightRead::Beat(0.0), SpMeasure(0.0)};
SpBar sp_bar {0.0, 0.0};
};
struct ProtoActivation {
PointPtr act_start;
PointPtr act_end;
};
struct Activation {
PointPtr act_start;
PointPtr act_end;
SightRead::Beat whammy_end {0.0};
SightRead::Beat sp_start {0.0};
SightRead::Beat sp_end {0.0};
};
// Part of the return value of ProcessedSong::is_candidate_valid. Says if an
// activation is valid, and if not whether the problem is too little or too much
// Star Power.
enum class ActValidity { success, insufficient_sp, surplus_sp };
// Return value of ProcessedSong::is_candidate_valid, providing information on
// whether an activation is valid, and if so the earliest position it can end.
struct ActResult {
SpPosition ending_position;
ActValidity validity;
};
struct Path {
std::vector<Activation> activations;
int score_boost {0};
};
// Represents a song processed for Star Power optimisation. The constructor
// should only fail due to OOM; invariants on the song are supposed to be
// upheld by the constructors of the arguments.
class ProcessedSong {
private:
static constexpr double NEG_INF = -std::numeric_limits<double>::infinity();
SpTimeMap m_time_map;
PointSet m_points;
SpData m_sp_data;
double m_minimum_sp_to_activate;
int m_total_bre_boost;
int m_total_solo_boost;
int m_base_score;
bool m_ignore_average_multiplier;
bool m_is_drums;
bool m_overlaps;
SpBar sp_from_phrases(PointPtr begin, PointPtr end) const;
std::vector<std::string> act_summaries(const Path& path) const;
std::vector<std::string> drum_act_summaries(const Path& path) const;
void append_activation(std::stringstream& stream,
const Activation& activation,
const std::string& act_summary) const;
// This static function is necessary to deal with a bug in MSVC. See
// https://developercommunity.visualstudio.com/t/ICE-with-MSVC-1940-with-default-functio/10750601
// for details.
static SpPosition default_position()
{
return {SightRead::Beat {NEG_INF}, SpMeasure {NEG_INF}};
}
public:
ProcessedSong(const SightRead::NoteTrack& track, SpTimeMap time_map,
const SqueezeSettings& squeeze_settings,
const SightRead::DrumSettings& drum_settings,
const Engine& engine,
const std::vector<SightRead::Tick>& od_beats,
const std::vector<SightRead::Tick>& unison_phrases);
// Return the minimum and maximum amount of SP can be acquired between two
// points. Does not include SP from the point act_start. first_point is
// given for the purposes of counting SP grantings notes, e.g. if start is
// after the middle of first_point's timing window. All whammy up to
// required_whammy_end is mandatory.
[[nodiscard]] SpBar total_available_sp(SightRead::Beat start,
PointPtr first_point,
PointPtr act_start,
SightRead::Beat required_whammy_end
= SightRead::Beat {NEG_INF}) const;
// Similar to total_available_sp, but no whammy is required and if it is
// possible to get a half bar then the earliest position >=
// earliest_potential_pos that grants a half bar is returned along with the
// SP only up to that position.
[[nodiscard]] std::tuple<SpBar, SpPosition>
total_available_sp_with_earliest_pos(
SightRead::Beat start, PointPtr first_point, PointPtr act_start,
SpPosition earliest_potential_pos) const;
// Returns an ActResult which says if an activation is valid, and if so the
// earliest position it can end. Checks squeezes against the given amount
// only.
[[nodiscard]] ActResult is_candidate_valid(
const ActivationCandidate& activation, double squeeze = 1.0,
SpPosition required_whammy_end = default_position()) const;
// Return the summary of a path.
[[nodiscard]] std::string path_summary(const Path& path) const;
// Return the position that is (100 - squeeze)% along the start of point's
// timing window.
[[nodiscard]] SpPosition adjusted_hit_window_start(PointPtr point,
double squeeze) const;
// Return the position that is squeeze% along the end of point's timing
// window.
[[nodiscard]] SpPosition adjusted_hit_window_end(PointPtr point,
double squeeze) const;
[[nodiscard]] const PointSet& points() const { return m_points; }
[[nodiscard]] const SpData& sp_data() const { return m_sp_data; }
[[nodiscard]] const SpTimeMap& sp_time_map() const { return m_time_map; }
[[nodiscard]] bool is_drums() const { return m_is_drums; }
[[nodiscard]] double minimum_sp_to_activate() const
{
return m_minimum_sp_to_activate;
}
};
#endif
| 6,318
|
C++
|
.h
| 143
| 37.734266
| 101
| 0.682911
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,783
|
optimiser.hpp
|
GenericMadScientist_CHOpt/include/optimiser.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_OPTIMISER_HPP
#define CHOPT_OPTIMISER_HPP
#include <atomic>
#include <cassert>
#include <limits>
#include <map>
#include <optional>
#include <tuple>
#include <vector>
#include <sightread/time.hpp>
#include "points.hpp"
#include "processed.hpp"
// The class that stores extra information needed on top of a ProcessedSong for
// the purposes of optimisation, and finds the optimal path. The song passed to
// Optimiser's constructor must outlive Optimiser; the class is done this way so
// that other code can make use of the PointIters that are returned by Optimiser
// without needing access to Optimiser itself.
class Optimiser {
private:
// The Cache is used to store paths starting from a certain point onwards,
// i.e., the solution to our subproblems in our dynamic programming
// algorithm. Cache.full_sp_paths represents the best path with the first
// activation at the point key or later, under the condition there is
// already full SP there.
struct CacheKey {
PointPtr point;
SpPosition position {SightRead::Beat(0.0), SpMeasure(0.0)};
friend bool operator<(const CacheKey& lhs, const CacheKey& rhs)
{
return std::tie(lhs.point, lhs.position.beat)
< std::tie(rhs.point, rhs.position.beat);
}
};
struct CacheValue {
std::vector<std::tuple<ProtoActivation, CacheKey>> possible_next_acts;
int score_boost;
};
struct Cache {
std::map<CacheKey, CacheValue> paths;
std::map<PointPtr, CacheValue> full_sp_paths;
};
// The idea is this is like a std::set<PointPtr>, but is add-only and takes
// advantage of the fact that we often tend to add all elements before a
// certain point.
class PointPtrRangeSet {
private:
PointPtr m_start;
PointPtr m_end;
PointPtr m_min_absent_ptr;
std::vector<PointPtr> m_abnormal_elements;
public:
PointPtrRangeSet(PointPtr start, PointPtr end)
: m_start {start}
, m_end {end}
, m_min_absent_ptr {start}
{
assert(start < end); // NOLINT
}
[[nodiscard]] bool contains(PointPtr element) const
{
if (m_start > element || m_end <= element) {
return false;
}
if (element < m_min_absent_ptr) {
return true;
}
return std::find(m_abnormal_elements.cbegin(),
m_abnormal_elements.cend(), element)
!= m_abnormal_elements.cend();
}
[[nodiscard]] PointPtr lowest_absent_element() const
{
return m_min_absent_ptr;
}
void add(PointPtr element)
{
assert(m_start <= element); // NOLINT
assert(element < m_end); // NOLINT
if (m_min_absent_ptr == element) {
++m_min_absent_ptr;
while (true) {
auto next_elem_iter = std::find(m_abnormal_elements.begin(),
m_abnormal_elements.end(),
m_min_absent_ptr);
if (next_elem_iter == m_abnormal_elements.end()) {
return;
}
std::swap(*next_elem_iter, m_abnormal_elements.back());
m_abnormal_elements.pop_back();
++m_min_absent_ptr;
}
} else {
m_abnormal_elements.push_back(element);
}
}
};
static constexpr double NEG_INF = -std::numeric_limits<double>::infinity();
static constexpr double BASE_DRUM_FILL_DELAY = 2.0 * 100;
const ProcessedSong* m_song;
const std::atomic<bool>* m_terminate;
const SightRead::Second m_drum_fill_delay;
SightRead::Second m_whammy_delay;
std::vector<PointPtr> m_next_candidate_points;
[[nodiscard]] PointPtr next_candidate_point(PointPtr point) const;
[[nodiscard]] CacheKey advance_cache_key(CacheKey key) const;
[[nodiscard]] CacheKey add_whammy_delay(CacheKey key) const;
[[nodiscard]] std::optional<CacheValue>
try_previous_best_subpaths(CacheKey key, const Cache& cache,
bool has_full_sp) const;
CacheValue find_best_subpaths(CacheKey key, Cache& cache,
bool has_full_sp) const;
int get_partial_path(CacheKey key, Cache& cache) const;
int get_partial_full_sp_path(PointPtr point, Cache& cache) const;
[[nodiscard]] double act_squeeze_level(ProtoActivation act,
CacheKey key) const;
[[nodiscard]] SpPosition forced_whammy_end(ProtoActivation act,
CacheKey key,
double sqz_level) const;
[[nodiscard]] std::tuple<SightRead::Beat, SightRead::Beat>
act_duration(ProtoActivation act, CacheKey key, double sqz_level,
SpPosition min_whammy_force) const;
[[nodiscard]] SightRead::Second
earliest_fill_appearance(CacheKey key, bool has_full_sp) const;
void complete_subpath(
PointPtr p, SpPosition starting_pos, SpBar sp_bar,
PointPtrRangeSet& attained_act_ends, Cache& cache,
int& best_score_boost,
std::vector<std::tuple<ProtoActivation, CacheKey>>& acts) const;
public:
Optimiser(const ProcessedSong* song, const std::atomic<bool>* terminate,
int speed, SightRead::Second whammy_delay);
// Return the optimal Star Power path.
[[nodiscard]] Path optimal_path() const;
};
#endif
| 6,475
|
C++
|
.h
| 152
| 33.263158
| 80
| 0.619727
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,784
|
stringutil.hpp
|
GenericMadScientist_CHOpt/include/stringutil.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_STRINGUTIL_HPP
#define CHOPT_STRINGUTIL_HPP
#include <string>
#include <string_view>
// This returns a string_view from the start of input until a carriage return
// or newline. input is changed to point to the first character past the
// detected newline character that is not a whitespace character.
std::string_view break_off_newline(std::string_view& input);
std::string_view skip_whitespace(std::string_view input);
std::string to_ordinal(int ordinal);
// Convert a UTF-8 or UTF-16le string to a UTF-8 string.
std::string to_utf8_string(std::string_view input);
#endif
| 1,348
|
C++
|
.h
| 30
| 43.166667
| 77
| 0.768879
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,785
|
settings.hpp
|
GenericMadScientist_CHOpt/include/settings.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2022, 2023, 2024 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_SETTINGS_HPP
#define CHOPT_SETTINGS_HPP
#include <memory>
#include <set>
#include <string>
#include <QStringList>
#include <sightread/drumsettings.hpp>
#include <sightread/songparts.hpp>
#include <sightread/time.hpp>
#include "engine.hpp"
enum class Game {
CloneHero,
FortniteFestival,
GuitarHeroOne,
RockBand,
RockBandThree
};
std::unique_ptr<Engine> game_to_engine(Game game,
SightRead::Instrument instrument,
bool precision_mode);
struct SqueezeSettings {
double squeeze;
double early_whammy;
SightRead::Second lazy_whammy {0.0};
SightRead::Second video_lag {0.0};
SightRead::Second whammy_delay {0.0};
static SqueezeSettings default_settings()
{
return {1.0, 1.0, SightRead::Second(0.0), SightRead::Second(0.0),
SightRead::Second(0.0)};
}
};
// This struct represents the options chosen on the command line by the user.
struct Settings {
bool blank;
std::string filename;
std::string image_path;
bool draw_image;
bool draw_bpms;
bool draw_solos;
bool draw_time_sigs;
SightRead::Difficulty difficulty;
SightRead::Instrument instrument;
SqueezeSettings squeeze_settings;
int speed;
bool is_lefty_flip;
Game game;
std::unique_ptr<Engine> engine;
SightRead::DrumSettings drum_settings;
float opacity;
};
// Parses the command line options.
Settings from_args(const QStringList& args);
#endif
| 2,301
|
C++
|
.h
| 71
| 27.943662
| 77
| 0.709648
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,786
|
imagebuilder.hpp
|
GenericMadScientist_CHOpt/include/imagebuilder.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2022, 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_IMAGEBUILDER_HPP
#define CHOPT_IMAGEBUILDER_HPP
#include <atomic>
#include <functional>
#include <string>
#include <tuple>
#include <vector>
#include <sightread/drumsettings.hpp>
#include <sightread/song.hpp>
#include <sightread/songparts.hpp>
#include <sightread/tempomap.hpp>
#include "engine.hpp"
#include "points.hpp"
#include "processed.hpp"
#include "sp.hpp"
#include "sptimemap.hpp"
struct DrawnRow {
double start;
double end;
};
struct DrawnNote {
double beat;
std::array<double, 7> lengths;
SightRead::NoteFlags note_flags;
bool is_sp_note;
};
class ImageBuilder {
private:
SightRead::TrackType m_track_type;
SightRead::Difficulty m_difficulty;
bool m_is_lefty_flip;
std::vector<DrawnRow> m_rows;
std::vector<double> m_half_beat_lines;
std::vector<double> m_beat_lines;
std::vector<double> m_measure_lines;
std::vector<std::tuple<double, double>> m_bpms;
std::vector<std::tuple<double, int, int>> m_time_sigs;
std::vector<DrawnNote> m_notes;
std::vector<int> m_base_values;
std::vector<int> m_score_values;
std::vector<double> m_sp_percent_values;
std::vector<double> m_sp_values;
std::string m_song_name;
std::string m_artist;
std::string m_charter;
std::vector<std::tuple<double, double>> m_green_ranges;
std::vector<std::tuple<double, double>> m_blue_ranges;
std::vector<std::tuple<double, double>> m_red_ranges;
std::vector<std::tuple<double, double>> m_yellow_ranges;
std::vector<std::tuple<double, double>> m_solo_ranges;
std::vector<std::tuple<double, std::string>> m_practice_sections;
std::vector<std::tuple<double, double>> m_bre_ranges;
std::vector<std::tuple<double, double>> m_fill_ranges;
std::vector<std::tuple<double, double>> m_unison_ranges;
float m_activation_opacity {0.33F};
int m_total_score {0};
bool m_overlap_engine {true};
void form_beat_lines(const SightRead::TempoMap& tempo_map);
static bool is_neutralised_phrase(SightRead::Beat note_pos,
const Path& path);
std::tuple<double, double>
sp_phrase_bounds(const SightRead::StarPower& phrase,
const SightRead::NoteTrack& track, const Path& path) const;
public:
ImageBuilder(const SightRead::NoteTrack& track,
SightRead::Difficulty difficulty,
const SightRead::DrumSettings& drum_settings,
bool is_lefty_flip, bool is_overlap_engine);
void add_bpms(const SightRead::TempoMap& tempo_map);
void add_bre(const SightRead::BigRockEnding& bre,
const SightRead::TempoMap& tempo_map);
void add_drum_fills(const SightRead::NoteTrack& track);
void add_measure_values(const PointSet& points,
const SightRead::TempoMap& tempo_map,
const Path& path);
void add_practice_sections(
const std::vector<SightRead::PracticeSection>& practice_sections,
const SightRead::TempoMap& tempo_map);
void add_solo_sections(const std::vector<SightRead::Solo>& solos,
const SightRead::TempoMap& tempo_map);
void add_song_header(const SightRead::SongGlobalData& global_data);
void add_sp_acts(const PointSet& points,
const SightRead::TempoMap& tempo_map, const Path& path);
void add_sp_percent_values(const SpData& sp_data, const SpTimeMap& time_map,
const PointSet& points, const Path& path);
void add_sp_phrases(const SightRead::NoteTrack& track,
const std::vector<SightRead::Tick>& unison_phrases,
const Path& path);
void add_sp_values(const SpData& sp_data, const Engine& engine);
void add_time_sigs(const SightRead::TempoMap& tempo_map);
void set_total_score(const PointSet& points,
const std::vector<SightRead::Solo>& solos,
const Path& path);
[[nodiscard]] const std::string& artist() const { return m_artist; }
[[nodiscard]] const std::vector<int>& base_values() const
{
return m_base_values;
}
[[nodiscard]] const std::vector<double>& beat_lines() const
{
return m_beat_lines;
}
[[nodiscard]] const std::vector<std::tuple<double, double>>&
blue_ranges() const
{
return m_blue_ranges;
}
[[nodiscard]] const std::vector<std::tuple<double, double>>& bpms() const
{
return m_bpms;
}
[[nodiscard]] const std::vector<std::tuple<double, double>>&
bre_ranges() const
{
return m_bre_ranges;
}
[[nodiscard]] const std::string& charter() const { return m_charter; }
[[nodiscard]] const std::vector<std::tuple<double, double>>&
fill_ranges() const
{
return m_fill_ranges;
}
[[nodiscard]] const std::vector<std::tuple<double, double>>&
green_ranges() const
{
return m_green_ranges;
}
[[nodiscard]] const std::vector<double>& half_beat_lines() const
{
return m_half_beat_lines;
}
[[nodiscard]] const std::vector<double>& measure_lines() const
{
return m_measure_lines;
}
[[nodiscard]] const std::vector<DrawnNote>& notes() const
{
return m_notes;
}
[[nodiscard]] const std::vector<std::tuple<double, std::string>>&
practice_sections() const
{
return m_practice_sections;
}
[[nodiscard]] const std::vector<std::tuple<double, double>>&
red_ranges() const
{
return m_red_ranges;
}
[[nodiscard]] const std::vector<DrawnRow>& rows() const { return m_rows; }
[[nodiscard]] const std::vector<int>& score_values() const
{
return m_score_values;
}
[[nodiscard]] const std::vector<std::tuple<double, double>>&
solo_ranges() const
{
return m_solo_ranges;
}
[[nodiscard]] const std::string& song_name() const { return m_song_name; }
[[nodiscard]] const std::vector<double>& sp_percent_values() const
{
return m_sp_percent_values;
}
[[nodiscard]] const std::vector<double>& sp_values() const
{
return m_sp_values;
}
[[nodiscard]] const std::vector<std::tuple<double, int, int>>&
time_sigs() const
{
return m_time_sigs;
}
[[nodiscard]] SightRead::TrackType track_type() const
{
return m_track_type;
}
[[nodiscard]] const std::vector<std::tuple<double, double>>&
unison_ranges() const
{
return m_unison_ranges;
}
[[nodiscard]] const std::vector<std::tuple<double, double>>&
yellow_ranges() const
{
return m_yellow_ranges;
}
[[nodiscard]] float activation_opacity() const
{
return m_activation_opacity;
}
float& activation_opacity() { return m_activation_opacity; }
[[nodiscard]] int total_score() const { return m_total_score; }
[[nodiscard]] SightRead::Difficulty difficulty() const
{
return m_difficulty;
}
[[nodiscard]] bool is_lefty_flip() const { return m_is_lefty_flip; }
};
ImageBuilder make_builder(SightRead::Song& song,
const SightRead::NoteTrack& track,
const Settings& settings,
const std::function<void(const char*)>& write,
const std::atomic<bool>* terminate);
#endif
| 8,198
|
C++
|
.h
| 222
| 30.396396
| 80
| 0.646786
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,787
|
sptimemap.hpp
|
GenericMadScientist_CHOpt/include/sptimemap.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_SPTIMEMAP_HPP
#define CHOPT_SPTIMEMAP_HPP
#include <utility>
#include <sightread/tempomap.hpp>
class SpMeasure {
private:
double m_value;
public:
explicit SpMeasure(double value)
: m_value {value}
{
}
[[nodiscard]] double value() const { return m_value; }
[[nodiscard]] SightRead::Beat to_beat(double beat_rate) const
{
return SightRead::Beat(m_value * beat_rate);
}
std::partial_ordering operator<=>(const SpMeasure& rhs) const
{
return m_value <=> rhs.m_value;
}
SpMeasure& operator+=(const SpMeasure& rhs)
{
m_value += rhs.m_value;
return *this;
}
SpMeasure& operator-=(const SpMeasure& rhs)
{
m_value -= rhs.m_value;
return *this;
}
SpMeasure& operator*=(double rhs)
{
m_value *= rhs;
return *this;
}
friend SpMeasure operator+(SpMeasure lhs, const SpMeasure& rhs)
{
lhs += rhs;
return lhs;
}
friend SpMeasure operator-(SpMeasure lhs, const SpMeasure& rhs)
{
lhs -= rhs;
return lhs;
}
friend SpMeasure operator*(SpMeasure lhs, double rhs)
{
lhs *= rhs;
return lhs;
}
friend double operator/(const SpMeasure& lhs, const SpMeasure& rhs)
{
return lhs.m_value / rhs.m_value;
}
};
struct SpPosition {
SightRead::Beat beat;
SpMeasure sp_measure;
};
enum class SpMode { Measure, OdBeat };
class SpTimeMap {
private:
SightRead::TempoMap m_tempo_map;
SpMode m_sp_mode;
public:
SpTimeMap(SightRead::TempoMap tempo_map, SpMode sp_mode)
: m_tempo_map {std::move(tempo_map)}
, m_sp_mode {sp_mode}
{
}
[[nodiscard]] SightRead::Beat to_beats(SightRead::Second seconds) const;
[[nodiscard]] SightRead::Beat to_beats(SpMeasure sp_measures) const;
[[nodiscard]] SightRead::Beat to_beats(SightRead::Tick ticks) const;
[[nodiscard]] SightRead::Second to_seconds(SightRead::Beat beats) const;
[[nodiscard]] SightRead::Second to_seconds(SpMeasure sp_measures) const;
[[nodiscard]] SpMeasure to_sp_measures(SightRead::Beat beats) const;
[[nodiscard]] SpMeasure to_sp_measures(SightRead::Second seconds) const;
};
#endif
| 3,005
|
C++
|
.h
| 97
| 26.216495
| 76
| 0.675788
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,788
|
sp.hpp
|
GenericMadScientist_CHOpt/include/sp.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_SP_HPP
#define CHOPT_SP_HPP
#include <algorithm>
#include <limits>
#include <tuple>
#include <vector>
#include <sightread/songparts.hpp>
#include <sightread/tempomap.hpp>
#include <sightread/time.hpp>
#include "engine.hpp"
#include "settings.hpp"
#include "sptimemap.hpp"
// Represents the minimum and maximum SP possible at a given time.
class SpBar {
private:
double m_min;
double m_max;
public:
SpBar(double min, double max)
: m_min {min}
, m_max {max}
{
}
double& min() { return m_min; }
double& max() { return m_max; }
[[nodiscard]] double min() const { return m_min; }
[[nodiscard]] double max() const { return m_max; }
void add_phrase()
{
constexpr double SP_PHRASE_AMOUNT = 0.25;
m_min += SP_PHRASE_AMOUNT;
m_max += SP_PHRASE_AMOUNT;
m_min = std::min(m_min, 1.0);
m_max = std::min(m_max, 1.0);
}
[[nodiscard]] bool
full_enough_to_activate(double minimum_sp_to_activate) const
{
return m_max >= minimum_sp_to_activate;
}
};
// This is used by the optimiser to calculate SP drain.
class SpData {
private:
struct BeatRate {
SightRead::Beat position;
double net_sp_gain_rate;
};
struct WhammyRange {
SpPosition start;
SpPosition end;
SightRead::Beat note;
};
struct WhammyPropagationState {
std::vector<BeatRate>::const_iterator current_beat_rate;
SightRead::Beat current_position;
double current_sp;
};
static constexpr double DEFAULT_BEATS_PER_BAR = 32.0;
static constexpr double MEASURES_PER_BAR = 8.0;
SpTimeMap m_time_map;
std::vector<BeatRate> m_beat_rates;
std::vector<WhammyRange> m_whammy_ranges;
SightRead::Beat m_last_whammy_point {
-std::numeric_limits<double>::infinity()};
std::vector<std::vector<WhammyRange>::const_iterator> m_initial_guesses;
const double m_sp_gain_rate;
const double m_default_net_sp_gain_rate;
static std::vector<BeatRate>
form_beat_rates(const SightRead::TempoMap& tempo_map,
const std::vector<SightRead::Tick>& od_beats,
const Engine& engine);
[[nodiscard]] double
propagate_over_whammy_range(SightRead::Beat start, SightRead::Beat end,
double sp_bar_amount) const;
[[nodiscard]] SightRead::Beat
whammy_propagation_endpoint(SightRead::Beat start, SightRead::Beat end,
double sp_bar_amount) const;
[[nodiscard]] std::vector<WhammyRange>::const_iterator
first_whammy_range_after(SightRead::Beat pos) const;
[[nodiscard]] WhammyPropagationState
initial_whammy_prop_state(SightRead::Beat start, SightRead::Beat end,
double sp_bar_amount) const;
SpPosition sp_drain_end_point(SpPosition start, double sp_bar_amount) const;
public:
SpData(const SightRead::NoteTrack& track, SpTimeMap time_map,
const std::vector<SightRead::Tick>& od_beats,
const SqueezeSettings& squeeze_settings, const Engine& engine);
// Return the maximum amount of SP available at the end after propagating
// over a range, or -1 if SP runs out at any point. Only includes SP gain
// from whammy.
[[nodiscard]] double propagate_sp_over_whammy_max(SpPosition start,
SpPosition end,
double sp) const;
// Return the minimum amount of SP is available at the end after propagating
// over a range, returning 0.0 if the minimum would hypothetically be
// negative.
[[nodiscard]] double
propagate_sp_over_whammy_min(SpPosition start, SpPosition end, double sp,
SpPosition required_whammy_end) const;
// Return if a beat is at a place that can be whammied.
[[nodiscard]] bool is_in_whammy_ranges(SightRead::Beat beat) const;
// Return the amount of whammy obtainable across a range.
[[nodiscard]] double available_whammy(SightRead::Beat start,
SightRead::Beat end) const;
// Return the amount of whammy obtainable across a range, from notes before
// note_pos.
[[nodiscard]] double available_whammy(SightRead::Beat start,
SightRead::Beat end,
SightRead::Beat note_pos) const;
// Return how far an activation can propagate based on whammy, returning the
// end of the range if it can be reached.
[[nodiscard]] SpPosition activation_end_point(SpPosition start,
SpPosition end,
double sp_bar_amount) const;
};
#endif
| 5,606
|
C++
|
.h
| 134
| 33.80597
| 80
| 0.645333
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,789
|
image.hpp
|
GenericMadScientist_CHOpt/include/image.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2022 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_IMAGE_HPP
#define CHOPT_IMAGE_HPP
#include <memory>
#include "imagebuilder.hpp"
class ImageImpl;
class Image {
private:
std::unique_ptr<ImageImpl> m_impl;
public:
explicit Image(const ImageBuilder& builder);
~Image();
Image(const Image&) = delete;
Image(Image&& image) noexcept;
Image& operator=(const Image&) = delete;
Image& operator=(Image&& image) noexcept;
void save(const char* filename) const;
};
#endif
| 1,212
|
C++
|
.h
| 35
| 32.028571
| 73
| 0.744226
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,791
|
test_helpers.hpp
|
GenericMadScientist_CHOpt/tests/test_helpers.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2023 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_TESTHELPERS_HPP
#define CHOPT_TESTHELPERS_HPP
#include <cmath>
#include <iomanip>
#include <ostream>
#include <tuple>
#include <vector>
#include <boost/test/unit_test.hpp>
#include <sightread/songparts.hpp>
#include <sightread/time.hpp>
#include "imagebuilder.hpp"
#include "points.hpp"
#include "processed.hpp"
#include "sp.hpp"
inline std::ostream& operator<<(std::ostream& stream, ActValidity validity)
{
stream << static_cast<int>(validity);
return stream;
}
inline bool operator==(const Activation& lhs, const Activation& rhs)
{
return std::tie(lhs.act_start, lhs.act_end)
== std::tie(rhs.act_start, rhs.act_end)
&& std::abs(lhs.sp_start.value() - rhs.sp_start.value()) < 0.01
&& std::abs(lhs.sp_end.value() - rhs.sp_end.value()) < 0.01;
}
inline std::ostream& operator<<(std::ostream& stream, const Activation& act)
{
stream << "{Start " << &(*act.act_start) << ", End " << &(*act.act_end)
<< ", SPStart " << act.sp_start.value() << "b, SPEnd "
<< act.sp_end.value() << "b}";
return stream;
}
inline bool operator==(const DrawnNote& lhs, const DrawnNote& rhs)
{
for (auto i = 0; i < 7; ++i) {
if (std::abs(lhs.lengths[i] - rhs.lengths[i]) >= 0.000001) {
return false;
}
}
return std::abs(lhs.beat - rhs.beat) < 0.000001
&& std::tie(lhs.note_flags, lhs.is_sp_note)
== std::tie(rhs.note_flags, rhs.is_sp_note);
}
inline std::ostream& operator<<(std::ostream& stream, const DrawnNote& note)
{
stream << '{' << note.beat << "b, ";
for (auto i = 0; i < 7; ++i) {
if (note.lengths[i] != -1) {
stream << "Colour " << i << " with Length " << note.lengths[i]
<< ", ";
}
}
stream << ", Is SP Note " << note.is_sp_note << '}';
return stream;
}
inline bool operator==(const DrawnRow& lhs, const DrawnRow& rhs)
{
return std::abs(lhs.start - rhs.start) < 0.000001
&& std::abs(lhs.end - rhs.end) < 0.000001;
}
inline std::ostream& operator<<(std::ostream& stream, const DrawnRow& row)
{
stream << '{' << row.start << ", " << row.end << '}';
return stream;
}
inline std::ostream& operator<<(std::ostream& stream, PointPtr addr)
{
stream << "Point @ " << &(*addr);
return stream;
}
inline bool operator==(const SpBar& lhs, const SpBar& rhs)
{
return std::abs(lhs.min() - rhs.min()) < 0.000001
&& std::abs(lhs.max() - rhs.max()) < 0.000001;
}
inline std::ostream& operator<<(std::ostream& stream, const SpBar& sp)
{
stream << "{Min " << sp.min() << ", Max " << sp.max() << '}';
return stream;
}
inline bool operator==(const SpMeasure& lhs, const SpMeasure& rhs)
{
return std::abs(lhs.value() - rhs.value()) < 0.000001;
}
inline std::ostream& operator<<(std::ostream& stream, SpMeasure measure)
{
stream << measure.value() << 'm';
return stream;
}
inline bool operator==(const SpPosition& lhs, const SpPosition& rhs)
{
return std::abs(lhs.beat.value() - rhs.beat.value()) <= 0.01
&& lhs.sp_measure == rhs.sp_measure;
}
inline std::ostream& operator<<(std::ostream& stream,
const SpPosition& position)
{
stream << "{Beat " << position.beat << ", SpMeasure" << position.sp_measure
<< '}';
return stream;
}
inline std::ostream& operator<<(std::ostream& stream,
const std::tuple<SpPosition, int>& tuple)
{
stream << '{' << std::get<0>(tuple) << ", " << std::get<1>(tuple) << '}';
return stream;
}
inline SightRead::Note make_note(int position, int length = 0,
SightRead::FiveFretNotes colour
= SightRead::FIVE_FRET_GREEN)
{
SightRead::Note note;
note.position = SightRead::Tick {position};
note.flags = SightRead::FLAGS_FIVE_FRET_GUITAR;
note.lengths[colour] = SightRead::Tick {length};
return note;
}
inline SightRead::Note make_chord(
int position,
const std::vector<std::tuple<SightRead::FiveFretNotes, int>>& lengths)
{
SightRead::Note note;
note.position = SightRead::Tick {position};
note.flags = SightRead::FLAGS_FIVE_FRET_GUITAR;
for (auto& [lane, length] : lengths) {
note.lengths[lane] = SightRead::Tick {length};
}
return note;
}
inline SightRead::Note make_ghl_note(int position, int length = 0,
SightRead::SixFretNotes colour
= SightRead::SIX_FRET_WHITE_LOW)
{
SightRead::Note note;
note.position = SightRead::Tick {position};
note.flags = SightRead::FLAGS_SIX_FRET_GUITAR;
note.lengths[colour] = SightRead::Tick {length};
return note;
}
inline SightRead::Note
make_drum_note(int position, SightRead::DrumNotes colour = SightRead::DRUM_RED,
SightRead::NoteFlags flags = SightRead::FLAGS_NONE)
{
SightRead::Note note;
note.position = SightRead::Tick {position};
note.flags
= static_cast<SightRead::NoteFlags>(flags | SightRead::FLAGS_DRUMS);
note.lengths[colour] = SightRead::Tick {0};
return note;
}
#endif
| 5,902
|
C++
|
.h
| 169
| 30.017751
| 79
| 0.631136
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,792
|
json_settings.hpp
|
GenericMadScientist_CHOpt/gui/json_settings.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2022 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_JSON_SETTINGS_HPP
#define CHOPT_JSON_SETTINGS_HPP
#include <string_view>
struct JsonSettings {
int squeeze;
int early_whammy;
int lazy_whammy;
int whammy_delay;
int video_lag;
bool is_lefty_flip;
};
JsonSettings load_saved_settings(std::string_view application_dir);
void save_settings(const JsonSettings& settings,
std::string_view application_dir);
#endif
| 1,161
|
C++
|
.h
| 32
| 33.28125
| 73
| 0.74911
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,793
|
mainwindow.hpp
|
GenericMadScientist_CHOpt/gui/mainwindow.hpp
|
/*
* CHOpt - Star Power optimiser for Clone Hero
* Copyright (C) 2020, 2021, 2023, 2024 Raymond Wright
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef CHOPT_MAINWINDOW_HPP
#define CHOPT_MAINWINDOW_HPP
#include <memory>
#include <optional>
#include <set>
#include <QMainWindow>
#include <QString>
#include <QThread>
#include <sightread/song.hpp>
#include "settings.hpp"
#include "songfile.hpp"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
private:
std::unique_ptr<Ui::MainWindow> m_ui;
std::optional<SongFile> m_loaded_file;
std::unique_ptr<QThread> m_thread;
Settings get_settings() const;
void load_file(const QString& file_name);
void populate_games(const std::set<Game>& games);
static constexpr int MAX_SPEED = 5000;
static constexpr int MIN_SPEED = 5;
protected:
void dragEnterEvent(QDragEnterEvent* event) override;
void dropEvent(QDropEvent* event) override;
public:
explicit MainWindow(QWidget* parent = nullptr);
~MainWindow();
private slots:
void clear_worker_thread();
void on_earlyWhammySlider_valueChanged(int value);
void on_engineComboBox_currentIndexChanged(int index);
void on_findPathButton_clicked();
void on_instrumentComboBox_currentIndexChanged(int index);
void on_opacitySlider_valueChanged(int value);
void on_selectFileButton_clicked();
void on_squeezeSlider_valueChanged(int value);
void on_videoLagSlider_valueChanged(int value);
void parsing_failed(const QString& file_name);
void path_found();
void song_read(SongFile loaded_file, const std::set<Game>& games,
const QString& file_name);
void write_message(const QString& message);
};
#endif
| 2,360
|
C++
|
.h
| 65
| 32.984615
| 73
| 0.749014
|
GenericMadScientist/CHOpt
| 33
| 4
| 5
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,794
|
flwidget.cpp
|
CryFeiFei_FLWidget/flwidget.cpp
|
#include "flwidget.h"
#ifdef Q_OS_WIN
#include <windows.h>
#include <windowsx.h>
#include <QMouseEvent>
#endif
namespace
{
constexpr int BOUDERWIDTH = 10;
}
FLWidget::FLWidget(QWidget *parent) : QWidget(parent), m_bouderWidth(BOUDERWIDTH)
{
setMouseTracking(true);
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
setStyleSheet("background:red");
setAttribute(Qt::WA_ShowModal);
resize(500, 500);
}
FLWidget::~FLWidget()
{
}
void FLWidget::mousePressEvent(QMouseEvent *e)
{
#ifdef Q_OS_WIN
if (e->button() == Qt::LeftButton)
m_curPos = e->pos();
#endif
return QWidget::mousePressEvent(e);
}
void FLWidget::mouseMoveEvent(QMouseEvent *e)
{
#ifdef Q_OS_WIN
if (e->buttons() & Qt::LeftButton)
move(e->pos() + pos() - m_curPos);
#endif
return QWidget::mouseMoveEvent(e);
}
bool FLWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
#ifdef Q_OS_WIN
MSG* msg = (MSG*)message;
switch(msg->message)
{
case WM_NCHITTEST:
int xPos = GET_X_LPARAM(msg->lParam) - this->frameGeometry().x();
int yPos = GET_Y_LPARAM(msg->lParam) - this->frameGeometry().y();
int nUseFulWidth = width() - m_bouderWidth;
int nUseFulHeight = height() - m_bouderWidth;
if (xPos < m_bouderWidth && yPos < m_bouderWidth) //左上角
*result = HTTOPLEFT;
else if (xPos>= nUseFulWidth && yPos < m_bouderWidth) //右上角
*result = HTTOPRIGHT;
else if (xPos < m_bouderWidth && yPos >= nUseFulHeight) //左下角
*result = HTBOTTOMLEFT;
else if (xPos >= nUseFulWidth && yPos >= nUseFulHeight) //右下角
*result = HTBOTTOMRIGHT;
else if (xPos < m_bouderWidth) //左边
*result = HTLEFT;
else if (xPos >= nUseFulWidth) //右边
*result = HTRIGHT;
else if (yPos < m_bouderWidth) //上边
*result = HTTOP;
else if (yPos >= nUseFulHeight) //下边
*result = HTBOTTOM;
else
return false;
return true;
}
#endif
return QWidget::nativeEvent(eventType, message, result); //此处返回false,留给其他事件处理器处理
}
| 2,026
|
C++
|
.cpp
| 71
| 24.957746
| 84
| 0.701389
|
CryFeiFei/FLWidget
| 32
| 12
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,797
|
flwidget_linux.cpp
|
CryFeiFei_FLWidget/flwidget_linux.cpp
|
#include "flwidget_linux.h"
#include <QLayout>
#include <QMouseEvent>
namespace
{
#define ResizeHandleWidth 10
}
FLWidget_Linux::FLWidget_Linux(QWidget *parent) : QWidget(parent)
{
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
setStyleSheet("background-color:red;");
QHBoxLayout* layoutMain = new QHBoxLayout(this);
layoutMain->setContentsMargins(ResizeHandleWidth, ResizeHandleWidth, ResizeHandleWidth, ResizeHandleWidth);
this->setLayout(layoutMain);
resizingCornerEdge = XUtils::CornerEdge::kInvalid;
setMouseTracking(true);
XUtils::SetMouseTransparent(this, true);
setAttribute(Qt::WA_ShowModal);
resize(400, 400);
}
void FLWidget_Linux::mouseMoveEvent(QMouseEvent *event)
{
#ifdef Q_OS_LINUX
const int x = event->x();
const int y = event->y();
if (resizingCornerEdge == XUtils::CornerEdge::kInvalid)
{
XUtils::UpdateCursorShape(this, x, y, this->layout()->contentsMargins(), ResizeHandleWidth);
}
#endif
return QWidget::mouseMoveEvent(event);
}
void FLWidget_Linux::mousePressEvent(QMouseEvent *event)
{
#ifdef Q_OS_LINUX
const int x = event->x();
const int y = event->y();
if (event->button() == Qt::LeftButton)
{
const XUtils::CornerEdge ce = XUtils::GetCornerEdge(this, x, y, this->layout()->contentsMargins(), ResizeHandleWidth);
if (ce != XUtils::CornerEdge::kInvalid)
{
resizingCornerEdge = ce;
//send x11 move event dont send mouserrelease event
XUtils::SendButtonRelease(this, event->pos(), event->globalPos());
XUtils::StartResizing(this, QCursor::pos(), ce);
}
}
#endif
return QWidget::mousePressEvent(event);
}
void FLWidget_Linux::resizeEvent(QResizeEvent *e)
{
#ifdef Q_OS_LINUX
int resizeHandleWidth = ResizeHandleWidth;
XUtils::SetWindowExtents(this, this->layout()->contentsMargins(), resizeHandleWidth);
#endif
return QWidget::resizeEvent(e);
}
void FLWidget_Linux::mouseReleaseEvent(QMouseEvent *event)
{
#ifdef Q_OS_LINUX
resizingCornerEdge = XUtils::CornerEdge::kInvalid;
#endif
return QWidget::mouseReleaseEvent(event);
}
| 2,020
|
C++
|
.cpp
| 66
| 28.636364
| 120
| 0.771649
|
CryFeiFei/FLWidget
| 32
| 12
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,800
|
flwidget.h
|
CryFeiFei_FLWidget/flwidget.h
|
#ifndef FLWIDGET_H
#define FLWIDGET_H
#include <QWidget>
#include <QMouseEvent>
class FLWidget : public QWidget
{
Q_OBJECT
public:
explicit FLWidget(QWidget *parent = nullptr);
~FLWidget();
public:
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
void mousePressEvent(QMouseEvent* e) override;
void mouseMoveEvent(QMouseEvent* e) override;
private:
int m_bouderWidth;
QPoint m_curPos;
signals:
};
#endif // FLWIDGET_H
| 469
|
C++
|
.h
| 20
| 21.7
| 85
| 0.79638
|
CryFeiFei/FLWidget
| 32
| 12
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,801
|
t265wrapper.cpp
|
pietroglyph_ftc265/lib/src/main/cpp/t265wrapper.cpp
|
// Copyright 2020-2021 Declan Freeman-Gleason
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser 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 Lesser General Public
// License along with this program. If not, see
// <https://www.gnu.org/licenses/>.
#include "t265wrapper.hpp"
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iterator>
#include <thread>
#include <vector>
#include <android/log.h>
// We use jlongs like pointers, so they better be large enough
static_assert(sizeof(jlong) >= sizeof(void *));
// Constants
constexpr auto originNodeName = "origin";
constexpr auto exportRelocMapStopDelay = std::chrono::seconds(10);
constexpr auto logTag = "ftc265";
// We cache all of these because we can
jclass holdingClass = nullptr; // This should always be the T265Camera jclass
jfieldID handleFieldId =
nullptr; // Field id for the field "nativeCameraObjectPointer"
jclass exception = nullptr; // This is "CameraJNIException"
std::vector<deviceAndSensors *> toBeCleaned;
std::mutex cleanupMutex;
/*
* A note on coordinate systems:
*
* Relative to the robot, the camera's Y is up and down, Z is forward and back,
* and X is side to side.
*
* Conversions are:
* Camera Z -> Robot X * -1
* Camera X -> Robot Y * -1
* Camera Quaternion -> Counter-clockwise Euler angles (currently just yaw)
*
* For ease of use, all coordinates that come out of this wrapper are in this
* "robot standard" coordinate system.
*/
// We do this so we don't have to fiddle with files
// Most of the below fields are supposed to be "ignored"
// See
// https://github.com/IntelRealSense/librealsense/blob/master/doc/t265.md#wheel-odometry-calibration-file-format
constexpr auto odometryConfig = R"(
{
"velocimeters": [
{
"scale_and_alignment": [
1.0,
0.0000000000000000,
0.0000000000000000,
0.0000000000000000,
1.0,
0.0000000000000000,
0.0000000000000000,
0.0000000000000000,
1.0
],
"noise_variance": %f,
"extrinsics": {
"T": [
%f,
0.0,
%f
],
"T_variance": [
9.999999974752427e-7,
9.999999974752427e-7,
9.999999974752427e-7
],
"W": [
0.0,
%f,
0.0
],
"W_variance": [
9.999999974752427e-5,
9.999999974752427e-5,
9.999999974752427e-5
]
}
}
]
}
)";
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) {
JNIEnv *env;
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK) {
__android_log_print(ANDROID_LOG_ERROR, logTag,
"Native code initialization failed! Wrong JNI version");
return JNI_ERR;
}
__android_log_print(ANDROID_LOG_INFO, logTag, "Native code initialized");
return JNI_VERSION_1_6;
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_spartronics4915_lib_T265Camera_newCamera(JNIEnv *env, jobject thisObj,
jstring mapPath) {
// This locking scheme is very conservative. This is important. When the T265
// is attached from a cold boot, it will first present as a Movidius device,
// which is handled on the Java end and ultimately gets passed to this code to
// be initialized. As we initialize it the camera appears to reboot (?),
// disconnect, and then reconnect with the T265 VID/PID. If we do not protect
// the entire init process *and* free process with a mutex then we'll end up
// free'ing this camera while we're still initializing. This global mutex also
// protects us from initialzing two cameras at once. Initialzing two cameras
// at once isn't theoretically a problem if they aren't the same USB device,
// but we don't discriminate and it's possible that the same USB device would
// be picked by both inits. Ultimately, forcing inits and frees to run in
// serial *globally* is in our best interest.
std::scoped_lock lk(cleanupMutex);
try {
rs2::context ctx;
ensureCache(env, thisObj);
deviceAndSensors *devAndSensors = nullptr;
try {
devAndSensors = getDeviceFromClass(env, thisObj);
} catch (std::runtime_error &) {
// Ignore the exception and check manually below
}
if (devAndSensors && devAndSensors->isRunning)
throw std::runtime_error("Can't make a new camera if the calling class "
"already has one (you need to call free first)");
auto pipeline = new rs2::pipeline();
// Set up a config to ensure we only get tracking capable devices
auto config = rs2::config();
config.disable_all_streams();
config.enable_stream(RS2_STREAM_POSE, RS2_FORMAT_6DOF);
// Get the currently used device
auto profile = config.resolve(*pipeline);
auto device = profile.get_device();
if (!device.is<rs2::tm2>()) {
throw std::runtime_error(
"The device you have plugged in is not tracking-capable");
}
// Get the odometry/pose sensors
// For the T265 both odom and pose will be from the *same* sensor
rs2::wheel_odometer *odom = nullptr;
rs2::pose_sensor *pose = nullptr;
for (const auto &sensor : device.query_sensors()) {
if (sensor.is<rs2::wheel_odometer>())
pose = new rs2::pose_sensor(sensor);
if (sensor.is<rs2::pose_sensor>())
odom = new rs2::wheel_odometer(sensor);
}
if (!odom)
throw std::runtime_error(
"Selected device does not support wheel odometry inputs");
if (!pose)
throw std::runtime_error("Selected device does not have a pose sensor");
// Import the relocalization map, if the path is nonempty
auto pathNativeStr = env->GetStringUTFChars(mapPath, 0);
if (std::strlen(pathNativeStr) > 0)
importRelocalizationMap(pathNativeStr, pose);
env->ReleaseStringUTFChars(mapPath, pathNativeStr);
/*
* We define a callback that will run in another thread.
* This is why we must take care to preserve a pointer to
* a jvm object, which we attach to the other thread
* so we can get a valid environment object and call the
* callback in Java. We also make a global reference to
* the current object, which will be cleaned up when the
* user calls free() from Java.
*/
JavaVM *jvm;
int error = env->GetJavaVM(&jvm);
if (error)
throw std::runtime_error(
"Couldn't get a JavaVM object from the current JNI environment");
auto globalThis = env->NewGlobalRef(thisObj); // Must be cleaned up later
// Need to new because the lifetime of this object is controlled by Java
// code and we set a field in the Java class to this pointer
devAndSensors = new deviceAndSensors(pipeline, odom, pose, globalThis);
auto consumerCallback = [jvm, devAndSensors](const rs2::frame &frame) {
JNIEnv *env = nullptr;
try {
// Attaching the thread is expensive and happens *every callback*...
// TODO: Cache env?
int error = jvm->AttachCurrentThread(&env, nullptr);
if (error)
throw std::runtime_error("Couldn't attach callback thread to jvm");
auto poseData = frame.as<rs2::pose_frame>().get_pose_data();
// rotation is a quaternion so we must convert to an euler angle (yaw)
auto yaw = 2 * atan2f(poseData.rotation.y, poseData.rotation.w);
auto callbackMethodID =
env->GetMethodID(holdingClass, "consumePoseUpdate", "(FFFFFFI)V");
if (!callbackMethodID)
throw std::runtime_error("consumePoseUpdate method doesn't exist");
auto velocityMagnitude =
hypotf(-poseData.velocity.z, -poseData.velocity.x);
env->CallVoidMethod(devAndSensors->globalThis, callbackMethodID,
-poseData.translation.z, -poseData.translation.x,
yaw, -poseData.velocity.z, -poseData.velocity.x,
poseData.angular_velocity.y,
poseData.tracker_confidence);
std::scoped_lock lk(devAndSensors->frameNumMutex);
devAndSensors->lastRecvdFrameNum = frame.get_frame_number();
} catch (std::exception &e) {
/*
* Unfortunately if we get an exception while attaching the thread
* we can't throw into Java code, so we'll just print to stderr
*/
if (env)
env->ThrowNew(exception, e.what());
else
__android_log_print(ANDROID_LOG_ERROR, logTag,
"Exception in frame consumer callback could not "
"be thrown in Java code. Exception was: %s",
e.what());
}
};
// Start streaming
pipeline->start(config, consumerCallback);
toBeCleaned.push_back(devAndSensors);
__android_log_print(ANDROID_LOG_INFO, logTag,
"Successfully initialized tracking device");
return reinterpret_cast<jlong>(devAndSensors);
} catch (std::exception &e) {
ensureCache(env, thisObj);
env->ThrowNew(exception, e.what());
return 0;
}
return 0;
}
extern "C" JNIEXPORT void JNICALL
Java_com_spartronics4915_lib_T265Camera_sendOdometryRaw(
JNIEnv *env, jobject thisObj, jint sensorId, jfloat xVel, jfloat yVel) {
try {
ensureCache(env, thisObj);
auto devAndSensors = getDeviceFromClass(env, thisObj);
if (!devAndSensors->isRunning)
return;
// throw std::runtime_error("Can't send odometry data when the device isn't
// running");
// jints are 32 bit and are signed so we have to be careful
if (sensorId > UINT8_MAX || sensorId < 0)
env->ThrowNew(exception,
"sensorId is out of range of a 8-bit unsigned integer");
std::scoped_lock lk(devAndSensors->frameNumMutex);
devAndSensors->wheelOdometrySensor->send_wheel_odometry(
sensorId, devAndSensors->lastRecvdFrameNum,
rs2_vector{.x = -yVel, .y = 0.0, .z = -xVel});
} catch (std::exception &e) {
env->ThrowNew(exception, e.what());
}
}
extern "C" JNIEXPORT void JNICALL
Java_com_spartronics4915_lib_T265Camera_exportRelocalizationMap(
JNIEnv *env, jobject thisObj, jstring savePath) {
try {
ensureCache(env, thisObj);
auto pathNativeStr = env->GetStringUTFChars(savePath, 0);
// Open file in binary mode
auto file = std::ofstream(pathNativeStr, std::ios::binary);
if (!file || file.bad())
throw std::runtime_error(
"Couldn't open file to write a relocalization map");
// Get data from sensor and write
auto devAndSensors = getDeviceFromClass(env, thisObj);
if (!devAndSensors->isRunning)
throw std::runtime_error(
"Can't export a relocalization map when the device isn't running "
"(have you already exported?)");
// We can't export while the camera is running
devAndSensors->pipeline->stop();
devAndSensors->isRunning = false;
// I know, this is really gross...
// Unfortunately there is apparently no way to figure out if we're ready to
// export the map. See:
// https://github.com/IntelRealSense/librealsense/issues/4024#issuecomment-494258285
std::this_thread::sleep_for(exportRelocMapStopDelay);
// set_static_node fails if the confidence is not High... We don't currently
// use the static node, but you really probably shouldn't be exporting your
// map if your confidence isn't high anyway.
auto success = devAndSensors->poseSensor->set_static_node(
originNodeName, rs2_vector{0, 0, 0}, rs2_quaternion{0, 0, 0, 1});
if (!success)
throw std::runtime_error(
"Couldn't set static node while exporting a relocalization map... "
"Your confidence must be \"High\" for this to work.");
auto data = devAndSensors->poseSensor->export_localization_map();
file.write(reinterpret_cast<const char *>(data.begin().base()),
data.size());
file.close();
env->ReleaseStringUTFChars(savePath, pathNativeStr);
__android_log_print(ANDROID_LOG_INFO, logTag,
"Relocalization map exported");
// TODO: Camera never gets started again...
// If we try to call pipeline->start() it doesn't work. Bug in librealsense?
} catch (std::exception &e) {
// TODO: Make sleep time configurable (this will probably be a common issue
// users run into)
auto what = std::string(e.what());
what +=
" (If you got something like \"null pointer passed for argument "
"\"buffer\"\", this means that you have a very large relocalization "
"map, and you should increase exportRelocMapStopDelay in ";
what += __FILE__;
what += ")";
env->ThrowNew(exception, what.c_str());
}
}
void importRelocalizationMap(const char *path, rs2::pose_sensor *poseSensor) {
// Open file and make a vector to hold contents
auto file = std::ifstream(path, std::ios::binary);
if (!file || file.bad())
throw std::runtime_error("Couldn't open file to read a relocalization map");
auto dataVec = std::vector<uint8_t>(std::istreambuf_iterator<char>(file),
std::istreambuf_iterator<char>());
// Pass contents to the pose sensor
auto success = poseSensor->import_localization_map(dataVec);
if (!success)
throw std::runtime_error(
"import_localization_map returned a value indicating failure");
// TODO: Transform by get_static_node("origin", ...)?
// Useful if users want to have the same origin. In practice this hasn't been
// requested and users seem content having their origin after map import being
// the real origin.
file.close();
}
extern "C" JNIEXPORT void JNICALL
Java_com_spartronics4915_lib_T265Camera_setOdometryInfo(
JNIEnv *env, jobject thisObj, jfloat xOffset, jfloat yOffset,
jfloat angOffset, jdouble measureCovariance) {
try {
ensureCache(env, thisObj);
// std::format cannot come soon enough :(
auto size = snprintf(nullptr, 0, odometryConfig, measureCovariance,
-yOffset, -xOffset, angOffset);
char buf[size];
snprintf(buf, size, odometryConfig, measureCovariance, -yOffset, -xOffset,
angOffset);
auto vecBuf = std::vector<uint8_t>(buf, buf + size);
auto devAndSensors = getDeviceFromClass(env, thisObj);
devAndSensors->wheelOdometrySensor->load_wheel_odometery_config(vecBuf);
} catch (std::exception &e) {
env->ThrowNew(exception, e.what());
}
}
extern "C" JNIEXPORT void JNICALL
Java_com_spartronics4915_lib_T265Camera_free(JNIEnv *env, jobject thisObj) {
// It's important that we cannot initialize another camera while we're
// free'ing or vice versa. This global mutex also prevents cleanup from being
// called simeltaneously. In practice this mutex is only ever contended when
// the T265 goes through a weird init sequence from cold boot (see comment in
// the newCamera method.)
std::scoped_lock lk(cleanupMutex);
try {
ensureCache(env, thisObj);
auto devAndSensors = getDeviceFromClass(env, thisObj);
toBeCleaned.erase(
std::remove(toBeCleaned.begin(), toBeCleaned.end(), devAndSensors),
toBeCleaned.end());
env->DeleteGlobalRef(devAndSensors->globalThis);
delete devAndSensors;
env->SetLongField(thisObj, handleFieldId, 0);
} catch (std::exception &e) {
env->ThrowNew(exception, e.what());
}
}
extern "C" JNIEXPORT void JNICALL
Java_com_spartronics4915_lib_T265Camera_cleanup(JNIEnv *env, jclass) {
std::scoped_lock lk(cleanupMutex);
try {
while (!toBeCleaned.empty()) {
auto back = toBeCleaned.back();
env->DeleteGlobalRef(back->globalThis);
delete back;
toBeCleaned.pop_back();
}
__android_log_print(ANDROID_LOG_INFO, logTag,
"Native wrapper successfully shut down");
} catch (std::exception &e) {
if (exception) {
env->ThrowNew(exception, e.what());
} else {
// JVM bits could have already been cleaned up when we throw
__android_log_print(ANDROID_LOG_ERROR, logTag, "Exception after JVM cleanup: %s", e.what());
std::cerr << e.what() << std::endl;
}
}
}
deviceAndSensors *getDeviceFromClass(JNIEnv *env, jobject thisObj) {
auto pointer = env->GetLongField(thisObj, handleFieldId);
if (pointer == 0)
throw std::runtime_error("nativeCameraObjectPointer cannot be 0");
return reinterpret_cast<deviceAndSensors *>(pointer);
}
void ensureCache(JNIEnv *env, jobject thisObj) {
if (!holdingClass) {
auto lHoldingClass = env->GetObjectClass(thisObj);
holdingClass = reinterpret_cast<jclass>(env->NewGlobalRef(lHoldingClass));
}
if (!handleFieldId) {
handleFieldId =
env->GetFieldID(holdingClass, "mNativeCameraObjectPointer", "J");
}
if (!exception) {
auto lException =
env->FindClass("com/spartronics4915/lib/T265Camera$CameraJNIException");
exception = reinterpret_cast<jclass>(env->NewGlobalRef(lException));
}
}
| 17,911
|
C++
|
.cpp
| 417
| 36.148681
| 112
| 0.664276
|
pietroglyph/ftc265
| 32
| 21
| 8
|
LGPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| true
| false
|
1,537,802
|
t265wrapper.hpp
|
pietroglyph_ftc265/lib/src/main/cpp/t265wrapper.hpp
|
// Copyright 2020-2021 Declan Freeman-Gleason
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser 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 Lesser General Public
// License along with this program. If not, see
// <https://www.gnu.org/licenses/>.
#include <jni.h>
#include <librealsense2/rs.hpp>
#include <mutex>
/* Header for class com_spartronics4915_lib_T265Camera */
#ifndef _Included_com_spartronics4915_lib_T265Camera
#define _Included_com_spartronics4915_lib_T265Camera
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_spartronics4915_lib_T265Camera
* Method: exportRelocalizationMap
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_com_spartronics4915_lib_T265Camera_exportRelocalizationMap(JNIEnv *,
jobject,
jstring);
/*
* Class: com_spartronics4915_lib_T265Camera
* Method: free
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_spartronics4915_lib_T265Camera_free(JNIEnv *,
jobject);
/*
* Class: com_spartronics4915_lib_T265Camera
* Method: setOdometryInfo
* Signature: (FFFD)V
*/
JNIEXPORT void JNICALL Java_com_spartronics4915_lib_T265Camera_setOdometryInfo(
JNIEnv *, jobject, jfloat, jfloat, jfloat, jdouble);
/*
* Class: com_spartronics4915_lib_T265Camera
* Method: sendOdometryRaw
* Signature: (IFF)V
*/
JNIEXPORT void JNICALL Java_com_spartronics4915_lib_T265Camera_sendOdometryRaw(
JNIEnv *, jobject, jint, jfloat, jfloat);
/*
* Class: com_spartronics4915_lib_T265Camera
* Method: newCamera
* Signature: (Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL
Java_com_spartronics4915_lib_T265Camera_newCamera(JNIEnv *, jobject, jstring);
/*
* Class: com_spartronics4915_lib_T265Camera
* Method: cleanup
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_spartronics4915_lib_T265Camera_cleanup(JNIEnv *,
jclass);
#ifdef __cplusplus
}
#endif
#endif
// NOT machine generated like the above :)
// The "native pointer" that the Java code holds points to an instance of this
// class.
class deviceAndSensors {
public:
deviceAndSensors(rs2::pipeline *pipe, rs2::wheel_odometer *odom,
rs2::pose_sensor *pose, jobject globalThis)
: pipeline(pipe), wheelOdometrySensor(odom), poseSensor(pose),
globalThis(globalThis) {}
~deviceAndSensors() {
delete pipeline;
delete poseSensor;
delete wheelOdometrySensor;
}
rs2::pipeline *pipeline;
rs2::wheel_odometer *wheelOdometrySensor;
rs2::pose_sensor *poseSensor;
jobject globalThis;
bool isRunning = true;
std::mutex frameNumMutex;
unsigned long long lastRecvdFrameNum = 0;
};
void importRelocalizationMap(const char *path, rs2::pose_sensor *pose);
deviceAndSensors *getDeviceFromClass(JNIEnv *env, jobject thisObj);
void ensureCache(JNIEnv *env, jobject thisObj);
| 3,522
|
C++
|
.h
| 97
| 31.42268
| 80
| 0.701348
|
pietroglyph/ftc265
| 32
| 21
| 8
|
LGPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| true
| false
|
1,537,804
|
multiFileProject.h
|
khoih-prog_FlashStorage_SAMD/examples/multiFileProject/multiFileProject.h
|
/****************************************************************************************************************************
multiFileProject.h
For SAMD21/SAMD51 using Flash emulated-EEPROM
The FlashStorage_SAMD library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of SAMD21/SAMD51. It now supports writing and reading the whole object, not just byte-and-byte.
Based on and modified from Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
*****************************************************************************************************************************/
// To demo how to include files in multi-file Projects
#pragma once
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
#include "FlashStorage_SAMD.hpp"
const int WRITTEN_SIGNATURE = 0xBEEFDEED;
// Create a structure that is big enough to contain a name
// and a surname. The "valid" variable is set to "true" once
// the structure is filled with actual data for the first time.
typedef struct
{
char name[100];
char surname[100];
} Person;
void testEEPROM();
| 1,240
|
C++
|
.h
| 22
| 54.181818
| 134
| 0.626656
|
khoih-prog/FlashStorage_SAMD
| 32
| 6
| 1
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,805
|
FlashStorage_SAMD.h
|
khoih-prog_FlashStorage_SAMD/src/FlashStorage_SAMD.h
|
/******************************************************************************************************************************************
FlashStorage_SAMD.h
For SAMD21/SAMD51 using Flash emulated-EEPROM
The FlashStorage_SAMD library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of SAMD21/SAMD51. It now supports writing and reading the whole object, not just byte-and-byte.
Based on and modified from Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by Cristian Maglie
Copyright (c) 2015 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
Version: 1.3.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/03/2020 Initial coding to add support to SAMD51 besides SAMD21
1.1.0 K Hoang 26/01/2021 Add supports to put() and get() for writing and reading the whole object. Fix bug.
1.2.0 K Hoang 18/08/2021 Optimize code. Add debug option
1.2.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.3.0 K Hoang 25/01/2022 Fix `multiple-definitions` linker error. Add support to many more boards.
1.3.1 K Hoang 25/01/2022 Reduce number of library files
1.3.2 K Hoang 26/01/2022 Make compatible with old libraries and codes
******************************************************************************************************************************************/
// The .hpp contains only definitions, and can be included as many times as necessary, without `Multiple Definitions` Linker Error
// The .h contains implementations, and can be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#pragma once
#ifndef FlashStorage_SAMD_h
#define FlashStorage_SAMD_h
#include <FlashStorage_SAMD.hpp>
#include <FlashStorage_SAMD_Impl.h>
#endif //#ifndef FlashStorage_SAMD_h
| 2,721
|
C++
|
.h
| 36
| 72.75
| 140
| 0.669536
|
khoih-prog/FlashStorage_SAMD
| 32
| 6
| 1
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,806
|
FlashStorage_SAMD.hpp
|
khoih-prog_FlashStorage_SAMD/src/FlashStorage_SAMD.hpp
|
/******************************************************************************************************************************************
FlashStorage_SAMD.hpp
For SAMD21/SAMD51 using Flash emulated-EEPROM
The FlashStorage_SAMD library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of SAMD21/SAMD51. It now supports writing and reading the whole object, not just byte-and-byte.
Based on and modified from Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by Cristian Maglie
Copyright (c) 2015 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
Version: 1.3.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/03/2020 Initial coding to add support to SAMD51 besides SAMD21
1.1.0 K Hoang 26/01/2021 Add supports to put() and get() for writing and reading the whole object. Fix bug.
1.2.0 K Hoang 18/08/2021 Optimize code. Add debug option
1.2.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.3.0 K Hoang 25/01/2022 Fix `multiple-definitions` linker error. Add support to many more boards.
1.3.1 K Hoang 25/01/2022 Reduce number of library files
1.3.2 K Hoang 26/01/2022 Make compatible with old libraries and codes
******************************************************************************************************************************************/
// The .hpp contains only definitions, and can be included as many times as necessary, without `Multiple Definitions` Linker Error
// The .h contains implementations, and can be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#pragma once
#ifndef FlashStorage_SAMD_hpp
#define FlashStorage_SAMD_hpp
#if !( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \
|| defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) \
|| defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD51__) || defined(__SAMD51J20A__) \
|| defined(__SAMD51J19A__) || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) \
|| defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \
|| defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \
|| defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) )
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
#endif
#ifndef FLASH_STORAGE_SAMD_VERSION
#define FLASH_STORAGE_SAMD_VERSION "FlashStorage_SAMD v1.3.2"
#define FLASH_STORAGE_SAMD_VERSION_MAJOR 1
#define FLASH_STORAGE_SAMD_VERSION_MINOR 3
#define FLASH_STORAGE_SAMD_VERSION_PATCH 2
#define FLASH_STORAGE_SAMD_VERSION_INT 1003002
#endif
#include <Arduino.h>
#if defined(SAMD_INDUSTRUINO_D21G)
#define BOARD_NAME "SAMD21 INDUSTRUINO_D21G"
#elif defined(ARDUINO_SAML_INDUSTRUINO_420MAKER)
#define BOARD_NAME "SAML21 INDUSTRUINO_420MAKER"
#endif
#if !defined(Serial)
#define Serial SERIAL_PORT_MONITOR
#endif
/////////////////////////////////////////////////////
#ifndef FLASH_DEBUG
#define FLASH_DEBUG 0
#endif
#if !defined(FLASH_DEBUG_OUTPUT)
#define FLASH_DEBUG_OUTPUT Serial
#endif
const char FLASH_MARK[] = "[FLASH] ";
const char FLASH_SP[] = " ";
#define FLASH_PRINT FLASH_DEBUG_OUTPUT.print
#define FLASH_PRINTLN FLASH_DEBUG_OUTPUT.println
#define FLASH_FLUSH FLASH_DEBUG_OUTPUT.flush
#define FLASH_PRINT_MARK FLASH_PRINT(FLASH_MARK)
#define FLASH_PRINT_SP FLASH_PRINT(FLASH_SP)
/////////////////////////////////////////////////////
#define FLASH_LOGERROR(x) if(FLASH_DEBUG>0) { FLASH_PRINT("[FLASH] "); FLASH_PRINTLN(x); }
#define FLASH_LOGERROR0(x) if(FLASH_DEBUG>0) { FLASH_PRINT(x); }
#define FLASH_HEXLOGERROR0(x) if(FLASH_DEBUG>0) { FLASH_PRINTLN(x, HEX); }
#define FLASH_LOGERROR1(x,y) if(FLASH_DEBUG>0) { FLASH_PRINT("[FLASH] "); FLASH_PRINT(x); FLASH_PRINT_SP; FLASH_PRINTLN(y); }
#define FLASH_LOGERROR2(x,y,z) if(FLASH_DEBUG>0) { FLASH_PRINT("[FLASH] "); FLASH_PRINT(x); FLASH_PRINT_SP; FLASH_PRINT(y); FLASH_PRINT_SP; FLASH_PRINTLN(z); }
#define FLASH_LOGERROR3(x,y,z,w) if(FLASH_DEBUG>0) { FLASH_PRINT("[FLASH] "); FLASH_PRINT(x); FLASH_PRINT_SP; FLASH_PRINT(y); FLASH_PRINT_SP; FLASH_PRINT(z); FLASH_PRINT_SP; FLASH_PRINTLN(w); }
/////////////////////////////////////////////////////
#define FLASH_LOGDEBUG(x) if(FLASH_DEBUG>1) { FLASH_PRINT("[FLASH] "); FLASH_PRINTLN(x); }
#define FLASH_LOGDEBUG0(x) if(FLASH_DEBUG>1) { FLASH_PRINT(x); }
#define FLASH_HEXLOGDEBUG0(x) if(FLASH_DEBUG>1) { FLASH_PRINTLN(x, HEX); }
#define FLASH_LOGDEBUG1(x,y) if(FLASH_DEBUG>1) { FLASH_PRINT("[FLASH] "); FLASH_PRINT(x); FLASH_PRINT_SP; FLASH_PRINTLN(y); }
#define FLASH_LOGDEBUG2(x,y,z) if(FLASH_DEBUG>1) { FLASH_PRINT("[FLASH] "); FLASH_PRINT(x); FLASH_PRINT_SP; FLASH_PRINT(y); FLASH_PRINT_SP; FLASH_PRINTLN(z); }
#define FLASH_LOGDEBUG3(x,y,z,w) if(FLASH_DEBUG>1) { FLASH_PRINT("[FLASH] "); FLASH_PRINT(x); FLASH_PRINT_SP; FLASH_PRINT(y); FLASH_PRINT_SP; FLASH_PRINT(z); FLASH_PRINT_SP; FLASH_PRINTLN(w); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Concatenate after macro expansion
#define PPCAT_NX(A, B) A ## B
#define PPCAT(A, B) PPCAT_NX(A, B)
#if defined(__SAMD51__)
#define Flash(name, size) \
__attribute__((__aligned__(8192))) \
static const uint8_t PPCAT(_data,name)[(size+8191)/8192*8192] = { }; \
FlashClass name(PPCAT(_data,name), size);
#define staticFlash(name, size) \
__attribute__((__aligned__(8192))) \
static const uint8_t PPCAT(_data,name)[(size+8191)/8192*8192] = { }; \
static FlashClass name(PPCAT(_data,name), size);
#define FlashStorage(name, T) \
__attribute__((__aligned__(8192))) \
static const uint8_t PPCAT(_data,name)[(sizeof(T)+8191)/8192*8192] = { }; \
FlashStorageClass<T> name(PPCAT(_data,name));
#define staticFlashStorage(name, T) \
__attribute__((__aligned__(8192))) \
static const uint8_t PPCAT(_data,name)[(sizeof(T)+8191)/8192*8192] = { }; \
static FlashStorageClass<T> name(PPCAT(_data,name));
#else
#define Flash(name, size) \
__attribute__((__aligned__(256))) \
static const uint8_t PPCAT(_data,name)[(size+255)/256*256] = { }; \
FlashClass name(PPCAT(_data,name), size);
#define staticFlash(name, size) \
__attribute__((__aligned__(256))) \
static const uint8_t PPCAT(_data,name)[(size+255)/256*256] = { }; \
static FlashClass name(PPCAT(_data,name), size);
#define FlashStorage(name, T) \
__attribute__((__aligned__(256))) \
static const uint8_t PPCAT(_data,name)[(sizeof(T)+255)/256*256] = { }; \
FlashStorageClass<T> name(PPCAT(_data,name));
#define staticFlashStorage(name, T) \
__attribute__((__aligned__(256))) \
static const uint8_t PPCAT(_data,name)[(sizeof(T)+255)/256*256] = { }; \
static FlashStorageClass<T> name(PPCAT(_data,name));
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class FlashClass
{
public:
FlashClass(const void *flash_addr = NULL, uint32_t size = 0);
void write(const void *data) { write(flash_address, data); }
void erase() { erase(flash_address, flash_size); }
void read(void *data) { read(flash_address, data); }
void write(const volatile void *flash_ptr, const void *data);
void erase(const volatile void *flash_ptr, uint32_t size);
void read(const volatile void *flash_ptr, void *data);
private:
void erase(const volatile void *flash_ptr);
const uint32_t PAGE_SIZE, PAGES, MAX_FLASH, ROW_SIZE;
const volatile void *flash_address;
const uint32_t flash_size;
};
/////////////////////////////////////////////////////
template<class T>
class FlashStorageClass
{
public:
FlashStorageClass(const void *flash_addr) : flash(flash_addr, sizeof(T)) { };
// Write data into flash memory.
// Compiler is able to optimize parameter copy.
inline void write(T &data) { flash.erase(); flash.write(&data); }
// Overloaded version of read.
// Compiler is able to optimize copy-on-return.
inline void read(T &data) { flash.read(&data); }
private:
FlashClass flash;
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef EEPROM_EMULATION_SIZE
#define EEPROM_EMULATION_SIZE 1024
#endif
const uint32_t SAMD_EEPROM_EMULATION_SIGNATURE = 0xFEEDDEED;
typedef struct
{
byte data[EEPROM_EMULATION_SIZE];
bool valid;
uint32_t signature;
} EEPROM_EMULATION;
/////////////////////////////////////////////////////
#if defined(__SAMD51__)
staticFlashStorage(eeprom_storage, EEPROM_EMULATION);
#else
staticFlashStorage(eeprom_storage, EEPROM_EMULATION);
#endif
class EEPROMClass
{
public:
EEPROMClass() : _initialized(false), _dirty(false), _commitASAP(true)
{
// Empty
}
/////////////////////////////////////////////////////
/**
* Read an eeprom cell
* @param index
* @return value
*/
//uint8_t read(int address);
uint8_t read(int address)
{
if (!_initialized)
init();
return _eeprom.data[address];
}
/////////////////////////////////////////////////////
/**
* Update a eeprom cell
* @param index
* @param value
*/
void update(int address, uint8_t value)
{
if (!_initialized)
init();
if (_eeprom.data[address] != value)
{
_dirty = true;
_eeprom.data[address] = value;
}
}
/////////////////////////////////////////////////////
/**
* Write value to an eeprom cell
* @param index
* @param value
*/
void write(int address, uint8_t value)
{
update(address, value);
}
/////////////////////////////////////////////////////
/**
* Read from eeprom cells to an object
* @param index
* @param value
*/
//Functionality to 'get' data to objects to from EEPROM.
template< typename T > T& get( int idx, T &t )
{
// Copy the data from the flash to the buffer if not yet
if (!_initialized)
init();
uint16_t offset = idx;
uint8_t* _pointer = (uint8_t *) &t;
for ( uint16_t count = sizeof(T) ; count ; --count, ++offset )
{
*_pointer++ = _eeprom.data[offset];
}
return t;
}
/////////////////////////////////////////////////////
/**
* Read from eeprom cells to an object
* @param index
* @param value
*/
//Functionality to 'get' data to objects to from EEPROM.
template< typename T > const T& put( int idx, const T &t )
{
// Copy the data from the flash to the buffer if not yet
if (!_initialized)
init();
uint16_t offset = idx;
const uint8_t* _pointer = (const uint8_t *) &t;
for ( uint16_t count = sizeof(T) ; count ; --count, ++offset )
{
_eeprom.data[offset] = *_pointer++;
}
if (_commitASAP)
{
_dirty = false;
_eeprom.valid = true;
// Save the data from the buffer
eeprom_storage.write(_eeprom);
}
else
{
// Delay saving the data from the buffer to the flash. Just flag and wait for commit() later
_dirty = true;
}
return t;
}
/////////////////////////////////////////////////////
/**
* Check whether the eeprom data is valid
* @return true, if eeprom data is valid (has been written at least once), false if not
*/
bool isValid()
{
if (!_initialized)
init();
return _eeprom.valid;
}
/////////////////////////////////////////////////////
/**
* Write previously made eeprom changes to the underlying flash storage
* Use this with care: Each and every commit will harm the flash and reduce it's lifetime (like with every flash memory)
*/
void commit()
{
if (!_initialized)
init();
if (_dirty)
{
_dirty = false;
_eeprom.valid = true;
// Save the data from the buffer
eeprom_storage.write(_eeprom);
}
}
/////////////////////////////////////////////////////
uint16_t length() { return EEPROM_EMULATION_SIZE; }
void setCommitASAP(bool value = true) { _commitASAP = value; }
bool getCommitASAP() { return _commitASAP; }
/////////////////////////////////////////////////////
private:
void init()
{
// Use reference
eeprom_storage.read(_eeprom);
if (_eeprom.signature != SAMD_EEPROM_EMULATION_SIGNATURE)
{
memset(_eeprom.data, 0xFF, EEPROM_EMULATION_SIZE);
_eeprom.signature = SAMD_EEPROM_EMULATION_SIGNATURE;
}
_eeprom.valid = true;
_initialized = true;
}
bool _initialized;
EEPROM_EMULATION _eeprom;
bool _dirty;
bool _commitASAP;
};
/////////////////////////////////////////////////////
static EEPROMClass EEPROM;
/////////////////////////////////////////////////////
#endif //#ifndef FlashStorage_SAMD_hpp
| 14,330
|
C++
|
.h
| 328
| 39.661585
| 194
| 0.602505
|
khoih-prog/FlashStorage_SAMD
| 32
| 6
| 1
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,807
|
FlashAsEEPROM_SAMD.h
|
khoih-prog_FlashStorage_SAMD/src/FlashAsEEPROM_SAMD.h
|
/******************************************************************************************************************************************
FlashAsEEPROM_SAMD.h
For SAMD21/SAMD51 using Flash emulated-EEPROM
The FlashStorage_SAMD library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of SAMD21/SAMD51. It now supports writing and reading the whole object, not just byte-and-byte.
Based on and modified from Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by Cristian Maglie
Copyright (c) 2015 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
Version: 1.3.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/03/2020 Initial coding to add support to SAMD51 besides SAMD21
1.1.0 K Hoang 26/01/2021 Add supports to put() and get() for writing and reading the whole object. Fix bug.
1.2.0 K Hoang 18/08/2021 Optimize code. Add debug option
1.2.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.3.0 K Hoang 25/01/2022 Fix `multiple-definitions` linker error. Add support to many more boards.
1.3.1 K Hoang 25/01/2022 Reduce number of library files
1.3.2 K Hoang 26/01/2022 Make compatible with old libraries and codes
******************************************************************************************************************************************/
// The .hpp contains only definitions, and can be included as many times as necessary, without `Multiple Definitions` Linker Error
// The .h contains implementations, and can be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#pragma once
#ifndef FlashAsEEPROM_SAMD_h
#define FlashAsEEPROM_SAMD_h
#include <FlashStorage_SAMD.hpp>
#include <FlashStorage_SAMD_Impl.h>
#endif //#ifndef FlashAsEEPROM_SAMD_h
| 2,725
|
C++
|
.h
| 36
| 72.861111
| 140
| 0.67003
|
khoih-prog/FlashStorage_SAMD
| 32
| 6
| 1
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,808
|
FlashAsEEPROM_SAMD.hpp
|
khoih-prog_FlashStorage_SAMD/src/FlashAsEEPROM_SAMD.hpp
|
/******************************************************************************************************************************************
FlashAsEEPROM_SAMD.hpp
For SAMD21/SAMD51 using Flash emulated-EEPROM
The FlashStorage_SAMD library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of SAMD21/SAMD51. It now supports writing and reading the whole object, not just byte-and-byte.
Based on and modified from Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by Cristian Maglie
Copyright (c) 2015 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
Version: 1.3.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/03/2020 Initial coding to add support to SAMD51 besides SAMD21
1.1.0 K Hoang 26/01/2021 Add supports to put() and get() for writing and reading the whole object. Fix bug.
1.2.0 K Hoang 18/08/2021 Optimize code. Add debug option
1.2.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.3.0 K Hoang 25/01/2022 Fix `multiple-definitions` linker error. Add support to many more boards.
1.3.1 K Hoang 25/01/2022 Reduce number of library files
1.3.2 K Hoang 26/01/2022 Make compatible with old libraries and codes
******************************************************************************************************************************************/
// The .hpp contains only definitions, and can be included as many times as necessary, without `Multiple Definitions` Linker Error
// The .h contains implementations, and can be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#pragma once
#ifndef FlashAsEEPROM_SAMD_hpp
#define FlashAsEEPROM_SAMD_hpp
#include <FlashStorage_SAMD.hpp>
#endif //#ifndef FlashAsEEPROM_SAMD_hpp
| 2,707
|
C++
|
.h
| 35
| 74.171429
| 140
| 0.668804
|
khoih-prog/FlashStorage_SAMD
| 32
| 6
| 1
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,809
|
FlashStorage_SAMD51.h
|
khoih-prog_FlashStorage_SAMD/src/FlashStorage_SAMD51.h
|
/******************************************************************************************************************************************
FlashStorage_SAMD51.h
For SAMD21/SAMD51 using Flash emulated-EEPROM
The FlashStorage_SAMD library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of SAMD21/SAMD51. It now supports writing and reading the whole object, not just byte-and-byte.
Based on and modified from Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by Cristian Maglie
Copyright (c) 2015 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
Version: 1.3.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/03/2020 Initial coding to add support to SAMD51 besides SAMD21
1.1.0 K Hoang 26/01/2021 Add supports to put() and get() for writing and reading the whole object. Fix bug.
1.2.0 K Hoang 18/08/2021 Optimize code. Add debug option
1.2.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.3.0 K Hoang 25/01/2022 Fix `multiple-definitions` linker error. Add support to many more boards.
1.3.1 K Hoang 25/01/2022 Reduce number of library files
1.3.2 K Hoang 26/01/2022 Make compatible with old libraries and codes
******************************************************************************************************************************************/
// The .hpp contains only definitions, and can be included as many times as necessary, without `Multiple Definitions` Linker Error
// The .h contains implementations, and can be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#pragma once
#ifndef FlashStorage_SAMD51_h
#define FlashStorage_SAMD51_h
#ifndef BOARD_NAME
#define BOARD_NAME "Unknown SAMD51 board"
#endif
static const uint32_t pageSizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024 };
/////////////////////////////////////////////////////
FlashClass::FlashClass(const void *flash_addr, uint32_t size) :
PAGE_SIZE(pageSizes[NVMCTRL->PARAM.bit.PSZ]),
PAGES(NVMCTRL->PARAM.bit.NVMP),
MAX_FLASH(PAGE_SIZE * PAGES),
ROW_SIZE(MAX_FLASH / 64),
flash_address((volatile void *)flash_addr),
flash_size(size)
{
}
/////////////////////////////////////////////////////
static inline uint32_t read_unaligned_uint32(const void *data)
{
union
{
uint32_t u32;
uint8_t u8[4];
} res;
const uint8_t *d = (const uint8_t *)data;
res.u8[0] = d[0];
res.u8[1] = d[1];
res.u8[2] = d[2];
res.u8[3] = d[3];
return res.u32;
}
/////////////////////////////////////////////////////
void FlashClass::write(const volatile void *flash_ptr, const void *data)
{
// Calculate data boundaries
uint32_t size = (flash_size + 3) / 4;
volatile uint32_t *dst_addr = (volatile uint32_t *)flash_ptr;
const uint8_t *src_addr = (uint8_t *)data;
// Disable automatic page write
NVMCTRL->CTRLA.bit.WMODE = 0;
////KH
/*
1. Configure manual write for the NVM using WMODE (NVMCTRL.CTRLA).
2. Make sure the NVM is ready to accept a new command (NVMCTRL.STATUS).
3. Clear page buffer ( NVMCTRL.CTRLB).
4. Make sure NVM is ready to accept a new command (NVMCTRL.STATUS).
5. Clear the DONE Flag (NVMCTRL.INTFLAG).
6. Write data to page buffer with 32-bit accesses at the needed address.
7. Perform page write (NVMCTRL.CTRLB).
8. Make sure NVM is ready to accept a new command (NVMCTRL.STATUS).
9. Clear the DONE Flag (NVMCTRL.INTFLAG).
*/
//KH
// 2. Make sure the NVM is ready to accept a new command (NVMCTRL.STATUS).
while (NVMCTRL->STATUS.bit.READY != NVMCTRL_STATUS_READY ) { }
// Do writes in pages
while (size)
{
// Execute "PBC" Page Buffer Clear
// 3. Clear page buffer ( NVMCTRL.CTRLB).
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_PBC;
// 4. Make sure the NVM is ready to accept a new command (NVMCTRL.STATUS).
//while (NVMCTRL->STATUS.bit.READY != NVMCTRL_STATUS_READY ) { }
// 5. Clear the DONE Flag (NVMCTRL.INTFLAG)
while (NVMCTRL->INTFLAG.bit.DONE == 0) { }
// 6. Write data to page buffer with 32-bit accesses at the needed address.
// Fill page buffer
uint32_t i;
for (i = 0; i < (PAGE_SIZE / 4) && size; i++)
{
*dst_addr = read_unaligned_uint32(src_addr);
src_addr += 4;
dst_addr++;
size--;
}
//7. Perform page write (NVMCTRL.CTRLB).
// Execute "WP" Write Page
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_WP;
// 8. Make sure NVM is ready to accept a new command (NVMCTRL.STATUS).
//while (NVMCTRL->STATUS.bit.READY != NVMCTRL_STATUS_READY ) { }
// 9. Clear the DONE Flag (NVMCTRL.INTFLAG)
while (NVMCTRL->INTFLAG.bit.DONE == 0) { }
}
}
/////////////////////////////////////////////////////
void FlashClass::read(const volatile void *flash_ptr, void *data)
{
FLASH_LOGERROR3(F("MAX_FLASH (KB) = "), MAX_FLASH / 1024, F(", ROW_SIZE ="), ROW_SIZE);
FLASH_LOGERROR1(F("FlashStorage size = "), flash_size);
FLASH_LOGERROR0(F("FlashStorage Start Address: 0x"));
FLASH_HEXLOGERROR0((uint32_t ) flash_address);
FLASH_LOGDEBUG0(F("Read: flash_ptr = 0x"));
FLASH_HEXLOGDEBUG0((uint32_t ) flash_ptr);
FLASH_LOGDEBUG0(F("data = 0x"));
FLASH_HEXLOGDEBUG0(* (uint32_t *) data);
memcpy(data, (const void *)flash_ptr, flash_size);
}
/////////////////////////////////////////////////////
void FlashClass::erase(const volatile void *flash_ptr, uint32_t size)
{
const uint8_t *ptr = (const uint8_t *)flash_ptr;
while (size > ROW_SIZE)
{
erase(ptr);
ptr += ROW_SIZE;
size -= ROW_SIZE;
}
erase(ptr);
}
/////////////////////////////////////////////////////
void FlashClass::erase(const volatile void *flash_ptr)
{
NVMCTRL->ADDR.reg = ((uint32_t)flash_ptr);
// Check, now erase PAGE, instead of ROW !!!
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | NVMCTRL_CTRLB_CMD_EB;
while (NVMCTRL->INTFLAG.bit.DONE == 0) { }
}
/////////////////////////////////////////////////////
#endif //#ifndef FlashStorage_SAMD51_h
| 6,969
|
C++
|
.h
| 150
| 43.06
| 140
| 0.630242
|
khoih-prog/FlashStorage_SAMD
| 32
| 6
| 1
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,810
|
FlashStorage_SAMD21.h
|
khoih-prog_FlashStorage_SAMD/src/FlashStorage_SAMD21.h
|
/******************************************************************************************************************************************
FlashStorage_SAMD21.h
For SAMD21/SAMD51 using Flash emulated-EEPROM
The FlashStorage_SAMD library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of SAMD21/SAMD51. It now supports writing and reading the whole object, not just byte-and-byte.
Based on and modified from Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by Cristian Maglie
Copyright (c) 2015 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
Version: 1.3.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/03/2020 Initial coding to add support to SAMD51 besides SAMD21
1.1.0 K Hoang 26/01/2021 Add supports to put() and get() for writing and reading the whole object. Fix bug.
1.2.0 K Hoang 18/08/2021 Optimize code. Add debug option
1.2.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.3.0 K Hoang 25/01/2022 Fix `multiple-definitions` linker error. Add support to many more boards.
1.3.1 K Hoang 25/01/2022 Reduce number of library files
1.3.2 K Hoang 26/01/2022 Make compatible with old libraries and codes
******************************************************************************************************************************************/
// The .hpp contains only definitions, and can be included as many times as necessary, without `Multiple Definitions` Linker Error
// The .h contains implementations, and can be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#pragma once
#ifndef FlashStorage_SAMD21_h
#define FlashStorage_SAMD21_h
#ifndef BOARD_NAME
#define BOARD_NAME "Unknown SAMD21 board"
#endif
static const uint32_t pageSizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024 };
/////////////////////////////////////////////////////
FlashClass::FlashClass(const void *flash_addr, uint32_t size) :
PAGE_SIZE(pageSizes[NVMCTRL->PARAM.bit.PSZ]),
PAGES(NVMCTRL->PARAM.bit.NVMP),
MAX_FLASH(PAGE_SIZE * PAGES),
ROW_SIZE(PAGE_SIZE * 4),
flash_address((volatile void *)flash_addr),
flash_size(size)
{
}
/////////////////////////////////////////////////////
static inline uint32_t read_unaligned_uint32(const void *data)
{
union
{
uint32_t u32;
uint8_t u8[4];
} res;
const uint8_t *d = (const uint8_t *)data;
res.u8[0] = d[0];
res.u8[1] = d[1];
res.u8[2] = d[2];
res.u8[3] = d[3];
return res.u32;
}
/////////////////////////////////////////////////////
void FlashClass::write(const volatile void *flash_ptr, const void *data)
{
// Calculate data boundaries
uint32_t size = (flash_size + 3) / 4;
volatile uint32_t *dst_addr = (volatile uint32_t *)flash_ptr;
const uint8_t *src_addr = (uint8_t *)data;
// Disable automatic page write
NVMCTRL->CTRLB.bit.MANW = 1;
// Do writes in pages
while (size)
{
// Execute "PBC" Page Buffer Clear
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC;
while (NVMCTRL->INTFLAG.bit.READY == 0) { }
// Fill page buffer
uint32_t i;
for (i = 0; i < (PAGE_SIZE / 4) && size; i++)
{
*dst_addr = read_unaligned_uint32(src_addr);
src_addr += 4;
dst_addr++;
size--;
}
// Execute "WP" Write Page
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_WP;
while (NVMCTRL->INTFLAG.bit.READY == 0) { }
}
}
/////////////////////////////////////////////////////
void FlashClass::read(const volatile void *flash_ptr, void *data)
{
FLASH_LOGERROR3(F("MAX_FLASH (KB) = "), MAX_FLASH / 1024, F(", ROW_SIZE ="), ROW_SIZE);
FLASH_LOGERROR1(F("FlashStorage size = "), flash_size);
FLASH_LOGERROR0(F("FlashStorage Start Address: 0x"));
FLASH_HEXLOGERROR0((uint32_t ) flash_address);
FLASH_LOGDEBUG0(F("Read: flash_ptr = 0x"));
FLASH_HEXLOGDEBUG0((uint32_t ) flash_ptr);
FLASH_LOGDEBUG0(F("data = 0x"));
FLASH_HEXLOGDEBUG0(* (uint32_t *) data);
memcpy(data, (const void *)flash_ptr, flash_size);
}
/////////////////////////////////////////////////////
void FlashClass::erase(const volatile void *flash_ptr, uint32_t size)
{
const uint8_t *ptr = (const uint8_t *)flash_ptr;
while (size > ROW_SIZE)
{
erase(ptr);
ptr += ROW_SIZE;
size -= ROW_SIZE;
}
erase(ptr);
}
/////////////////////////////////////////////////////
void FlashClass::erase(const volatile void *flash_ptr)
{
NVMCTRL->ADDR.reg = ((uint32_t)flash_ptr) / 2;
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_ER;
while (!NVMCTRL->INTFLAG.bit.READY) { }
}
#endif //#ifndef FlashStorage_SAMD21_h
| 5,591
|
C++
|
.h
| 124
| 41.919355
| 140
| 0.623963
|
khoih-prog/FlashStorage_SAMD
| 32
| 6
| 1
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,811
|
FlashStorage_SAMD_Impl.h
|
khoih-prog_FlashStorage_SAMD/src/FlashStorage_SAMD_Impl.h
|
/******************************************************************************************************************************************
FlashStorage_SAMD_Impl.h
For SAMD21/SAMD51 using Flash emulated-EEPROM
The FlashStorage_SAMD library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of SAMD21/SAMD51. It now supports writing and reading the whole object, not just byte-and-byte.
Based on and modified from Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by Cristian Maglie
Copyright (c) 2015 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
Version: 1.3.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/03/2020 Initial coding to add support to SAMD51 besides SAMD21
1.1.0 K Hoang 26/01/2021 Add supports to put() and get() for writing and reading the whole object. Fix bug.
1.2.0 K Hoang 18/08/2021 Optimize code. Add debug option
1.2.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.3.0 K Hoang 25/01/2022 Fix `multiple-definitions` linker error. Add support to many more boards.
1.3.1 K Hoang 25/01/2022 Reduce number of library files
1.3.2 K Hoang 26/01/2022 Make compatible with old libraries and codes
******************************************************************************************************************************************/
// The .hpp contains only definitions, and can be included as many times as necessary, without `Multiple Definitions` Linker Error
// The .h contains implementations, and can be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#pragma once
#ifndef FlashStorage_SAMD_Impl_h
#define FlashStorage_SAMD_Impl_h
#if ( defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) )
#include "FlashStorage_SAMD51.h"
#elif ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) \
|| defined(ARDUINO_SAMD_MKRWAN1310) || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) \
|| defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(ARDUINO_SAML_INDUSTRUINO_420MAKER) \
|| defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \
|| defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \
|| defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) )
#include "FlashStorage_SAMD21.h"
#else
#error This code is intended to run only on the SAMD21 or SAMD51 boards ! Please check your Tools->Board setting.
#endif
#endif //#ifndef FlashStorage_SAMD_Impl_h
| 3,835
|
C++
|
.h
| 47
| 78.425532
| 143
| 0.673642
|
khoih-prog/FlashStorage_SAMD
| 32
| 6
| 1
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,814
|
prob_point_cloud_registration_ex.cc
|
iralabdisco_probabilistic_point_clouds_registration/src/prob_point_cloud_registration_ex.cc
|
#include <limits>
#include <memory>
#include <vector>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <boost/filesystem.hpp>
#include <Eigen/Core>
#include <Eigen/Sparse>
#include <pcl/common/transforms.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <tclap/CmdLine.h>
#include "prob_point_cloud_registration/prob_point_cloud_registration.h"
#include "prob_point_cloud_registration/utilities.hpp"
typedef pcl::PointXYZ PointType;
using prob_point_cloud_registration::ProbPointCloudRegistration;
using prob_point_cloud_registration::ProbPointCloudRegistrationParams;
int main(int argc, char **argv)
{
bool use_gaussian = false, ground_truth = false;
std::string source_file_name;
std::string target_file_name;
std::string ground_truth_file_name;
ProbPointCloudRegistrationParams params;
try {
TCLAP::CmdLine cmd("Probabilistic point cloud registration", ' ', "1.0");
TCLAP::UnlabeledValueArg<std::string> source_file_name_arg("source_file_name",
"The path of the source point cloud", true, "source_cloud.pcd", "string", cmd);
TCLAP::UnlabeledValueArg<std::string> target_file_name_arg("target_file_name",
"The path of the target point cloud", true, "target_cloud.pcd", "string", cmd);
TCLAP::ValueArg<float> source_filter_arg("s", "source_filter_size",
"The leaf size of the voxel filter of the source cloud", false, 0, "float", cmd);
TCLAP::ValueArg<float> target_filter_arg("t", "target_filter_size",
"The leaf size of the voxel filter of the target cloud", false, 0, "float", cmd);
TCLAP::ValueArg<int> max_neighbours_arg("m", "max_neighbours",
"The max cardinality of the neighbours' set", false, 20, "int", cmd);
TCLAP::ValueArg<int> num_iter_arg("i", "num_iter",
"The maximum number of iterations to perform", false, 1000, "int", cmd);
TCLAP::ValueArg<float> dof_arg("d", "dof", "The Degree of freedom of t-distribution", false, 5,
"float", cmd);
TCLAP::ValueArg<float> radius_arg("r", "radius", "The radius of the neighborhood search", false, 3,
"float", cmd);
TCLAP::ValueArg<float> cost_drop_tresh_arg("c", "cost_drop_treshold",
"If the cost_drop drops below this threshold for too many iterations, the algorithm terminate",
false, 0.01, "float", cmd);
TCLAP::ValueArg<int> num_drop_iter_arg("n", "num_drop_iter",
"The maximum number of iterations during which the cost drop is allowed to be under cost_drop_thresh",
false, 5, "int", cmd);
TCLAP::SwitchArg use_gaussian_arg("u", "use_gaussian",
"Whether to use a gaussian instead the a t-distribution", cmd, false);
TCLAP::SwitchArg verbose_arg("v", "verbose",
"Verbosity", cmd, false);
TCLAP::ValueArg<std::string> ground_truth_arg("g", "ground_truth",
"The path of the ground truth for the source cloud, if available", false, "ground_truth.pcd",
"string", cmd);
TCLAP::SwitchArg dump_arg("", "dump",
"Dump registration data to file", cmd, false);
cmd.parse(argc, argv);
params.max_neighbours = max_neighbours_arg.getValue();
use_gaussian = use_gaussian_arg.getValue();
params.dof = dof_arg.getValue();
params.radius = radius_arg.getValue();
params.n_iter = num_iter_arg.getValue();
params.verbose = verbose_arg.getValue();
params.cost_drop_thresh = cost_drop_tresh_arg.getValue();
params.n_cost_drop_it = num_drop_iter_arg.getValue();
params.summary = dump_arg.getValue();
source_file_name = source_file_name_arg.getValue();
target_file_name = target_file_name_arg.getValue();
params.source_filter_size = source_filter_arg.getValue();
params.target_filter_size = target_filter_arg.getValue();
if (ground_truth_arg.isSet()) {
ground_truth = true;
ground_truth_file_name = ground_truth_arg.getValue();
}
} catch (TCLAP::ArgException &e) {
std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
exit(EXIT_FAILURE);
}
if (use_gaussian) {
if (params.verbose) {
std::cout << "Using gaussian model" << std::endl;
}
params.dof = std::numeric_limits<double>::infinity();
} else {
if (params.verbose) {
std::cout << "Using a t-distribution with " << params.dof << " dof" << std::endl;
}
}
if (params.verbose) {
std::cout << "Radius of the neighborhood search: " << params.radius << std::endl;
std::cout << "Max number of neighbours: " << params.max_neighbours << std::endl;
std::cout << "Max number of iterations: " << params.n_iter << std::endl;
std::cout << "Cost drop threshold: " << params.cost_drop_thresh << std::endl;
std::cout << "Num cost drop iter: " << params.n_cost_drop_it << std::endl;
std::cout << "Loading source point cloud from " << source_file_name << std::endl;
}
pcl::PointCloud<PointType>::Ptr source_cloud =
std::make_shared<pcl::PointCloud<PointType>>();
if (pcl::io::loadPCDFile<PointType>(source_file_name, *source_cloud) == -1) {
std::cout << "Could not load source cloud, closing" << std::endl;
exit(EXIT_FAILURE);
}
if (params.verbose) {
std::cout << "Loading target point cloud from " << target_file_name << std::endl;
}
pcl::PointCloud<PointType>::Ptr target_cloud =
std::make_shared<pcl::PointCloud<PointType>>();
if (pcl::io::loadPCDFile<PointType>(target_file_name, *target_cloud) == -1) {
std::cout << "Could not load target cloud, closing" << std::endl;
exit(EXIT_FAILURE);
}
pcl::PointCloud<PointType>::Ptr source_ground_truth;
if (ground_truth) {
std::cout << "Loading ground truth point cloud from " << ground_truth_file_name << std::endl;
source_ground_truth = std::make_shared<pcl::PointCloud<PointType>>();
if (pcl::io::loadPCDFile<PointType>(ground_truth_file_name, *source_ground_truth) == -1) {
std::cout << "Could not load ground truth" << std::endl;
ground_truth = false;
}
}
std::unique_ptr<ProbPointCloudRegistration> registration;
if (ground_truth) {
registration = std::make_unique<ProbPointCloudRegistration>(source_cloud, target_cloud, params,
source_ground_truth);
} else {
registration = std::make_unique<ProbPointCloudRegistration>(source_cloud, target_cloud,
params);
}
if (params.verbose) {
std::cout << "Registration\n";
}
registration->align();
auto estimated_transform = registration->transformation();
pcl::PointCloud<PointType>::Ptr aligned_source = std::make_shared<pcl::PointCloud<PointType>>();
pcl::transformPointCloud (*source_cloud, *aligned_source, estimated_transform);
if (params.verbose) {
std::cout << "Transformation history:" << std::endl;
for (auto trans : registration->transformation_history()) {
Eigen::Quaterniond rotq(trans.rotation());
std::cout << "T: " << trans.translation().x() << ", " << trans.translation().y() << ", " <<
trans.translation().z() << " ||| R: " << rotq.x() << ", " << rotq.y() << ", " << rotq.z() << ", " <<
rotq.w() << std::endl;
}
boost::filesystem::path source_path(source_file_name);
std::string aligned_source_name = "aligned_" + source_path.filename().string();
std::cout << "Saving aligned source cloud to: " << aligned_source_name.c_str() << std::endl;
pcl::io::savePCDFile(aligned_source_name, *aligned_source);
}
if (params.summary) {
boost::filesystem::path source_path(source_file_name);
boost::filesystem::path target_path(target_file_name);
std::string report_file_name = source_path.stem().string() + "_" + target_path.stem().string() + "_summary.txt";
std::cout << "Saving registration report to: " << report_file_name << std::endl;
std::ofstream report_file;
report_file.open(report_file_name);
report_file << "Source: " << source_file_name << " with filter size: " << params.source_filter_size
<<
std::endl;
report_file << "Target:" << target_file_name << " with filter size: " << params.target_filter_size
<<
std::endl;
report_file << "dof: " << params.dof << " | Radius: " << params.radius << " | Max_iter: " <<
params.n_iter << " | Max neigh: " << params.max_neighbours << " | Cost_drop_thresh_: " <<
params.cost_drop_thresh << " | N_cost_drop_it: " << params.n_cost_drop_it << std::endl;
report_file << registration->report();
}
if (ground_truth)
{
double mse_gtruth = prob_point_cloud_registration::calculateMSE(aligned_source, source_ground_truth);
std::cout <<"MSE w.r.t. ground truth: "<<mse_gtruth << std::endl;
}
return 0;
}
| 9,974
|
C++
|
.cc
| 175
| 44.531429
| 149
| 0.571443
|
iralabdisco/probabilistic_point_clouds_registration
| 30
| 11
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,815
|
prob_point_cloud_registration.cc
|
iralabdisco_probabilistic_point_clouds_registration/src/prob_point_cloud_registration.cc
|
#include <cstdio>
#include <fstream>
#include <thread>
#include <boost/make_shared.hpp>
#include <pcl/common/angles.h>
#include <pcl/common/transforms.h>
#include <pcl/kdtree/kdtree_flann.h>
#include "prob_point_cloud_registration/prob_point_cloud_registration.h"
#include "prob_point_cloud_registration/utilities.hpp"
namespace prob_point_cloud_registration {
ProbPointCloudRegistration::ProbPointCloudRegistration(
pcl::PointCloud<pcl::PointXYZ>::Ptr source_cloud,
pcl::PointCloud<pcl::PointXYZ>::Ptr target_cloud,
ProbPointCloudRegistrationParams parameters): parameters_(parameters),
target_cloud_(target_cloud), mse_ground_truth_(0), current_iteration_(0), mse_prev_it_(0),
cost_drop_(0), num_unusefull_iter_(0), output_stream_(parameters.verbose)
{
source_cloud_ = std::make_shared<pcl::PointCloud<pcl::PointXYZ>>(*source_cloud);
filtered_source_cloud_ = std::make_shared<pcl::PointCloud<pcl::PointXYZ>>();
if (parameters_.source_filter_size > 0) {
output_stream_ << "Filtering source point cloud with leaf of size " <<
parameters_.source_filter_size << "\n";
filter_.setInputCloud(source_cloud_);
filter_.setLeafSize(parameters_.source_filter_size, parameters_.source_filter_size,
parameters_.source_filter_size);
filter_.filter(*filtered_source_cloud_);
} else {
*filtered_source_cloud_ = *source_cloud_;
}
if (parameters_.target_filter_size > 0) {
output_stream_ << "Filtering target point cloud with leaf of size " <<
parameters_.target_filter_size << "\n";
filter_.setInputCloud(target_cloud_);
filter_.setLeafSize(parameters_.target_filter_size, parameters_.target_filter_size,
parameters_.target_filter_size);
filter_.filter(*target_cloud_);
}
if (parameters_.summary) {
prev_source_cloud_ = std::make_shared<pcl::PointCloud<pcl::PointXYZ>>(*source_cloud);
report_ <<
"iter, n_success_steps, initial_cost, final_cost, tx, ty, tz, roll, pitch, yaw, mse_prev_iter, mse_gtruth"
<< std::endl;
}
ground_truth_ = false;
}
ProbPointCloudRegistration::ProbPointCloudRegistration(
pcl::PointCloud<pcl::PointXYZ>::Ptr source_cloud,
pcl::PointCloud<pcl::PointXYZ>::Ptr target_cloud,
ProbPointCloudRegistrationParams parameters,
pcl::PointCloud<pcl::PointXYZ>::Ptr ground_truth_cloud):
ProbPointCloudRegistration::ProbPointCloudRegistration(source_cloud, target_cloud, parameters)
{
ground_truth_cloud_ = std::make_shared<pcl::PointCloud<pcl::PointXYZ>>(*ground_truth_cloud);
ground_truth_ = true;
mse_ground_truth_ = prob_point_cloud_registration::calculateMSE(source_cloud_, ground_truth_cloud_);
output_stream_ << "Initial MSE w.r.t. ground truth: " << mse_ground_truth_ << "\n";
}
void ProbPointCloudRegistration::align()
{
while (!hasConverged()) {
pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
kdtree.setInputCloud(target_cloud_);
std::vector<float> distances;
Eigen::SparseMatrix<double, Eigen::RowMajor> data_association(filtered_source_cloud_->size(),
target_cloud_->size());
std::vector<Eigen::Triplet<double>> tripletList;
for (std::size_t i = 0; i < filtered_source_cloud_->size(); i++) {
std::vector<int> neighbours;
kdtree.radiusSearch(*filtered_source_cloud_, i, parameters_.radius, neighbours, distances,
parameters_.max_neighbours);
int k = 0;
for (int j : neighbours) {
tripletList.push_back(Eigen::Triplet<double>(i, j, distances[k]));
k++;
}
}
data_association.setFromTriplets(tripletList.begin(), tripletList.end());
data_association.makeCompressed();
ProbPointCloudRegistrationIteration registration(*filtered_source_cloud_, *target_cloud_,
data_association,
parameters_);
ceres::Solver::Options options;
options.linear_solver_type = ceres::DENSE_QR;
options.use_nonmonotonic_steps = true;
if (parameters_.verbose) {
options.minimizer_progress_to_stdout = true;
} else {
options.minimizer_progress_to_stdout = false;
}
options.max_num_iterations = std::numeric_limits<int>::max();
options.function_tolerance = 10e-6;
options.num_threads = std::thread::hardware_concurrency();
ceres::Solver::Summary summary;
registration.solve(options, &summary);
Eigen::Affine3d current_trans;
if (current_iteration_ > 0) {
current_trans = registration.transformation() * transformation_history_.back();
} else {
current_trans = registration.transformation();
}
transformation_history_.push_back(current_trans);
output_stream_ << summary.FullReport() << "\n";
pcl::transformPointCloud (*source_cloud_, *source_cloud_, registration.transformation());
pcl::transformPointCloud (*filtered_source_cloud_, *filtered_source_cloud_,
registration.transformation());
if (ground_truth_) {
mse_ground_truth_ = prob_point_cloud_registration::calculateMSE(source_cloud_, ground_truth_cloud_);
output_stream_ << "MSE w.r.t. ground truth: " << mse_ground_truth_ << "\n";
}
cost_drop_ = (summary.initial_cost - summary.final_cost) / summary.initial_cost;
if (parameters_.summary) {
mse_prev_it_ = prob_point_cloud_registration::calculateMSE(source_cloud_, prev_source_cloud_);
*prev_source_cloud_ = *source_cloud_;
auto rpy = current_trans.rotation().eulerAngles(0, 1, 2);
report_ << current_iteration_ << ", " << summary.num_successful_steps << ", " <<
summary.initial_cost << ", " << summary.final_cost << ", " << current_trans.translation().x() <<
", " << current_trans.translation().y() << ", " << current_trans.translation().z() << ", " <<
pcl::rad2deg(rpy(0, 0)) << ", " << pcl::rad2deg(rpy(1, 0)) << ", " << pcl::rad2deg(rpy(2,
0)) << ", " << mse_prev_it_ << ", " << mse_ground_truth_ << std::endl;
}
current_iteration_++;
}
if (ground_truth_) {
mse_ground_truth_ = prob_point_cloud_registration::calculateMSE(source_cloud_, ground_truth_cloud_);
std::cout << "MSE w.r.t. ground truth: " << mse_ground_truth_ << std::endl;
}
}
bool ProbPointCloudRegistration::hasConverged()
{
if (current_iteration_ == parameters_.n_iter) {
output_stream_ << "Terminating because maximum number of iterations has been reached ( " <<
current_iteration_ << " iter)\n";
return true;
}
if (cost_drop_ < parameters_.cost_drop_thresh) {
if (num_unusefull_iter_ > parameters_.n_cost_drop_it) {
output_stream_ << "Terminating because cost drop has been under " << parameters_.cost_drop_thresh *
100 <<
" % for more than " << parameters_.n_cost_drop_it << " iterations\n";
return true;
} else {
num_unusefull_iter_++;
}
} else {
num_unusefull_iter_ = 0;
}
return false;
}
} // namespace prob_point_cloud_registration
| 7,732
|
C++
|
.cc
| 149
| 41.181208
| 177
| 0.604332
|
iralabdisco/probabilistic_point_clouds_registration
| 30
| 11
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,816
|
output_stream.hpp
|
iralabdisco_probabilistic_point_clouds_registration/include/prob_point_cloud_registration/output_stream.hpp
|
#ifndef PROB_POINT_CLOUD_REGISTRATION_OUTPUT_STREAM_HPP
#define PROB_POINT_CLOUD_REGISTRATION_OUTPUT_STREAM_HPP
#include <iostream>
namespace prob_point_cloud_registration {
class OutputStream
{
private:
bool verbose_;
public:
OutputStream(bool verbose): verbose_(verbose) {}
template <typename T>
OutputStream &operator<<(T &&t)
{
if (verbose_) {
std::cout << t;
}
return *this;
}
};
} // namespace prob_point_cloud_registration
#endif
| 502
|
C++
|
.h
| 21
| 19.809524
| 55
| 0.689076
|
iralabdisco/probabilistic_point_clouds_registration
| 30
| 11
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,817
|
utilities.hpp
|
iralabdisco_probabilistic_point_clouds_registration/include/prob_point_cloud_registration/utilities.hpp
|
#ifndef PROB_POINT_CLOUD_REGISTRATION_UTILITIES_HPP
#define PROB_POINT_CLOUD_REGISTRATION_UTILITIES_HPP
#include <assert.h>
#include <limits>
#include <Eigen/Core>
#include <Eigen/Sparse>
#include <pcl/common/distances.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/kdtree/kdtree_flann.h>
namespace prob_point_cloud_registration {
using pcl::euclideanDistance;
inline double calculateMSE(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1,
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2)
{
assert(cloud1->size() == cloud2->size());
double mse = 0;
for (int i = 0; i < cloud1->size(); i++) {
mse += euclideanDistance(cloud1->at(i), cloud2->at(i));
}
mse /= cloud1->size();
return mse;
}
inline double averageClosestDistance(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1,
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2)
{
double avgDistance = 0;
pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
kdtree.setInputCloud(cloud2);
for (std::size_t i = 0; i < cloud1->size(); i++) {
std::vector<int> neighbours;
std::vector<float> distances;
neighbours.reserve(1);
distances.reserve(1);
kdtree.nearestKSearch(*cloud1, i, 1, neighbours, distances);
avgDistance += distances[0];
}
avgDistance /= cloud1->size();
return avgDistance;
}
inline double sumSquaredError(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1,
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2)
{
double sum = 0;
double median_distance;
pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
kdtree.setInputCloud(cloud2);
for (std::size_t i = 0; i < cloud1->size(); i++) {
std::vector<int> neighbours;
std::vector<float> distances;
neighbours.reserve(1);
distances.reserve(1);
kdtree.nearestKSearch(*cloud1, i, 1, neighbours, distances);
sum += distances[0];
}
return sum;
}
inline double robustSumSquaredError(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1,
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2)
{
double sum = 0;
double median_distance;
pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
kdtree.setInputCloud(cloud2);
std::vector<double> all_distances;
for (std::size_t i = 0; i < cloud1->size(); i++) {
std::vector<int> neighbours;
std::vector<float> distances;
neighbours.reserve(1);
distances.reserve(1);
kdtree.nearestKSearch(*cloud1, i, 1, neighbours, distances);
all_distances.push_back(distances[0]);
}
std::sort(all_distances.begin(), all_distances.end());
if (all_distances.size() % 2 != 0) {
median_distance = all_distances[(all_distances.size() + 1) / 2];
} else {
median_distance = (all_distances[all_distances.size() / 2] + all_distances[(all_distances.size() /
2) + 1]) / 2.0;
}
int num_filtered = 0;
for (auto it = all_distances.begin(); it != all_distances.end(); it++) {
if (*it <= median_distance * 3 && *it >= median_distance / 3) {
sum += (*it);
num_filtered++;
}
}
if (num_filtered < 10) {
return std::numeric_limits<double>::max();
}
return sum;
}
inline double robustSumSquaredError(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1,
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2, double factor)
{
double sum = 0;
double median_distance;
pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
kdtree.setInputCloud(cloud2);
std::vector<double> all_distances;
for (std::size_t i = 0; i < cloud1->size(); i++) {
std::vector<int> neighbours;
std::vector<float> distances;
neighbours.reserve(1);
distances.reserve(1);
kdtree.nearestKSearch(*cloud1, i, 1, neighbours, distances);
all_distances.push_back(distances[0]);
}
std::sort(all_distances.begin(), all_distances.end());
if (all_distances.size() % 2 != 0) {
median_distance = all_distances[(all_distances.size() + 1) / 2];
} else {
median_distance = (all_distances[all_distances.size() / 2] + all_distances[(all_distances.size() /
2) + 1]) / 2.0;
}
int num_filtered = 0;
for (auto it = all_distances.begin(); it != all_distances.end(); it++) {
if (*it <= median_distance * factor && *it >= median_distance / factor) {
sum += (*it);
num_filtered++;
}
}
if (num_filtered < 10) {
return std::numeric_limits<double>::max();
}
return sum;
}
inline double robustAveragedSumSquaredError(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1,
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2)
{
double sum = 0;
double median_distance;
pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
kdtree.setInputCloud(cloud2);
std::vector<double> all_distances;
for (std::size_t i = 0; i < cloud1->size(); i++) {
std::vector<int> neighbours;
std::vector<float> distances;
neighbours.reserve(1);
distances.reserve(1);
kdtree.nearestKSearch(*cloud1, i, 1, neighbours, distances);
all_distances.push_back(distances[0]);
}
std::sort(all_distances.begin(), all_distances.end());
if (all_distances.size() % 2 != 0) {
median_distance = all_distances[(all_distances.size() + 1) / 2];
} else {
median_distance = (all_distances[all_distances.size() / 2] + all_distances[(all_distances.size() /
2) + 1]) / 2.0;
}
int num_filtered = 0;
for (auto it = all_distances.begin(); it != all_distances.end(); it++) {
if (*it <= median_distance * 3 && *it >= median_distance / 3) {
sum += (*it);
num_filtered++;
}
}
if (num_filtered < 10) {
return std::numeric_limits<double>::max();
}
return sum / num_filtered;
}
inline double medianClosestDistance(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1,
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2)
{
double median_distance = 0;
pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
kdtree.setInputCloud(cloud2);
std::vector<float> distances;
for (std::size_t i = 0; i < cloud1->size(); i++) {
std::vector<int> neighbours;
std::vector<float> dist;
neighbours.reserve(1);
distances.reserve(1);
kdtree.nearestKSearch(*cloud1, i, 1, neighbours, dist);
distances.push_back(dist[0]);
}
std::sort(distances.begin(), distances.end());
if (distances.size() % 2 != 0) {
median_distance = distances[(distances.size() + 1) / 2];
} else {
median_distance = (distances[distances.size() / 2] + distances[(distances.size() / 2) + 1]) / 2.0;
}
return median_distance;
}
inline double robustMedianClosestDistance(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1,
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2)
{
double median_distance = 0;
pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
kdtree.setInputCloud(cloud2);
std::vector<float> distances;
std::vector<float> filtered_distances;
for (std::size_t i = 0; i < cloud1->size(); i++) {
std::vector<int> neighbours;
std::vector<float> dist;
neighbours.reserve(1);
distances.reserve(1);
kdtree.nearestKSearch(*cloud1, i, 1, neighbours, dist);
distances.push_back(dist[0]);
}
std::sort(distances.begin(), distances.end());
if (distances.size() % 2 != 0) {
median_distance = distances[(distances.size() + 1) / 2];
} else {
median_distance = (distances[distances.size() / 2] + distances[(distances.size() / 2) + 1]) / 2.0;
}
for (auto it = distances.begin(); it != distances.end(); it++) {
if (*it <= median_distance * 3 && *it >= median_distance / 3.0) {
filtered_distances.push_back(*it);
}
}
if (filtered_distances.size() % 2 != 0) {
median_distance = filtered_distances[(filtered_distances.size() + 1) / 2];
} else {
median_distance = (filtered_distances[filtered_distances.size() / 2] +
filtered_distances[(filtered_distances.size() / 2) + 1]) / 2.0;
}
return median_distance / filtered_distances.size();
}
inline double medianDistance(std::vector<Eigen::Triplet<double>> tripletList)
{
double median_distance;
std::sort(tripletList.begin(), tripletList.end(), [] (Eigen::Triplet<double> x,
Eigen::Triplet<double> y) {
return x.value() < y.value();
});
if (tripletList.size() % 2 != 0) {
median_distance = tripletList[(tripletList.size() + 1) / 2].value();
} else {
median_distance = (tripletList[tripletList.size() / 2].value() + tripletList[(tripletList.size() /
2) + 1].value()) / 2.0;
}
return median_distance;
}
inline Eigen::Quaterniond
euler2Quaternion( const double roll,
const double pitch,
const double yaw )
{
Eigen::AngleAxisd rollAngle(roll, Eigen::Vector3d::UnitX());
Eigen::AngleAxisd pitchAngle(pitch, Eigen::Vector3d::UnitY());
Eigen::AngleAxisd yawAngle(yaw, Eigen::Vector3d::UnitZ());
Eigen::Quaterniond q = yawAngle * pitchAngle * rollAngle;
return q;
}
} // namespace prob_point_cloud_registration
#endif
| 9,765
|
C++
|
.h
| 248
| 31.149194
| 109
| 0.588966
|
iralabdisco/probabilistic_point_clouds_registration
| 30
| 11
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,822
|
prob_point_cloud_registration_params.hpp
|
iralabdisco_probabilistic_point_clouds_registration/include/prob_point_cloud_registration/prob_point_cloud_registration_params.hpp
|
#ifndef PROB_POINT_CLOUD_REGISTRATION_POINT_CLOUD_REGISTRATION_PARAMS_HPP
#define PROB_POINT_CLOUD_REGISTRATION_POINT_CLOUD_REGISTRATION_PARAMS_HPP
namespace prob_point_cloud_registration {
struct ProbPointCloudRegistrationParams {
int max_neighbours = 20;
double dof = 5;
double radius = 1;
int n_iter = 1000;
double cost_drop_thresh = 0.01;
double n_cost_drop_it = 5;
bool verbose = false;
bool summary = false;
double initial_rotation[4] = {1, 0, 0, 0};
double initial_translation[3] = {0, 0, 0};
double source_filter_size = 0;
double target_filter_size = 0;
};
}
#endif
| 624
|
C++
|
.h
| 19
| 29.210526
| 73
| 0.713101
|
iralabdisco/probabilistic_point_clouds_registration
| 30
| 11
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,823
|
prob_point_cloud_registration.h
|
iralabdisco_probabilistic_point_clouds_registration/include/prob_point_cloud_registration/prob_point_cloud_registration.h
|
#ifndef PROB_POINT_CLOUD_REGISTRATION_POINT_CLOUD_REGISTRATION_HPP
#define PROB_POINT_CLOUD_REGISTRATION_POINT_CLOUD_REGISTRATION_HPP
#include <sstream>
#include <Eigen/Core>
#include <pcl/filters/filter.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include "prob_point_cloud_registration/output_stream.hpp"
#include "prob_point_cloud_registration/prob_point_cloud_registration_iteration.hpp"
#include "prob_point_cloud_registration/prob_point_cloud_registration_params.hpp"
namespace prob_point_cloud_registration {
class ProbPointCloudRegistration
{
public:
ProbPointCloudRegistration(
pcl::PointCloud<pcl::PointXYZ>::Ptr source_cloud,
pcl::PointCloud<pcl::PointXYZ>::Ptr target_cloud,
ProbPointCloudRegistrationParams parameters);
ProbPointCloudRegistration(
pcl::PointCloud<pcl::PointXYZ>::Ptr source_cloud,
pcl::PointCloud<pcl::PointXYZ>::Ptr target_cloud,
ProbPointCloudRegistrationParams parameters,
pcl::PointCloud<pcl::PointXYZ>::Ptr ground_truth_cloud);
void align();
bool hasConverged();
inline Eigen::Affine3d transformation()
{
return transformation_history_.back();
}
inline std::vector<Eigen::Affine3d> transformation_history()
{
return transformation_history_;
}
inline std::string report()
{
return report_.str();
}
private:
ProbPointCloudRegistrationParams parameters_;
pcl::PointCloud<pcl::PointXYZ>::Ptr target_cloud_;
pcl::PointCloud<pcl::PointXYZ>::Ptr source_cloud_;
pcl::PointCloud<pcl::PointXYZ>::Ptr filtered_source_cloud_;
pcl::PointCloud<pcl::PointXYZ>::Ptr prev_source_cloud_;
pcl::PointCloud<pcl::PointXYZ>::Ptr ground_truth_cloud_;
bool ground_truth_;
double mse_ground_truth_;
double mse_prev_it_;
double cost_drop_;
int num_unusefull_iter_;
int current_iteration_;
OutputStream output_stream_;
std::vector<Eigen::Affine3d> transformation_history_;
std::stringstream report_;
pcl::VoxelGrid<pcl::PointXYZ> filter_;
};
} // namespace prob_point_cloud_registration
#endif
| 2,161
|
C++
|
.h
| 58
| 32.706897
| 84
| 0.737219
|
iralabdisco/probabilistic_point_clouds_registration
| 30
| 11
| 0
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,861
|
lgtstore.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgtstore.cpp
|
#include "lgtstore.h"
#if ENABLED(LGT_LCD_TFT)
#include "w25qxx.h"
#include "lgtsdcard.h"
#include "lgttftlanguage.h"
#include "lgttouch.h"
#include "lgtsdcard.h"
// #include "../../src/libs/crc16.h"
#include "../feature/runout.h"
#include "../feature/powerloss.h"
#define WRITE_VAR(value) do { FLASH_WRITE_VAR(addr, value); addr += sizeof(value); } while(0)
#define READ_VAR(value) do { FLASH_READ_VAR(addr, value); addr += sizeof(value); } while(0)
LgtStore lgtStore;
// this coanst text arry must sync with settings struct and settingPointer function
static const char *txt_menu_setts[SETTINGS_MAX_LEN] = {
TXT_MENU_SETTS_JERK_X, // 0
TXT_MENU_SETTS_JERK_Y,
TXT_MENU_SETTS_JERK_Z,
TXT_MENU_SETTS_JERK_E,
TXT_MENU_SETTS_VMAX_X,
TXT_MENU_SETTS_VMAX_Y, // 5
TXT_MENU_SETTS_VMAX_Z,
TXT_MENU_SETTS_VMAX_E,
TXT_MENU_SETTS_VMIN,
TXT_MENU_SETTS_VTRAVEL,
TXT_MENU_SETTS_AMAX_X, // 10
TXT_MENU_SETTS_AMAX_Y,
TXT_MENU_SETTS_AMAX_Z,
TXT_MENU_SETTS_AMAX_E,
TXT_MENU_SETTS_ARETRACT,
TXT_MENU_SETTS_STEP_X, // 15
TXT_MENU_SETTS_STEP_Y,
TXT_MENU_SETTS_STEP_Z,
TXT_MENU_SETTS_STEP_E,
TXT_MENU_SETTS_ACCL,
TXT_MENU_SETTS_LIST_ORDER, // 20
TXT_MENU_SETTS_CHECK_FILA,
TXT_MENU_SETTS_RECOVERY
};
LgtStore::LgtStore()
{
memset(reinterpret_cast<void *>(&m_settings), 0, sizeof(m_settings));
clear();
}
/**
* @brief save lgt custom settings into spiflash,
* and run M500 command or save other settings
*/
void LgtStore::save()
{
// set version string
strcpy(m_settings.version, SETTINGS_VERSION);
// calc crc
// uint16_t crc = 0;
// crc16(&crc, reinterpret_cast<void *>(&m_settings.acceleration), sizeof(m_settings) - 4 - 2);
// SERIAL_ECHOLNPAIR("save crc: ", crc);
// m_settings.crc = crc;
// save lgt custom settings in spiflash
uint32_t addr = SPIFLASH_ADDR_SETTINGS;
WRITE_VAR(m_settings.version);
WRITE_VAR(m_settings.listOrder);
SERIAL_ECHOPAIR("settings stored in spiflash(", addr - SPIFLASH_ADDR_SETTINGS);
SERIAL_ECHOLN(" bytes)");
// save other settings in internal flash
queue.enqueue_now_P("M500");
setModified(false);
}
/**
* validate if settings is stored in spiflash
*/
bool LgtStore::validate(const char *current, const char*stored)
{
if (strcmp(current, stored) == 0)
return true;
return false;
}
/**
* @brief load lgt custom settings from spiflash,
* spi flash -> settings struct -> memory(apply),
* load sequence must be consistent with save sequcence.
*/
bool LgtStore::load()
{
uint32_t addr = SPIFLASH_ADDR_SETTINGS;
SERIAL_ECHOLN("-- load settings form spiflash start --");
READ_VAR(m_settings.version);
SERIAL_ECHOLNPAIR("stored version: ", m_settings.version);
SERIAL_ECHOLNPAIR("current version: ", SETTINGS_VERSION);
if (!validate(SETTINGS_VERSION, m_settings.version)) {
SERIAL_ECHOLN("load failed, reset settings");
_reset();
return false;
}
READ_VAR(m_settings.listOrder);
SERIAL_ECHOLNPAIR("listOrder: ", m_settings.listOrder);
lgtCard.setListOrder(m_settings.listOrder);
SERIAL_ECHOLN("-- load settings form spiflash end --");
return true;
}
/**
* reset lgt custom variables
*/
void LgtStore::_reset()
{
lgtCard.setListOrder(true);
}
/**
* reset all variables
*/
void LgtStore::reset()
{
float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[] = DEFAULT_MAX_FEEDRATE;
long tmp3[] = DEFAULT_MAX_ACCELERATION;
LOOP_XYZE_N(i) {
planner.settings.axis_steps_per_mm[i] = tmp1[i];
planner.settings.max_feedrate_mm_s[i] = tmp2[i];
planner.settings.max_acceleration_mm_per_s2[i] = tmp3[i];
}
planner.refresh_positioning();
planner.settings.acceleration = DEFAULT_ACCELERATION;
planner.settings.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;;
planner.settings.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
planner.settings.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
#if DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE)
planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
#endif
runout.enabled = true;
recovery.enable(PLR_ENABLED_DEFAULT);
_reset();
}
/**
* apply settings struct to variables
*/
void LgtStore::applySettings()
{
LOOP_XYZE_N(i) {
planner.settings.axis_steps_per_mm[i] = m_settings.axis_steps_per_unit[i];
planner.settings.max_feedrate_mm_s[i] = m_settings.max_feedrate[i];
planner.settings.max_acceleration_mm_per_s2[i] = m_settings.max_acceleration_units_per_sq_second[i];
}
planner.refresh_positioning();
planner.settings.acceleration = m_settings.acceleration;
planner.settings.retract_acceleration = m_settings.retract_acceleration;;
planner.settings.min_feedrate_mm_s = m_settings.minimumfeedrate;
planner.settings.min_travel_feedrate_mm_s = m_settings.mintravelfeedrate;
planner.max_jerk[X_AXIS] = m_settings.max_x_jerk;
planner.max_jerk[Y_AXIS] = m_settings.max_y_jerk;
planner.max_jerk[Z_AXIS] = m_settings.max_z_jerk;
#if DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE)
planner.max_jerk[E_AXIS] = m_settings.max_e_jerk;
#endif
lgtCard.setListOrder(m_settings.listOrder);
runout.enabled = m_settings.enabledRunout;
recovery.enable(m_settings.enabledPowerloss);
}
/**
* sync variables to settings struct
*/
void LgtStore::syncSettings()
{
LOOP_XYZE_N(i) {
m_settings.axis_steps_per_unit[i] = planner.settings.axis_steps_per_mm[i];
m_settings.max_feedrate[i] = planner.settings.max_feedrate_mm_s[i];
m_settings.max_acceleration_units_per_sq_second[i] = planner.settings.max_acceleration_mm_per_s2[i];
}
// planner.refresh_positioning();
m_settings.acceleration = planner.settings.acceleration;
m_settings.retract_acceleration = planner.settings.retract_acceleration;
m_settings.minimumfeedrate = planner.settings.min_feedrate_mm_s;
m_settings.mintravelfeedrate = planner.settings.min_travel_feedrate_mm_s;
m_settings.max_x_jerk = planner.max_jerk[X_AXIS];
m_settings.max_y_jerk = planner.max_jerk[Y_AXIS];
m_settings.max_z_jerk = planner.max_jerk[Z_AXIS];
#if DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE)
m_settings.max_e_jerk = planner.max_jerk[E_AXIS];
#endif
m_settings.listOrder = lgtCard.isReverseList();
m_settings.enabledRunout = runout.enabled;
m_settings.enabledPowerloss = recovery.enabled;
}
/**
* @brief get settting string for lcd
*/
void LgtStore::settingString(uint8_t i, char* str)
{
char p[10] = {0};
if (i >= SETTINGS_MAX_LEN) { /* error index */
return;
} else if (i > 20) { /* bool type: off/on */
#ifndef Chinese
const char * format = "%8s";
#else
const char * format = "%5s";
#endif
if(*reinterpret_cast<bool *>(settingPointer(i)))
sprintf(p, format, TXT_MENU_SETTS_VALUE_ON);
else
sprintf(p, format, TXT_MENU_SETTS_VALUE_OFF);
} else if (i == 20) { // bool type: inverse/forward
#ifndef Chinese
const char * format = "%8s";
#else
const char * format = "%5s";
#endif
if(*reinterpret_cast<bool *>(settingPointer(i)))
sprintf(p, format, TXT_MENU_SETTS_VALUE_INVERSE);
else
sprintf(p, format, TXT_MENU_SETTS_VALUE_FORWARD);
} else if (i >= 10 && i<= 13) { /* uint32 type */
#ifndef Chinese
sprintf(p,"%8lu", *reinterpret_cast<uint32_t *>(settingPointer(i)));
#else
sprintf(p,"%6lu", *reinterpret_cast<uint32_t *>(settingPointer(i)));
#endif
} else { /* float type */
sprintf(p,"%8.2f", *reinterpret_cast<float *>(settingPointer(i)));
}
sprintf(str, "%-20s%s", txt_menu_setts[i], p);
}
void *LgtStore::settingPointer(uint8_t i)
{
switch(i)
{
// float type
case 0:
return &m_settings.max_x_jerk;
case 1:
return &m_settings.max_y_jerk;
case 2:
return &m_settings.max_z_jerk;
case 3:
return &m_settings.max_e_jerk;
case 4:
return &m_settings.max_feedrate[X_AXIS];
case 5:
return &m_settings.max_feedrate[Y_AXIS];
case 6:
return &m_settings.max_feedrate[Z_AXIS];
case 7:
return &m_settings.max_feedrate[E_AXIS];
case 8:
return &m_settings.minimumfeedrate;
case 9:
return &m_settings.mintravelfeedrate;
// uint32 type
case 10:
return &m_settings.max_acceleration_units_per_sq_second[X_AXIS];
case 11:
return &m_settings.max_acceleration_units_per_sq_second[Y_AXIS];
case 12:
return &m_settings.max_acceleration_units_per_sq_second[Z_AXIS];
case 13:
return &m_settings.max_acceleration_units_per_sq_second[E_AXIS];
// float type
case 14:
return &m_settings.retract_acceleration;
case 15:
return &m_settings.axis_steps_per_unit[X_AXIS];
case 16:
return &m_settings.axis_steps_per_unit[Y_AXIS];
case 17:
return &m_settings.axis_steps_per_unit[Z_AXIS];
case 18:
return &m_settings.axis_steps_per_unit[E_AXIS];
case 19:
return &m_settings.acceleration;
// bool type
case 20:
return &m_settings.listOrder;
case 21:
return &m_settings.enabledRunout;
case 22:
return &m_settings.enabledPowerloss;
default: return 0;
}
}
float LgtStore::distanceMultiplier(uint8_t i)
{
switch(i){
case 2: case 15: case 16: case 17: case 18:
return 0.1;
case 0: case 1: case 3:case 4: case 5: case 6: case 7:
case 8: case 9: case 12:
return 1.0;
case 10: case 11: case 13: case 14: case 19:
return 100.0;
default:
return 0.0;
}
}
/**
* @brief change setting value
* @param i setting index
* @param distance change value
* @retval None
*/
void LgtStore::changeSetting(uint8_t i, int8_t distance)
{
if(i >= SETTINGS_MAX_LEN){ /* error index */
return;
}
else if(i >= 20) /* bool type */
{
*(bool *)settingPointer(i) = !(*(bool *)settingPointer(i));
}
else if(i >= 10 && i<= 13) /* unsigned long type */
{
*(unsigned long *)settingPointer(i) = *(unsigned long *)settingPointer(i) +
distance * (unsigned long)distanceMultiplier(i);
if((long)*(unsigned long *)settingPointer(i) < 0)
*(unsigned long *)settingPointer(i) = 0; //minimum value
}
else /* float type */
{
*(float *)settingPointer(i) = *(float *)settingPointer(i) + distance * distanceMultiplier(i);
if(*(float *)settingPointer(i) < 0.0)
*(float *)settingPointer(i) = 0.0; //minimum value
}
setModified(true);
}
bool LgtStore::selectSetting(uint16_t item)
{
if (item < LIST_ITEM_MAX) {
uint16_t n = m_currentPage * LIST_ITEM_MAX + item;
if (n < SETTINGS_MAX_LEN) {
m_currentItem = item;
m_currentSetting = n;
m_isSelectSetting = true;
return false; // success to set
}
}
return true; // fail to set
}
/**
* @brief save touch calibration data into spiflash
*/
void LgtStore::saveTouch()
{
TouchCalibration &touch = lgtTouch.calibrationData();
// set version string
strcpy(touch.version, TOUCH_VERSION);
// save calibration data in spiflash
uint32_t addr = SPIFLASH_ADDR_TOUCH;
WRITE_VAR(touch);
SERIAL_ECHOPAIR("touch data stored in spiflash(", addr - SPIFLASH_ADDR_TOUCH);
SERIAL_ECHOLN(" bytes)");
}
/**
* @brief load touch calibration data from spiflash
*/
bool LgtStore::loadTouch()
{
SERIAL_ECHOLN("-- load touch data form spiflash start --");
uint32_t addr = SPIFLASH_ADDR_TOUCH;
TouchCalibration &touch = lgtTouch.calibrationData();
READ_VAR(touch.version);
SERIAL_ECHOLNPAIR("stored version: ", touch.version);
SERIAL_ECHOLNPAIR("current version: ", TOUCH_VERSION);
if (!validate(TOUCH_VERSION, touch.version)) {
SERIAL_ECHOLN("load failed. calibrate touch screen");
// lgtTouch.resetCalibration();
lgtTouch.calibrate(false);
return false;
}
READ_VAR(touch.xCalibration);
SERIAL_ECHOLNPAIR("xCali: ", touch.xCalibration);
READ_VAR(touch.yCalibration);
SERIAL_ECHOLNPAIR("yCali: ", touch.yCalibration);
READ_VAR(touch.xOffset);
SERIAL_ECHOLNPAIR("xOffset: ", touch.xOffset);
READ_VAR(touch.yOffset);
SERIAL_ECHOLNPAIR("yOffset: ", touch.yOffset);
SERIAL_ECHOLN("-- load touch data form spiflash end --");
return true;
}
/**
* @brief save data of powerloss into spiflash
*/
void LgtStore::saveRecovery()
{
// save recovery data in spiflash
uint32_t addr = SPIFLASH_ADDR_RECOVERY;
// SERIAL_ECHOLNPAIR("save filename: ", card.longFilename);
WRITE_VAR(card.longFilename);
WRITE_VAR(lgtCard.printTime());
SERIAL_ECHOPAIR("recovery data stored in spiflash(", addr - SPIFLASH_ADDR_RECOVERY);
SERIAL_ECHOLN(" bytes)");
}
/**
* @brief load data of powerloss into spiflash
*/
bool LgtStore::loadRecovery()
{
SERIAL_ECHOLN("-- load recovery data form spiflash start --");
uint32_t addr = SPIFLASH_ADDR_RECOVERY;
READ_VAR(card.longFilename);
SERIAL_ECHOLNPAIR("longfilename: ", card.longFilename);
READ_VAR(lgtCard.printTime());
SERIAL_ECHOLNPAIR("printTime: ", lgtCard.printTime());
SERIAL_ECHOLN("-- load recovery data from spiflash end --");
return true;
}
/**
* @brief clear verison value of settings stored in spiflash
*/
void LgtStore::clearSettings()
{
char tmp[4] = {0};
FLASH_WRITE_VAR(SPIFLASH_ADDR_SETTINGS, tmp);
SERIAL_ECHOLN("settings in spiflash has been cleared");
}
/**
* @brief clear version value of touch calibration stored in spiflash
*/
void LgtStore::clearTouch()
{
char tmp[4] = {0};
FLASH_WRITE_VAR(SPIFLASH_ADDR_TOUCH, tmp);
SERIAL_ECHOLN("touch data in spiflash has been cleared");
}
#endif
| 14,119
|
C++
|
.cpp
| 425
| 28.781176
| 108
| 0.66889
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,862
|
lgtsdcard.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgtsdcard.cpp
|
// #include "../inc/MarlinConfigPre.h"
#include "lgtsdcard.h"
#if ENABLED(LGT_LCD_TFT)
#include "../module/printcounter.h"
#include "../HAL/STM32F1/sdio.h"
#include "lgtstore.h"
// #define DEBUG_LGTSDCARD
#define DEBUG_OUT ENABLED(DEBUG_LGTSDCARD)
#include "../../core/debug_out.h"
LgtSdCard lgtCard;
// init class static variable
char LgtSdCard::gComment[GCOMMENT_SIZE];
uint8_t LgtSdCard::indexGc = 0;
// define static variable and function
static char *CodePointer = nullptr;
static inline bool codeSeen(char *p,char code)
{
CodePointer = strchr(p,code);
return(CodePointer != nullptr);
}
static inline uint16_t codeValue()
{
return (strtoul(CodePointer + 1, nullptr, 10));
}
static inline uint16_t codeValue2()
{
return (strtoul(CodePointer + 17, nullptr, 10));
}
// class function definition
LgtSdCard::LgtSdCard()
{
clear();
m_printTime = 0;
ZERO(parentSelectFile);
}
uint16_t LgtSdCard::count()
{
if (card.isMounted()) {
m_fileCount = card.get_num_Files();
m_pageCount = m_fileCount / LIST_ITEM_MAX;
if(m_fileCount % LIST_ITEM_MAX > 0)
m_pageCount++;
} else {
m_fileCount = 0;
m_pageCount = 0;
}
return m_fileCount;
}
/**
* clear part of file variable when init card
*/
void LgtSdCard::_clear()
{
m_fileCount = 0;
m_pageCount = 0;
m_currentPage = 0;
m_currentItem = 0;
m_currentFile = 0;
m_isSelectFile = false;
}
/**
* clear all file variable when init card
*/
void LgtSdCard::clear()
{
_clear();
indexGc = 0;
m_dirDepth = 0;
}
bool LgtSdCard::isDir()
{
return card.flag.filenameIsDir;
}
/**
* filename for open file
*/
const char *LgtSdCard::shortFilename()
{
if (!m_isSelectFile)
return nullptr;
return card.filename;
}
/**
* longfilename for showing
*/
const char *LgtSdCard::longFilename()
{
// if (!m_isSelectFile)
// return nullptr;
return card.longFilename;
}
/**
* get trimmed longfilename(no more than 25 char) for showing in lcd
*/
const char *LgtSdCard::filename(uint16_t i)
{
#define MAX_TRIM_FILENAME_LEN 25
if (m_fileCount == 0)
return nullptr;
card.getfilename_sorted(i);
char *fn = card.longFilename[0] ? card.longFilename : card.filename;
uint16_t len = strlen(fn);
if (len > MAX_TRIM_FILENAME_LEN) {
// const char *suffix = "...";
// strncpy_P(fn + MAX_TRIM_FILENAME_LEN - 3, suffix, sizeof(suffix));
fn[MAX_TRIM_FILENAME_LEN - 3] = '.';
fn[MAX_TRIM_FILENAME_LEN - 2] = '.';
fn[MAX_TRIM_FILENAME_LEN - 1] = '.';
fn[MAX_TRIM_FILENAME_LEN ] = '\0';
fn[MAX_TRIM_FILENAME_LEN + 1] = '\0';
}
return fn;
}
/**
* get trimmed longfilename if select a file
*/
const char *LgtSdCard::filename()
{
if (m_isSelectFile) {
return filename(m_currentFile);
} else {
return nullptr;
}
}
/**
* try to select a file in file list
* return 0: failed to set when exceed file index scope
*/
uint8_t LgtSdCard::selectFile(uint16_t item)
{
if (item < LIST_ITEM_MAX) {
if (m_isReverseList) {
uint16_t n = m_currentPage * LIST_ITEM_MAX + item + 1;
if ( n <= m_fileCount) {
m_currentItem = item;
m_currentFile = m_fileCount - n;
m_isSelectFile = true;
return 1; // success to set
}
} else {
uint16_t n = m_currentPage * LIST_ITEM_MAX + item;
if (n < m_fileCount) {
m_currentItem = item;
m_currentFile = n;
m_isSelectFile = true;
return 1; // success to set
}
}
}
return 0; // fail to set
}
/**
* get the page of selected file
*/
uint16_t LgtSdCard::selectedPage()
{
if (!m_isSelectFile)
return 0;
if (m_isReverseList) {
return (m_fileCount - 1 - m_currentFile) / LIST_ITEM_MAX;
} else {
return m_currentFile / LIST_ITEM_MAX;
}
}
/**
* get the page of selected file
*/
uint16_t LgtSdCard::selectedItem()
{
if (!m_isSelectFile)
return 0;
if (m_isReverseList) {
return (m_fileCount - 1 - m_currentFile) % LIST_ITEM_MAX;
} else {
return m_currentFile % LIST_ITEM_MAX;
}
}
bool LgtSdCard::isMaxDirDepth()
{
return (dirDepth() >= MAX_DIR_DEPTH);
}
bool LgtSdCard::isRootDir()
{
return dirDepth() == 0;/* card.flag.workDirIsRoot */; //
}
void LgtSdCard::changeDir(const char *relpath)
{
card.cd(relpath);
}
int8_t LgtSdCard::upDir()
{
return card.cdup();
}
/**
* get up time form lcd
*/
void LgtSdCard::upTime(char *p)
{
uint16_t h, m, s;
h = print_job_timer.duration() / 3600;
m = print_job_timer.duration() % 3600 / 60;
s = print_job_timer.duration() % 60;
sprintf(p,"%02d:%02d:%02d", h, m, s);
}
/**
* get down time for lcd
*/
void LgtSdCard::downTime(char *p)
{
if (m_printTime == 0)
return;
uint16_t remain, h, m;
remain= uint16(ceil(float(m_printTime) * card.ratioNotDone()));
h = remain / 60;
m = remain % 60;
// DEBUG_ECHOLNPAIR_F("remain ratio: ", card.ratioNotDone());
// DEBUG_ECHOLNPAIR("remain: ", remain);
sprintf(p, "%d H %d M", h, m);
}
/**
* parse and get total print time from gcode comment
*/
void LgtSdCard::parseComment()
{
if (strstr(gComment, "TIME:") != nullptr) {
DEBUG_ECHOLNPAIR("comment:", gComment);
parseCura();
lgtStore.saveRecovery();
}
else if(strstr(gComment,"Print time") != nullptr)
{
DEBUG_ECHOLNPAIR("comment:", gComment);
parseLegacyCura();
lgtStore.saveRecovery();
}
}
/**
* parse cura(after v2.0) gcode comment
*/
void LgtSdCard::parseCura()
{
uint32_t second = 0;
char *p = strchr(gComment, ':');
if(p != nullptr){
second = uint32_t(strtol(p + 1, nullptr, 10));
m_printTime = second / 60;
DEBUG_ECHOLNPAIR("printTime:", m_printTime);
}
}
/**
* parse old cura(before v2.0) gocde comment
*/
void LgtSdCard::parseLegacyCura()
{
uint16_t hour = 0;
uint16_t minute = 0;
if (strstr(gComment,"hour") != nullptr) { // x hour(s)
if (codeSeen(gComment,':'))
hour = codeValue();
if (hour == 1) {
if (codeSeen(gComment,'r')) // 1 hour
minute = codeValue2();
} else if (codeSeen(gComment,'s')) { // x hours
minute = codeValue() ;
}
} else if(codeSeen(gComment,':')) { // minute(s)
minute = codeValue();
}
m_printTime = hour * 60 + minute;
DEBUG_ECHOLNPAIR("hour:", hour);
DEBUG_ECHOLNPAIR("minute:", minute);
DEBUG_ECHOLNPAIR("printTime:", m_printTime);
}
CardUpdate LgtSdCard::update()
{
SDIO_Init();
const bool state = (SDIO_GetCardState() != SDIO_CARD_ERROR); // true: sd ok
if (state != m_cardState) {
m_cardState = state;
if (state) {
card.mount();
if (card.isMounted()) {
DEBUG_ECHOLNPAIR("card mount ok");// ExtUI::onMediaInserted();
return CardUpdate::MOUNTED;
} else {
DEBUG_ECHOLNPAIR("card mount error");// ExtUI::onMediaError();
return CardUpdate::ERROR;
}
} else {
const bool ok = card.isMounted();
card.release();
if (ok) {
DEBUG_ECHOLNPAIR("card removed");// ExtUI::onMediaRemoved();
return CardUpdate::REMOVED;
}
}
}
return CardUpdate::NOCHANGED;
}
#endif // LGT_LCD_TFT
| 7,444
|
C++
|
.cpp
| 300
| 20.41
| 79
| 0.612621
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,863
|
lgttouch.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgttouch.cpp
|
#include "../inc/MarlinConfig.h"
#if ENABLED(LGT_LCD_TFT)
#include "lgttouch.h"
#include "lcddrive/lcdapi.h"
#include "lgttftlanguage.h"
#include "lgtstore.h"
#include "../module/temperature.h"
//#define DEBUG_LGT_TOUCH
#define DEBUG_OUT ENABLED(DEBUG_LGT_TOUCH)
#include "../../core/debug_out.h"
#define MAX_READ_XY_REPEAT 10u // max touch read times
#define ERR_RANGE 50u // touch error range
LgtTouch lgtTouch;
/**
* read touch x-y value
* value can't less than 100 or more than 4000
*/
uint8_t LgtTouch::readTouchXY(uint16_t &x,uint16_t &y)
{
uint16_t xtemp,ytemp;
xtemp = touch.getInTouch(XPT2046_X);
if (xtemp < 100 || xtemp > 4000)
return 0; // failed
ytemp = touch.getInTouch(XPT2046_Y);
if(ytemp < 100 || ytemp > 4000)
return 0; // failed
x=xtemp;
y=ytemp;
return 1; // successful
}
/** read x-y ad value two time
*/
uint8_t LgtTouch::readTouchXY2(uint16_t &x, uint16_t &y)
{
uint16_t x1,y1;
uint16_t x2,y2;
for (uint8_t i = 0; i < MAX_READ_XY_REPEAT; ++i) {
if (readTouchXY(x1,y1))
if (readTouchXY(x2,y2))
if ((x1 > x2 - ERR_RANGE) && (x2 > x1 - ERR_RANGE) &&
(y1 > y2 -ERR_RANGE) && (y2 > y1 - ERR_RANGE)) {
x = (x1 + x2)/2;
y = (y1 + y2)/2;
return 1;
}
}
return 0;
}
uint8_t LgtTouch::readTouchPoint(uint16_t &x, uint16_t &y)
{
if (calib.xCalibration + calib.xOffset == 0) {
// Not yet set, so use defines as fallback...
calib.xCalibration = XPT2046_X_CALIBRATION;
calib.xOffset = XPT2046_X_OFFSET;
calib.yCalibration = XPT2046_Y_CALIBRATION;
calib.yOffset = XPT2046_Y_OFFSET;
}
if (!isTouched())
return 0;
uint16_t xAd, yAd;
if (readTouchXY2(xAd, yAd)) {
x = uint16_t((uint32_t(xAd) * calib.xCalibration) >> 16) + calib.xOffset;
y = uint16_t((uint32_t(yAd) * calib.yCalibration) >> 16) + calib.yOffset;
} else {
DEBUG_ECHOLN("read touch failed");
x = y = 0;
return 0;
}
if (!isTouched()) // recheck if touched
return 0;
return 1;
}
uint8_t LgtTouch::calibrate(bool needKill/* =true */)
{
// for safety
thermalManager.disable_all_heaters();
uint16_t color = YELLOW;
uint16_t bgColor = BLACK;
uint16_t length;
// uint32_t i;
uint16_t x[4] = {0,0,0,0};
uint16_t y[4] = {0,0,0,0};
char text[41];
SERIAL_ECHOLN("start calibration");
lgtlcd.setColor(color);
lgtlcd.setBgColor(bgColor);
for (uint8_t i = 0; i < 4;) {
lgtlcd.clear(bgColor);
/**
* Test coordinates and colors inversion.
* Draw RED and GREEN squares in top left area of the screen.
*/
lgtlcd.setWindow(40, 20, 99, 69);
length = sprintf(text, TXT_TFT_CONTROLLER_ID, lgtlcd.lcdId());
// center horizontal alignment, x = (320 - len * 8) / 2
lgtlcd.print(160 - length * 4, 48, text);
// length = sprintf(text, TXT_TFT_CONTROLLER, controller);
// lgtlcd.print(160 - length * 4, 66, text);
length = sprintf(text, TXT_TOUCH_CALIBRATION);
lgtlcd.print(92, 88, text);
switch (i) {
case 0:
lgtlcd.drawCross( 20 , 20, 0xFFFF);
length = sprintf(text, TXT_TOP_LEFT);
break;
case 1:
lgtlcd.drawCross( 20, 219, 0xFFFF);
length = sprintf(text, TXT_BOTTOM_LEFT);
break;
case 2:
lgtlcd.drawCross(299, 20, 0xFFFF);
length = sprintf(text, TXT_TOP_RIGHT);
break;
case 3:
lgtlcd.drawCross(299, 219, 0xFFFF);
length = sprintf(text, TXT_BOTTOM_RIGHT);
break;
}
lgtlcd.print(160 - length * 4, 108, text);
// wait for touch then read touch
// waitForTouch(x[i], y[i]);
while (1) {
if ((isTouched()) && readTouchXY2(x[i], y[i]))
break;
}
DEBUG_ECHOPAIR("\ntouched i:", i);
DEBUG_ECHOLNPAIR(" x:", x[i]);
DEBUG_ECHOLNPAIR(" y:", y[i]);
if ((x[i] < 409 || x[i] > 1637) && (y[i] < 409 || y[i] > 1637)) {
switch (i) {
case 0: // Top Left
i++;
waitForRelease();
delay(300);
continue;
case 1: // Bottom Left
if (((x[0] < 409 && x[1] < 409) || (x[0] > 1637 && x[1] > 1637)) && ((y[0] < 409 && y[1] > 1637) || (y[0] > 1637 && y[1] < 409))) {
i++;
waitForRelease();
delay(300);
continue;
}
break;
case 2: // Top Right
if (((x[0] < 409 && x[2] > 1637) || (x[0] > 1637 && x[2] < 409)) && ((y[0] < 409 && y[2] < 409) || (y[0] > 1637 && y[2] > 1637))) {
i++;
waitForRelease();
delay(300);
continue;
}
break;
case 3: // Bottom Right
if (((x[0] < 409 && x[3] > 1637) || (x[0] > 1637 && x[3] < 409)) && ((y[0] < 409 && y[3] > 1637) || (y[0] > 1637 && y[3] < 409))) {
i++;
waitForRelease();
delay(300);
continue;
}
break;
}
}
delay(1500);
lgtlcd.clear(RED);
waitForRelease();
delay(500);
}
// calulate touch coefficient
// 36569088L == ((int32_t)(299 - 20)) << 17
calib.xCalibration = (int16_t)(36569088L / ((int32_t)x[3] + (int32_t)x[2] - (int32_t)x[1] - (int32_t)x[0]));
// 26083328L == ((int32_t)(219 - 20)) << 17
calib.yCalibration = (int16_t)(26083328L / ((int32_t)y[3] - (int32_t)y[2] + (int32_t)y[1] - (int32_t)y[0]));
calib.xOffset = (int16_t)(20 - ((((int32_t)(x[0] + x[1])) * (int32_t)calib.xCalibration) >> 17));
calib.yOffset = (int16_t)(20 - ((((int32_t)(y[0] + y[2])) * (int32_t)calib.yCalibration) >> 17));
// print result to lcd
lgtlcd.clear(bgColor);
length = sprintf(text, TXT_TFT_CONTROLLER_ID, lgtlcd.lcdId());
lgtlcd.print(160 - length * 4, 48, text);
// length = sprintf(text,TXT_TFT_CONTROLLER, controller);
// lgtlcd.print(160 - length * 4, 66, text);
lgtlcd.setColor(GREEN);
length = sprintf(text, TXT_CALI_COMPLETED);
lgtlcd.print(160 - length * 4, 88, text);
lgtlcd.setColor(YELLOW);
sprintf(text, TXT_X_CALIBRATION);
lgtlcd.print(76, 108, text);
sprintf(text, "%6d", calib.xCalibration);
lgtlcd.m_color = calib.xCalibration >= 0 ? GREEN : RED;
lgtlcd.print(196, 108, text);
lgtlcd.m_color = YELLOW;
sprintf(text, TXT_Y_CALIBRATION);
lgtlcd.print(76, 124, text);
sprintf(text, "%6d", calib.yCalibration);
lgtlcd.m_color = calib.yCalibration >= 0 ? GREEN : RED;
lgtlcd.print(196, 124, text);
lgtlcd.m_color = YELLOW;
sprintf(text, TXT_X_OFFSET);
lgtlcd.print(76, 140, text);
sprintf(text, "%6d", calib.xOffset);
lgtlcd.m_color = calib.xOffset >= 0 ? GREEN : RED;
lgtlcd.print(196, 140, text);
lgtlcd.m_color = YELLOW;
sprintf(text, TXT_Y_OFFSET);
lgtlcd.print(76, 156, text);
sprintf(text, "%6d", calib.yOffset);
lgtlcd.m_color = calib.yOffset >= 0 ? GREEN : RED;
lgtlcd.print(196, 156, text);
lgtlcd.m_color = GREEN;
length = sprintf(text, TXT_PROMPT_INFO1);
lgtlcd.print(160 - length * 4, 180, text); // center alignment
// length = sprintf(text, TXT_PROMPT_INFO2);
// lgtlcd.print(160 - length * 4, 198, text);
lgtlcd.m_color = WHITE;
// print result to serial
MYSERIAL0.print("xCalibration:");
MYSERIAL0.print(calib.xCalibration);
MYSERIAL0.println();
MYSERIAL0.print("yCalibration:");
MYSERIAL0.print(calib.yCalibration);
MYSERIAL0.println();
MYSERIAL0.print("xOffset:");
MYSERIAL0.print(calib.xOffset);
MYSERIAL0.println();
MYSERIAL0.print("yOffset:");
MYSERIAL0.print(calib.yOffset);
x[0] = (uint16_t)((((int32_t)x[0] * (int32_t)calib.xCalibration) >> 16) + calib.xOffset);
x[1] = (uint16_t)((((int32_t)x[1] * (int32_t)calib.xCalibration) >> 16) + calib.xOffset);
x[2] = (uint16_t)((((int32_t)x[2] * (int32_t)calib.xCalibration) >> 16) + calib.xOffset);
x[3] = (uint16_t)((((int32_t)x[3] * (int32_t)calib.xCalibration) >> 16) + calib.xOffset);
y[0] = (uint16_t)((((int32_t)y[0] * (int32_t)calib.yCalibration) >> 16) + calib.yOffset);
y[1] = (uint16_t)((((int32_t)y[1] * (int32_t)calib.yCalibration) >> 16) + calib.yOffset);
y[2] = (uint16_t)((((int32_t)y[2] * (int32_t)calib.yCalibration) >> 16) + calib.yOffset);
y[3] = (uint16_t)((((int32_t)y[3] * (int32_t)calib.yCalibration) >> 16) + calib.yOffset);
MYSERIAL0.println("\nCalibrated coordinates:");
MYSERIAL0.print("X: "); MYSERIAL0.print(x[0]); MYSERIAL0.print(" Y: "); MYSERIAL0.println(y[0]);
MYSERIAL0.print("X: "); MYSERIAL0.print(x[1]); MYSERIAL0.print(" Y: "); MYSERIAL0.println(y[1]);
MYSERIAL0.print("X: "); MYSERIAL0.print(x[2]); MYSERIAL0.print(" Y: "); MYSERIAL0.println(y[2]);
MYSERIAL0.print("X: "); MYSERIAL0.print(x[3]); MYSERIAL0.print(" Y: "); MYSERIAL0.println(y[3]);
MYSERIAL0.flush();
// save data
lgtStore.saveTouch();
lgtlcd.setColor(BLACK);
lgtlcd.setBgColor(WHITE);
if (needKill) {
// wait for touch then killed
while (!isTouched()) { /* nada */ }
kill();
}
return 1;
}
void LgtTouch::resetCalibration()
{
calib.xCalibration = XPT2046_X_CALIBRATION;
calib.yCalibration = XPT2046_Y_CALIBRATION;
calib.xOffset = XPT2046_X_OFFSET;
calib.yOffset = XPT2046_Y_OFFSET;
}
#endif
| 9,134
|
C++
|
.cpp
| 257
| 30.712062
| 141
| 0.599977
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,864
|
w25qxx.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/w25qxx.cpp
|
#include "../inc/MarlinConfig.h"
#if ENABLED(SPI_FLASH) && PIN_EXISTS(SPI_CS)
#include "w25qxx.h"
#include "../HAL/shared/HAL_SPI.h"
// #define DEBUG_SPIFLASH
#define DEBUG_OUT ENABLED(DEBUG_SPIFLASH)
#include "../../core/debug_out.h"
// device ID
#define W25Q80 0XEF13
#define W25Q16 0XEF14
#define W25Q32 0XEF15
#define W25Q64 0XEF16
#define W25Q128 0XEF17
#define W25Q256 0XEF18
// command
#define W25X_WriteEnable 0x06
#define W25X_WriteDisable 0x04
#define W25X_ReadStatusReg 0x05
#define W25X_WriteStatusReg 0x01
#define W25X_ReadData 0x03
#define W25X_FastReadData 0x0B
#define W25X_FastReadDual 0x3B
#define W25X_PageProgram 0x02
#define W25X_BlockErase 0xD8
#define W25X_SectorErase 0x20
#define W25X_ChipErase 0xC7
#define W25X_PowerDown 0xB9
#define W25X_ReleasePowerDown 0xAB
#define W25X_DeviceID 0xAB
#define W25X_ManufactDeviceID 0x90
#define W25X_JedecDeviceID 0x9F
#define W25QXX_CS(v) WRITE(SPI_CS_PIN, v) //digitalWrite(PC5,v)
#define FLASH_PAGE_SIZE NOOP // 4096
W25QXX spiFlash;
void W25QXX::W25QXX_Init(void)
{
OUT_WRITE(SPI_CS_PIN, HIGH);
spiInit(SPI_FULL_SPEED);
W25QXX_ReadID();
}
uint16_t W25QXX::W25QXX_ReadID()
{
uint16_t temp=0;
W25QXX_CS(0);
spiSend(0x90);
spiSend(0x00);
spiSend(0x00);
spiSend(0x00);
temp|=spiRec()<<8;
temp|=spiRec();
W25QXX_CS(1);
DEBUG_ECHOLNPAIR("spiflash id:", temp);
return temp;
}
//write spi falsh
//Writes the specified length of data at the specified address
//This function has erase function
//pBuffer:data storage area
//WriteAddr: address of start writing (24bit)
//NumByteToWrite:number of bytes to write (max:65535)
void W25QXX::W25QXX_Write(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite)
{
static uint8_t W25QXX_BUFFER[4096];
uint32_t secpos;
uint16_t secoff;
uint16_t secremain;
uint16_t i;
uint8_t* W25QXX_BUF;
W25QXX_BUF=W25QXX_BUFFER;
secpos=WriteAddr/4096; //Sector address
secoff=WriteAddr%4096; //Offset within the sector(扇区内的偏移)
secremain=4096-secoff; //Sector remaining space size
// Serial1.print("WriteAddr:");
// Serial1.println(WriteAddr);
// Serial1.print("NumByteToWrite:");
// Serial1.println(NumByteToWrite);
if(NumByteToWrite<=secremain)
secremain=NumByteToWrite; // <=4096 bytes
while(1)
{
W25QXX_Read(W25QXX_BUF,secpos*4096,4096); //Read the contents of the entire sector(读出整个扇区的内容)
for(i=0;i<secremain;i++)
{
// Serial1.println(W25QXX_BUF[secoff+i]);
if(W25QXX_BUF[secoff+i]!=0XFF) //Need to erase
break;
}
if(i<secremain) //Need to erase
{
W25QXX_Erase_Sector(secpos);
for(i=0;i<secremain;i++)
{
W25QXX_BUF[i+secoff]=pBuffer[i];
}
W25QXX_Write_NoCheck(W25QXX_BUF,secpos*4096,4096);
}
else
W25QXX_Write_NoCheck(pBuffer,WriteAddr,secremain);
if(secremain==NumByteToWrite)
break;
else
{
secpos++;
secoff=0;
pBuffer+=secremain;
WriteAddr+=secremain;
NumByteToWrite-=secremain;
if(NumByteToWrite>4096)
secremain=4096;
else
secremain=NumByteToWrite;
}
}
}
void W25QXX::W25QXX_Read(uint8_t* pBuffer,uint32_t ReadAddr,uint16_t NumByteToRead)
{
// uint16_t i;
W25QXX_CS(0);
spiSend(W25X_ReadData);
spiSend((uint8_t)(ReadAddr>>16));
spiSend((uint8_t)(ReadAddr>>8));
spiSend((uint8_t)ReadAddr);
// for(i=0;i<NumByteToRead;i++)
// {
// pBuffer[i]=spiRec();
// }
spiRead(pBuffer,NumByteToRead);
W25QXX_CS(1);
}
void W25QXX::W25QXX_Erase_Sector(uint32_t Dst_Addr)
{
Dst_Addr*=4096;
W25QXX_Write_Enable(); //SET WEL
W25QXX_Wait_Busy();
W25QXX_CS(0);
spiSend(W25X_SectorErase);
spiSend((uint8_t)(Dst_Addr>>16));
spiSend((uint8_t)(Dst_Addr>>8));
spiSend((uint8_t)Dst_Addr);
W25QXX_CS(1);
W25QXX_Wait_Busy();
}
void W25QXX::W25QXX_Write_NoCheck(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite)
{
uint16_t pageremain;
pageremain=256-WriteAddr%256;
if(NumByteToWrite<=pageremain)
pageremain=NumByteToWrite;
while(1)
{
W25QXX_Write_Page(pBuffer,WriteAddr,pageremain);
if(NumByteToWrite==pageremain)
break;
else
{
pBuffer+=pageremain;
WriteAddr+=pageremain;
NumByteToWrite-=pageremain;
if(NumByteToWrite>256)
pageremain=256;
else
pageremain=NumByteToWrite;
}
}
}
void W25QXX::W25QXX_Write_Enable(void)
{
W25QXX_CS(0);
spiSend(W25X_WriteEnable);
W25QXX_CS(1);
}
void W25QXX::W25QXX_Write_Disable(void)
{
W25QXX_CS(0);
spiSend(W25X_WriteDisable);
W25QXX_CS(1);
}
void W25QXX::W25QXX_Wait_Busy(void)
{
while((W25QXX_ReadSR()&0x01)==0x01);
}
uint8_t W25QXX::W25QXX_ReadSR(void)
{
uint8_t byte=0;
W25QXX_CS(0);
spiSend(W25X_ReadStatusReg);
byte=spiRec();
W25QXX_CS(1);
return byte;
}
void W25QXX::W25QXX_Write_SR(uint8_t sr)
{
W25QXX_CS(0);
spiSend(W25X_WriteStatusReg);
spiSend(sr);
W25QXX_CS(1);
}
void W25QXX::W25QXX_Write_Page(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite)
{
uint16_t i=0;
W25QXX_Write_Enable();
W25QXX_CS(0);
spiSend(W25X_PageProgram);
spiSend((uint8_t)(WriteAddr>>16));
spiSend((uint8_t)(WriteAddr>>8));
spiSend((uint8_t)WriteAddr);
for(i=0;i<NumByteToWrite;i++)
{
spiSend(pBuffer[i]);
}
W25QXX_CS(1);
W25QXX_Wait_Busy();
}
void W25QXX::W25QXX_Erase_Chip(void)
{
W25QXX_Write_Enable();
W25QXX_Wait_Busy();
W25QXX_CS(0);
spiSend(W25X_ChipErase);
W25QXX_CS(1);
W25QXX_Wait_Busy();
}
void W25QXX::W25QXX_WAKEUP(void)
{
W25QXX_CS(0);
spiSend(W25X_ReleasePowerDown); //send W25X_PowerDown command 0xAB
W25QXX_CS(1);
delay_us(3);
}
void W25QXX::W25QXX_PowerDown(void)
{
W25QXX_CS(0);
spiSend(W25X_PowerDown);
W25QXX_CS(1);
delay_us(3);
}
#endif // SPI_FLASH_CS
| 6,391
|
C++
|
.cpp
| 237
| 21.624473
| 100
| 0.648026
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,865
|
lgtgcode.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgtgcode.cpp
|
#include "../inc/MarlinConfigPre.h"
#if ENABLED(LGT_LCD_TFT)
#include "../gcode/gcode.h"
#include "lgttouch.h"
#include "lgtstore.h"
#include "lgttftlcd.h"
#define DEBUG_OUT 0
#include "../../core/debug_out.h"
/**
* @brief start touch calibration and save touch data
* in spiflash, or clear touch data in spiflash
*/
void GcodeSuite::M995()
{
if (parser.seen('C'))
lgtStore.clearTouch();
else
lgtTouch.calibrate();
}
/**
* @brief clear settings in spiflash
*/
void GcodeSuite::M2100()
{
if (parser.seen('C'))
lgtStore.clearSettings();
}
/**
* @brief change to MENU
*/
void GcodeSuite::M2101()
{
if (parser.seen('P')) {
int16_t pageNum = parser.value_int();
DEBUG_ECHOPAIR("parse P:", pageNum);
switch (pageNum) {
case 0:
lgtlcdtft.changePageAtOnce(eMENU_MOVE);
break;
case 1:
lgtlcdtft.changePageAtOnce(eMENU_LEVELING);
break;
default:
break;
}
}
}
#endif
| 1,041
|
C++
|
.cpp
| 48
| 16.979167
| 55
| 0.60689
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,866
|
lgttftlcd.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgttftlcd.cpp
|
#include "../inc/MarlinConfig.h"
#if ENABLED(LGT_LCD_TFT)
#include "lgttftlcd.h"
#include "lgttftdef.h"
#include "lgttftlanguage.h"
#include "lcddrive/lcdapi.h"
#include "lgttouch.h"
#include "w25qxx.h"
#include "lgtsdcard.h"
#include "lgtstore.h"
#include "../module/temperature.h"
#include "../sd/cardreader.h"
// #include "../HAL/STM32F1/sdio.h"
#include "../module/motion.h"
#include "../module/planner.h"
#include "../module/printcounter.h"
#include "../feature/runout.h"
#include "../feature/powerloss.h"
// #define DEBUG_LGTLCDTFT
#define DEBUG_OUT ENABLED(DEBUG_LGTLCDTFT)
#include "../../core/debug_out.h"
// wrap a new name for being compatible with old codes
#define lcd lgtlcd
#define displayImage(x, y, addr) lcd.showImage(x, y, addr)
#define White WHITE
#define Black BLACK
#define lcdClear(color) lcd.clear(color)
#define LCD_Fill(x, y, ex, ey, c) lcd.fill(x, y, ex, ey, c)
#define color lcd.m_color
#define POINT_COLOR color
#define bgColor lcd.m_bgColor
#define display_image LgtLcdTft
#define enqueue_and_echo_commands_P(s) queue.enqueue_now_P(s)
#define LCD_DrawLine(x, y, ex, ey) lcd.drawHVLine(x, y, ex, ey)
#define LCD_DrawRectangle(x, y, ex, ey) lcd.drawRect(x, y, ex, ey)
#define Green GREEN
#ifndef Chinese
#define LCD_ShowString(x,y,txt) lcd.print(x,y,txt)
#else
#define LCD_ShowString(x,y,txt) lcd_print_gbk(x,y,txt)
#endif
#define CLEAN_STRING(str) memset((void*)str,0,sizeof(str))
#define FILL_ZONE(x, y, w, h, bg_color) LCD_Fill((uint16_t)(x), (uint16_t)(y), (uint16_t)((x)+(w)-1), (uint16_t)((y)+(h)-1), (uint16_t)bg_color)
#define CLEAN_ZONE(x, y, w, h) FILL_ZONE(x, y, w, h, WHITE)
#define CLEAN_SINGLE_TXT(x, y, w) CLEAN_ZONE(x, y, w, 16) /* clean single line text */
#if HAS_FILAMENT_SENSOR
#define IS_RUN_OUT() (runout.enabled && READ(FIL_RUNOUT_PIN))
#else
#define IS_RUN_OUT() false
#endif
LgtLcdTft lgtlcdtft;
bool recovery_flag;
static bool recoveryStatus = false;
// auto feed in/out
static uint8_t default_move_distance=5;
static int8_t dir_auto_feed=0; // filament change status
static uint16_t cur_x=0,cur_y=0; // save touch point position
static char s_text[64];
// for movement
static bool is_aixs_homed[XYZ]={false};
static bool is_bed_select = false;
static bool is_printing=false; // print status. true on printing, false on not printing(idle, paused, and so on)
static bool is_print_finish=false; // true on finish printing
static bool isPrintStarted = false; // ture on print started(including pause), false on idle
static uint8_t ret_menu_extrude = 0; // used for extrude page return 0 to home page , 2 to adjust more page, 4 to file page
// bool pause_print=false;
static bool cur_flag=false;
static int8_t cur_pstatus=10; //0 is heating ,1 is printing, 2 is pause
static int8_t cur_ppage=10; // 0 is heating page , 1 is printing page, 2 is pause page
#if defined(LK1_PLUS) || defined(U20_PLUS)
constexpr millis_t REFRESH_INTERVAL = 120000; // 2 minutes
static millis_t nextTimeRefresh = 0;
#endif
static E_PRINT_CMD current_print_cmd=E_PRINT_CMD_NONE;
static E_BUTTON_KEY current_button_id=eBT_BUTTON_NONE;
// /********** window definition **********/
static E_WINDOW_ID current_window_ID = eMENU_HOME,next_window_ID =eWINDOW_NONE;
// for puase printing
static float resume_xyze_position[XYZE]={0.0};
static float resume_feedrate = 0.0;
// /***************************static function definition****************************************/
static void LGT_Line_To_Current_Position(AxisEnum axis)
{
const float manual_feedrate_mm_m[] = MANUAL_FEEDRATE;
if (!planner.is_full())
planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[(int8_t)axis]), active_extruder);
}
static void stopExtrude()
{
DEBUG_ECHOLN("stop extrude");
planner.quick_stop();
planner.synchronize(); // wait clean done
if (dir_auto_feed != 0)
dir_auto_feed=0;
}
static void changeFilament(int16_t length)
{
if (length == 0) return;
int8_t dir = length > 0 ? 1 : -1;
current_position[E_AXIS] = current_position[E_AXIS] + length;
if (dir > 0) { // slowly load filament
DEBUG_ECHOLN("load start");
LGT_Line_To_Current_Position(E_AXIS);
dir_auto_feed = 1;
} else { // fast unload filament
DEBUG_ECHOLN("unload start");
if (!planner.is_full())
line_to_current_position(UNLOAD_FILA_FEEDRATE);
dir_auto_feed = -1;
}
}
static void clearVarPrintEnd()
{
lgtCard.setPrintTime(0);
lgtCard.clear();
recovery_flag=false;
// reset flow and feedrate
planner.flow_percentage[0]=100;
feedrate_percentage=100;
}
static void abortPrintEnd()
{
#if ENABLED(SDSUPPORT)
is_printing = wait_for_heatup = false;
card.flag.abort_sd_printing = true;
#endif
isPrintStarted = false;
print_job_timer.stop();
clearVarPrintEnd();
}
// /***************************class definition start************************************/
LgtLcdTft::LgtLcdTft()
{
}
// misc function
void LgtLcdTft::setPrintState(int8_t state)
{
if(is_printing)
{
cur_pstatus = state;
}
}
uint8_t LgtLcdTft::printState()
{
return cur_pstatus;
}
bool LgtLcdTft::isPrinting()
{
return is_printing;
}
void LgtLcdTft::setRecoveryStatus(bool status)
{
recoveryStatus = status;
DEBUG_ECHOLNPAIR("recovery: ", recoveryStatus);
}
void LgtLcdTft::actAfterRecovery()
{
setRecoveryStatus(false);
if (current_window_ID == eMENU_PRINT)
displayImage(260, 180, IMG_ADDR_BUTTON_END);
}
void LgtLcdTft::setPrintCommand(E_PRINT_CMD cmd)
{
current_print_cmd = cmd;
}
void LgtLcdTft::moveOnPause()
{
if (!all_axes_homed()) return;
resume_feedrate = feedrate_mm_s;
resume_xyze_position[X_AXIS]=current_position[X_AXIS];
resume_xyze_position[Y_AXIS]=current_position[Y_AXIS];
resume_xyze_position[E_AXIS]=current_position[E_AXIS];
DEBUG_ECHOLNPAIR_F("save X:", resume_xyze_position[X_AXIS]);
DEBUG_ECHOLNPAIR_F("save Y:", resume_xyze_position[Y_AXIS]);
DEBUG_ECHOLNPAIR_F("save E:", resume_xyze_position[E_AXIS]);
DEBUG_ECHOLNPAIR_F("save feedrate", resume_feedrate);
// fast retract filament
current_position[E_AXIS] = current_position[E_AXIS] - 2;
line_to_current_position(120.0);
// move to pause position
do_blocking_move_to_xy(FILAMENT_RUNOUT_MOVE_X, FILAMENT_RUNOUT_MOVE_Y, FILAMENT_RUNOUT_MOVE_F);
// waiting move done
planner.synchronize();
}
void LgtLcdTft::pausePrint()
{
is_printing = false; // genuine pause state
cur_pstatus=2;
current_print_cmd=E_PRINT_CMD_NONE;
// show resume button and status in print menu
if (current_window_ID == eMENU_PRINT) {
LCD_Fill(260,30,320,90,White); //clean pause/resume icon display zone
displayImage(260, 30, IMG_ADDR_BUTTON_RESUME);
displayPause();
}
// move head to specific position
moveOnPause();
setPrintCommand(E_PRINT_RESUME);
#if HAS_FILAMENT_SENSOR
changeToPageRunout();
#endif
}
void LgtLcdTft::resumePrint()
{
queue.inject_P(PSTR("M24"));
// slow extrude filament
current_position[E_AXIS] = current_position[E_AXIS] + 3;
line_to_current_position(1.0);
// back to break posion, need some time
do_blocking_move_to_xy(resume_xyze_position[X_AXIS], resume_xyze_position[Y_AXIS], FILAMENT_RUNOUT_MOVE_F);
// waiting move done
planner.synchronize();
// resume value
planner.set_e_position_mm(destination[E_AXIS] = current_position[E_AXIS] = resume_xyze_position[E_AXIS]);
feedrate_mm_s = resume_feedrate;
#if HAS_FILAMENT_SENSOR
runout.reset();
#endif
is_printing = true; // genuine pause state
cur_pstatus=1;
current_print_cmd=E_PRINT_CMD_NONE;
// show pause button and status
if (current_window_ID == eMENU_PRINT) {
LCD_Fill(260,30,320,90,White); //clean pause/resume icon display zone
displayImage(260, 30, IMG_ADDR_BUTTON_PAUSE);
displayPrinting();
}
#if defined(LK1_PLUS) || defined(U20_PLUS)
nextTimeRefresh = millis() + REFRESH_INTERVAL; // delay refresh for preventing from showing error
#endif
}
void LgtLcdTft::startAutoFeed(int8_t dir)
{
if(dir == dir_auto_feed || abs(dir) != 1) return;
if(thermalManager.degTargetHotend(eHeater::H0)<PREHEAT_TEMP_EXTRUDE)
{
thermalManager.setTargetHotend(PREHEAT_TEMP_EXTRUDE, eHeater::H0);
if(thermalManager.degHotend(eHeater::H0)>PREHEAT_TEMP_EXTRUDE-5)
{
DEBUG_ECHOLN("change filament");
if (dir == -dir_auto_feed) // reverse move need stop firstly
stopExtrude();
changeFilament(CHANGE_FILA_LENGTH * dir);
}
if(is_bed_select)
{
is_bed_select=false;
lcd.showImage(15, 95, IMG_ADDR_BUTTON_BED_OFF);
}
dispalyExtrudeTemp(RED);
}
else if(thermalManager.degHotend(eHeater::H0)>PREHEAT_TEMP_EXTRUDE-5)
{
DEBUG_ECHOLN("change filament");
if (dir == -dir_auto_feed) // reverse move need stop firstly
stopExtrude();
changeFilament(CHANGE_FILA_LENGTH * dir);
if(is_bed_select)
{
is_bed_select=false;
lcd.showImage(15, 95, IMG_ADDR_BUTTON_BED_OFF);
}
}
}
void LgtLcdTft::changePageAtOnce(E_WINDOW_ID page)
{
next_window_ID = page;
LGT_Ui_Update();
}
void LgtLcdTft::changeToPageRunout()
{
// check if it in runout state
if (runout.filament_ran_out) {
// change to no filament dialog
dispalyDialogYesNo(eDIALOG_START_JOB_NOFILA);
current_window_ID=eMENU_DIALOG_NO_FIL_PRINT;;
}
}
void LgtLcdTft::changeToPageRecovery()
{
ENABLE_AXIS_Z(); // lock z moter prevent from drop down
DEBUG_ECHOLN("show recovery dialog");
dispalyDialogYesNo(eDIALOG_PRINT_RECOVERY);
current_window_ID = eMENU_DIALOG_RECOVERY;
}
// /***************************launch page*******************************************/
void LgtLcdTft::displayStartUpLogo(void)
{
lcdClear(White);
#if defined(U30) || defined(U20) || defined(U20_PLUS)
displayImage(60, 95, IMG_ADDR_STARTUP_LOGO_0);
#elif defined(LK1) || defined(LK1_PLUS) || defined(LK2) || defined(LK4)
displayImage(45, 100, IMG_ADDR_STARTUP_LOGO_2);
#endif
}
// /***************************home page*******************************************/
void LgtLcdTft::displayWindowHome(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_HOME); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_HOME); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_HOME_CN);
#endif
displayImage(50, 45, IMG_ADDR_BUTTON_MOVE);
displayImage(133, 45, IMG_ADDR_BUTTON_FILE);
displayImage(215, 45, IMG_ADDR_BUTTON_EXTRUDE);
displayImage(50, 145, IMG_ADDR_BUTTON_PREHEAT);
if(false==recovery_flag)
{
displayImage(133, 145, IMG_ADDR_BUTTON_RECOVERY_DISABLE);
color=PT_COLOR_DISABLE;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_RECOVERY);
LCD_ShowString(129,209,s_text);
}
else
{
displayImage(133, 145, IMG_ADDR_BUTTON_RECOVERY);
color=BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_RECOVERY);
LCD_ShowString(129,209,s_text);
}
displayImage(215, 145, IMG_ADDR_BUTTON_MORE);
color=BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_MORE);
LCD_ShowString(227,209,s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_FILE);
LCD_ShowString(142,109,s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_EXTRUDE);
LCD_ShowString(216,109,s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_MOVE);
#ifndef Chinese
LCD_ShowString(41,109,s_text);
#else
LCD_ShowString(62,109,s_text);
#endif
sprintf((char*)s_text,"%s",TXT_MENU_HOME_PREHEAT);
#ifndef Chinese
LCD_ShowString(39,209,s_text);
#else
LCD_ShowString(62,209,s_text);
#endif
}
void display_image::scanWindowHome(uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>50&&rv_x<105&&rv_y>45&&rv_y<95)
{
next_window_ID=eMENU_MOVE;
}
else if(rv_x>133&&rv_x<188&&rv_y>45&&rv_y<95)
{
next_window_ID=eMENU_FILE;
}
else if(rv_x>215&&rv_x<270&&rv_y>45&&rv_y<95) // extrude
{
ret_menu_extrude = 0;
next_window_ID=eMENU_EXTRUDE;
}
else if(rv_x>50&&rv_x<105&&rv_y>145&&rv_y<195)
{
next_window_ID=eMENU_PREHEAT;
}
else if(rv_x>133&&rv_x<188&&rv_y>145&&rv_y<195) //recovery deprecated button
{
// if(recovery_flag)
// {
// next_window_ID=eMENU_DIALOG_RECOVERY;
// }
}
else if(rv_x>215&&rv_x<270&&rv_y>145&&rv_y<195)
{
next_window_ID=eMENU_HOME_MORE;
}
}
// /***************************Move page*******************************************/
void display_image::displayWindowMove(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 25, BG_COLOR_CAPTION_MOVE); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_MOVE); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_MOVE_CN); //caption words
#endif
displayImage(5, 180, IMG_ADDR_BUTTON_HOME_ALL);
displayImage(5, 55, IMG_ADDR_BUTTON_HOME_X);
displayImage(125, 55, IMG_ADDR_BUTTON_HOME_Y);
displayImage(125, 180, IMG_ADDR_BUTTON_HOME_Z);
displayImage(0, 118, IMG_ADDR_BUTTON_MINUS_X);
displayImage(65, 170, IMG_ADDR_BUTTON_MINUS_Y);
displayImage(193, 170, IMG_ADDR_BUTTON_MINUS_Z);
displayImage(115, 118, IMG_ADDR_BUTTON_PLUS_X);
displayImage(65, 55, IMG_ADDR_BUTTON_PLUS_Y);
displayImage(193, 55, IMG_ADDR_BUTTON_PLUS_Z);
// default_move_distance = 5; //default distance
initialMoveDistance(260, 55);
displayImage(260, 110, IMG_ADDR_BUTTON_UNLOCK);
displayImage(260, 180, IMG_ADDR_BUTTON_RETURN);
POINT_COLOR=BLUE;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s","X:");
LCD_ShowString(40,32,s_text);
sprintf((char*)s_text,"%s","Y:");
LCD_ShowString(130,32,s_text);
sprintf((char*)s_text,"%s","Z:");
LCD_ShowString(220,32,s_text);
displayMoveCoordinate();
}
void display_image::changeMoveDistance(uint16_t pos_x, uint16_t pos_y)
{
switch(default_move_distance)
{
default: break;
case 1:
default_move_distance = 5;
displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_5);
break;
case 5:
default_move_distance = 10;
displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_10);
break;
case 10:
if(current_window_ID == eMENU_EXTRUDE
|| current_window_ID == eMENU_ADJUST
||current_window_ID == eMENU_ADJUST_MORE
|| current_window_ID == eMENU_PREHEAT)
{
default_move_distance = 0xff;
displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_MAX);
}
else /* if not in temperature menu */
{
default_move_distance = 1;
displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_1);
}
break;
case 0xff:
default_move_distance = 1;
displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_1);
break;
}
}
void display_image::initialMoveDistance(uint16_t pos_x, uint16_t pos_y)
{
switch(default_move_distance)
{
default: break;
case 1: displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_1); break;
case 5: displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_5); break;
case 10: displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_10); break;
case 0xff: displayImage(pos_x, pos_y, IMG_ADDR_BUTTON_DISTANCE_MAX); break;
}
}
void display_image::displayMoveCoordinate(void)
{
for(int i=0;i<3;i++)
{
CLEAN_SINGLE_TXT(POS_MOVE_COL_TXT+20 + POS_MOVE_TXT_INTERVAL * i, POS_MOVE_ROW_0, 60);
CLEAN_STRING(s_text);
sprintf(s_text,"%.1f",current_position[i]);
LCD_ShowString(60 + 90 * i, 32,s_text);
}
}
void display_image::scanWindowMove( uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>260&&rv_x<315&&rv_y>180&&rv_y<235) //return home
{
next_window_ID=eMENU_HOME;
}
else if(rv_x>0&&rv_x<60&&rv_y>115&&rv_y<165) //-X move
{
current_button_id=eBT_MOVE_X_MINUS;
}
else if(rv_x>115&&rv_x<175&&rv_y>115&&rv_y<165) //+X move
{
current_button_id=eBT_MOVE_X_PLUS;
}
else if(rv_x>65&&rv_x<115&&rv_y>170&&rv_y<230) //-Y move
{
current_button_id=eBT_MOVE_Y_MINUS;
}
else if(rv_x>65&&rv_x<115&&rv_y>55&&rv_y<115) //+Y move
{
current_button_id=eBT_MOVE_Y_PLUS;
}
else if(rv_x>190&&rv_x<240&&rv_y>170&&rv_y<230) //-Z move
{
current_button_id=eBT_MOVE_Z_MINUS;
}
else if(rv_x>190&&rv_x<240&&rv_y>55&&rv_y<115) //+Z move
{
current_button_id=eBT_MOVE_Z_PLUS;
}
else if(rv_x>5&&rv_x<55&&rv_y>55&&rv_y<105) //x homing
{
current_button_id=eBT_MOVE_X_HOME;
}
else if(rv_x>125&&rv_x<175&&rv_y>55&&rv_y<105) //y homing
{
current_button_id=eBT_MOVE_Y_HOME;
}
else if(rv_x>125&&rv_x<175&&rv_y>180&&rv_y<230) //z homing
{
current_button_id=eBT_MOVE_Z_HOME;
}
else if(rv_x>5&&rv_x<55&&rv_y>180&&rv_y<230) //all homing
{
current_button_id=eBT_MOVE_ALL_HOME;
}
else if(rv_x>260&&rv_x<315&&rv_y>110&&rv_y<165) //unlock all motors
{
disable_all_steppers();
set_all_unhomed();
}
else if(rv_x>260&&rv_x<315&&rv_y>55&&rv_y<95) //select distance
{
current_button_id=eBT_DISTANCE_CHANGE;
}
}
// /***************************File page*******************************************/
void display_image::displayWindowFiles(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_FILE); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_FILE); //caption words
displayImage(255, 30, IMG_ADDR_BUTTON_OPEN);
#else
displayImage(115, 5, IMG_ADDR_CAPTION_FILE_CN); //caption words
displayImage(255, 30, IMG_ADDR_BUTTON_OPEN_CN);
#endif
displayImage(255, 105, IMG_ADDR_BUTTON_RETURN_FOLDER);
displayImage(150, 180, IMG_ADDR_BUTTON_PAGE_NEXT);
displayImage(35, 180, IMG_ADDR_BUTTON_PAGE_LAST);
displayImage(255, 180, IMG_ADDR_BUTTON_RETURN);
// draw frame
POINT_COLOR=DARKBLUE;
LCD_DrawLine(0, 175, 240, 175);
LCD_DrawLine(0, 176, 240, 176);
LCD_DrawLine(240, 175, 240, 25);
LCD_DrawLine(241, 176, 241, 25);
if(!updateCard())
updateFilelist();
}
bool LgtLcdTft::updateCard()
{
bool changed = true;
uint8_t res = lgtCard.update();
switch (res) {
case CardUpdate::MOUNTED :
lgtCard.clear();
updateFilelist();
break;
case CardUpdate::ERROR :
case CardUpdate::REMOVED :
lgtCard.clear();
displayPromptSDCardError();
break;
default:
changed = false;
break;
}
return changed;
}
void display_image::displayPromptSDCardError(void)
{
LCD_Fill(100, 195, 145, 215, White); //clean file page number display zone
LCD_Fill(0, 25, 239, 174,White); //clean file list display zone
displayImage(45, 85, IMG_ADDR_PROMPT_ERROR);
color=RED;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s", TXT_MENU_FILE_SD_ERROR);
LCD_ShowString(80, 92,s_text);
color=Black;
}
void display_image::displayPromptEmptyFolder(void)
{
LCD_Fill(100, 195, 145, 215, White); //clean file page number display zone
LCD_Fill(0, 25, 239, 174,White); //clean file list display zone
color = GRAY;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s", TXT_MENU_FILE_EMPTY);
LCD_ShowString(35,87,s_text);
color = BLACK;
}
void display_image::displayFilePageNumber(void)
{
LCD_Fill(100, 195, 145, 215, White); //celan file page number display zone
if(lgtCard.fileCount() > 0)
{
CLEAN_STRING(s_text);
POINT_COLOR=BLACK;
sprintf((char *)s_text, "%d/%d", lgtCard.page() + 1, lgtCard.pageCount());
LCD_ShowString(105, 200,s_text);
}
}
void display_image::displayFileList()
{
LCD_Fill(0, 25, 239, 174,White); //clean file list display zone
lcd.setColor(BLACK);
if(lgtCard.isReverseList()) // inverse
{
int16_t start = lgtCard.fileCount() - 1 - lgtCard.page() * LIST_ITEM_MAX;
int16_t end = start - LIST_ITEM_MAX;
NOLESS(end, -1);
// DEBUG_ECHOLNPAIR("list start:", start);
// DEBUG_ECHOLNPAIR("list end: ", end);
for (int16_t i = start, j = 0; i > end; --i, ++j) {
// DEBUG_ECHOLNPAIR("sd filename: ", lgtCard.filename(i));
LCD_ShowString(35, 32 + j * 30, lgtCard.filename(i));
if(lgtCard.isDir())
displayImage(0, 25 + j * 30, IMG_ADDR_INDICATOR_FOLDER);
else
displayImage(0, 25 + j * 30, IMG_ADDR_INDICATOR_FILE);
}
} else { // forward
uint16_t start = lgtCard.page() * LIST_ITEM_MAX;
uint16_t end = start + LIST_ITEM_MAX;
NOMORE(end, lgtCard.fileCount());
// DEBUG_ECHOLNPAIR("list start:", start);
// DEBUG_ECHOLNPAIR("list end: ", end);
for (uint16_t i = start, j = 0; i < end; ++i, ++j) {
// DEBUG_ECHOLNPAIR("sd filename: ", lgtCard.filename(i));
LCD_ShowString(35, 32 + j * 30, lgtCard.filename(i));
if(lgtCard.isDir())
displayImage(0, 25 + j * 30, IMG_ADDR_INDICATOR_FOLDER);
else
displayImage(0, 25 + j * 30, IMG_ADDR_INDICATOR_FILE);
}
}
}
/**
* call when file count is changed
* such as change dir, remove, insert card
*/
void display_image::updateFilelist()
{
if(!lgtCard.isCardInserted()) {
lgtCard.clear();
displayPromptSDCardError();
} else {
int fCount = lgtCard.count();
DEBUG_ECHOLNPAIR("sd filecount", fCount);
if (fCount == 0) {
displayPromptEmptyFolder();
} else {
displayFileList();
displayFilePageNumber();
}
}
}
/// highlight selecetd item when return from open file dialog
void display_image::highlightChosenFile()
{
if (lgtCard.isFileSelected() &&
(lgtCard.selectedPage() == lgtCard.page())) {
uint16_t item = lgtCard.item();
lcd.fill(35, 25 + item * 30, 239, 55 - 1 + item * 30, DARKBLUE);
// .. reprint filename
lcd.setColor(WHITE);
lcd.setBgColor(DARKBLUE);
lcd.print(35, 32 + item*30, lgtCard.filename());
lcd.setColor(BLACK);
lcd.setBgColor(WHITE);
}
}
void LgtLcdTft::chooseFile(uint16_t item)
{
uint16_t lastItem = lgtCard.item();
uint16_t lastIndex = lgtCard.fileIndex(); // save last selected file index
uint16_t lastPage = lgtCard.selectedPage(); // save last selected page
bool isLastSelect = lgtCard.isFileSelected();
DEBUG_ECHOLNPAIR("last item: ", lastItem);
DEBUG_ECHOLNPAIR("last index: ", lastIndex);
DEBUG_ECHOLNPAIR("last is select", isLastSelect);
DEBUG_ECHOLNPAIR("try select item: ", item);
// if (lastItem == item && item > 0) // nothing should change
// return;
if (!lgtCard.selectFile(item)) // fail to select file
return;
if (lastIndex == lgtCard.fileIndex() &&
((lastIndex == 0 && isLastSelect) ||
lastIndex != 0)) {
return; // nothing should change
}
DEBUG_ECHOLNPAIR("select index: ", lgtCard.fileIndex());
if (isLastSelect && (lastPage == lgtCard.page())) { // only restore when selected page is as same as last one
// restore last selected item
lcd.fill(35, 25 + lastItem * 30, 239, 55 - 1 + lastItem * 30, WHITE);
lcd.print(35, 32 + lastItem*30, lgtCard.filename(lastIndex));
}
// highlight selecetd item
highlightChosenFile();
}
void display_image::scanWindowFile( uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>260&&rv_x<315&&rv_y>176&&rv_y<226) //return home
{
next_window_ID=eMENU_HOME;
}
else if(rv_x>0&&rv_x<240&&rv_y>25&&rv_y<55) //1st file
{
current_button_id=eBT_FILE_LIST1;
}
else if(rv_x>0&&rv_x<240&&rv_y>55&&rv_y<85) //2nd file
{
current_button_id=eBT_FILE_LIST2;
}
else if(rv_x>0&&rv_x<240&&rv_y>85&&rv_y<115) //3rd file
{
current_button_id=eBT_FILE_LIST3;
}
else if(rv_x>0&&rv_x<240&&rv_y>115&&rv_y<145) //4th file
{
current_button_id=eBT_FILE_LIST4;
}
else if(rv_x>0&&rv_x<240&&rv_y>145&&rv_y<175) //5th file
{
current_button_id=eBT_FILE_LIST5;
}
else if(rv_x>35&&rv_x<90&&rv_y>180&&rv_y<235) //last page
{
current_button_id=eBT_FILE_LAST;
}
else if(rv_x>150&&rv_x<205&&rv_y>180&&rv_y<235) //next page
{
current_button_id=eBT_FILE_NEXT;
}
else if(rv_x>255&&rv_x<310&&rv_y>30&&rv_y<85) //open file or folder
{
current_button_id=eBT_FILE_OPEN;
}
else if(rv_x>255&&rv_x<310&&rv_y>105&&rv_y<160) //return parent dir
{
current_button_id=eBT_FILE_FOLDER;
}
}
// /***************************Extrude page*******************************************/
void display_image::displayWindowExtrude(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_EXTRUDE); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_EXTRUDE); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_EXTRUDE_CN); //caption words
#endif
displayImage(5, 34, IMG_ADDR_BUTTON_ADD);
displayImage(5, 176, IMG_ADDR_BUTTON_SUB);
displayImage(15, 95, IMG_ADDR_BUTTON_BED_OFF);
displayImage(86, 34, IMG_ADDR_BUTTON_PLUS_E);
displayImage(86, 166, IMG_ADDR_BUTTON_MINUS_E);
displayImage(167, 44, IMG_ADDR_BUTTON_FEED_IN_0);
displayImage(167, 166, IMG_ADDR_BUTTON_FEED_OUT_0);
default_move_distance = 10;
initialMoveDistance(260, 40);
#ifndef Chinese
displayImage(260, 101, IMG_ADDR_BUTTON_FEED_STOP);
#else
displayImage(260, 101, IMG_ADDR_BUTTON_FEED_STOP_CN);
#endif
displayImage(260, 176, IMG_ADDR_BUTTON_RETURN);
POINT_COLOR = 0xC229;
LCD_DrawRectangle(96, 121, 134, 140); //jog frame //97 126
POINT_COLOR = BLUE;
LCD_DrawRectangle(180, 121, 219, 140); //auto frame
POINT_COLOR=BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_EXTRUDE_MANUAL);
LCD_ShowString(100,123,s_text);
sprintf((char*)s_text,"%s",TXT_MENU_EXTRUDE_AUTOMATIC);
LCD_ShowString(184,123,s_text);
dispalyExtrudeTemp();
}
void display_image::dispalyExtrudeTemp(void)
{
LCD_Fill(5,143,65,163,White); //clean extruder/bed temperature display zone
POINT_COLOR=BLACK;
CLEAN_STRING(s_text);
if(!is_bed_select)
sprintf((char *)s_text,"%d/%d",(int16_t)thermalManager.degHotend(eHeater::H0), thermalManager.degTargetHotend(eHeater::H0));
else{
sprintf((char *)s_text,"%d/%d", (int16_t)thermalManager.degBed(),thermalManager.degTargetBed());
}
LCD_ShowString(8,143,s_text);
}
/**
* note user head target temp. is changed
*/
void display_image::dispalyExtrudeTemp(uint16_t Color)
{
LCD_Fill(5,143,65,163,White); //clean extruder/bed temperature display zone
POINT_COLOR=Color;
CLEAN_STRING(s_text);
if(!is_bed_select)
sprintf((char *)s_text,"%d/%d",(int16_t)thermalManager.degHotend(eHeater::H0), thermalManager.degTargetHotend(eHeater::H0));
else{
sprintf((char *)s_text,"%d/%d", (int16_t)thermalManager.degBed(),thermalManager.degTargetBed());
}
LCD_ShowString(8,143,s_text);
POINT_COLOR=BLACK;
}
void display_image::displayRunningAutoFeed(void)
{
if (dir_auto_feed==0) {
return;
} else if (!planner.has_blocks_queued()) { // clean feed status when filament change blocks done
dir_auto_feed = 0;
return;
}
static bool is_display_run_auto_feed = false;
if(!is_display_run_auto_feed)
{
if(dir_auto_feed == 1)
{
LCD_Fill(167,96,234,99,White); //clean partial feed in display zone
displayImage(167, 41, IMG_ADDR_BUTTON_FEED_IN_1);
}
else
{
LCD_Fill(167,166,234,169,White); //clean partial feed out display zone
displayImage(167, 169, IMG_ADDR_BUTTON_FEED_OUT_1);
}
}
else
{
if(dir_auto_feed == 1)
{
LCD_Fill(167,41,234,44,White); //clean partial feed in display zone
displayImage(167, 44, IMG_ADDR_BUTTON_FEED_IN_0);
}
else
{
LCD_Fill(167,221,234,224,White); //clean partial feed out display zone
displayImage(167, 166, IMG_ADDR_BUTTON_FEED_OUT_0);
}
}
is_display_run_auto_feed = !is_display_run_auto_feed;
}
void display_image::scanWindowExtrude( uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>260&&rv_x<315&&rv_y>176&&rv_y<226) //return home/adjust more/file page
{
if (ret_menu_extrude == 0)
next_window_ID=eMENU_HOME;
else if (ret_menu_extrude == 2)
next_window_ID=eMENU_ADJUST_MORE;
else if (ret_menu_extrude == 4)
next_window_ID=eMENU_FILE1;
// ret_menu_extrude = 0;
if(dir_auto_feed!=0)
stopExtrude();
}
else if(rv_x>5&&rv_x<60&&rv_y>34&&rv_y<89) //add extruder/bed temperature
{
current_button_id=eBT_TEMP_PLUS;
}
else if(rv_x>5&&rv_x<60&&rv_y>176&&rv_y<231) //subtract extruder/bed temperature
{
current_button_id=eBT_TEMP_MINUS;
}
else if(rv_x>15&&rv_x<65&&rv_y>95&&rv_y<136) //select bed/extruder
{
current_button_id=eBT_BED_E;
}
else if(rv_x>85&&rv_x<140&&rv_y>35&&rv_y<100) //+e move
{
current_button_id=eBT_JOG_EPLUS;
}
else if(rv_x>85&&rv_x<140&&rv_y>165&&rv_y<230) //-e move
{
current_button_id=eBT_JOG_EMINUS;
}
else if(rv_x>167&&rv_x<237&&rv_y>45&&rv_y<100) //autofeed in positive direction
{
current_button_id=eBT_AUTO_EPLUS;
}
else if(rv_x>167&&rv_x<237&&rv_y>165&&rv_y<220) //autofeed in negative direction
{
current_button_id=eBT_AUTO_EMINUS;
}
else if(rv_x>260&&rv_x<315&&rv_y>40&&rv_y<80) //change distance
{
current_button_id=eBT_DISTANCE_CHANGE;
}
else if(rv_x>260&&rv_x<315&&rv_y>100&&rv_y<155) //stop autofeed
{
current_button_id=eBT_STOP;
}
}
// /***************************preheating page*******************************************/
void display_image::displayWindowPreheat(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_PREHEAT); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_PREHEAT); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_PREHEAT_CN); //caption words
#endif
displayImage(10, 30, IMG_ADDR_BUTTON_ADD);
displayImage(10, 95, IMG_ADDR_BUTTON_ADD);
displayImage(180, 30, IMG_ADDR_BUTTON_SUB);
displayImage(180, 95, IMG_ADDR_BUTTON_SUB);
displayImage(75, 42, IMG_ADDR_INDICATOR_HEAD);
displayImage(75, 107, IMG_ADDR_INDICATOR_BED);
default_move_distance = 10;
initialMoveDistance(260, 37);
displayImage(260, 95, IMG_ADDR_BUTTON_COOLING);
displayImage(10, 160, IMG_ADDR_BUTTON_FILAMENT_2);
displayImage(95, 160, IMG_ADDR_BUTTON_FILAMENT_0);
displayImage(180, 160, IMG_ADDR_BUTTON_FILAMENT_1);
displayImage(260, 160, IMG_ADDR_BUTTON_RETURN);
POINT_COLOR=BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s","PLA");
LCD_ShowString(25,217,s_text);
sprintf((char*)s_text,"%s","ABS");
LCD_ShowString(109,217,s_text);
sprintf((char*)s_text,"%s","PETG");
LCD_ShowString(191,217,s_text);
updatePreheatingTemp();
}
void display_image::updatePreheatingTemp(void)
{
LCD_Fill(110,49,170,69,White); //clean extruder temperature display zone
LCD_Fill(110,114,170,134,White); //clean bed temperature display zone
POINT_COLOR=BLACK;
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%d/%d",(int16_t)thermalManager.degHotend(eHeater::H0),thermalManager.degTargetHotend(eHeater::H0));
LCD_ShowString(110,49,s_text);
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%d/%d",(int16_t)thermalManager.degBed(),thermalManager.degTargetBed());
LCD_ShowString(110,114,s_text);
}
void display_image::scanWindowPreheating( uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>260&&rv_x<315&&rv_y>160&&rv_y<215) //return home
{
next_window_ID=eMENU_HOME;
}
else if(rv_x>10&&rv_x<65&&rv_y>30&&rv_y<85) /* add extruder0 temperature */
{
current_button_id=eBT_PR_E_PLUS;
}
else if(rv_x>180&&rv_x<235&&rv_y>30&&rv_y<85) /* subtract extruder0 temperature */
{
current_button_id= eBT_PR_E_MINUS;
}
else if(rv_x>10&&rv_x<65&&rv_y>95&&rv_y<150) /* add bed temperature */
{
current_button_id=eBT_PR_B_PLUS;
}
else if(rv_x>180&&rv_x<235&&rv_y>95&&rv_y<150) /* subtract bed temperature */
{
current_button_id=EBT_PR_B_MINUS;
}
else if(rv_x>260&&rv_x<315&&rv_y>37&&rv_y<77) /* change distance */
{
current_button_id=eBT_DISTANCE_CHANGE;
}
else if(rv_x>260&&rv_x<315&&rv_y>95&&rv_y<150) /* cooling down */
{
current_button_id=eBT_PR_COOL;
}
else if(rv_x>10&&rv_x<65&&rv_y>160&&rv_y<215) /* filament 0 PLA */
{
current_button_id=eBT_PR_PLA;
}
else if(rv_x>95&&rv_x<150&&rv_y>160&&rv_y<215) /* filament 1 ABS */
{
current_button_id=eBT_PR_ABS;
}
else if(rv_x>180&&rv_x<235&&rv_y>160&&rv_y<215) /* filament 2 PETG */
{
current_button_id=eBT_PR_PETG;
}
}
// /***************************home More page*******************************************/
void display_image::displayWindowHomeMore(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_HOME); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_HOME); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_HOME_CN);
#endif
displayImage(50, 45, IMG_ADDR_BUTTON_LEVELING);
displayImage(133, 45, IMG_ADDR_BUTTON_SETTINGS);
displayImage(215, 45, IMG_ADDR_BUTTON_ABOUT);
displayImage(215, 145, IMG_ADDR_BUTTON_RETURN);
POINT_COLOR = BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_MORE_ABOUT);
LCD_ShowString(224,109,s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_MORE_RETURN);
LCD_ShowString(220,209,s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_MORE_LEVELING);
LCD_ShowString(46,109,s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_MORE_SETTINGS);
LCD_ShowString(130,109,s_text);
}
void display_image::scanWindowMoreHome(uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>50&&rv_x<105&&rv_y>45&&rv_y<95)
{
set_all_unhomed();
next_window_ID=eMENU_LEVELING;
}
else if(rv_x>133&&rv_x<188&&rv_y>45&&rv_y<95)
{
next_window_ID=eMENU_SETTINGS;
}
else if(rv_x>215&&rv_x<270&&rv_y>45&&rv_y<95)
{
next_window_ID=eMENU_ABOUT;
}
else if(rv_x>215&&rv_x<270&&rv_y>145&&rv_y<195) //return home
{
next_window_ID=eMENU_HOME;
}
}
// /***************************leveling page*******************************************/
void display_image::displayWindowLeveling(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_LEVELING); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_LEVELING); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_LEVELING_CN); //caption words
#endif
/* rectangular frame*/
lcd.setColor(PT_COLOR_DISABLE);
LCD_DrawRectangle(48, 73, 48+140, 73+121);
lcd.setColor(BLACK);
/* icons showing */
displayImage(20, 45, IMG_ADDR_BUTTON_LEVELING0); //top left
displayImage(160, 45, IMG_ADDR_BUTTON_LEVELING1); //top right
displayImage(160, 165, IMG_ADDR_BUTTON_LEVELING2); //bottom right
displayImage(20, 165, IMG_ADDR_BUTTON_LEVELING3); //bottom left
displayImage(90, 105, IMG_ADDR_BUTTON_LEVELING4); //center
displayImage(245, 45, IMG_ADDR_BUTTON_UNLOCK);
displayImage(245, 165, IMG_ADDR_BUTTON_RETURN);
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_LEVELING_UNLOCK);
LCD_ShowString(235,109,s_text);
}
void display_image::scanWindowLeveling( uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>245&&rv_x<300&&rv_y>165&&rv_y<220) /* return */
{
next_window_ID=eMENU_HOME_MORE;
current_button_id=eBT_MOVE_RETURN; //Z up 10mm
}
else if(rv_x>20&&rv_x<75&&rv_y>45&&rv_y<100) /* 0 top left */
{
current_button_id=eBT_MOVE_L0;
}
else if(rv_x>160&&rv_x<215&&rv_y>45&&rv_y<100) /* 1 top right */
{
current_button_id=eBT_MOVE_L1;
}
else if(rv_x>160&&rv_x<215&&rv_y>165&&rv_y<220) /* 2 bottom right */
{
current_button_id=eBT_MOVE_L2;
}
else if(rv_x>20&&rv_x<75&&rv_y>165&&rv_y<220) /* 3 bottom left */
{
current_button_id=eBT_MOVE_L3;
}
else if(rv_x>90&&rv_x<145&&rv_y>105&&rv_y<160) /* 4 center */
{
current_button_id=eBT_MOVE_L4;
}
else if(rv_x>245&&rv_x<300&&rv_y>45&&rv_y<100) /* unlock x and y */
{
enqueue_and_echo_commands_P(PSTR("M84 X0 Y0"));
set_all_unhomed();
}
}
// /***************************settings page*******************************************/
void display_image::displayWindowSettings(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_SETTINGS); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_SETTINGS); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_SETTINGS_CN); //caption words
#endif
displayImage(255, 30, IMG_ADDR_BUTTON_MODIFY);
displayImage(255, 105, IMG_ADDR_BUTTON_RESTORE);
displayImage(178, 180, IMG_ADDR_BUTTON_SAVE);
displayImage(5, 180, IMG_ADDR_BUTTON_PAGE_LAST);
displayImage(101, 180, IMG_ADDR_BUTTON_PAGE_NEXT);
displayImage(255, 180, IMG_ADDR_BUTTON_RETURN);
//draw frame
POINT_COLOR=DARKBLUE;
LCD_DrawLine(0, 175, 240, 175);
LCD_DrawLine(0, 176, 240, 176);
LCD_DrawLine(240, 175, 240, 25);
LCD_DrawLine(241, 176, 241, 25);
displayArgumentList();
displayArugumentPageNumber();
}
void display_image::displayArugumentPageNumber(void)
{
LCD_Fill(69, 195, 94, 215, WHITE); //celan file page display zone
CLEAN_STRING(s_text);
color=BLACK;
sprintf((char *)s_text, "%d/%d", lgtStore.page() + 1, SETTINGS_MAX_PAGE);
LCD_ShowString(69, 200,s_text);
}
void display_image::displayArgumentList(void)
{
LCD_Fill(0, 25, 239, 174,White); //clean file list display zone
color = BLACK;
uint8_t start = lgtStore.page() * LIST_ITEM_MAX;
uint8_t end = start + LIST_ITEM_MAX;
NOMORE(end, SETTINGS_MAX_LEN);
// DEBUG_ECHOLNPAIR("list start:", start);
// DEBUG_ECHOLNPAIR("list end: ", end);
for (uint8_t i = start, j = 0; i < end; ++i, ++j) {
CLEAN_STRING(s_text);
lgtStore.settingString(i, s_text);
LCD_ShowString(10, 32 + 30*j, s_text);
}
}
// highlight selecetd item when return from open file dialog
void LgtLcdTft::highlightSetting()
{
if (lgtStore.isSettingSelected() &&
(lgtStore.selectedPage() == lgtStore.page())) {
uint16_t item = lgtStore.item();
lcd.fill(0, 25 + item * 30, 239, 55 - 1 + item * 30, DARKBLUE);
// .. reprint name
lcd.setColor(WHITE);
lcd.setBgColor(DARKBLUE);
CLEAN_STRING(s_text);
lgtStore.settingString(lgtStore.settingIndex(), s_text);
lcd.print(10, 32 + item*30, s_text);
lcd.setColor(BLACK);
lcd.setBgColor(WHITE);
}
}
void LgtLcdTft::chooseSetting(uint16_t item)
{
uint16_t lastItem = lgtStore.item();
uint16_t lastIndex = lgtStore.settingIndex(); // save last selected file index
uint16_t lastPage = lgtStore.selectedPage(); // save last selected page
bool isLastSelect = lgtStore.isSettingSelected();
// DEBUG_ECHOLNPAIR("last item: ", lastItem);
// DEBUG_ECHOLNPAIR("last index: ", lastIndex);
// DEBUG_ECHOLNPAIR("last is select", isLastSelect);
// DEBUG_ECHOLNPAIR("try select item: ", item);
if (lgtStore.selectSetting(item)) // fail to select file
return;
if (lastIndex == lgtStore.settingIndex() &&
((lastIndex == 0 && isLastSelect) ||
lastIndex != 0)) {
return; // nothing should change
}
DEBUG_ECHOLNPAIR("select index: ", lgtStore.settingIndex());
if (isLastSelect && (lastPage == lgtStore.page())) { // only restore when selected page is as same as last one
// restore last selected item
lcd.fill(0, 25 + lastItem * 30, 239, 55 - 1 + lastItem * 30, WHITE);
CLEAN_STRING(s_text);
lgtStore.settingString(lastIndex, s_text);
lcd.print(10, 32 + lastItem*30, s_text);
}
// highlight selecetd item
highlightSetting();
}
void display_image::scanWindowSettings(uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>255&&rv_x<315&&rv_y>180&&rv_y<240) //return
{
next_window_ID=eMENU_HOME_MORE;
}
else if(rv_x>0&&rv_x<240&&rv_y>25&&rv_y<55) //1st
{
current_button_id=eBT_FILE_LIST1;
}
else if(rv_x>0&&rv_x<240&&rv_y>55&&rv_y<85) //2nd
{
current_button_id=eBT_FILE_LIST2;
}
else if(rv_x>0&&rv_x<240&&rv_y>85&&rv_y<115) //3rd
{
current_button_id=eBT_FILE_LIST3;
}
else if(rv_x>0&&rv_x<240&&rv_y>115&&rv_y<145) //4th
{
current_button_id=eBT_FILE_LIST4;
}
else if(rv_x>0&&rv_x<240&&rv_y>145&&rv_y<175) //5th
{
current_button_id=eBT_FILE_LIST5;
}
else if(rv_x>5&&rv_x<60&&rv_y>180&&rv_y<235) //last page
{
current_button_id=eBT_SETTING_LAST;
}
else if(rv_x>100&&rv_x<155&&rv_y>180&&rv_y<235) //next page
{
current_button_id=eBT_SETTING_NEXT;
}
else if(rv_x>255&&rv_x<315&&rv_y>30&&rv_y<85) //modify
{
current_button_id=eBT_SETTING_MODIFY;
}
else if(rv_x>255&&rv_x<315&&rv_y>105&&rv_y<160) //restore
{
current_button_id=eBT_SETTING_REFACTORY;
}
else if(rv_x>178&&rv_x<233&&rv_y>180&&rv_y<235) //save
{
current_button_id=eBT_SETTING_SAVE;
}
}
// /***************************settings modify page*******************************************/
void display_image::displayWindowSettings2(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_SETTINGS); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_SETTINGS); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_SETTINGS_CN); //caption words
#endif
initialMoveDistance(255, 43);
displayImage(150, 180, IMG_ADDR_BUTTON_SUB);
displayImage(35, 180, IMG_ADDR_BUTTON_ADD);
displayImage(255, 180, IMG_ADDR_BUTTON_RETURN);
displayModifyArgument();
}
void display_image::displayModifyArgument(void)
{
LCD_Fill(170, 100, 240, 120, WHITE); //celan value display zone
POINT_COLOR = BLACK;
memset(s_text, 0, sizeof(s_text));
lgtStore.settingString(s_text);
LCD_ShowString(10, 100,s_text);
}
void display_image::scanWindowSettings2(uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>255&&rv_x<315&&rv_y>180&&rv_y<240) //return
{
next_window_ID=eMENU_SETTINGS_RETURN;
}
else if(rv_x>35&&rv_x<90&&rv_y>180&&rv_y<235) //add
{
current_button_id=eBT_SETTING_ADD;
}
else if(rv_x>150&&rv_x<205&&rv_y>180&&rv_y<235) //subs
{
current_button_id=eBT_SETTING_SUB;
}else if(rv_x>255&&rv_x<315&&rv_y>43&&rv_y<83) //distance
{
current_button_id=eBT_DISTANCE_CHANGE;
}
}
// /***************************about page*******************************************/
void display_image::displayWindowAbout(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 24, BG_COLOR_CAPTION_ABOUT); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_ABOUT); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_ABOUT_CN); //caption words
#endif
displayImage(259, 153, IMG_ADDR_BUTTON_RETURN);
// draw seperator
POINT_COLOR = PT_COLOR_DISABLE;
LCD_DrawLine(0, 83, 240, 83);
LCD_DrawLine(0, 133, 240, 133);
// print text
POINT_COLOR = BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_HOME_MORE_RETURN);
LCD_ShowString(263,212,s_text);
// print label
POINT_COLOR = BLUE;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_ABOUT_MAX_SIZE_LABEL);
LCD_ShowString(10,40,s_text);
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_ABOUT_FW_VER_LABLE);
LCD_ShowString(10,90,s_text);
// print infomation
POINT_COLOR = BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",MAC_SIZE);
LCD_ShowString(10,60,s_text);
CLEAN_STRING(s_text);
sprintf((char *)s_text, "%s", FW_VERSION);
LCD_ShowString(10, 110,s_text);
}
void display_image::scanWindowAbout(uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>260&&rv_x<315&&rv_y>153&&rv_y<208) //select return
{
next_window_ID=eMENU_HOME_MORE;
}
}
// /***************************Printing page*******************************************/
void display_image::displayWindowPrint(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 25, BG_COLOR_CAPTION_PRINT); //caption background
//display file name
bgColor = BG_COLOR_CAPTION_PRINT;
color=WHITE;
if(recovery_flag==false)
LCD_ShowString(10,5, lgtCard.longFilename());
else
;
bgColor = WHITE;
color=BLACK;
displayImage(10, 30, IMG_ADDR_INDICATOR_HEAD);
displayImage(140, 30, IMG_ADDR_INDICATOR_FAN_0);
displayImage(10, 70, IMG_ADDR_INDICATOR_BED);
displayImage(144, 70, IMG_ADDR_INDICATOR_HEIGHT);
displayImage(10, 150, IMG_ADDR_INDICATOR_TIMER_CD);
displayImage(140, 150, IMG_ADDR_INDICATOR_TIMER_CU);
LCD_Fill(10,110,200,140,LIGHTBLUE); //progress bar background
switch(cur_ppage)
{
case 0:
displayImage(260, 30, IMG_ADDR_BUTTON_PAUSE_DISABLE);
current_print_cmd=E_PRINT_DISPAUSE;
cur_pstatus=0;
break;
case 1: //printing
displayImage(260, 30, IMG_ADDR_BUTTON_PAUSE);
cur_pstatus=1;
//current_print_cmd=E_PRINT_PAUSE;
break;
case 2:
displayImage(260, 30, IMG_ADDR_BUTTON_RESUME);
cur_pstatus=2;
break;
case 3:
displayImage(260, 30, IMG_ADDR_BUTTON_PAUSE_DISABLE);
current_print_cmd=E_PRINT_DISPAUSE;
cur_pstatus=3;
break;
case 10:
default:
//disable button pause
displayImage(260, 30, IMG_ADDR_BUTTON_PAUSE_DISABLE);
current_print_cmd=E_PRINT_DISPAUSE;
break;
}
cur_flag=true;
displayImage(260, 105, IMG_ADDR_BUTTON_ADJUST);
if (!recoveryStatus)
displayImage(260, 180, IMG_ADDR_BUTTON_END);
displayPrintInformation();
}
void display_image::displayPrintInformation(void)
{
displayRunningFan(140, 30);
displayPrintTemperature();
displayHeightValue();
displayFanSpeed();
dispalyCurrentStatus();
displayPrintProgress();
displayCountUpTime();
displayCountDownTime();
}
void display_image::displayRunningFan(uint16_t pos_x, uint16_t pos_y)
{
if(thermalManager.scaledFanSpeed(eFan::FAN0) == 0) return;
static bool is_fan0_display = false;
if(!is_fan0_display)
{
displayImage(pos_x, pos_y, IMG_ADDR_INDICATOR_FAN_0);
}
else
{
displayImage(pos_x, pos_y, IMG_ADDR_INDICATOR_FAN_1);
}
is_fan0_display = !is_fan0_display;
}
void display_image::displayFanSpeed(void)
{
LCD_Fill(170,30,250,60,White); //clean fan speed display zone
color=Black;
CLEAN_STRING(s_text);
sprintf((char *)s_text,"F: %d", thermalManager.scaledFanSpeed(eFan::FAN0));
LCD_ShowString(175,37,s_text);
}
void display_image::displayPrintTemperature(void)
{
LCD_Fill(45,30,130,60,White); //clean extruder display zone
LCD_Fill(45,70,130,100,White); //clean bed display zone
color=Black;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"E: %d/%d",(int16_t)thermalManager.degHotend(eHeater::H0),thermalManager.degTargetHotend(eHeater::H0));
LCD_ShowString(45,37,s_text);
CLEAN_STRING(s_text);
sprintf((char *)s_text,"B: %d/%d",(int16_t)thermalManager.degBed(),thermalManager.degTargetBed());
LCD_ShowString(45,77,s_text);
}
void display_image::displayPrintProgress(void)
{
LCD_Fill(210,110,250,140,White); //clean percentage display zone
uint8_t percent;
if (is_print_finish)
percent = 100;
else
percent = card.percentDone();
LCD_Fill(10,110,(uint16_t)(10+percent*1.9),140,DARKBLUE); //display current progress
color=Black;
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%d %%",percent);
LCD_ShowString(210,117,s_text);
}
void display_image::displayHeightValue(void)
{
LCD_Fill(170,70,250,100,White); //clean height display zone
color=Black;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"Z: %.1f",current_position[Z_AXIS]);
LCD_ShowString(175,77,s_text);
}
void display_image::dispalyCurrentStatus(void)
{
switch(cur_pstatus)
{
case 0: //heating
displayHeating();
current_print_cmd=E_PRINT_DISPAUSE;
cur_ppage=0;
cur_pstatus=10;
break;
case 1: //printing
displayPrinting();
current_print_cmd=E_PRINT_PAUSE;
cur_pstatus=10;
cur_ppage=1;
break;
case 2: //pause
// if(READ(FIL_RUNOUT_PIN))
// displayNofilament();
// else
displayPause();
cur_pstatus=10;
cur_ppage=2;
break;
case 3: // finish
LCD_Fill(260,30,320,90,White); //clean pause/resume icon display zone
LCD_Fill(0,190,200,240,White); //clean prompt display zone
//disable pause button
displayImage(260, 30, IMG_ADDR_BUTTON_PAUSE_DISABLE);
displayImage(10, 195, IMG_ADDR_PROMPT_COMPLETE);
color =Green;
current_print_cmd=E_PRINT_DISPAUSE;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_PRINT_STATUS_FINISH);
LCD_ShowString(45,202,s_text);
is_printing=false;
is_print_finish=true;
isPrintStarted = false;
cur_pstatus=10;
cur_ppage=3;
// lgtCard.setPrintTime(0); //Make sure that the remaining time is 0 after printing
clearVarPrintEnd();
break;
case 10:
default:
break;
}
}
void display_image::displayCountUpTime(void)
{
// if (is_print_finish)
// return;
LCD_Fill(175,150,250,180,White); //clean cout-up timer display zone
color=Black;
CLEAN_STRING(s_text);
lgtCard.upTime(s_text);
LCD_ShowString(175,157,s_text);
}
void display_image::displayCountDownTime(void)
{
// if (is_print_finish)
// return;
if( lgtCard.printTime() == 0){ /* if don't get total time */
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%s",TXT_MENU_PRINT_CD_TIMER_NULL);
LCD_ShowString(45,157,s_text);
}else{ /* if get total time */
LCD_Fill(45,150,130,180,White); /* clean count-down timer display zone */
color=Black;
CLEAN_STRING(s_text);
lgtCard.downTime(s_text);
LCD_ShowString(45,157,s_text);
}
}
void display_image::displayHeating(void)
{
LCD_Fill(0,190,200,240,White);
displayImage(260, 30, IMG_ADDR_BUTTON_PAUSE_DISABLE);
displayImage(10, 195, IMG_ADDR_PROMPT_HEATING);
color=RED;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_PRINT_STATUS_HEATING);
LCD_ShowString(45,202,s_text);
color=BLACK;
}
void display_image::displayPrinting(void)
{
LCD_Fill(0,190,200,240,White);
displayImage(260, 30, IMG_ADDR_BUTTON_PAUSE);
//prompt printing
displayImage(10, 195, IMG_ADDR_PROMPT_PRINTING);
color=BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_PRINT_STATUS_RUNNING);
LCD_ShowString(45,202,s_text);
}
void display_image::displayPause(void)
{
LCD_Fill(0,190,200,240,White);
displayImage(260, 30, IMG_ADDR_BUTTON_RESUME);
//prompt pause
displayImage(10, 195, IMG_ADDR_PROMPT_PAUSE);
color=BLACK;
CLEAN_STRING(s_text);
sprintf((char*)s_text,"%s",TXT_MENU_PRINT_STATUS_PAUSING);
LCD_ShowString(45,202,s_text);
}
void display_image::scanWindowPrint( uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>260&&rv_x<315&&rv_y>30&&rv_y<85) //pause or resume
{
current_button_id=eBT_PRINT_PAUSE;
}
else if(rv_x>260&&rv_x<315&&rv_y>105&&rv_y<160) //adjust
{
current_button_id=eBT_PRINT_ADJUST;
}
else if(rv_x>260&&rv_x<315&&rv_y>180&&rv_y<235) //end
{
if (!recoveryStatus)
current_button_id=eBT_PRINT_END;
}
}
// /***************************Adjust page*******************************************/
void display_image::displayWindowAdjust(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 25, BG_COLOR_CAPTION_ADJUST); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_ADJUST); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_ADJUST_CN); //caption words
#endif
displayImage(5, 35, IMG_ADDR_BUTTON_ADD);
displayImage(69, 35, IMG_ADDR_BUTTON_ADD);
displayImage(133, 35, IMG_ADDR_BUTTON_ADD);
displayImage(196, 35, IMG_ADDR_BUTTON_ADD);
displayImage(5, 175, IMG_ADDR_BUTTON_SUB);
displayImage(69, 175, IMG_ADDR_BUTTON_SUB);
displayImage(133, 175, IMG_ADDR_BUTTON_SUB);
displayImage(196, 175, IMG_ADDR_BUTTON_SUB);
initialMoveDistance(260, 40);
displayImage(260, 101, IMG_ADDR_BUTTON_MORE);
displayImage(260, 175, IMG_ADDR_BUTTON_RETURN);
displayImage(20, 105, IMG_ADDR_INDICATOR_HEAD);
displayImage(85, 105, IMG_ADDR_INDICATOR_BED);
displayImage(144, 105, IMG_ADDR_INDICATOR_FAN_0);
#ifndef Chinese
displayImage(209, 105, IMG_ADDR_INDICATOR_SPEED);
#else
displayImage(209, 105, IMG_ADDR_INDICATOR_SPEED_CN);
#endif
dispalyAdjustTemp();
dispalyAdjustFanSpeed();
dispalyAdjustMoveSpeed();
}
void display_image::dispalyAdjustTemp(void)
{
LCD_Fill(5,143,65,163,White); //clean extruder temperature display zone
LCD_Fill(74,143,134,163,White); //clean bed temperature display zone
color=BLACK;
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%d/%d",(int16_t)(thermalManager.degHotend(eHeater::H0)),thermalManager.degTargetHotend(eHeater::H0));
LCD_ShowString(5,143,s_text);
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%d/%d",(int16_t)(thermalManager.degBed()),thermalManager.degTargetBed());
LCD_ShowString(74,143,s_text);
}
void display_image::dispalyAdjustFanSpeed(void)
{
LCD_Fill(146,143,196,163,White); //clean fan speed display zone
color=Black;
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%03d",thermalManager.scaledFanSpeed(eFan::FAN0));
LCD_ShowString(146,143,s_text);
}
void display_image::dispalyAdjustMoveSpeed(void)
{
LCD_Fill(208,143,258,163,White); //clean feed rate display zone
color=Black;
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%03d%%",feedrate_percentage);
LCD_ShowString(208,143,s_text);
}
void display_image::scanWindowAdjust(uint16_t rv_x,uint16_t rv_y)
{
if(rv_x>260&&rv_x<315&&rv_y>175&&rv_y<230) //return
{
next_window_ID=eMENU_PRINT;
}
else if(rv_x>5&&rv_x<60&&rv_y>35&&rv_y<90) //add extruder temperature or flow multiplier
{
current_button_id=eBT_ADJUSTE_PLUS;
}
else if(rv_x>5&&rv_x<60&&rv_y>175&&rv_y<230) //subtract extruder temperature or flow multiplier
{
current_button_id=eBT_ADJUSTE_MINUS;
}
else if(rv_x>69&&rv_x<124&&rv_y>35&&rv_y<90) //add bed temperature
{
current_button_id=eBT_ADJUSTBED_PLUS;
}
else if(rv_x>69&&rv_x<124&&rv_y>175&&rv_y<230) //subtract bed temperature
{
current_button_id=eBT_ADJUSTBED_MINUS;
}
else if(rv_x>133&&rv_x<188&&rv_y>35&&rv_y<90) //add fan speed
{
current_button_id=eBT_ADJUSTFAN_PLUS;
}
else if(rv_x>133&&rv_x<188&&rv_y>175&&rv_y<230) //subtract fan speed
{
current_button_id=eBT_ADJUSTFAN_MINUS;
}
else if(rv_x>196&&rv_x<251&&rv_y>35&&rv_y<90) //add feed rate
{
current_button_id=eBT_ADJUSTSPEED_PLUS;
}
else if(rv_x>196&&rv_x<251&&rv_y>175&&rv_y<230) //subtract feed rate
{
current_button_id=eBT_ADJUSTSPEED_MINUS;
}
else if(rv_x>260&&rv_x<315&&rv_y>40&&rv_y<80) //change distance
{
current_button_id=eBT_DISTANCE_CHANGE;
}
else if(rv_x>260&&rv_x<315&&rv_y>100&&rv_y<155) //select more
{
next_window_ID=eMENU_ADJUST_MORE;
}
}
// /***************************Adjust more page*******************************************/
void display_image::displayWindowAdjustMore(void)
{
lcdClear(White);
LCD_Fill(0, 0, 320, 25, BG_COLOR_CAPTION_ADJUST); //caption background
#ifndef Chinese
displayImage(115, 5, IMG_ADDR_CAPTION_ADJUST); //caption words
#else
displayImage(115, 5, IMG_ADDR_CAPTION_ADJUST_CN); //caption words
#endif
displayImage(5, 35, IMG_ADDR_BUTTON_ADD);
displayImage(5, 175, IMG_ADDR_BUTTON_SUB);
#ifndef Chinese
displayImage(20, 105, IMG_ADDR_INDICATOR_FLOW);
#else
displayImage(20, 105, IMG_ADDR_INDICATOR_FLOW_CN);
#endif
initialMoveDistance(260, 40);
displayImage(260, 101, IMG_ADDR_BUTTON_MORE);
displayImage(260, 175, IMG_ADDR_BUTTON_RETURN);
if(cur_ppage==2){ //when printing pause
displayImage(196, 35, IMG_ADDR_BUTTON_EXTRUDE);
}
dispalyAdjustFlow();
}
void display_image::dispalyAdjustFlow(void)
{
if(cur_pstatus==2) //show extrude when no filament in adjustmore page
{
displayImage(196, 35, IMG_ADDR_BUTTON_EXTRUDE);
cur_ppage=2;
cur_pstatus=10;
}
LCD_Fill(5,143,65,163,White); //clean flow display zone
color=Black;
CLEAN_STRING(s_text);
sprintf((char *)s_text,"%03d%%",planner.flow_percentage[0]);
LCD_ShowString(19,143,s_text);
}
void display_image::scanWindowAdjustMore(uint16_t rv_x,uint16_t rv_y)
{
if(rv_x>260&&rv_x<315&&rv_y>175&&rv_y<230) //return
{
next_window_ID=eMENU_PRINT;
}
else if(rv_x>5&&rv_x<60&&rv_y>35&&rv_y<90) //add flow
{
current_button_id=eBT_ADJUSTE_PLUS;
}
else if(rv_x>5&&rv_x<60&&rv_y>175&&rv_y<230) //subtract flow
{
current_button_id=eBT_ADJUSTE_MINUS;
}
else if(rv_x>196&&rv_x<251&&rv_y>35&&rv_y<90) //go to extrude
{
if(cur_ppage==2) { // print pause status
ret_menu_extrude = 2;
next_window_ID=eMENU_EXTRUDE;
}
}
else if(rv_x>260&&rv_x<315&&rv_y>40&&rv_y<80) //change distance
{
current_button_id=eBT_DISTANCE_CHANGE;
}
else if(rv_x>260&&rv_x<315&&rv_y>100&&rv_y<155) //select more
{
next_window_ID=eMENU_ADJUST;
}
}
// /***************************dialog page*******************************************/
const char* c_dialog_text[eDIALOG_MAX][4]={
{TXT_DIALOG_CAPTION_START, DIALOG_PROMPT_PRINT_START1,DIALOG_PROMPT_PRINT_START2,DIALOG_PROMPT_PRINT_START3},
{TXT_DIALOG_CAPTION_EXIT, DIALOG_PROMPT_PRINT_EXIT1,DIALOG_PROMPT_PRINT_EXIT2,DIALOG_PROMPT_PRINT_EXIT3},
{TXT_DIALOG_CAPTION_ABORT, DIALOG_PROMPT_PRINT_ABORT1,DIALOG_PROMPT_PRINT_ABORT2,DIALOG_PROMPT_PRINT_ABORT3},
{TXT_DIALOG_CAPTION_RECOVERY, DIALOG_PROMPT_PRINT_RECOVERY1,DIALOG_PROMPT_PRINT_RECOVERY2,DIALOG_PROMPT_PRINT_RECOVERY3},
{TXT_DIALOG_CAPTION_ERROR, DIALOG_PROMPT_ERROR_READ1,DIALOG_PROMPT_ERROR_READ2,DIALOG_PROMPT_ERROR_READ3},
{TXT_DIALOG_CAPTION_RESTORE, DIALOG_PROMPT_SETTS_RESTORE1,DIALOG_PROMPT_SETTS_RESTORE2,DIALOG_PROMPT_SETTS_RESTORE3},
{TXT_DIALOG_CAPTION_SAVE, DIALOG_PROMPT_SETTS_SAVE_OK1,DIALOG_PROMPT_SETTS_SAVE_OK2,DIALOG_PROMPT_SETTS_SAVE_OK3},
{TXT_DIALOG_CAPTION_SAVE, DIALOG_PROMPT_SETTS_SAVE1,DIALOG_PROMPT_SETTS_SAVE2,DIALOG_PROMPT_SETTS_SAVE3},
{TXT_DIALOG_CAPTION_NO_FIALMENT, DIALOG_PROMPT_NO_FILAMENT1,DIALOG_PROMPT_NO_FILAMENT2,DIALOG_PROMPT_NO_FILAMENT3},
{TXT_DIALOG_CAPTION_ERROR, DIALOG_ERROR_FILE_TYPE1,DIALOG_ERROR_FILE_TYPE2,DIALOG_ERROR_FILE_TYPE3},
{TXT_DIALOG_CAPTION_ERROR, DIALOG_ERROR_TEMP_BED1,DIALOG_ERROR_TEMP_BED2,DIALOG_ERROR_TEMP_BED3},
{TXT_DIALOG_CAPTION_ERROR, DIALOG_ERROR_TEMP_HEAD1,DIALOG_ERROR_TEMP_HEAD2,DIALOG_ERROR_TEMP_HEAD3},
{TXT_DIALOG_CAPTION_OPEN_FOLER, DIALOG_PROMPT_MAX_FOLDER1,DIALOG_PROMPT_MAX_FOLDER2,DIALOG_PROMPT_MAX_FOLDER3},
{TXT_DIALOG_CAPTION_NO_FIALMENT, DIALOG_START_PRINT_NOFILA1,DIALOG_START_PRINT_NOFILA2,DIALOG_START_PRINT_NOFILA3},
{TXT_DIALOG_CAPTION_WAIT, "", DIALOG_PROMPT_WAIT, ""}
};
void display_image::dispalyDialogYesNo(uint8_t dialog_index)
{
displayImage(60, 45, IMG_ADDR_DIALOG_BODY);
displayImage(85, 130, IMG_ADDR_BUTTON_YES);
displayImage(180, 130, IMG_ADDR_BUTTON_NO);
displayImage(70, 80, IMG_ADDR_PROMPT_QUESTION);
displayDialogText(dialog_index);
}
void display_image::dispalyDialogYes(uint8_t dialog_index)
{
displayImage(60, 45, IMG_ADDR_DIALOG_BODY);
displayImage(132, 130, IMG_ADDR_BUTTON_YES);
if(dialog_index==eDIALOG_SETTS_SAVE_OK)
displayImage(70, 80, IMG_ADDR_PROMPT_COMPLETE);
else
displayImage(70, 80, IMG_ADDR_PROMPT_ERROR);
displayDialogText(dialog_index);
}
void display_image::displayWaitDialog()
{
displayImage(60, 45, IMG_ADDR_DIALOG_BODY);
displayImage(70, 80, IMG_ADDR_PROMPT_PAUSE);
displayDialogText(eDIALOG_WAIT);
}
void display_image::displayDialogText(uint8_t dialog_index)
{
/* caption */
bgColor=BG_COLOR_CAPTION_DIALOG;
color = WHITE;
LCD_ShowString(70,50,(char*)c_dialog_text[dialog_index][0]);
/* prompt */
bgColor = WHITE;
color = BLACK;
LCD_ShowString(110,76,(char*)c_dialog_text[dialog_index][1]);
LCD_ShowString(110,92,(char*)c_dialog_text[dialog_index][2]);
LCD_ShowString(110,108,(char*)c_dialog_text[dialog_index][3]);
}
void display_image::scanDialogStart(uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>85&&rv_x<140&&rv_y>130&&rv_y<185) //select yes
{
current_button_id=eBT_DIALOG_PRINT_START;
}
else if(rv_x>180&&rv_x<235&&rv_y>130&&rv_y<185) //select no
{
current_button_id=eBT_DIALOG_PRINT_NO;
}
}
void display_image::scanDialogEnd( uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>85&&rv_x<140&&rv_y>130&&rv_y<185) //select yes
{
current_button_id=eBT_DIALOG_ABORT_YES;
}
else if(rv_x>180&&rv_x<235&&rv_y>130&&rv_y<185) //select no
{
next_window_ID=eMENU_PRINT;
}
}
void display_image::scanDialogNoFilament(uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>85&&rv_x<140&&rv_y>130&&rv_y<185) //select yes
{
current_button_id=eBT_DIALOG_NOFILANET_YES;
}
else if(rv_x>180&&rv_x<235&&rv_y>130&&rv_y<185) //select no
{
current_button_id=eBT_DIALOG_PRINT_NO;
}
}
void display_image::scanDialogNoFilamentInPrint(uint16_t rv_x, uint16_t rv_y )
{
if(rv_x>85&&rv_x<140&&rv_y>130&&rv_y<185) //select yes
{
current_button_id = eBT_DIALOG_NOFILANET_PRINT_YES;
}
else if(rv_x>180&&rv_x<235&&rv_y>130&&rv_y<185) //select no
{
current_button_id = eBT_DIALOG_NOFILANET_PRINT_NO;
}
}
void display_image::scanDialogRecovery( uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>85&&rv_x<140&&rv_y>130&&rv_y<185) //select yes
{
current_button_id = eBT_DIALOG_RECOVERY_OK;
}
else if(rv_x>180&&rv_x<235&&rv_y>130&&rv_y<185) //select no
{
current_button_id = eBT_DIALOG_RECOVERY_NO;
}
}
void display_image::scanDialogSave(uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>85&&rv_x<140&&rv_y>130&&rv_y<185) //select yes
{
current_button_id=eBT_DIALOG_SAVE_YES;
}
else if(rv_x>180&&rv_x<235&&rv_y>130&&rv_y<185) //select no
{
next_window_ID=eMENU_HOME_MORE;
}
}
void display_image::scanDialogSaveOk(uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>132&&rv_x<187&&rv_y>130&&rv_y<185) //select ok
{
next_window_ID = eMENU_SETTINGS_RETURN;
}
}
void display_image::scanDialogRefactory(uint16_t rv_x, uint16_t rv_y)
{
if(rv_x>85&&rv_x<140&&rv_y>130&&rv_y<185) //select yes
{
current_button_id=eBT_DIALOG_REFACTORY_YES;
}
else if(rv_x>180&&rv_x<235&&rv_y>130&&rv_y<185) //select no
{
next_window_ID=eMENU_SETTINGS_RETURN;
}
}
// /************************* other page *******************************/
static int8_t errorIndex(const char *error, const char *component)
{
if (error == nullptr)
return -1;
const char *E1 = "E1";
const char *BED = "Bed";
#define IS_ERROR(e) (strcmp(error, GET_TEXT(e)) == 0)
#define IS_E1() (strcmp(component, E1) == 0)
#define IS_BED() (strcmp(component, BED) == 0)
int8_t index;
if (IS_ERROR(MSG_ERR_MINTEMP)) {
if (IS_E1())
index = 0;
else if (IS_BED())
index = 1;
else
index = -1;
} else if (IS_ERROR(MSG_ERR_MAXTEMP)) {
if (IS_E1())
index = 2;
else if (IS_BED())
index = 3;
else
index = -1;
} else if (IS_ERROR(MSG_HEATING_FAILED_LCD)) {
if (IS_E1())
index = 4;
else if (IS_BED())
index = 5;
else
index = -1;
} else if (IS_ERROR(MSG_THERMAL_RUNAWAY)) {
if (IS_E1())
index = 6;
else if (IS_BED())
index = 7;
else
index = -1;
} else if (IS_ERROR(MSG_LCD_HOMING_FAILED)) {
index = 8;
} else if (IS_ERROR(MSG_LCD_PROBING_FAILED)) {
index = 9;
} else { // unknown error
index = -1;
}
return index;
}
void display_image::displayWindowKilled(const char* error, const char *component)
{
lcd.clear(BG_COLOR_KILL_MENU);
lcd.setBgColor(BG_COLOR_KILL_MENU);
lcd.setColor(WHITE);
lcd.print(40, 70, TXT_PRINTER_KILLED_INFO1);
lcd.print(40, 90, TXT_PRINTER_KILLED_INFO2);
lcd.setColor(YELLOW);
CLEAN_STRING(s_text);
const char *errMsgKilled[] = {
TXT_ERR_MINTEMP,
TXT_ERR_MIN_TEMP_BED,
TXT_ERR_MAXTEMP,
TXT_ERR_MAX_TEMP_BED,
TXT_ERR_HEATING_FAILED,
TXT_ERR_HEATING_FAILED_BED,
TXT_ERR_TEMP_RUNAWAY,
TXT_ERR_TEMP_RUNAWAY_BED,
TXT_ERR_HOMING_FAILED,
TXT_ERR_PROBING_FAILED
};
int8_t errIndex = errorIndex(error, component);
if (errIndex > -1) {
sprintf(s_text, "Error %i: %s", errIndex + 1, errMsgKilled[errIndex]);
lcd.print(40, 180, s_text);
}
lcd.setBgColor(WHITE);
lcd.setColor(BLACK);
}
void display_image::changeToPageKilled(const char* error, const char *component)
{
displayWindowKilled(error, component);
current_window_ID = eWINDOW_NONE;
}
/********************************************************
* is_bed:false->extruder0, true->bed
* sign: false->plus, true->minus
* return: false->no change
*********************************************************/
bool display_image::setTemperatureInWindow(bool is_bed, bool sign)
{
if((is_bed&&thermalManager.degBed()<0)||
(thermalManager.degHotend(eHeater::H0)<0))
return false;
int16_t temp_limit;
int16_t p_temp;
if(!sign)
{ /* add */
if(!is_bed){ /* extruder */
temp_limit = MAX_ADJUST_TEMP_EXTRUDE;
p_temp = thermalManager.degTargetHotend(eHeater::H0);
}
else{ /* bed */
temp_limit = MAX_ADJUST_TEMP_BED;
p_temp = thermalManager.degTargetBed();
}
if(p_temp < temp_limit){ /* within the limit */
if(default_move_distance == 0xff)
if(!is_bed){
if(p_temp < NORMAL_ADJUST_TEMP_EXTRUDE)
p_temp = NORMAL_ADJUST_TEMP_EXTRUDE;
else
p_temp = MAX_ADJUST_TEMP_EXTRUDE;
}
else{
if(p_temp < NORMAL_ADJUST_TEMP_BED)
p_temp = NORMAL_ADJUST_TEMP_BED;
else
p_temp = MAX_ADJUST_TEMP_BED;
}
else{ /* if distance is 1, 5, 10 */
p_temp += default_move_distance;
if(p_temp > temp_limit)
p_temp= temp_limit;
}
if (!is_bed)
thermalManager.setTargetHotend(p_temp, eHeater::H0);
else
thermalManager.setTargetBed(p_temp);
return true;
}
}
else
{ /* minus */
if(!is_bed){ /* extruder */
temp_limit = MIN_ADJUST_TEMP_EXTRUDE;
p_temp = thermalManager.degTargetHotend(eHeater::H0);
}
else { /* bed */
temp_limit = MIN_ADJUST_TEMP_BED;
p_temp = thermalManager.degTargetBed();
}
if(p_temp > temp_limit){ /* within the limit */
if(default_move_distance == 0xff)
if(!is_bed){
if(p_temp <= NORMAL_ADJUST_TEMP_EXTRUDE)
p_temp = MIN_ADJUST_TEMP_EXTRUDE;
else
p_temp = NORMAL_ADJUST_TEMP_EXTRUDE;
}
else{
if(p_temp <= NORMAL_ADJUST_TEMP_BED)
p_temp = MIN_ADJUST_TEMP_BED;
else
p_temp = NORMAL_ADJUST_TEMP_BED;
}
else{
p_temp -= default_move_distance;
if(p_temp < temp_limit)
p_temp = temp_limit;
}
if (!is_bed)
thermalManager.setTargetHotend(p_temp, eHeater::H0);
else
thermalManager.setTargetBed(p_temp);
return true;
}
}
return false;
}
/**
* page switching
*/
void display_image::LGT_Ui_Update(void)
{
if (next_window_ID == eWINDOW_NONE)
return;
switch (next_window_ID)
{
case eMENU_HOME:
current_window_ID=eMENU_HOME;
next_window_ID=eWINDOW_NONE;
displayWindowHome();
break;
case eMENU_HOME_MORE:
if((current_window_ID==eMENU_LEVELING)&&all_axes_homed())
enqueue_and_echo_commands_P(PSTR("G0 Z10 F500"));
if(current_window_ID == eMENU_SETTINGS && lgtStore.isModified()) {
dispalyDialogYesNo(eDIALOG_SETTS_SAVE);
current_window_ID=eMENU_DIALOG_SAVE;
} else {
current_window_ID=eMENU_HOME_MORE;
displayWindowHomeMore();
}
next_window_ID=eWINDOW_NONE;
break;
case eMENU_MOVE:
current_window_ID=eMENU_MOVE;
next_window_ID=eWINDOW_NONE;
displayWindowMove();
break;
case eMENU_FILE:
current_window_ID=eMENU_FILE;
next_window_ID=eWINDOW_NONE;
lgtCard.clear();
lgtCard.setCardState(false); // enforce init card
displayWindowFiles();
break;
case eMENU_FILE1: // just return to file page
current_window_ID=eMENU_FILE;
next_window_ID=eWINDOW_NONE;
displayWindowFiles();
highlightChosenFile();
break;
case eMENU_EXTRUDE:
current_window_ID=eMENU_EXTRUDE;
next_window_ID=eWINDOW_NONE;
is_bed_select=false;
displayWindowExtrude();
break;
case eMENU_PREHEAT:
current_window_ID=eMENU_PREHEAT;
next_window_ID=eWINDOW_NONE;
displayWindowPreheat();
break;
case eMENU_LEVELING:
current_window_ID=eMENU_LEVELING;
next_window_ID=eWINDOW_NONE;
// set_all_unhomed();
displayWindowLeveling();
break;
case eMENU_ABOUT:
current_window_ID=eMENU_ABOUT;
next_window_ID=eWINDOW_NONE;
displayWindowAbout();
break;
case eMENU_PRINT:
current_window_ID=eMENU_PRINT;
next_window_ID=eWINDOW_NONE;
displayWindowPrint();
break;
case eMENU_ADJUST:
current_window_ID=eMENU_ADJUST;
next_window_ID=eWINDOW_NONE;
displayWindowAdjust();
break;
case eMENU_ADJUST_MORE:
current_window_ID=eMENU_ADJUST_MORE;
next_window_ID=eWINDOW_NONE;
displayWindowAdjustMore();
break;
case eMENU_DIALOG_RECOVERY:
current_window_ID=eMENU_DIALOG_RECOVERY;
next_window_ID=eWINDOW_NONE;
dispalyDialogYesNo(eDIALOG_PRINT_RECOVERY);
break;
case eMENU_SETTINGS:
current_window_ID=eMENU_SETTINGS;
next_window_ID=eWINDOW_NONE;
lgtStore.syncSettings(); // sync setttings struct before list
lgtStore.setModified(false);
displayWindowSettings();
highlightSetting();
break;
case eMENU_SETTINGS_RETURN: // for return to setting page without sync data
current_window_ID=eMENU_SETTINGS;
next_window_ID=eWINDOW_NONE;
displayWindowSettings();
highlightSetting();
break;
case eMENU_SETTINGS2:
current_window_ID=eMENU_SETTINGS2;
next_window_ID=eWINDOW_NONE;
displayWindowSettings2();
break;
default: // no page change just button press
break;
}
next_window_ID = eWINDOW_NONE;
}
/**
* touch scanning
*/
void LgtLcdTft::LGT_MainScanWindow(void)
{
switch (current_window_ID)
{
case eMENU_HOME:
scanWindowHome(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_HOME_MORE:
scanWindowMoreHome(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_MOVE:
scanWindowMove(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_FILE:
scanWindowFile(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_EXTRUDE:
scanWindowExtrude(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_PREHEAT:
scanWindowPreheating(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_LEVELING:
scanWindowLeveling(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_SETTINGS:
scanWindowSettings(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_SETTINGS2:
scanWindowSettings2(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_ABOUT:
scanWindowAbout(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_PRINT:
scanWindowPrint(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_ADJUST:
scanWindowAdjust(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_ADJUST_MORE:
scanWindowAdjustMore(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_DIALOG_START:
scanDialogStart(cur_x,cur_y);
cur_x=cur_y=0;
case eMENU_DIALOG_NO_FIL:
scanDialogNoFilament(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_DIALOG_NO_FIL_PRINT:
scanDialogNoFilamentInPrint(cur_x,cur_y);
cur_x=cur_y=0;
case eMENU_DIALOG_END:
scanDialogEnd(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_DIALOG_RECOVERY:
scanDialogRecovery(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_DIALOG_REFACTORY:
scanDialogRefactory(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_DIALOG_SAVE:
scanDialogSave(cur_x,cur_y);
cur_x=cur_y=0;
break;
case eMENU_DIALOG_SAVE_OK:
scanDialogSaveOk(cur_x,cur_y);
cur_x=cur_y=0;
break;
default:
break;
}
}
/**
* process button pressing
*/
void display_image::LGT_Ui_Buttoncmd(void)
{
if (current_button_id == eBT_BUTTON_NONE)
return;
DEBUG_ECHOLNPAIR("button id:", current_button_id);
switch (current_button_id)
{
// menu move buttons
case eBT_MOVE_X_MINUS:
if (!planner.is_full()) {
current_position[X_AXIS]-=default_move_distance;
if(is_aixs_homed[X_AXIS]||all_axes_homed())
{
if(current_position[X_AXIS]<0)
current_position[X_AXIS]=0;
}
LGT_Line_To_Current_Position(X_AXIS);
displayMoveCoordinate();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_X_PLUS:
if (!planner.is_full()) {
current_position[X_AXIS]+=default_move_distance;
if(current_position[X_AXIS]>X_BED_SIZE)
current_position[X_AXIS]=X_BED_SIZE;
LGT_Line_To_Current_Position(X_AXIS);
displayMoveCoordinate();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_X_HOME:
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28 X0"));
enqueue_and_echo_commands_P("M2101 P0");
current_button_id=eBT_BUTTON_NONE;
is_aixs_homed[X_AXIS]=true;
break;
case eBT_MOVE_Y_MINUS:
if (!planner.is_full()) {
current_position[Y_AXIS]-=default_move_distance;
if(is_aixs_homed[Y_AXIS]||all_axes_homed())
{
if(current_position[Y_AXIS]<0)
current_position[Y_AXIS]=0;
}
LGT_Line_To_Current_Position(Y_AXIS);
displayMoveCoordinate();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_Y_PLUS:
if (!planner.is_full()) {
current_position[Y_AXIS]+=default_move_distance;
if(current_position[Y_AXIS]>Y_BED_SIZE)
current_position[Y_AXIS]=Y_BED_SIZE;
LGT_Line_To_Current_Position(Y_AXIS);
displayMoveCoordinate();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_Y_HOME:
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28 Y0"));
enqueue_and_echo_commands_P("M2101 P0");
current_button_id=eBT_BUTTON_NONE;
is_aixs_homed[Y_AXIS]=true;
break;
case eBT_MOVE_Z_MINUS:
if (!planner.is_full()) {
current_position[Z_AXIS]-=default_move_distance;
if(is_aixs_homed[Z_AXIS]||all_axes_homed())
{
if(current_position[Z_AXIS]<0)
current_position[Z_AXIS]=0;
}
LGT_Line_To_Current_Position(Z_AXIS);
displayMoveCoordinate();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_Z_PLUS:
if (!planner.is_full()) {
current_position[Z_AXIS]+=default_move_distance;
if(current_position[Z_AXIS]>Z_MACHINE_MAX)
current_position[Z_AXIS]=Z_MACHINE_MAX;
LGT_Line_To_Current_Position(Z_AXIS);
displayMoveCoordinate();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_Z_HOME:
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28 Z0"));
enqueue_and_echo_commands_P("M2101 P0");
current_button_id=eBT_BUTTON_NONE;
is_aixs_homed[Z_AXIS]=true;
break;
case eBT_MOVE_ALL_HOME:
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28"));
enqueue_and_echo_commands_P("M2101 P0");
current_button_id=eBT_BUTTON_NONE;
break;
// menu leveling buttons
case eBT_MOVE_L0:
if(!all_axes_homed())
{
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28"));
enqueue_and_echo_commands_P("M2101 P1");
thermalManager.disable_all_heaters();
}
enqueue_and_echo_commands_P(PSTR("G0 Z10 F500"));
#if defined(LK1) || defined(U20)
enqueue_and_echo_commands_P(PSTR("G0 X50 Y250 F5000"));
#elif defined(LK2) || defined(LK4) || defined(U30)
enqueue_and_echo_commands_P(PSTR("G0 X50 Y170 F5000"));
#elif defined(LK1_PLUS) || defined(U20_PLUS)
enqueue_and_echo_commands_P(PSTR("G0 X50 Y350 F5000"));
#endif
enqueue_and_echo_commands_P(PSTR("G0 Z0 F300"));
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_L1:
if(!all_axes_homed())
{
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28"));
enqueue_and_echo_commands_P("M2101 P1");
thermalManager.disable_all_heaters();
}
enqueue_and_echo_commands_P(PSTR("G0 Z10 F500"));
#if defined(LK1) || defined(U20)
enqueue_and_echo_commands_P(PSTR("G0 X250 Y250 F5000"));
#elif defined(LK2) || defined(LK4) || defined(U30)
enqueue_and_echo_commands_P(PSTR("G0 X170 Y170 F5000"));
#elif defined(LK1_PLUS) || defined(U20_PLUS)
enqueue_and_echo_commands_P(PSTR("G0 X350 Y350 F5000"));
#endif
enqueue_and_echo_commands_P(PSTR("G0 Z0 F300"));
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_L2:
if(!all_axes_homed())
{
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28"));
enqueue_and_echo_commands_P("M2101 P1");
thermalManager.disable_all_heaters();
}
enqueue_and_echo_commands_P(PSTR("G0 Z10 F500"));
#if defined(LK1) || defined(U20)
enqueue_and_echo_commands_P(PSTR("G0 X250 Y50 F5000"));
#elif defined(LK2) || defined(LK4) || defined(U30)
enqueue_and_echo_commands_P(PSTR("G0 X170 Y50 F5000"));
#elif defined(LK1_PLUS) || defined(U20_PLUS)
enqueue_and_echo_commands_P(PSTR("G0 X350 Y50 F5000"));
#endif
enqueue_and_echo_commands_P(PSTR("G0 Z0 F300"));
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_L3:
if(!all_axes_homed())
{
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28"));
enqueue_and_echo_commands_P("M2101 P1");
thermalManager.disable_all_heaters();
}
enqueue_and_echo_commands_P(PSTR("G0 Z10 F500"));
#if defined(LK1) || defined(U20)
enqueue_and_echo_commands_P(PSTR("G0 X50 Y50 F5000"));
#elif defined(LK2) || defined(LK4) || defined(U30)
enqueue_and_echo_commands_P(PSTR("G0 X50 Y50 F5000"));
#elif defined(LK1_PLUS) || defined(U20_PLUS)
enqueue_and_echo_commands_P(PSTR("G0 X50 Y50 F5000"));
#endif
enqueue_and_echo_commands_P(PSTR("G0 Z0 F300"));
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_L4:
if(!all_axes_homed())
{
// show wait dialog
displayWaitDialog();
current_window_ID = eMENU_DIALOG_WAIT;
enqueue_and_echo_commands_P(PSTR("G28"));
enqueue_and_echo_commands_P("M2101 P1");
thermalManager.disable_all_heaters();
}
enqueue_and_echo_commands_P(PSTR("G0 Z10 F500"));
#if defined(LK1) || defined(U20)
enqueue_and_echo_commands_P(PSTR("G0 X150 Y150 F5000"));
#elif defined(LK2) || defined(LK4) || defined(U30)
enqueue_and_echo_commands_P(PSTR("G0 X110 Y110 F5000"));
#elif defined(LK1_PLUS) || defined(U20_PLUS)
enqueue_and_echo_commands_P(PSTR("G0 X200 Y200 F5000"));
#endif
enqueue_and_echo_commands_P(PSTR("G0 Z0 F300"));
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_MOVE_RETURN:
if (all_axes_homed())
enqueue_and_echo_commands_P(PSTR("G0 Z10 F500"));
current_button_id=eBT_BUTTON_NONE;
break;
// menu preheatting buttons
case eBT_PR_PLA:
current_button_id=eBT_BUTTON_NONE;
if(thermalManager.degHotend(eHeater::H0)<0||thermalManager.degBed()<0)
break;
thermalManager.setTargetHotend(PREHEAT_PLA_TEMP_EXTRUDE, eHeater::H0);
thermalManager.setTargetBed(PREHEAT_PLA_TEMP_BED);
updatePreheatingTemp();
break;
case eBT_PR_ABS:
current_button_id=eBT_BUTTON_NONE;
if(thermalManager.degHotend(eHeater::H0)<0||thermalManager.degBed()<0)
break;
thermalManager.setTargetHotend(PREHEAT_ABS_TEMP_EXTRUDE, eHeater::H0);
thermalManager.setTargetBed(PREHEAT_ABS_TEMP_BED);
updatePreheatingTemp();
break;
case eBT_PR_PETG:
current_button_id=eBT_BUTTON_NONE;
if(thermalManager.degHotend(eHeater::H0)<0||thermalManager.degBed()<0)
break;
thermalManager.setTargetHotend(PREHEAT_PETG_TEMP_EXTRUDE, eHeater::H0);
thermalManager.setTargetBed(PREHEAT_PETG_TEMP_BED);
updatePreheatingTemp();
break;
case eBT_PR_COOL:
current_button_id=eBT_BUTTON_NONE;
if(thermalManager.degHotend(eHeater::H0)>0)
thermalManager.setTargetBed(MIN_ADJUST_TEMP_BED);
if(thermalManager.degHotend(eHeater::H0)>0)
thermalManager.setTargetHotend(MIN_ADJUST_TEMP_EXTRUDE, eHeater::H0);
updatePreheatingTemp();
break;
case eBT_PR_E_PLUS:
if(setTemperatureInWindow(false, false))
{
updatePreheatingTemp();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_PR_E_MINUS:
if(setTemperatureInWindow(false, true))
{
updatePreheatingTemp();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_PR_B_PLUS:
if(setTemperatureInWindow(true, false))
{
updatePreheatingTemp();
}
current_button_id=eBT_BUTTON_NONE;
break;
case EBT_PR_B_MINUS:
if(setTemperatureInWindow(true, true))
{
updatePreheatingTemp();
}
current_button_id=eBT_BUTTON_NONE;
break;
// menu extrude buttons
case eBT_TEMP_PLUS:
if(is_bed_select) //add bed temperature
{
setTemperatureInWindow(true,false);
}
else //add extrude temprature
{
setTemperatureInWindow(false,false);
}
dispalyExtrudeTemp();
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_TEMP_MINUS:
if(is_bed_select) //subtract bed temperature
{
setTemperatureInWindow(true,true);
}
else //subtract extrude temprature
{
setTemperatureInWindow(false,true);
}
dispalyExtrudeTemp();
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_JOG_EPLUS:
stopExtrude();
if(thermalManager.degTargetHotend(eHeater::H0)<PREHEAT_TEMP_EXTRUDE)
{
thermalManager.setTargetHotend(PREHEAT_TEMP_EXTRUDE, eHeater::H0);
if(thermalManager.degHotend(eHeater::H0)>PREHEAT_TEMP_EXTRUDE-5)
{
current_position[E_AXIS] = current_position[E_AXIS]+default_move_distance;
LGT_Line_To_Current_Position(E_AXIS);
}
if(is_bed_select)
{
is_bed_select=false;
displayImage(15, 95, IMG_ADDR_BUTTON_BED_OFF);
}
dispalyExtrudeTemp(RED);
}
else if(thermalManager.degHotend(eHeater::H0)>PREHEAT_TEMP_EXTRUDE-5)
{
current_position[E_AXIS] = current_position[E_AXIS]+default_move_distance;
LGT_Line_To_Current_Position(E_AXIS);
if(is_bed_select)
{
is_bed_select=false;
displayImage(15, 95, IMG_ADDR_BUTTON_BED_OFF);
}
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_JOG_EMINUS:
stopExtrude();
if(thermalManager.degTargetHotend(eHeater::H0)<PREHEAT_TEMP_EXTRUDE)
{
thermalManager.setTargetHotend(PREHEAT_TEMP_EXTRUDE, eHeater::H0);
if(thermalManager.degHotend(eHeater::H0)>195)
{
current_position[E_AXIS] = current_position[E_AXIS]-default_move_distance;
LGT_Line_To_Current_Position(E_AXIS);
}
if(is_bed_select)
{
is_bed_select=false;
displayImage(15, 95, IMG_ADDR_BUTTON_BED_OFF);
}
dispalyExtrudeTemp(RED);
}
else if(thermalManager.degHotend(eHeater::H0)>PREHEAT_TEMP_EXTRUDE-5)
{
current_position[E_AXIS] = current_position[E_AXIS]-default_move_distance;
LGT_Line_To_Current_Position(E_AXIS);
if(is_bed_select)
{
is_bed_select=false;
displayImage(15, 95, IMG_ADDR_BUTTON_BED_OFF);
}
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_AUTO_EPLUS:
startAutoFeed(1);
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_AUTO_EMINUS:
startAutoFeed(-1);
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_STOP:
stopExtrude();
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_BED_E:
is_bed_select=!is_bed_select;
if(is_bed_select) //bed mode
displayImage(15, 95, IMG_ADDR_BUTTON_BED_ON);
else //extruder mode
displayImage(15, 95, IMG_ADDR_BUTTON_BED_OFF);
current_button_id=eBT_BUTTON_NONE;
dispalyExtrudeTemp();
break;
case eBT_DISTANCE_CHANGE:
switch(current_window_ID)
{
case eMENU_MOVE:
changeMoveDistance(260, 55);
break;
case eMENU_PREHEAT:
changeMoveDistance(260,37);
break;
case eMENU_EXTRUDE:case eMENU_ADJUST:case eMENU_ADJUST_MORE:
changeMoveDistance(260,40);
break;
case eMENU_SETTINGS2:
changeMoveDistance(255,43);
break;
default:
break;
}
current_button_id=eBT_BUTTON_NONE;
break;
// menu file buttons
case eBT_FILE_NEXT:
if (lgtCard.nextPage()) {
displayFileList();
displayFilePageNumber();
highlightChosenFile();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_FILE_LAST:
if (lgtCard.previousPage()) {
displayFileList();
displayFilePageNumber();
highlightChosenFile();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_FILE_LIST1:
if(current_window_ID==eMENU_FILE) {
chooseFile(0);
} else
chooseSetting(0);
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_FILE_LIST2:
if(current_window_ID==eMENU_FILE) {
chooseFile(1);
} else
chooseSetting(1);
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_FILE_LIST3:
if(current_window_ID==eMENU_FILE)
chooseFile(2);
else
chooseSetting(2);
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_FILE_LIST4:
if(current_window_ID==eMENU_FILE)
chooseFile(3);
else
chooseSetting(3);
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_FILE_LIST5:
if(current_window_ID==eMENU_FILE)
chooseFile(4);
else
chooseSetting(4);
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_FILE_OPEN:
{
current_button_id=eBT_BUTTON_NONE;
if(!lgtCard.isFileSelected() ||
(lgtCard.isFileSelected() &&
(lgtCard.selectedPage() != lgtCard.page()))) {
break;
}
if (lgtCard.filename() == nullptr) // get short and long filename
break;
const char *fn = lgtCard.shortFilename();
DEBUG_ECHOLNPAIR("open shortname: ", fn);
if(lgtCard.isDir()) {
if (!lgtCard.isMaxDirDepth()) {
lgtCard.changeDir(fn);
DEBUG_ECHOLNPAIR("current depth: ", lgtCard.dirDepth());
// file variable has been cleared after changeDir
updateFilelist();
} else {
;// show prompt dialog on max directory
}
} else { // is gcode
if (IS_RUN_OUT()) {
dispalyDialogYesNo(eDIALOG_START_JOB_NOFILA);
current_window_ID=eMENU_DIALOG_NO_FIL;
} else {
dispalyDialogYesNo(eDIALOG_PRINT_START);
current_window_ID=eMENU_DIALOG_START;
}
}
break;
}
case eBT_FILE_FOLDER:
current_button_id=eBT_BUTTON_NONE;
if (!lgtCard.isRootDir()) {
lgtCard.upDir();
// lgtCard.clear();
// updateFilelist();
lgtCard.count();
DEBUG_ECHOLNPAIR("current count: ", lgtCard.fileCount());
lgtCard.reselectFile();
displayFileList();
displayFilePageNumber();
highlightChosenFile();
}
break;
// menu print buttons
case eBT_PRINT_PAUSE:
switch(current_print_cmd)
{
case E_PRINT_DISPAUSE:
break;
case E_PRINT_PAUSE:
DEBUG_ECHOLN("touch pause");
// enqueue_and_echo_commands_P((PSTR("M25")));
queue.inject_P(PSTR("M25"));
// show resume button and status in print menu
LCD_Fill(260,30,320,90,White); //clean pause/resume icon display zone
displayImage(260, 30, IMG_ADDR_BUTTON_RESUME);
displayPause();
break;
case E_PRINT_RESUME:
DEBUG_ECHOLN("touch resume");
resumePrint();
break;
default:
break;
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_PRINT_ADJUST:
next_window_ID=eMENU_ADJUST;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_PRINT_END:
if(is_print_finish)
{
clearVarPrintEnd();
next_window_ID = eMENU_HOME;
} else // abort print
{
dispalyDialogYesNo(eDIALOG_PRINT_ABORT);
current_window_ID=eMENU_DIALOG_END;
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_DIALOG_ABORT_YES:
abortPrintEnd();
next_window_ID = eMENU_HOME;
current_button_id=eBT_BUTTON_NONE;
break;
// menu print adjust buttons
case eBT_ADJUSTE_PLUS:
if(current_window_ID==eMENU_ADJUST) //add e temp
{
if(setTemperatureInWindow(false,false))
dispalyAdjustTemp();
}
else //add flow
{
planner.flow_percentage[0]+=default_move_distance;
if(planner.flow_percentage[0]>999)
planner.flow_percentage[0]=999;
dispalyAdjustFlow();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_ADJUSTE_MINUS:
if(current_window_ID==eMENU_ADJUST) //subtract e temp
{
if(setTemperatureInWindow(false,true))
dispalyAdjustTemp();
}
else //subtract flow
{
planner.flow_percentage[0]-=default_move_distance;
if(planner.flow_percentage[0]<10)
planner.flow_percentage[0]=0;
dispalyAdjustFlow();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_ADJUSTBED_PLUS:
if(setTemperatureInWindow(true,false))
dispalyAdjustTemp();
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_ADJUSTBED_MINUS:
if(setTemperatureInWindow(true,true))
dispalyAdjustTemp();
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_ADJUSTFAN_PLUS: {
int16_t tempFan=thermalManager.scaledFanSpeed(eFan::FAN0);
tempFan+=default_move_distance;
if(tempFan>255)
tempFan=255;
thermalManager.set_fan_speed(eFan::FAN0, uint8_t(tempFan));
dispalyAdjustFanSpeed();
current_button_id=eBT_BUTTON_NONE;
break;
}
case eBT_ADJUSTFAN_MINUS: {
int16_t tempFan=thermalManager.scaledFanSpeed(eFan::FAN0);
tempFan-=default_move_distance;
if(tempFan<0)
tempFan=0;
thermalManager.set_fan_speed(eFan::FAN0, uint8_t(tempFan));
dispalyAdjustFanSpeed();
current_button_id=eBT_BUTTON_NONE;
break;
}
case eBT_ADJUSTSPEED_PLUS:
feedrate_percentage+=default_move_distance;
if(feedrate_percentage>999)
feedrate_percentage=999;
dispalyAdjustMoveSpeed();
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_ADJUSTSPEED_MINUS:
feedrate_percentage-=default_move_distance;
if(feedrate_percentage<10)
feedrate_percentage=10;
dispalyAdjustMoveSpeed();
current_button_id=eBT_BUTTON_NONE;
break;
// dialog buttons
case eBT_DIALOG_PRINT_START: {
is_printing=true;
is_print_finish=cur_flag=false;
isPrintStarted = true;
cur_ppage=0;cur_pstatus=0;
const char *fn = lgtCard.shortFilename();
DEBUG_ECHOLNPAIR("open file: ", fn);
char cmd[4+ strlen(fn) + 1];
sprintf_P(cmd, PSTR("M23 %s"), fn);
enqueue_and_echo_commands_P(cmd);
enqueue_and_echo_commands_P(PSTR("M24"));
lgtStore.saveRecovery();
#if HAS_FILAMENT_SENSOR
runout.reset();
#endif
next_window_ID = eMENU_PRINT;
current_button_id=eBT_BUTTON_NONE;
}
break;
case eBT_DIALOG_PRINT_NO:
case eBT_DIALOG_NOFILANET_NO:
next_window_ID=eMENU_FILE1;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_DIALOG_NOFILANET_YES:
ret_menu_extrude = 4;
next_window_ID = eMENU_EXTRUDE;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_DIALOG_NOFILANET_PRINT_NO:
next_window_ID=eMENU_PRINT;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_DIALOG_NOFILANET_PRINT_YES:
ret_menu_extrude = 2;
next_window_ID = eMENU_EXTRUDE;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_DIALOG_RECOVERY_OK:
// clear some variables
is_printing=true;
is_print_finish=cur_flag=false;
isPrintStarted = true;
cur_ppage=0;cur_pstatus=0;
// retrive filename and printtime
lgtStore.loadRecovery();
// start recovery
DEBUG_ECHOLN("recovery start");
queue.inject_P(PSTR("M1000")); // == recovery.resume()
next_window_ID = eMENU_PRINT;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_DIALOG_RECOVERY_NO:
recovery.cancel(); // == M1000 C
setRecoveryStatus(false);
DISABLE_AXIS_Z(); // release Z motor
next_window_ID = eMENU_HOME;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_DIALOG_REFACTORY_YES:
lgtStore.reset();
lgtStore.syncSettings();
lgtStore.setModified(true);
next_window_ID=eMENU_SETTINGS_RETURN;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_DIALOG_SAVE_YES: // save and return home more
if (lgtStore.isModified()) {
// apply and save current settings
lgtStore.applySettings();
lgtStore.save();
next_window_ID = eMENU_HOME_MORE;
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_SETTING_MODIFY:
current_button_id=eBT_BUTTON_NONE;
if (lgtStore.isSettingSelected() &&
(lgtStore.selectedPage() == lgtStore.page()))
next_window_ID=eMENU_SETTINGS2;
break;
case eBT_SETTING_REFACTORY:
dispalyDialogYesNo(eDIALOG_SETTS_RESTORE);
current_window_ID=eMENU_DIALOG_REFACTORY;
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_SETTING_SAVE: // save and show save ok dialog
if (lgtStore.isModified()) {
// apply and save current settings
lgtStore.applySettings();
lgtStore.save();
dispalyDialogYes(eDIALOG_SETTS_SAVE_OK);
current_window_ID=eMENU_DIALOG_SAVE_OK;
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_SETTING_LAST:
if (lgtStore.previousPage()) {
displayArgumentList();
displayArugumentPageNumber();
highlightSetting();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_SETTING_NEXT:
if (lgtStore.nextPage()) {
displayArgumentList();
displayArugumentPageNumber();
highlightSetting();
}
current_button_id=eBT_BUTTON_NONE;
break;
case eBT_SETTING_ADD:
current_button_id=eBT_BUTTON_NONE;
lgtStore.changeSetting(int8_t(default_move_distance));
displayModifyArgument();
break;
case eBT_SETTING_SUB:
current_button_id=eBT_BUTTON_NONE;
lgtStore.changeSetting(int8_t(default_move_distance) * -1);
displayModifyArgument();
break;
default:
current_button_id=eBT_BUTTON_NONE;
break;
}
current_button_id = eBT_BUTTON_NONE;
}
void display_image::LGT_Printer_Data_Update(void)
{
constexpr millis_t UPDATE_INTERVAL = 1000u;
static millis_t next_update_Time = 0;
const millis_t now = millis();
if(ELAPSED(now, next_update_Time)){
next_update_Time = UPDATE_INTERVAL + millis();
// checkTemprature();
switch (current_window_ID) {
case eMENU_MOVE:
displayMoveCoordinate();
break;
case eMENU_PRINT:
displayPrintInformation();
break;
case eMENU_ADJUST:
dispalyAdjustFanSpeed();
dispalyAdjustTemp();
dispalyAdjustMoveSpeed();
displayRunningFan(144, 105);
switch(cur_pstatus) //save current status page when in adjust page
{
case 0:
cur_ppage=0;
break;
case 1:
cur_ppage=1;
break;
case 2:
cur_ppage=2;
break;
case 3:
cur_ppage=10;
break;
default:
break;
}
break;
case eMENU_ADJUST_MORE:
dispalyAdjustFlow();
switch(cur_pstatus) //save current status page when in adjust page
{
case 0:
cur_ppage=0;
break;
case 1:
cur_ppage=1;
break;
case 2:
cur_ppage=2;
break;
case 3:
cur_ppage=10;
break;
default:
break;
}
break;
case eMENU_PREHEAT:
updatePreheatingTemp();
break;
case eMENU_EXTRUDE:
dispalyExtrudeTemp();
// actAutoFeed();
displayRunningAutoFeed();
break;
case eMENU_FILE:
// update card state
updateCard();
break;
default:
break;
}
}
}
void LgtLcdTft::refreshScreen()
{
#if defined(LK1_PLUS) || defined(U20_PLUS)
if (isPrintStarted) { // refresh screen only when printing is started
const millis_t now = millis();
if (ELAPSED(now, nextTimeRefresh)) {
next_window_ID = current_window_ID;
LGT_Ui_Update();
nextTimeRefresh = now + REFRESH_INTERVAL;
}
}
#endif
}
void LgtLcdTft::init()
{
// init tft-lcd
lcd.init();
lcd.clear();
// load touch calibration
lgtStore.loadTouch();
// load lgt settings
lgtStore.load();
displayStartUpLogo();
delay(1000); // delay sometime to show logo
displayWindowHome();
#if ENABLED(POWER_LOSS_RECOVERY)
recovery.check();
if (recoveryStatus)
changeToPageRecovery();
#endif
}
void LgtLcdTft::loop()
{
#define TOUCH_DELAY 10u // millsecond
#define CHECK_TOUCH_TIME 4u
#define TRUELY_TOUCHED() (touchCheck > CHECK_TOUCH_TIME)
static millis_t nextTouchReadTime = 0;
static uint8_t touchCheck = 0;
if (lgtTouch.isTouched()) {
if (!TRUELY_TOUCHED()) {
const millis_t time = millis();
if (ELAPSED(time, nextTouchReadTime)) {
nextTouchReadTime = time + TOUCH_DELAY;
touchCheck++;
if (TRUELY_TOUCHED()) { // truely touched
lgtTouch.readTouchPoint(cur_x, cur_y);
DEBUG_ECHOPAIR("touch: x: ", cur_x);
DEBUG_ECHOLNPAIR(", y: ", cur_y);
LGT_MainScanWindow(); // touch pos will be clear after scanning
}
}
}
} else if (TRUELY_TOUCHED()) { // touch released
touchCheck = 0; // reset touch checker
DEBUG_ECHOLN("touch: released ");
LGT_Ui_Buttoncmd();
LGT_Ui_Update();
} else { // idle
touchCheck = 0; // reset touch checker
LGT_Printer_Data_Update();
refreshScreen();
}
}
#endif
| 97,614
|
C++
|
.cpp
| 3,141
| 27.161732
| 152
| 0.668007
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,867
|
lcdapi.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lcddrive/lcdapi.cpp
|
#include "lcdio.h"
#if ENABLED(LGT_LCD_TFT)
#include "lcdapi.h"
#include "ili9341.h"
#include "st7789v.h"
#include "lcdfont16.h"
#include "../w25qxx.h"
#include <libmaple/dma.h>
LgtLcdApi lgtlcd;
/**
* consturctor
*/
LgtLcdApi::LgtLcdApi() :
m_lcdID(0),
m_color(BLACK),
m_bgColor(WHITE)
{
}
uint8_t LgtLcdApi::init()
{
// reset lcd
OUT_WRITE(LCD_BACKLIGHT_PIN, LOW);
OUT_WRITE(LCD_RESET_PIN, LOW); // perform a clean hardware reset
_delay_ms(5);
OUT_WRITE(LCD_RESET_PIN, HIGH);
_delay_ms(5);
OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
#ifdef LCD_USE_DMA_FSMC
dma_init(FSMC_DMA_DEV);
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM);
#endif
// FSMC init
LCD_IO_Init(FSMC_CS_PIN, FSMC_RS_PIN);
m_lcdID= LCD_IO_ReadData(0x0000); //read id
uint32_t getdata;
if (m_lcdID == 0)
{
// read ID1 register to get LCD controller ID, MOST of the time located in register 0x04, like ST7789V
getdata = LCD_IO_ReadData(0x04, 3);
m_lcdID = (uint16_t)(getdata & 0xFFFF);
}
//If ID1 is 0, it means we need to check alternate registers, like 0xD3 in the case of ILI9341
if (m_lcdID == 0)
{
m_lcdID = LCD_IO_ReadData(0x00);
if (m_lcdID == 0)
{
// reading ID4 register (0xD3) to get ILI9341 identifier instead of register ID (0x04)
getdata = LCD_IO_ReadData(0xD3, 3);
m_lcdID = (uint16_t)(getdata & 0xFFFF);
}
}
const char *lcdControllerName = "unknown";
switch (m_lcdID) {
case ILI9341_ID: // ILI9341
ILI9341_Init();
lcdControllerName = "ILI9341";
break;
case ST7789V_ID: // ST7789V
ST7789V_Init();
lcdControllerName = "ST7789V";
break;
// case 0x1505: // R61505U
// break;
// case 0x8989: // SSD1289
// break;
// case 0x9325: // ILI9325
// break;
// case 0x9328: // ILI9328
// break;
// case 0x0404: // No LCD Controller detected
// break;
default:
break; // Unknown LCD Controller
}
SERIAL_ECHOLNPAIR("LCD Controller: ", lcdControllerName);
return 1;
}
void LgtLcdApi::setCursor(uint16_t Xpos, uint16_t Ypos)
{
if (m_lcdID == ILI9341_ID)
ILI9341_SetCursor(Xpos, Ypos);
else if (m_lcdID == ST7789V_ID)
ST7789V_SetCursor(Xpos, Ypos);
}
/**
* set show rectangle
* and prepare write gram
*/
void LgtLcdApi::setWindow(uint16_t Xmin, uint16_t Ymin, uint16_t XMax /* = 319 */, uint16_t Ymax /* = 239 */)
{
if (m_lcdID == ILI9341_ID)
ILI9341_SetWindow(Xmin, Ymin, XMax, Ymax);
else if (m_lcdID == ST7789V_ID)
ST7789V_SetWindow(Xmin, Ymin, XMax, Ymax);
}
void LgtLcdApi::prepareWriteRAM()
{
if (m_lcdID == ILI9341_ID)
ILI9341_WriteRam();
else if (m_lcdID == ST7789V_ID)
ST7789V_WriteRam();
}
void LgtLcdApi::backLightOn()
{
OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
}
void LgtLcdApi::backLightOff()
{
OUT_WRITE(LCD_BACKLIGHT_PIN, LOW);
}
/**
* Fill in a specified area with a single color
* (sx,sy),(ex,ey): Filled rectangular diagonal coordinates Area size:(ex-sx+1)*(ey-sy+1)
* color: Filled color
*/
void LgtLcdApi::fill(uint16_t sx,uint16_t sy,uint16_t ex,uint16_t ey,uint16_t color)
{
#if ENABLED(LCD_USE_DMA_FSMC)
setWindow(sx, sy, ex, ey);
uint32_t count = (ex - sx + 1) * (ey - sy + 1);
NOMORE(count, LCD_PIXELS_COUNT);
LCD_IO_WriteMultiple(color, count);
#else
uint16_t i,j;
uint16_t xlen=0;
// uint16_t temp;
xlen=ex-sx+1;
for(i=sy;i<=ey;i++)
{
setCursor(sx,i); //Setting cursor position
prepareWriteRAM(); //start writing gram
for(j=0;j<xlen;j++)
LCD_IO_WriteData(color); //show color
}
#endif
}
/**
* print string in lcd
*/
void LgtLcdApi::print(uint16_t x, uint16_t y, const char *text)
{
for (uint16_t l = 0; (*(uint8_t*)(text + l) != 0) && ((x + l * 8 + 8) < 320); l ++) {
uint16_t i, j, k;
uint8_t character;
character = (*(uint8_t*)(text + l) < 32 || *(uint8_t*)(text + l) > 127) ? 0 : *(text + l) - 32;
setWindow(x + l * 8, y, x + l * 8 + 7, y + 15);
for (i = 0; i < 2; i++)
for (j = 0; j < 8; j++)
for (k = 0; k < 8; k++)
LCD_IO_WriteData(font16[character][i + 2 * k] & (128 >> j) ? m_color : m_bgColor);
}
}
void LgtLcdApi::showImage(uint16_t x_st, uint16_t y_st, uint32_t addr)
{
imageHeader head;
spiFlash.W25QXX_Read(reinterpret_cast<uint8_t *>(&head), addr, sizeof(head));
// SERIAL_ECHOLNPAIR("image-w: ", head.w);
// SERIAL_ECHOLNPAIR("image-h: ", head.h);
showRawImage(x_st, y_st, head.w, head.h, addr + sizeof(imageHeader));
}
void LgtLcdApi::showRawImage(uint16_t xsta,uint16_t ysta,uint16_t width,uint16_t high, uint32_t addr)
{
static uint8_t image_buffer[IMAGE_BUFF_SIZE];
#if defined(SLOW_SHOW_IMAGE)
uint16_t x = xsta, y= ysta;
#endif
// calculate read times
uint32_t image_size = width * high * 2;
uint16_t get_image_times=image_size/IMAGE_BUFF_SIZE;
if((image_size-get_image_times*IMAGE_BUFF_SIZE)>0) {
get_image_times = get_image_times + 1;
}
setWindow(xsta, ysta, xsta + width - 1, ysta + high - 1);
for(uint16_t k = 0; k < get_image_times; k++) {
uint16_t real_size = (get_image_times-k)>1?IMAGE_BUFF_SIZE:(image_size-k*IMAGE_BUFF_SIZE);
spiFlash.W25QXX_Read(image_buffer, addr+k*IMAGE_BUFF_SIZE,real_size);
#if 0 //ENABLED(LCD_USE_DMA_FSMC) // to do: no need swap bytes
#define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))
for (uint16_t i = 0; i < real_size; i = i + 2) {
SWAP(image_buffer[i], image_buffer[i + 1]); // little-endian to big-endian
}
LCD_IO_WriteSequence(reinterpret_cast<uint16_t *>(image_buffer), real_size / 2);
#elif DISABLED(SLOW_SHOW_IMAGE)
for (uint16_t i = 0; i < real_size; i = i + 2) {
uint16_t color = image_buffer[i] | (image_buffer[i + 1] << 8); // little-endian
LCD_IO_WriteData(color);
}
#else
setCursor(x,y);
prepareWriteRAM();
for(uint16_t i=0; i< real_size; i = i + 2)
{
uint16_t color=image_buffer[i]|image_buffer[i+1]<<8;
LCD_IO_WriteData(color);
x++;
if(x>=(xsta+width))
{
x=xsta;
y++;
setCursor(x,y);
prepareWriteRAM();
}
}
#endif
}
}
void LgtLcdApi::drawCross(uint16_t x, uint16_t y, uint16_t color)
{
setWindow(x - 15, y, x + 15, y);
LCD_IO_WriteMultiple(color, 31);
setWindow(x, y - 15, x, y + 15);
LCD_IO_WriteMultiple(color, 31);
}
#endif // LGT_LCD_TFT
| 6,942
|
C++
|
.cpp
| 216
| 26.388889
| 109
| 0.586372
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,868
|
ili9341.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lcddrive/ili9341.cpp
|
// #include "../../inc/MarlinConfig.h"
#include "lcdio.h"
#if ENABLED(LGT_LCD_TFT)
#include "ili9341.h"
void ILI9341_Init(void) {
// TOUCH_LCD_IO_Init();
/* Sleep In Command */
LCD_IO_WriteReg(ILI9341_SLEEP_IN);
/* SW Reset Command */
LCD_IO_WriteReg(ILI9341_SWRESET);
/* Wait for 200ms */
LCD_Delay(200);
/* Normal display for Driver Down side */
LCD_IO_WriteReg(ILI9341_NORMAL_DISPLAY);
LCD_IO_WriteData(0xE8); // MY and ML flipped + bit 3 RGB and BGR changed.
/* Color mode 16bits/pixel */
LCD_IO_WriteReg(ILI9341_COLOR_MODE);
LCD_IO_WriteData(0x55);
/* Set Column address CASET */
LCD_IO_WriteReg(ILI9341_CASET);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x01);
LCD_IO_WriteData(0x3F);
/* Set Row address RASET */
LCD_IO_WriteReg(ILI9341_RASET);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0xEF);
/* VCOM setting */
LCD_IO_WriteReg(ILI9341_VCOM_CTRL1);
LCD_IO_WriteData(0x3E);
LCD_IO_WriteData(0x28);
LCD_IO_WriteReg(ILI9341_VCOM_CTRL2);
LCD_IO_WriteData(0x86);
/* Frame Rate Control in normal mode */
LCD_IO_WriteReg(ILI9341_FR_CTRL);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x18);
/* Power Control */
LCD_IO_WriteReg(ILI9341_POWER_CTRL1);
LCD_IO_WriteData(0x23);
LCD_IO_WriteReg(ILI9341_POWER_CTRL2);
LCD_IO_WriteData(0x10);
/* Sleep Out Command */
LCD_IO_WriteReg(ILI9341_SLEEP_OUT);
/* Wait for 120ms */
LCD_Delay(120);
/* Display ON command */
ILI9341_DisplayOn();
}
void ILI9341_DisplayOn(void) {
/* Display ON command */
LCD_IO_WriteReg(ILI9341_DISPLAY_ON);
/* Sleep Out command */
LCD_IO_WriteReg(ILI9341_SLEEP_OUT);
}
void ILI9341_WriteRam(void) {
LCD_IO_WriteReg(ILI9341_WRITE_RAM);
}
void ILI9341_SetCursor(uint16_t Xpos, uint16_t Ypos) {
/* CASET: Comumn Addrses Set */
LCD_IO_WriteReg(ILI9341_CASET);
LCD_IO_WriteData((Xpos >> 8) & 0xFF);
LCD_IO_WriteData(Xpos & 0xFF);
LCD_IO_WriteData(0x01);
LCD_IO_WriteData(0x3F);
/* RASET: Row Addrses Set */
LCD_IO_WriteReg(ILI9341_RASET);
LCD_IO_WriteData((Ypos >> 8) & 0xFF);
LCD_IO_WriteData(Ypos & 0xFF);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0xEF);
LCD_IO_WriteReg(ILI9341_WRITE_RAM);
}
void ILI9341_SetWindow(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
/* CASET: Comumn Addrses Set */
LCD_IO_WriteReg(ILI9341_CASET);
LCD_IO_WriteData((Xmin >> 8) & 0xFF);
LCD_IO_WriteData(Xmin & 0xFF);
LCD_IO_WriteData((Xmax >> 8) & 0xFF);
LCD_IO_WriteData(Xmax & 0xFF);
/* RASET: Row Addrses Set */
LCD_IO_WriteReg(ILI9341_RASET);
LCD_IO_WriteData((Ymin >> 8) & 0xFF);
LCD_IO_WriteData(Ymin & 0xFF);
LCD_IO_WriteData((Ymax >> 8) & 0xFF);
LCD_IO_WriteData(Ymax & 0xFF);
LCD_IO_WriteReg(ILI9341_WRITE_RAM);
}
#endif // LGT_LCD_TFT
| 2,843
|
C++
|
.cpp
| 92
| 28
| 84
| 0.696226
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,869
|
st7789v.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lcddrive/st7789v.cpp
|
#include "lcdio.h"
#if ENABLED(LGT_LCD_TFT)
#include "st7789v.h"
void ST7789V_Init(void) {
// TOUCH_LCD_IO_Init();
/* Sleep In Command */
LCD_IO_WriteReg(ST7789V_SLEEP_IN);
/* Wait for 10ms */
LCD_Delay(10);
/* SW Reset Command */
LCD_IO_WriteReg(ST7789V_SWRESET);
/* Wait for 200ms */
LCD_Delay(200);
/* Sleep Out Command */
LCD_IO_WriteReg(ST7789V_SLEEP_OUT);
/* Wait for 120ms */
LCD_Delay(120);
/* Normal display for Driver Down side */
LCD_IO_WriteReg(ST7789V_NORMAL_DISPLAY);
LCD_IO_WriteData(0xA0);
//LCD_IO_WriteData(0xA0);
/* Color mode 16bits/pixel */
LCD_IO_WriteReg(ST7789V_COLOR_MODE);
LCD_IO_WriteData(0x55);
/* Set Column address CASET */
LCD_IO_WriteReg(ST7789V_CASET);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x01);
LCD_IO_WriteData(0x3F);
/* Set Row address RASET */
LCD_IO_WriteReg(ST7789V_RASET);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0xEF);
/* PORCH control setting */
LCD_IO_WriteReg(ST7789V_PORCH_CTRL);
LCD_IO_WriteData(0x0C);
LCD_IO_WriteData(0x0C);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0x33);
LCD_IO_WriteData(0x33);
/* GATE control setting */
LCD_IO_WriteReg(ST7789V_GATE_CTRL);
LCD_IO_WriteData(0x35);
/* VCOM setting */
LCD_IO_WriteReg(ST7789V_VCOM_SET);
LCD_IO_WriteData(0x1F);
/* LCM Control setting */
LCD_IO_WriteReg(ST7789V_LCM_CTRL);
LCD_IO_WriteData(0x2C);
/* VDV and VRH Command Enable */
LCD_IO_WriteReg(ST7789V_VDV_VRH_EN);
LCD_IO_WriteData(0x01);
LCD_IO_WriteData(0xC3);
/* VDV Set */
LCD_IO_WriteReg(ST7789V_VDV_SET);
LCD_IO_WriteData(0x20);
/* Frame Rate Control in normal mode */
LCD_IO_WriteReg(ST7789V_FR_CTRL);
LCD_IO_WriteData(0x0F);
/* Power Control */
LCD_IO_WriteReg(ST7789V_POWER_CTRL);
//Values to be spyed on the LA.
//LCD_IO_WriteData(0xA4);
//LCD_IO_WriteData(0xA1);
/* Display ON command */
ST7789V_DisplayOn();
}
void ST7789V_DisplayOn(void) {
/* Display ON command */
LCD_IO_WriteReg(ST7789V_DISPLAY_ON);
/* Sleep Out command */
LCD_IO_WriteReg(ST7789V_SLEEP_OUT);
}
void ST7789V_WriteRam() {
LCD_IO_WriteReg(ST7789V_WRITE_RAM);
}
void ST7789V_SetCursor(uint16_t Xpos, uint16_t Ypos) {
/* CASET: Comumn Addrses Set */
LCD_IO_WriteReg(ST7789V_CASET);
LCD_IO_WriteData((Xpos >> 8) & 0xFF);
LCD_IO_WriteData(Xpos & 0xFF);
LCD_IO_WriteData(0x01);
LCD_IO_WriteData(0x3F);
/* RASET: Row Addrses Set */
LCD_IO_WriteReg(ST7789V_RASET);
LCD_IO_WriteData((Ypos >> 8) & 0xFF);
LCD_IO_WriteData(Ypos & 0xFF);
LCD_IO_WriteData(0x00);
LCD_IO_WriteData(0xEF);
LCD_IO_WriteReg(ST7789V_WRITE_RAM);
}
void ST7789V_SetWindow(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
/* CASET: Comumn Addrses Set */
LCD_IO_WriteReg(ST7789V_CASET);
LCD_IO_WriteData((Xmin >> 8) & 0xFF);
LCD_IO_WriteData(Xmin & 0xFF);
LCD_IO_WriteData((Xmax >> 8) & 0xFF);
LCD_IO_WriteData(Xmax & 0xFF);
/* RASET: Row Addrses Set */
LCD_IO_WriteReg(ST7789V_RASET);
LCD_IO_WriteData((Ymin >> 8) & 0xFF);
LCD_IO_WriteData(Ymin & 0xFF);
LCD_IO_WriteData((Ymax >> 8) & 0xFF);
LCD_IO_WriteData(Ymax & 0xFF);
LCD_IO_WriteReg(ST7789V_WRITE_RAM);
}
#endif
| 3,272
|
C++
|
.cpp
| 110
| 26.763636
| 84
| 0.694001
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,870
|
lgtdwlcd.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/lcd/lgtdwlcd.cpp
|
#include "lgtdwlcd.h"
#if ENABLED(LGT_LCD_DW)
#include "lgtdwdef.h"
#include "../module/temperature.h"
#include "../sd/cardreader.h"
#include "../module/motion.h"
#include "../module/planner.h"
#include "../module/printcounter.h"
#include "../feature/runout.h"
#include "../feature/powerloss.h"
// debug define
// #define DEBUG_LGTDWLCD
#define DEBUG_OUT ENABLED(DEBUG_LGTDWLCD)
#include "../core/debug_out.h"
LGT_SCR_DW lgtLcdDw;
static int ii_setup = 0;
DATA Rec_Data;
DATA Send_Data;
duration_t Duration_Time;
unsigned char data_storage[DATA_SIZE];
char total_time[7]; //Total print time for each model
uint32_t total_print_time = 0;
char printer_work_time[31]; //Total work time of printers
int gcode_id[FILE_LIST_NUM], sel_fileid =-1;
int gcode_num=0;
millis_t recovery_time=0;
uint8_t recovery_percent = 0;
float level_z_height = 0.0;
float recovery_z_height = 0.0,recovery_E_len=0.0;
float resume_x_position=0.0,resume_y_position=0.0,resume_e_position= 0.0, resume_feedrate = 0.0;
bool sd_init_flag = true;
bool tartemp_flag = false; // flag for target temp whether is changed
bool LGT_is_printing = false;
bool LGT_stop_printing = false;
bool return_home = false;
#ifdef LK1_PRO
bool led_on = true;
#endif // LK1_PRO
bool xy_home = false;
#if ANY(LK4_PRO, LK5_PRO)
bool xyz_home = false,z_home=false;
#endif
// bool leveling_wait = false;
int re_count = 0;
E_MENU_TYPE menu_type= eMENU_IDLE;
PRINTER_STATUS status_type= PRINTER_SETUP;
PRINTER_KILL_STATUS kill_type = PRINTER_NORMAL;
static char fila_type = 0; // 0 refer to PLA, 1 refer to ABS
// 0 no check, 1 check PLA, 2 check ABS, used for "no enough temp" dialog in fila [OK] return
char menu_fila_type_chk = 0;
// 0 for 10 mm, 1 for 1 mm, 2 for 0.1 mm, used for "no enough temp" dialog in move [OK] return
char menu_move_dis_chk = 0;
#if ENABLED(LK1_PRO)
static char menu_measu_dis_chk = 1; //step 1 to 1mm and step 2 to 0.1mm
static char menu_measu_step = 0; // 0 for not start, 1 for step 1, 2 for step 2, 3 for step 3
#endif
char cmd_E[24] = { 0 };
unsigned int filament_len = 10;
unsigned int filament_temp = 200;
bool check_recovery = false; // for recovery dialog
char leveling_sta = 0; // for leveling menu
// #define COOL_BEFORE_LEVELING // cool hot-end and bed before leveling, and restore hot-end and bed temperature after leveling.
#if ENABLED(COOL_BEFORE_LEVELING)
static int16_t old_tar_temp_end = 0, old_tar_temp_bed = 0; // for leveling menu
#endif
bool is_abort_recovery_resume = false;
bool is_recovery_resuming = false; // for recovery resume
// #define MYSERIAL1 customizedSerial2//MSerial2
static void LGT_Line_To_Current(AxisEnum axis)
{
const float manual_feedrate_mm_m[] = MANUAL_FEEDRATE;
if (!planner.is_full())
planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[(int8_t)axis]), active_extruder);
}
static inline void LGT_Total_Time_To_String(char* buf, uint32_t time)
{
uint32_t h = time / 60;
uint32_t m = time % 60;
sprintf_P(buf, PSTR("%lu h %lu m"), h, m);
}
void LGT_SCR_DW::LGT_Power_Loss_Recovery_Resume() {
// recovery_time = recovery.info.print_job_elapsed;
// recovery_percent = recovery.info.have_percentdone;
// recovery_z_height = recovery.info.current_position.z;
}
void LGT_SCR_DW::LGT_Pause_Move()
{
if (!all_axes_known() && !all_axes_homed())
return;
DEBUG_ECHOLN("pause move");
resume_x_position = current_position[X_AXIS];
resume_y_position = current_position[Y_AXIS];
resume_e_position = current_position[E_AXIS];
resume_feedrate = feedrate_mm_s;
DEBUG_ECHOLNPAIR_F("save X:", resume_x_position);
DEBUG_ECHOLNPAIR_F("save Y:", resume_y_position);
DEBUG_ECHOLNPAIR_F("save E:", resume_e_position);
DEBUG_ECHOLNPAIR_F("save feedrate", feedrate_mm_s);
current_position[E_AXIS] = current_position[E_AXIS] - 3;
planner.synchronize();
LGT_Line_To_Current(E_AXIS);
do_blocking_move_to_xy(FILAMENT_RUNOUT_MOVE_X, FILAMENT_RUNOUT_MOVE_Y, FILAMENT_RUNOUT_MOVE_F);
planner.synchronize();
DEBUG_ECHOLNPAIR("queue-length", queue.length);
}
void LGT_SCR_DW::goFinishPage()
{
status_type = PRINTER_PRINTING_F;
LGT_Change_Page(ID_DIALOG_PRINT_FINISH);
}
void LGT_SCR_DW::saveFinishTime()
{
Duration_Time = (print_job_timer.duration()) + recovery_time;
total_print_time = Duration_Time.minute()+ total_print_time;
eeprom_write_dword((uint32_t*)EEPROM_INDEX, total_print_time);
}
LGT_SCR_DW::LGT_SCR_DW()
{
memset(data_storage, 0, sizeof(data_storage));
memset(&Rec_Data,0,sizeof(Rec_Data));
memset(total_time, 0, sizeof(total_time));
memset(printer_work_time, 0, sizeof(printer_work_time));
Rec_Data.head[0] = DW_FH_0;
Rec_Data.head[1] = DW_FH_1;
Send_Data.head[0] = DW_FH_0;
Send_Data.head[1] = DW_FH_1;
_btnPauseEnabled = true;
_btnFilamentEnabled1 = true;
_btnFilamentEnabled2 = true;
}
void LGT_SCR_DW::begin()
{
MYSERIAL1.begin(115200);
delay(600);
status_type = PRINTER_SETUP;
#if ENABLED(POWER_LOSS_RECOVERY)
recovery.check();
#endif
DEBUG_PRINT_P(PSTR("dw: begin\n"));
lgtLcdDw.readScreenModel();
delay(1000); // wait for showing logo
}
void LGT_SCR_DW::LGT_LCD_startup_settings()
{
if (ii_setup < STARTUP_COUNTER)
{
if (ii_setup >= (STARTUP_COUNTER-1000))
{
tartemp_flag = true;
if (card.isMounted()) {
DEBUG_PRINT_P(PSTR("dw: sd ok"));
lgtLcdDw.LGT_Display_Filename();
}
if (check_recovery == false)
{
DEBUG_PRINT_P(PSTR("dw: go home page"));
menu_type = eMENU_HOME;
lgtLcdDw.LGT_Change_Page(ID_MENU_HOME);
}
else // recovery is true
{
DEBUG_PRINT_P(PSTR("dw: go recovery"));
return_home = true;
check_recovery = false;
ENABLE_AXIS_Z();
lgtLcdDw.LGT_Change_Page(ID_DIALOG_PRINT_RECOVERY);
}
lgtLcdDw.LGT_Printer_Data_Updata();
lgtLcdDw.LGT_DW_Setup(); //about machine
ii_setup = STARTUP_COUNTER;
}
ii_setup++;
}
if (LGT_stop_printing == true)
{
LGT_stop_printing = false;
lgtLcdDw.LGT_Stop_Printing();
}
}
void LGT_SCR_DW::LGT_Main_Function()
{
static millis_t Next_Temp_Time = 0;
LGT_Get_MYSERIAL1_Cmd();
if (millis() >= Next_Temp_Time)
{
Next_Temp_Time += 2000;
if (tartemp_flag == true) //M104/M109/M190/140
{
tartemp_flag = false;
if(LGT_is_printing==false)
status_type = PRINTER_HEAT;
LGT_Send_Data_To_Screen(ADDR_VAL_TAR_E, thermalManager.degTargetHotend(0));
LGT_Send_Data_To_Screen(ADDR_VAL_TAR_B, thermalManager.degTargetBed());
}
LGT_Printer_Data_Updata();
LGT_Get_MYSERIAL1_Cmd();
}
#ifdef LK1_PRO
if (led_on == true)
LGT_Printer_Light_Update();
#endif // LK1_PRO
LGT_SDCard_Status_Update();
}
/*************************************
FUNCTION: Getting and saving commands of MYSERIAL1(DWIN_Screen)
**************************************/
void LGT_SCR_DW::LGT_Get_MYSERIAL1_Cmd()
{
memset(data_storage, 0, sizeof(data_storage));
while (re_count<DATA_SIZE &&MYSERIAL1.available() > 0)
{
data_storage[re_count] = MYSERIAL1.read();
if (data_storage[0] != DW_FH_0)
{
continue;
}
delay(5);
re_count++;
}
if (re_count < 1) //null
return;
else if (re_count >= 2 && (Rec_Data.head[0] == data_storage[0]) && (Rec_Data.head[1] == data_storage[1]))
{
// MYSERIAL0.print((char *)data_storage); // debug
Rec_Data.cmd = data_storage[3];
if (Rec_Data.cmd == DW_CMD_VAR_R)
{
Rec_Data.addr = data_storage[4];
Rec_Data.addr = (Rec_Data.addr << 8) | data_storage[5];
Rec_Data.datalen = data_storage[6];
for (unsigned int i = 0; i < Rec_Data.datalen; i = i + 2)
{
Rec_Data.data[i / 2] = data_storage[7 + i];
Rec_Data.data[i / 2] = (Rec_Data.data[i / 2] << 8) | data_storage[8 + i];
}
LGT_Analysis_DWIN_Screen_Cmd();
re_count = 0;
memset(data_storage, 0, sizeof(data_storage));
memset(&Rec_Data,0,sizeof(Rec_Data));
Rec_Data.head[0] = DW_FH_0;
Rec_Data.head[1] = DW_FH_1;
}
else
{
re_count = 0;
memset(data_storage, 0, sizeof(data_storage));
}
}
else
{
re_count = 0;
memset(data_storage, 0, sizeof(data_storage));
}
}
void LGT_SCR_DW::LGT_Change_Page(unsigned int pageid)
{
memset(data_storage, 0, sizeof(data_storage));
data_storage[0] = DW_FH_0;
data_storage[1] = DW_FH_1;
if (hasDwScreen()) {
data_storage[2] = 0x07;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = 0x00;
data_storage[5] = 0x84;
data_storage[6] = 0x5A;
data_storage[7] = 0x01;
data_storage[8] = (unsigned char)(pageid >> 8) & 0xFF;
data_storage[9] = (unsigned char)(pageid & 0x00FF);
for (int i = 0; i < 10; i++)
MYSERIAL1.write(data_storage[i]);
} else if (hasJxScreen()) {
data_storage[2] = 0x04;
data_storage[3] = JX_CMD_REG_W;
data_storage[4] = JX_ADDR_REG_PAGE;
data_storage[5] = (unsigned char)(pageid >> 8) & 0xFF;
data_storage[6] = (unsigned char)(pageid & 0x00FF);
for (int i = 0; i < 7; i++)
MYSERIAL1.write(data_storage[i]);
}
}
void LGT_SCR_DW::LGT_Send_Data_To_Screen(uint16_t Addr, int16_t Num)
{
memset(data_storage, 0, sizeof(data_storage));
data_storage[0] = Send_Data.head[0];
data_storage[1] = Send_Data.head[1];
data_storage[2] = 0x05;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = (unsigned char)(Addr>> 8); //(Num >> 8) & 0xFF
data_storage[5] = (unsigned char)(Addr & 0x00FF);
data_storage[6] = (unsigned char)(Num >> 8);
data_storage[7] = (unsigned char)(Num & 0x00FF);
for (int i = 0; i < 8; i++)
{
MYSERIAL1.write(data_storage[i]);
delayMicroseconds(1);
}
}
void LGT_SCR_DW::LGT_Send_Data_To_Screen(unsigned int addr, char* buf)
{
memset(data_storage, 0, sizeof(data_storage));
int len = strlen(buf);
data_storage[0] = Send_Data.head[0];
data_storage[1] = Send_Data.head[1];
data_storage[2] = (unsigned char)(3 + len + 2)/* 0x0A */;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = (unsigned char)(addr >> 8);
data_storage[5] = (unsigned char)(addr & 0x00FF);
for (int i = 0; i < len /* 7 */; i++)
{
data_storage[6 + i] = buf[i];
}
data_storage[6 + len] = 0xFF;
data_storage[6+ len + 1] = 0xFF;
for (int i = 0; i < 6 + len + 2/* 13 */; i++)
{
MYSERIAL1.write(data_storage[i]);
delayMicroseconds(1);
}
}
void LGT_SCR_DW::LGT_Send_Data_To_Screen1(unsigned int addr,const char* buf)
{
memset(data_storage, 0, sizeof(data_storage));
int len = strlen(buf);
data_storage[0] = Send_Data.head[0];
data_storage[1] = Send_Data.head[1];
data_storage[2] = (unsigned char)(3+ len + 2)/* 0x22 */;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = (unsigned char)(addr >> 8);
data_storage[5] = (unsigned char)(addr & 0x00FF);
for (int i = 0; i < len/* 31 */; i++)
{
data_storage[6 + i] = buf[i];
}
data_storage[6 + len] = 0xFF;
data_storage[6+ len + 1] = 0xFF;
for (int i = 0; i < 6 + len + 2/* 37 */; i++)
{
MYSERIAL1.write(data_storage[i]);
delayMicroseconds(1);
}
}
void LGT_SCR_DW::LGT_Printer_Data_Updata()
{
uint8_t progress_percent = 0;
uint16_t LGT_feedrate = 0;
switch (menu_type)
{
case eMENU_HOME:
case eMENU_UTILI_FILA:
case eMENU_HOME_FILA:
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_E, (int16_t)thermalManager.degHotend(eExtruder::E0));
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_B, (int16_t)thermalManager.degBed());
// DEBUG_PRINT_P("home temp. update");
break;
case eMENU_TUNE:
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_E, (int16_t)thermalManager.degHotend(0));
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_B, (int16_t)thermalManager.degBed());
LGT_Get_MYSERIAL1_Cmd();
LGT_Send_Data_To_Screen(ADDR_VAL_FAN,thermalManager.scaledFanSpeed(0));
LGT_Send_Data_To_Screen(ADDR_VAL_FEED,feedrate_percentage);
LGT_Send_Data_To_Screen(ADDR_VAL_FLOW,planner.flow_percentage[0]);
break;
case eMENU_MOVE:
LGT_Send_Data_To_Screen(ADDR_VAL_MOVE_POS_X, (int16_t)(current_position[X_AXIS] * 10));
LGT_Send_Data_To_Screen(ADDR_VAL_MOVE_POS_Y, (int16_t)(current_position[Y_AXIS] * 10));
LGT_Send_Data_To_Screen(ADDR_VAL_MOVE_POS_Z, (int16_t)(current_position[Z_AXIS] * 10));
LGT_Send_Data_To_Screen(ADDR_VAL_MOVE_POS_E, (int16_t)(current_position[E_AXIS] * 10));
break;
case eMENU_TUNE_E:
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_E, (int16_t)thermalManager.degHotend(eExtruder::E0));
break;
case eMENU_TUNE_B:
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_B, (int16_t)thermalManager.degBed());
break;
case eMENU_TUNE_FAN:
LGT_Send_Data_To_Screen(ADDR_VAL_FAN, thermalManager.fan_speed[eFan::FAN0]);
break;
case eMENU_TUNE_SPEED:
LGT_Send_Data_To_Screen(ADDR_VAL_FEED,feedrate_percentage);
LGT_feedrate = (uint16_t)(MMS_SCALED(feedrate_mm_s) * 10);
if (LGT_feedrate > 3000)
LGT_feedrate = 3000;
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_FEED, LGT_feedrate);
break;
case eMENU_TUNE_FLOW:
LGT_Send_Data_To_Screen(ADDR_VAL_FLOW,planner.flow_percentage[eExtruder::E0]);
break;
case eMENU_PRINT_HOME:
if (card.sdprinting_done_state)
break;
progress_percent = card.percentDone();
if(progress_percent>0)
LGT_Send_Data_To_Screen(ADDR_VAL_HOME_PROGRESS, (uint16_t)progress_percent);
else
LGT_Send_Data_To_Screen(ADDR_VAL_HOME_PROGRESS, (uint16_t)recovery_percent);
Duration_Time = (print_job_timer.duration()) + recovery_time;
Duration_Time.toDigital(total_time);
LGT_Send_Data_To_Screen(ADDR_TXT_HOME_ELAP_TIME,total_time);
//delay(10);
LGT_Send_Data_To_Screen(ADDR_VAL_HOME_Z_HEIGHT, (int16_t)((current_position[Z_AXIS] + recovery_z_height) * 10)); //Current Z height
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_E, (int16_t)thermalManager.degHotend(eExtruder::E0));
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_B, (int16_t)thermalManager.degBed());
break;
default:
break;
}
}
void LGT_SCR_DW::LGT_DW_Setup()
{
#if 1
if (eeprom_read_byte((const uint8_t*)(EEPROM_INDEX + 5)) != 0)
{
eeprom_write_dword((uint32_t*)EEPROM_INDEX, 0);
eeprom_write_byte((uint8_t *)(EEPROM_INDEX + 5), 0);
}
total_print_time = eeprom_read_dword((const uint32_t*)EEPROM_INDEX);
#endif
LGT_Send_Data_To_Screen1(ADDR_TXT_ABOUT_MODEL, MAC_MODEL);
LGT_Send_Data_To_Screen1(ADDR_TXT_ABOUT_SIZE, MAC_SIZE);
LGT_Send_Data_To_Screen1(ADDR_TXT_ABOUT_FW_BOARD, BOARD_FW_VER);
}
/*************************************
FUNCTION: Analysising the commands of DWIN_Screen
**************************************/
void LGT_SCR_DW::LGT_Analysis_DWIN_Screen_Cmd()
{
DEBUG_ECHOPAIR("ADDR: ", Rec_Data.addr);
DEBUG_ECHOPAIR(" VALUE:", Rec_Data.data[0]);
uint16_t LGT_feedrate = 0;
switch (Rec_Data.addr) {
case ADDR_VAL_PRINT_FILE_SELECT: //Selecting gocede file and displaying on screen
if (int(Rec_Data.data[0]) < gcode_num && int(Rec_Data.data[0]) != sel_fileid) // scope verificaion
{
DEHILIGHT_FILE_NAME();
sel_fileid = Rec_Data.data[0];
LGT_MAC_Send_Filename(ADDR_TXT_PRINT_FILE_SELECT, gcode_id[sel_fileid]);
HILIGHT_FILE_NAME();
}
break;
case ADDR_VAL_TAR_E:
thermalManager.setTargetHotend(Rec_Data.data[0], eExtruder::E0);
break;
case ADDR_VAL_TAR_B:
thermalManager.setTargetBed(Rec_Data.data[0]);
break;
case ADDR_VAL_UTILI_FILA_CHANGE_LEN:
filament_len = Rec_Data.data[0];
break;
case ADDR_VAL_FILA_CHANGE_TEMP:
filament_temp = Rec_Data.data[0];
break;
case ADDR_TXT_ABOUT_MAC_TIME:
total_print_time = eeprom_read_dword((const uint32_t*)EEPROM_INDEX);
LGT_Total_Time_To_String(printer_work_time, total_print_time);
LGT_Send_Data_To_Screen1(ADDR_TXT_ABOUT_WORK_TIME_MAC, printer_work_time);
break;
case ADDR_VAL_BUTTON_KEY:
processButton();
break;
case ADDR_VAL_FAN:
thermalManager.set_fan_speed(eFan::FAN0, Rec_Data.data[0]);
break;
case ADDR_VAL_FEED:
feedrate_percentage = Rec_Data.data[0];
LGT_feedrate = (uint16_t)(MMS_SCALED(feedrate_mm_s) * 10);
if (LGT_feedrate > 3000)
LGT_feedrate = 3000;
LGT_Send_Data_To_Screen(ADDR_VAL_CUR_FEED,LGT_feedrate);
break;
case ADDR_VAL_FLOW:
planner.flow_percentage[eExtruder::E0] = Rec_Data.data[0];
break;
case ADDR_VAL_MENU_TYPE:
menu_type = (E_MENU_TYPE)(Rec_Data.data[0]);
LGT_Printer_Data_Updata();
// write in page handle
if (menu_type == eMENU_UTILI_FILA || menu_type == eMENU_HOME_FILA)
menu_fila_type_chk = 0; // clear variable
else if (menu_type == eMENU_MOVE)
menu_move_dis_chk = 0; // clear variable
break;
default:
break;
}
}
int LGT_SCR_DW::LGT_Get_Extrude_Temp()
{
if (fila_type == 0)
{
return (PLA_E_TEMP - 5);
}
else
return (ABS_E_TEMP - 5);
}
void LGT_SCR_DW::processButton()
{
#if 1
switch ((E_BUTTON_KEY)Rec_Data.data[0]) {
case eBT_MOVE_X_PLUS_0:
if (planner.is_full())
break;
if (current_position[X_AXIS] < X_MAX_POS) {
current_position[X_AXIS] = current_position[X_AXIS] + 10;
if (current_position[X_AXIS] > X_MAX_POS)
current_position[X_AXIS] = X_MAX_POS;
LGT_Line_To_Current(X_AXIS);
}
break;
case eBT_MOVE_X_MINUS_0:
if (planner.is_full())
break;
current_position[X_AXIS] = current_position[X_AXIS] - 10;
#ifdef LK1_PRO
if (xy_home == true)
#else //LK4_PRO or LK5 PRO
if (xyz_home == true || xy_home == true)
#endif
{
if (current_position[X_AXIS] < X_MIN_POS)
current_position[X_AXIS] = X_MIN_POS;
}
LGT_Line_To_Current(X_AXIS);
break;
case eBT_MOVE_X_PLUS_1:
if (planner.is_full())
break;
if (current_position[X_AXIS] < X_MAX_POS) {
current_position[X_AXIS] = current_position[X_AXIS] + 1;
if (current_position[X_AXIS] > X_MAX_POS)
current_position[X_AXIS] = X_MAX_POS;
LGT_Line_To_Current(X_AXIS);
}
break;
case eBT_MOVE_X_MINUS_1:
if (planner.is_full())
break;
current_position[X_AXIS] = current_position[X_AXIS] - 1;
#ifdef LK1_PRO
if (xy_home == true)
#else ////LK4_PRO or LK5 PRO
if (xyz_home == true || xy_home == true)
#endif
{
if (current_position[X_AXIS] < X_MIN_POS)
current_position[X_AXIS] = X_MIN_POS;
}
LGT_Line_To_Current(X_AXIS);
break;
case eBT_MOVE_X_PLUS_2:
if (planner.is_full())
break;
if (current_position[X_AXIS] < X_MAX_POS) {
current_position[X_AXIS] = current_position[X_AXIS] + 0.1;
if (current_position[X_AXIS] > X_MAX_POS)
current_position[X_AXIS] = X_MAX_POS;
LGT_Line_To_Current(X_AXIS);
}
break;
case eBT_MOVE_X_MINUS_2:
if (planner.is_full())
break;
current_position[X_AXIS] = current_position[X_AXIS] - 0.1;
#ifdef LK1_PRO
if (xy_home == true)
#else //LK4_PRO//LK4_PRO or LK5 PRO
if (xyz_home == true || xy_home == true)
#endif
{
if (current_position[X_AXIS] < X_MIN_POS)
current_position[X_AXIS] = X_MIN_POS;
}
LGT_Line_To_Current(X_AXIS);
break;
//Y Axis
case eBT_MOVE_Y_PLUS_0:
if (planner.is_full())
break;
if (current_position[Y_AXIS] < Y_MAX_POS) {
current_position[Y_AXIS] = current_position[Y_AXIS] + 10;
if (current_position[Y_AXIS] > Y_MAX_POS)
current_position[Y_AXIS] = Y_MAX_POS;
LGT_Line_To_Current(Y_AXIS);
}
break;
case eBT_MOVE_Y_MINUS_0:
if (planner.is_full())
break;
current_position[Y_AXIS] = current_position[Y_AXIS] - 10;
#ifdef LK1_PRO
if (xy_home == true)
#else ////LK4_PRO or LK5 PRO
if (xyz_home == true || xy_home == true)
#endif
{
if (current_position[Y_AXIS] < Y_MIN_POS)
current_position[Y_AXIS] = Y_MIN_POS;
}
LGT_Line_To_Current(Y_AXIS);
break;
case eBT_MOVE_Y_PLUS_1:
if (planner.is_full())
break;
if (current_position[Y_AXIS] < Y_MAX_POS) {
current_position[Y_AXIS] = current_position[Y_AXIS] + 1;
if (current_position[Y_AXIS] > Y_MAX_POS)
current_position[Y_AXIS] = Y_MAX_POS;
LGT_Line_To_Current(Y_AXIS);
}
break;
case eBT_MOVE_Y_MINUS_1:
if (planner.is_full())
break;
current_position[Y_AXIS] = current_position[Y_AXIS] - 1;
#ifdef LK1_PRO
if (xy_home == true)
#else ////LK4_PRO or LK5 PRO
if (xyz_home == true || xy_home == true)
#endif
{
if (current_position[Y_AXIS] < Y_MIN_POS)
current_position[Y_AXIS] = Y_MIN_POS;
}
LGT_Line_To_Current(Y_AXIS);
break;
case eBT_MOVE_Y_PLUS_2:
if (planner.is_full())
break;
if (current_position[Y_AXIS] < Y_MAX_POS) {
current_position[Y_AXIS] = current_position[Y_AXIS] + 0.1;
if (current_position[Y_AXIS] > Y_MAX_POS)
current_position[Y_AXIS] = Y_MAX_POS;
LGT_Line_To_Current(Y_AXIS);
}
break;
case eBT_MOVE_Y_MINUS_2:
if (planner.is_full())
break;
current_position[Y_AXIS] = current_position[Y_AXIS] - 0.1;
#ifdef LK1_PRO
if (xy_home == true)
#else ////LK4_PRO or LK5 PRO
if (xyz_home == true || xy_home == true)
#endif
{
if (current_position[Y_AXIS] < Y_MIN_POS)
current_position[Y_AXIS] = Y_MIN_POS;
}
LGT_Line_To_Current(Y_AXIS);
break;
//Z Axis
case eBT_MOVE_Z_PLUS_0:
if (planner.is_full())
break;
if (current_position[Z_AXIS] < Z_MAX_POS) {
current_position[Z_AXIS] = current_position[Z_AXIS] + 10;
if (current_position[Z_AXIS] > Z_MAX_POS)
current_position[Z_AXIS] = Z_MAX_POS;
LGT_Line_To_Current(Z_AXIS);
#ifdef LK1_PRO
if (menu_type != eMENU_MOVE)
{
level_z_height = 10 + level_z_height;
LGT_Send_Data_To_Screen(ADDR_VAL_LEVEL_Z_UP_DOWN, (uint16_t)(10 * level_z_height));
}
#endif // LK1_PRO
}
break;
case eBT_MOVE_Z_MINUS_0:
if (planner.is_full())
break;
current_position[Z_AXIS] = current_position[Z_AXIS] - 10;
#if ANY(LK4_PRO, LK5_PRO)
if (xyz_home == true || z_home == true)
{
if (current_position[Z_AXIS] < Z_MIN_POS)
current_position[Z_AXIS] = Z_MIN_POS;
}
#endif // LK4_PRO, LK5_PRO
LGT_Line_To_Current(Z_AXIS);
#ifdef LK1_PRO
if (menu_type != eMENU_MOVE)
{
level_z_height = level_z_height - 10;
LGT_Send_Data_To_Screen(ADDR_VAL_LEVEL_Z_UP_DOWN, (uint16_t)(10 * level_z_height));
}
#endif // LK1_PRO
break;
case eBT_MOVE_Z_PLUS_1:
if (planner.is_full())
break;
if (current_position[Z_AXIS] < Z_MAX_POS) {
current_position[Z_AXIS] = current_position[Z_AXIS] + 1;
if (current_position[Z_AXIS] > Z_MAX_POS)
current_position[Z_AXIS] = Z_MAX_POS;
LGT_Line_To_Current(Z_AXIS);
#ifdef LK1_PRO
if (menu_type != eMENU_MOVE)
{
level_z_height = level_z_height + 1;
LGT_Send_Data_To_Screen(ADDR_VAL_LEVEL_Z_UP_DOWN, (uint16_t)(10 * level_z_height));
}
#endif // LK1_PRO
}
break;
case eBT_MOVE_Z_MINUS_1:
if (planner.is_full())
break;
current_position[Z_AXIS] = current_position[Z_AXIS] - 1;
#if ANY(LK4_PRO, LK5_PRO)
if (xyz_home == true || z_home == true)
{
if (current_position[Z_AXIS] < Z_MIN_POS)
current_position[Z_AXIS] = Z_MIN_POS;
}
#endif // LK4_PRO, LK5_PRO
LGT_Line_To_Current(Z_AXIS);
#ifdef LK1_PRO
if (menu_type != eMENU_MOVE)
{
level_z_height = level_z_height - 1;
LGT_Send_Data_To_Screen(ADDR_VAL_LEVEL_Z_UP_DOWN, (uint16_t)(10 * level_z_height));
}
#endif // LK1_PRO
break;
case eBT_MOVE_Z_PLUS_2:
if (planner.is_full())
break;
if (current_position[Z_AXIS] < Z_MAX_POS) {
current_position[Z_AXIS] = current_position[Z_AXIS] + 0.1;
if (current_position[Z_AXIS] > Z_MAX_POS)
current_position[Z_AXIS] = Z_MAX_POS;
LGT_Line_To_Current(Z_AXIS);
#ifdef LK1_PRO
if (menu_type != eMENU_MOVE)
{
level_z_height = level_z_height + 0.1;
LGT_Send_Data_To_Screen(ADDR_VAL_LEVEL_Z_UP_DOWN, (uint16_t)(10 * level_z_height));
}
#endif // LK1_PRO
}
break;
case eBT_MOVE_Z_MINUS_2:
if (planner.is_full())
break;
current_position[Z_AXIS] = current_position[Z_AXIS] - 0.1;
#if ANY(LK4_PRO, LK5_PRO)
if (xyz_home == true || z_home == true)
{
if (current_position[Z_AXIS] < Z_MIN_POS)
current_position[Z_AXIS] = Z_MIN_POS;
}
#endif // LK4_PRO, LK5_PRO
LGT_Line_To_Current(Z_AXIS);
#ifdef LK1_PRO
if (menu_type != eMENU_MOVE)
{
level_z_height = level_z_height - 0.1;
LGT_Send_Data_To_Screen(ADDR_VAL_LEVEL_Z_UP_DOWN, (uint16_t)(10 * level_z_height));
}
#endif // LK1_PRO
break;
//E Axis
case eBT_MOVE_E_PLUS_0:
if (planner.is_full())
break;
if (thermalManager.degHotend(eExtruder::E0) >= LGT_Get_Extrude_Temp())
{
current_position[E_AXIS] = current_position[E_AXIS]+10;
LGT_Line_To_Current(E_AXIS);
}
else
{
menu_move_dis_chk = 0;
LGT_Send_Data_To_Screen(ADDR_VAL_EXTRUDE_TEMP, LGT_Get_Extrude_Temp());
LGT_Change_Page(ID_DIALOG_MOVE_NO_TEMP);
}
break;
case eBT_MOVE_E_MINUS_0:
if (planner.is_full())
break;
if (thermalManager.degHotend(eExtruder::E0) >= LGT_Get_Extrude_Temp())
{
current_position[E_AXIS] = current_position[E_AXIS]-10;
LGT_Line_To_Current(E_AXIS);
}
else
{
menu_move_dis_chk = 0;
LGT_Send_Data_To_Screen(ADDR_VAL_EXTRUDE_TEMP, LGT_Get_Extrude_Temp());
LGT_Change_Page(ID_DIALOG_MOVE_NO_TEMP);
}
break;
case eBT_MOVE_E_PLUS_1:
if (planner.is_full())
break;
if (thermalManager.degHotend(eExtruder::E0) >= LGT_Get_Extrude_Temp())
{
current_position[E_AXIS] = current_position[E_AXIS]+1;
LGT_Line_To_Current(E_AXIS);
}
else
{
menu_move_dis_chk = 1;
LGT_Send_Data_To_Screen(ADDR_VAL_EXTRUDE_TEMP, LGT_Get_Extrude_Temp());
LGT_Change_Page(ID_DIALOG_MOVE_NO_TEMP);
}
break;
case eBT_MOVE_E_MINUS_1:
if (planner.is_full())
break;
if (thermalManager.degHotend(eExtruder::E0) >= LGT_Get_Extrude_Temp())
{
current_position[E_AXIS] = current_position[E_AXIS]-1;
LGT_Line_To_Current(E_AXIS);
}
else
{
menu_move_dis_chk = 1;
LGT_Send_Data_To_Screen(ADDR_VAL_EXTRUDE_TEMP, LGT_Get_Extrude_Temp());
LGT_Change_Page(ID_DIALOG_MOVE_NO_TEMP);
}
break;
case eBT_MOVE_E_PLUS_2:
if (planner.is_full())
break;
if (thermalManager.degHotend(eExtruder::E0) >= LGT_Get_Extrude_Temp())
{
current_position[E_AXIS] = current_position[E_AXIS]+0.1;
LGT_Line_To_Current(E_AXIS);
}
else
{
menu_move_dis_chk = 2;
LGT_Send_Data_To_Screen(ADDR_VAL_EXTRUDE_TEMP, LGT_Get_Extrude_Temp());
LGT_Change_Page(ID_DIALOG_MOVE_NO_TEMP);
}
break;
case eBT_MOVE_E_MINUS_2:
if (planner.is_full())
break;
if (thermalManager.degHotend(eExtruder::E0) >= LGT_Get_Extrude_Temp())
{
current_position[E_AXIS] = current_position[E_AXIS]-0.1;
LGT_Line_To_Current(E_AXIS);
}
else
{
menu_move_dis_chk = 2;
LGT_Send_Data_To_Screen(ADDR_VAL_EXTRUDE_TEMP, LGT_Get_Extrude_Temp());
LGT_Change_Page(ID_DIALOG_MOVE_NO_TEMP);
}
break;
//Axis Homing
case eBT_MOVE_XY_HOME:
LGT_Change_Page(ID_DIALOG_MOVE_WAIT);
delay(5);
queue.enqueue_now_P(PSTR("G28 X0 Y0\nM2008"));
xy_home = true;
break;
case eBT_MOVE_Z_HOME:
LGT_Change_Page(ID_DIALOG_MOVE_WAIT);
delay(5);
#ifdef LK1_PRO
queue.enqueue_now_P(PSTR("G28"));
xy_home = true;
#else // ANY(LK4_PRO, LK5_PRO)
queue.enqueue_now_P(PSTR("G28 Z0\nM2008"));
z_home = true;
#endif
break;
case eBT_DIAL_MOVE_NO_TEMP_RET: // ok button
if (menu_move_dis_chk == 0)
LGT_Change_Page(ID_MENU_MOVE_0);
else // equal to 1 or 2
LGT_Change_Page(ID_MENU_MOVE_1 - 1 + menu_move_dis_chk);
break;
case eBT_DIAL_FILA_NO_TEMP_RET:
if (menu_type == eMENU_UTILI_FILA) {
LGT_Change_Page(ID_MENU_UTILI_FILA_0 + menu_fila_type_chk);
}
else { // menu_type == eMENU_HOME_FILA
LGT_Change_Page(ID_MENU_HOME_FILA_0 + menu_fila_type_chk);
}
break;
case eBT_MOVE_DISABLE:
queue.clear();
quickstop_stepper();
break;
case eBT_MOVE_ENABLE:
enable_all_steppers();
break;
case eBT_MOVE_P0:
menu_move_dis_chk = 0;
break;
case eBT_MOVE_P1:
menu_move_dis_chk = 1;
break;
case eBT_MOVE_P2:
menu_move_dis_chk = 2;
break;
// ----- file menu -----
case eBT_PRINT_FILE_OPEN:
if (sel_fileid >-1)
{
uint8_t i = sel_fileid / 5;
if (i == 0)
LGT_Change_Page(ID_DIALOG_PRINT_START_0);
else
{
LGT_Change_Page(ID_DIALOG_PRINT_START_1 - 1 + i);
}
}
break;
case eBT_PRINT_FILE_OPEN_YES:
if (sel_fileid > -1)
{
// get filename
card.getfilename_sorted(gcode_id[sel_fileid]);
card.openAndPrintFile(card.filename);
LGT_MAC_Send_Filename(ADDR_TXT_HOME_FILE_NAME, gcode_id[sel_fileid]);
delay(5);
// prepare home data, then jumpt to home page
menu_type = eMENU_PRINT_HOME;
LGT_Printer_Data_Updata();
status_type = PRINTER_PRINTING;
LGT_is_printing = true;
LGT_Send_Data_To_Screen(ADDR_VAL_ICON_HIDE, int16_t(0));
// idle();
fila_type = 0; //PLA
LGT_Change_Page(ID_MENU_PRINT_HOME);
// save filename to the flash of touch screen
LGT_Save_Recovery_Filename(DW_CMD_VAR_W, DW_FH_1, ADDR_TXT_HOME_FILE_NAME,32);
// set unhomed for prevent from some potential issues(resume after begining runout)
set_all_unhomed();
set_all_unknown();
// filament runout handling
if (READ(FIL_RUNOUT_PIN) == FIL_RUNOUT_INVERTING) {
if(READ(FIL_RUNOUT_PIN) == FIL_RUNOUT_INVERTING) {
queue.enqueue_one_P(PSTR("M25"));
lgtLcdDw.LGT_Change_Page(ID_DIALOG_NO_FILA);
status_type = PRINTER_PAUSE;
}
}
}
break;
case eBT_PRINT_FILE_CLEAN: //Cleaning sel_fileid
if (sel_fileid > -1)
{
DEHILIGHT_FILE_NAME();
sel_fileid = -1;
LGT_Clean_DW_Display_Data(ADDR_TXT_PRINT_FILE_SELECT); //Cleaning sel_file txt
LGT_Clean_DW_Display_Data(ADDR_TXT_HOME_ELAP_TIME); //Cleaning time
}
menu_type = eMENU_FILE;
break;
// ----- print home menu -----
case eBT_PRINT_HOME_PAUSE:
if (_btnPauseEnabled) {
DEBUG_ECHOLN("pause");
LGT_Change_Page(ID_DIALOG_PRINT_WAIT);
status_type = PRINTER_PAUSE;
LGT_is_printing = false;
card.pauseSDPrint();
print_job_timer.pause();
queue.inject_P(PSTR("M2001"));
}
break;
case eBT_PRINT_HOME_RESUME:
DEBUG_ECHOLN("resume");
LGT_Change_Page(ID_DIALOG_PRINT_WAIT);
if (all_axes_known() || all_axes_homed()) {
// go to original posion
do_blocking_move_to_xy(resume_x_position,resume_y_position,50);
planner.synchronize(); // wait move done
DEBUG_ECHOLNPAIR_F("cur feedrate", feedrate_mm_s);
feedrate_mm_s = resume_feedrate;
// planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = (resume_e_position - 2))); resume in LGT_Change_Filament()
}
LGT_Change_Page(ID_MENU_PRINT_HOME);
card.startFileprint();
print_job_timer.start();
runout.reset();
menu_type = eMENU_PRINT_HOME;
status_type = PRINTER_PRINTING;
LGT_is_printing = true; // need test
break;
case eBT_PRINT_HOME_ABORT:
DEBUG_ECHOLNPGM("abort");
LGT_Change_Page(ID_DIALOG_PRINT_WAIT);
wait_for_heatup = false;
LGT_stop_printing = true;
LGT_is_printing = false;
// abort recovery resume if in recovery resuming
if (is_recovery_resuming) {
is_abort_recovery_resume = true;
}
saveFinishTime();
LGT_Exit_Print_Page();
break;
case eBT_PRINT_HOME_FINISH:
runout.reset();
LGT_Change_Page(ID_MENU_HOME);
LGT_Exit_Print_Page();
LGT_is_printing = false;
break;
//----- filament menu -----
case eBT_UTILI_FILA_PLA:
menu_fila_type_chk = 1;
fila_type = 0;
thermalManager.setTargetHotend(PLA_E_TEMP, eExtruder::E0);
status_type = PRINTER_HEAT;
thermalManager.setTargetBed(PLA_B_TEMP);
filament_temp = PLA_E_TEMP;
LGT_Send_Data_To_Screen(ADDR_VAL_TAR_E, thermalManager.degTargetHotend(eExtruder::E0));
delayMicroseconds(1);
LGT_Send_Data_To_Screen(ADDR_VAL_TAR_B, thermalManager.degTargetBed());
LGT_Send_Data_To_Screen(ADDR_VAL_FILA_CHANGE_TEMP, thermalManager.degTargetHotend(eExtruder::E0));
break;
case eBT_UTILI_FILA_ABS:
fila_type = 1;
menu_fila_type_chk = 2;
thermalManager.setTargetHotend(ABS_E_TEMP, eExtruder::E0);
status_type = PRINTER_HEAT;
thermalManager.setTargetBed(ABS_B_TEMP);
filament_temp = ABS_E_TEMP;
LGT_Send_Data_To_Screen(ADDR_VAL_TAR_E, thermalManager.degTargetHotend(eExtruder::E0));
delayMicroseconds(1);
LGT_Send_Data_To_Screen(ADDR_VAL_TAR_B, thermalManager.degTargetBed());
LGT_Send_Data_To_Screen(ADDR_VAL_FILA_CHANGE_TEMP, thermalManager.degTargetHotend(eExtruder::E0));
break;
case eBT_UTILI_FILA_LOAD:
if (thermalManager.degHotend(eExtruder::E0) >= (filament_temp - 5))
{
if (menu_type == eMENU_HOME_FILA)
queue.inject_P(PSTR("M2004"));
else if (menu_type == eMENU_UTILI_FILA)
queue.enqueue_now_P(PSTR("M2004"));
}
else
{
memset(cmd_E, 0, sizeof(cmd_E));
if (menu_type == eMENU_UTILI_FILA) {
sprintf_P(cmd_E, PSTR("M109 S%i"), filament_temp);
LGT_Change_Page(ID_DIALOG_UTILI_FILA_WAIT);
queue.enqueue_one_now(cmd_E);
queue.enqueue_one_P(PSTR("M2004"));
} else if (menu_type == eMENU_HOME_FILA) {
sprintf_P(cmd_E, PSTR("M109 S%i\nM2004"), filament_temp);
LGT_Change_Page(ID_DIALOG_PRINT_FILA_WAIT);
queue.inject(cmd_E);
}
}
break;
case eBT_UTILI_FILA_UNLOAD:
if (thermalManager.degHotend(eExtruder::E0) >= (filament_temp - 5))
{
if (menu_type == eMENU_HOME_FILA) {
queue.inject_P(PSTR("M2005"));
DEBUG_ECHOLNPGM("inject M2005");
} else if (menu_type == eMENU_UTILI_FILA) {
queue.enqueue_now_P(PSTR("M2005"));
DEBUG_ECHOLNPGM("enqueue M2005");
}
}
else
{
memset(cmd_E, 0, sizeof(cmd_E));
if (menu_type == eMENU_UTILI_FILA) {
sprintf_P(cmd_E, PSTR("M109 S%i"), filament_temp);
LGT_Change_Page(ID_DIALOG_UTILI_FILA_WAIT);
queue.enqueue_one_now(cmd_E);
queue.enqueue_one_P(PSTR("M2005"));
DEBUG_ECHOLNPGM("enqueue M109 M2005");
} else if (menu_type == eMENU_HOME_FILA) {
sprintf_P(cmd_E, PSTR("M109 S%i\nM2005"), filament_temp);
LGT_Change_Page(ID_DIALOG_PRINT_FILA_WAIT);
queue.inject(cmd_E);
DEBUG_ECHOLNPGM("inject M109 M2005");
}
}
break;
// ----- print filament menu -----
case eBT_PRINT_FILA_HEAT_NO:
DEBUG_ECHOLNPGM("fila heating canceled");
if (menu_type == eMENU_UTILI_FILA)
queue.clear();
else if (menu_type == eMENU_HOME_FILA)
queue.clearInject();
wait_for_heatup = false;
if (menu_type == eMENU_UTILI_FILA)
{
thermalManager.disable_all_heaters();
LGT_Change_Page(ID_MENU_UTILI_FILA_0 + menu_fila_type_chk);
}
else if (menu_type == eMENU_HOME_FILA)
{
planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = (resume_e_position-2)));
LGT_Change_Page(ID_MENU_HOME_FILA_0);
}
break;
case eBT_PRINT_FILA_UNLOAD_OK:
DEBUG_ECHOLNPGM("unload ok");
if (menu_type == eMENU_UTILI_FILA)
{
LGT_Change_Page(ID_MENU_UTILI_FILA_0 + menu_fila_type_chk);
}
else if (menu_type == eMENU_HOME_FILA)
{
LGT_Change_Page(ID_MENU_HOME_FILA_0);
}
if (menu_type == eMENU_UTILI_FILA)
queue.clear();
else if (menu_type == eMENU_HOME_FILA)
queue.clearInject();
quickstop_stepper();
delay(5);
break;
case eBT_PRINT_FILA_LOAD_OK:
DEBUG_ECHOLNPGM("load ok");
if (menu_type == eMENU_UTILI_FILA)
{
LGT_Change_Page(ID_MENU_UTILI_FILA_0 + menu_fila_type_chk);
}
else if (menu_type == eMENU_HOME_FILA)
{
LGT_Change_Page(ID_DIALOG_LOAD_FINISH);
}
if (menu_type == eMENU_UTILI_FILA)
queue.clear();
else if (menu_type == eMENU_HOME_FILA)
queue.clearInject();
quickstop_stepper();
delay(5);
break;
case eBT_PRINT_FILA_CHANGE_YES:
DEBUG_ECHOLN("pause");
if(menu_type==eMENU_PRINT_HOME)
LGT_Change_Page(ID_DIALOG_PRINT_WAIT);
else if(menu_type== eMENU_TUNE)
LGT_Change_Page(ID_DIALOG_PRINT_TUNE_WAIT);
status_type = PRINTER_PAUSE;
LGT_is_printing = false;
card.pauseSDPrint();
print_job_timer.pause();
queue.inject_P(PSTR("M2006"));
break;
// ---- power loss recovery ----
case eBT_HOME_RECOVERY_YES:
LGT_Send_Data_To_Screen(ADDR_VAL_ICON_HIDE, int16_t(0));
return_home = false;
#ifdef LK1_PRO
status_type = PRINTER_PRINTING;
#endif // LK1_PRO
delay(5);
#if ENABLED(POWER_LOSS_RECOVERY)
LGT_is_printing = true;
LGT_Save_Recovery_Filename(DW_CMD_VAR_W, DW_FH_0, ADDR_TXT_HOME_FILE_NAME, 32);
queue.inject_P(PSTR("M1000")); // == recovery.resume()
// LGT_Power_Loss_Recovery_Resume(); // recovery data write to UI
is_recovery_resuming = true;
menu_type = eMENU_PRINT_HOME;
LGT_Printer_Data_Updata();
LGT_Change_Page(ID_MENU_PRINT_HOME);
#endif
break;
case eBT_HOME_RECOVERY_NO:
total_print_time = total_print_time+ recovery.info.print_job_elapsed/60;
eeprom_write_dword((uint32_t*)EEPROM_INDEX, total_print_time);
#if ENABLED(POWER_LOSS_RECOVERY)
recovery.cancel(); // == M1000 C
#endif
DISABLE_AXIS_Z();
return_home = false;
recovery_time = 0;
recovery_percent = 0;
recovery_z_height = 0.0;
recovery_E_len = 0.0;
LGT_Change_Page(ID_MENU_HOME);
menu_type = eMENU_HOME;
break;
// ----- manual leveling menu -----
case eBT_UTILI_LEVEL_CORNER_POS_1:
#ifdef LK1_PRO
if (xy_home == false)
{
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
queue.enqueue_one_P(PSTR("G28 X0 Y0"));
xy_home = true;
}
queue.enqueue_one_P(PSTR("G1 X50 Y50"));
#elif defined(LK5_PRO)
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X50 Y50 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#else //LK4_PRO
// if (queue.length >= BUFSIZE)
// break;
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X30 Y30 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#endif
break;
case eBT_UTILI_LEVEL_CORNER_POS_2: //45 002D
#ifdef LK1_PRO
if (xy_home == false)
{
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
queue.enqueue_one_P(PSTR("G28 X0 Y0"));
xy_home = true;
}
queue.enqueue_one_P(PSTR("G1 X250 Y50"));
#elif defined(LK5_PRO)
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X250 Y50 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#else //LK4_PRO
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X190 Y30 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#endif
break;
case eBT_UTILI_LEVEL_CORNER_POS_3:
#ifdef LK1_PRO
if (xy_home == false)
{
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
queue.enqueue_one_P(PSTR("G28 X0 Y0"));
xy_home = true;
}
queue.enqueue_one_P(PSTR("G1 X250 Y250"));
#elif defined(LK5_PRO)
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X250 Y250 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#else //LK4_PRO
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X190 Y190 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#endif
break;
case eBT_UTILI_LEVEL_CORNER_POS_4:
#ifdef LK1_PRO
if (xy_home == false)
{
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
queue.enqueue_one_P(PSTR("G28 X0 Y0"));
xy_home = true;
}
queue.enqueue_one_P(PSTR("G1 X50 Y250"));
#elif defined(LK5_PRO)
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X50 Y250 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#else //LK4_PRO
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X30 Y190 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#endif
break;
case eBT_UTILI_LEVEL_CORNER_POS_5:
#ifdef LK1_PRO
if (xy_home == false)
{
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
queue.enqueue_one_P(PSTR("G28 X0 Y0"));
xy_home = true;
}
queue.enqueue_one_P(PSTR("G1 X150 Y150"));
#elif defined(LK5_PRO)
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X150 Y150 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#else //LK4_PRO
if (xyz_home == false)
{
#if ENABLED(COOL_BEFORE_LEVELING)
// save current tatgethotend
old_tar_temp_end = thermalManager.degTargetHotend(eExtruder::E0);
old_tar_temp_bed = thermalManager.degTargetBed();
// zero temp for prevent from damaging bed or hot end
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
#endif // COOL_BEFORE_LEVELING
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28"));
xyz_home = true;
}
queue.enqueue_one_P(PSTR("G1 Z10 F500"));
queue.enqueue_one_P(PSTR("G1 X110 Y110 F5000"));
queue.enqueue_one_P(PSTR("G1 Z0 F300"));
#endif
break;
case eBT_UTILI_LEVEL_CORNER_BACK:
#ifdef LK1_PRO
if (xy_home) {
xy_home = false;
queue.enqueue_one_P(PSTR("G1 Z10 F500")); //up 10mm to prevent from damaging bed
}
#else //LK4_PRO or LK5_PRO
if (xyz_home) {
xyz_home = false;
queue.enqueue_one_P(PSTR("G1 Z10 F500")); //up 10mm to prevent from damaging bed
#if ENABLED(COOL_BEFORE_LEVELING)
// retrive target temp
DEBUG_ECHOPAIR("\ntartemp_end", old_tar_temp_end);
DEBUG_ECHOPAIR("tartemp_bed", old_tar_temp_bed);
DEBUG_EOL();
thermalManager.setTargetHotend(old_tar_temp_end, eExtruder::E0);
thermalManager.setTargetBed(old_tar_temp_bed);
#endif // COOL_BEFORE_LEVELING
}
#endif
break;
// ----- u20 auto leveling with probe -----
#ifdef LK1_PRO
case eBT_UTILI_LEVEL_MEASU_START: // == PREVIOUS
LGT_Change_Page(ID_DIALOG_LEVEL_WAIT);
level_z_height = 0;
LGT_Send_Data_To_Screen(ADDR_VAL_LEVEL_Z_UP_DOWN,0);
menu_measu_step = 1;
menu_measu_dis_chk = 1;
thermalManager.setTargetHotend(0, eExtruder::E0);
thermalManager.setTargetBed(0);
queue.enqueue_now_P(PSTR("G28 X0 Y0"));
// queue.enqueue_now_P(PSTR("G1 X150 Y150 F3000"));
queue.enqueue_now_P(PSTR("G1 X180 Y153 F3000"));
queue.enqueue_now_P(PSTR("M2002"));
xy_home = true;
break;
case eBT_UTILI_LEVEL_MEASU_DIS_0:
menu_measu_dis_chk = 0;
break;
case eBT_UTILI_LEVEL_MEASU_DIS_1: //50 0032
menu_measu_dis_chk = 1;
break;
case eBT_UTILI_LEVEL_MEASU_S1_NEXT:
menu_measu_step = 2;
menu_measu_dis_chk = 1;
break;
case eBT_UTILI_LEVEL_MEASU_S2_NEXT:
menu_measu_step = 3;
menu_measu_dis_chk = 1;
settings.reset();
queue.enqueue_now_P(PSTR("G28"));
queue.enqueue_now_P(PSTR("G29"));
break;
case eBT_UTILI_LEVEL_MEASU_S1_EXIT_NO:
LGT_Change_Page(ID_MENU_MEASU_S1 + menu_measu_dis_chk);
break;
case eBT_UTILI_LEVEL_MEASU_S2_EXIT_NO:
LGT_Change_Page(ID_MENU_MEASU_S2 + menu_measu_dis_chk);
break;
case eBT_UTILI_LEVEL_MEASU_EXIT_OK:
queue.clear();
quickstop_stepper();
queue.enqueue_now_P(PSTR("M18"));
break;
case eBT_UTILI_LEVEL_MEASU_S3_EXIT_NO:
LGT_Change_Page(ID_MENU_MEASU_S3);
break;
case eBT_UTILI_LEVEL_MEASU_STOP_MOVE:
level_z_height = 0;
LGT_Send_Data_To_Screen(ADDR_VAL_LEVEL_Z_UP_DOWN, 0);
queue.clear();
quickstop_stepper();
queue.enqueue_now_P(PSTR("M17"));
break;
case eBT_TUNE_SWITCH_LEDS:
led_on = !led_on;
if (led_on == false)
{
LED_Bright_State(LED_BLUE, 10, 0); //close LED
LGT_Send_Data_To_Screen(ADDR_VAL_LEDS_SWITCH, 1);
delay(5);
}
else
{
LGT_Send_Data_To_Screen(ADDR_VAL_LEDS_SWITCH, 0);
delay(5);
}
break;
#endif //LK1_PRO
// added for JX screen
case eBT_PRINT_HOME_FILAMENT:
if (_btnFilamentEnabled1) {
LGT_Change_Page(ID_DIALOG_CHANGE_FILA_0);
}
break;
case eBT_PRINT_TUNE_FILAMENT:
if (_btnFilamentEnabled2) {
LGT_Change_Page(ID_DIALOG_CHANGE_FILA_1);
}
break;
default: break;
}
#endif // 0
}
void LGT_SCR_DW::LGT_Change_Filament(int fila_len)
{
if (fila_len >= 0)
{
if (menu_type == eMENU_UTILI_FILA)
{
LGT_Change_Page(ID_DIALOG_UTILI_FILA_LOAD);
}
else if (menu_type == eMENU_HOME_FILA)
{
LGT_Change_Page(ID_DIALOG_PRINT_FILA_LOAD);
}
}
else
{
if (menu_type == eMENU_UTILI_FILA)
{
LGT_Change_Page(ID_DIALOG_UTILI_FILA_UNLOAD);
}
else if (menu_type == eMENU_HOME_FILA)
{
LGT_Change_Page(ID_DIALOG_PRINT_FILA_UNLOAD);
}
}
current_position[E_AXIS] = current_position[E_AXIS]+ fila_len;
if (fila_len>=0) //load filament
{
LGT_Line_To_Current(E_AXIS);
}
else //unload filament
{
if (!planner.is_full())
planner.buffer_line(current_position, 600, 0, current_position[E_AXIS]);
}
planner.synchronize();
if (menu_type == eMENU_UTILI_FILA)
{
LGT_Change_Page(ID_MENU_UTILI_FILA_0 + menu_fila_type_chk);
}
else if (menu_type == eMENU_HOME_FILA)
{
planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = (resume_e_position - 2)));
if (fila_len >= 0)
{
LGT_Change_Page(ID_DIALOG_LOAD_FINISH);
}
else
{
LGT_Change_Page(ID_MENU_HOME_FILA_0);
}
}
}
void LGT_SCR_DW::LGT_Display_Filename()
{
gcode_num = 0;
uint16_t var_addr = ADDR_TXT_PRINT_FILE_ITEM_0;
const uint16_t FileCnt = card.get_num_Files(); //FileCnt:Total number of files
DEBUG_ECHOLNPAIR("gcode cout: ", FileCnt);
for (int i = (FileCnt - 1); i >= 0; i--) //Reverse order
//for (int i=0;i<FileCnt;i++)
{
card.getfilename_sorted(i);
if (!card.flag.filenameIsDir)
{
DEBUG_ECHOLN(card.longFilename);
gcode_id[gcode_num] = i;
gcode_num++;
LGT_MAC_Send_Filename(var_addr, i);
var_addr = var_addr + LEN_FILE_NAME;
if (gcode_num == 10|| gcode_num==20)
idle();
if (gcode_num >= FILE_LIST_NUM)
break;
}
}
}
/*************************************
FUNCTION: Printing SD card files to DWIN_Screen
**************************************/
void LGT_SCR_DW::LGT_MAC_Send_Filename(uint16_t Addr, uint16_t Serial_Num)
{
card.getfilename_sorted(Serial_Num);
int len = strlen(card.longFilename);
data_storage[0] = DW_FH_0;
data_storage[1] = DW_FH_1;
data_storage[2] = len+3+2; /* 0x22 */;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = (Addr & 0xFF00) >> 8;
data_storage[5] = Addr;
for (int i = 0; i < len/* 31 */; i++)
{
data_storage[6 + i] = card.longFilename[i];
}
data_storage[6 + len] = 0XFF;
data_storage[6 + len + 1] = 0xFF;
for (int i = 0; i < len + 6 + 2/* 37 */; i++)
{
MYSERIAL1.write(data_storage[i]);
delayMicroseconds(1);
}
}
/*************************************
FUNCTION: Checking sdcard and updating file list on screen
**************************************/
void LGT_SCR_DW::LGT_SDCard_Status_Update()
{
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
const uint8_t sd_status = (uint8_t)IS_SD_INSERTED();
if (!sd_status)
{
if (sd_init_flag ==true)
{
sd_init_flag = false;
if (!card.isMounted())
{
card.mount();
delay(2);
if (card.isMounted())
{
if (menu_type == eMENU_FILE)
{
if (ii_setup == (STARTUP_COUNTER + 1))
{
LGT_Change_Page(ID_MENU_PRINT_FILES_O);
}
}
LGT_Display_Filename();
}
}
}
}
else
{
if (sd_init_flag == false)
{
if (return_home)
{
return_home = false;
menu_type = eMENU_HOME;
LGT_Change_Page(ID_MENU_HOME);
}
DEHILIGHT_FILE_NAME();
sel_fileid = -1;
uint16_t var_addr = ADDR_TXT_PRINT_FILE_ITEM_0;
for (int i = 0; i < gcode_num; i++) //Cleaning filename
{
LGT_Clean_DW_Display_Data(var_addr);
var_addr = var_addr+LEN_FILE_NAME;
if (i == 10 || i == 20)
LGT_Get_MYSERIAL1_Cmd();
}
LGT_Clean_DW_Display_Data(ADDR_TXT_PRINT_FILE_SELECT);
card.release();
gcode_num = 0;
}
sd_init_flag = true;
}
#endif
}
void LGT_SCR_DW::LGT_Save_Recovery_Filename(unsigned char cmd, unsigned char sys_cmd,unsigned int addr, unsigned int length)
{
memset(data_storage, 0, sizeof(data_storage));
data_storage[0] = Send_Data.head[0];
data_storage[1] = Send_Data.head[1];
data_storage[2] = 0x0B;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = 0x00;
data_storage[5] = 0x08;
data_storage[6] = sys_cmd;
data_storage[7] = 0x00;
data_storage[8] = 0x00;
data_storage[9] = 0x00;
data_storage[10] = (unsigned char)(addr >> 8);
data_storage[11] = (unsigned char)(addr & 0x00FF);
data_storage[12] = (unsigned char)(length >> 8);
data_storage[13] = (unsigned char)(length & 0x00FF);
for (int i = 0; i < 14; i++)
{
MYSERIAL1.write(data_storage[i]);
delayMicroseconds(1);
}
}
void LGT_SCR_DW::LGT_Exit_Print_Page() //return to home menu
{
feedrate_percentage = 100;
planner.flow_percentage[0] = 100;
LGT_Clean_DW_Display_Data(ADDR_TXT_HOME_FILE_NAME);
LGT_Clean_DW_Display_Data(ADDR_VAL_FAN);
LGT_Send_Data_To_Screen(ADDR_VAL_HOME_PROGRESS, int16_t(0));
recovery_time = 0;
recovery_percent = 0;
recovery_z_height = 0.0;
recovery_E_len = 0.0;
menu_type = eMENU_HOME;
LGT_Printer_Data_Updata();
status_type = PRINTER_STANDBY;
idle();
planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = 0));
}
void LGT_SCR_DW::LGT_Clean_DW_Display_Data(unsigned int addr)
{
memset(data_storage, 0, sizeof(data_storage));
data_storage[0] = DW_FH_0;
data_storage[1] = DW_FH_1;
data_storage[2] = 0x05;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = (addr & 0xFF00) >> 8;
data_storage[5] = addr;
data_storage[6] = 0xFF;
data_storage[7] = 0xFF;
for (int i = 0; i < 8; i++)
MYSERIAL1.write(data_storage[i]);
}
// abort sd printing
void LGT_SCR_DW::LGT_Stop_Printing()
{
#if ENABLED(SDSUPPORT)
// wait_for_heatup = wait_for_user = false;
// card.flag.abort_sd_printing = true;
#endif
card.endFilePrint(
#if SD_RESORT
true
#endif
);
queue.clear();
quickstop_stepper();
delay(100);
print_job_timer.stop();
thermalManager.disable_all_heaters();
thermalManager.zero_fan_speeds();
wait_for_heatup = false;
#if ENABLED(POWER_LOSS_RECOVERY)
recovery.purge();
#endif
// end gcodes
if (is_recovery_resuming) {
is_recovery_resuming = false;
} else {
queue.enqueue_one_P(PSTR("G91"));
queue.enqueue_one_P(PSTR("G1 Z10"));
queue.enqueue_one_P(PSTR("G90"));
queue.enqueue_one_P(PSTR("G28 X0"));
}
queue.enqueue_one_P(PSTR("M2000")); // goto home page
}
/*************************************
FUNCTION: Disable and enable button of DWIN_Screen
pageid: page n (page 1:0001)
buttonid:button n + return value (button 5+06:0506)
sta:disable or enable (0000:disable 0001:enable)
**************************************/
void LGT_SCR_DW::LGT_Disable_Enable_Screen_Button(unsigned int pageid, unsigned int buttonid, unsigned int sta)
{
if (hasDwScreen()) {
memset(data_storage, 0, sizeof(data_storage));
data_storage[0] = Send_Data.head[0];
data_storage[1] = Send_Data.head[1];
data_storage[2] = 0x0B;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = 0x00;
data_storage[5] = 0xB0;
data_storage[6] = 0x5A;
data_storage[7] = 0xA5;
data_storage[8] = (unsigned char)(pageid>>8);
data_storage[9] = (unsigned char)(pageid&0x00FF);
data_storage[10] = (unsigned char)(buttonid>>8);
data_storage[11] = (unsigned char)(buttonid & 0x00FF);
data_storage[12] = (unsigned char)(sta >> 8);
data_storage[13] = (unsigned char)(sta & 0x00FF);
for (int i = 0; i < 14; i++)
{
MYSERIAL1.write(data_storage[i]);
delayMicroseconds(1);
}
} else if (hasJxScreen()) {
bool state = sta != 0 ? true : false;
if (pageid == ID_MENU_PRINT_HOME) {
if (buttonid == 5) { // pause button
_btnPauseEnabled = state;
} else if (buttonid == 517) { // filament1 button
// MYSERIAL0.print("fila1: ");
// MYSERIAL0.println(int(state));
_btnFilamentEnabled1 = state;
}
} else if (pageid == ID_MENU_PRINT_TUNE) {
if (buttonid == 1541 || buttonid == 1797) { // filament2 button LK4 Pro: 1541, LK1 Pro: 1797
// MYSERIAL0.print("fila2: ");
// MYSERIAL0.println(int(state));
_btnFilamentEnabled2 = state;
}
}
}
}
void LGT_SCR_DW::LGT_Screen_System_Reset()
{
memset(data_storage, 0, sizeof(data_storage));
data_storage[0] = Send_Data.head[0];
data_storage[1] = Send_Data.head[1];
data_storage[2] = 0x07;
data_storage[3] = DW_CMD_VAR_W;
data_storage[4] = 0x00;
data_storage[5] = 0x04;
data_storage[6] = 0x55;
data_storage[7] = 0xAA;
data_storage[8] = 0x5A;
data_storage[9] = 0xA5;
for (int i = 0; i < 10; i++)
{
MYSERIAL1.write(data_storage[i]);
delayMicroseconds(1);
}
}
void LGT_SCR_DW::hideButtonsBeforeHeating()
{
if (LGT_is_printing)
{
LGT_Send_Data_To_Screen(ADDR_VAL_ICON_HIDE, int16_t(0));
LGT_Get_MYSERIAL1_Cmd();
LGT_Disable_Enable_Screen_Button(ID_MENU_PRINT_HOME, 5, 0);
LGT_Get_MYSERIAL1_Cmd();
delay(50);
#ifdef LK1_PRO
LGT_Disable_Enable_Screen_Button(ID_MENU_PRINT_TUNE, 1797, 0);
#else
LGT_Disable_Enable_Screen_Button(ID_MENU_PRINT_TUNE, 1541, 0);
#endif
LGT_Get_MYSERIAL1_Cmd();
delay(50);
LGT_Disable_Enable_Screen_Button(ID_MENU_PRINT_HOME, 517, 0);
}
}
void LGT_SCR_DW::showButtonsAfterHeating()
{
if (LGT_is_printing)
{
LGT_Send_Data_To_Screen(ADDR_VAL_ICON_HIDE, int16_t(1));
LGT_Disable_Enable_Screen_Button(ID_MENU_PRINT_HOME, 5, 1);
LGT_Get_MYSERIAL1_Cmd();
delay(50);
#ifdef LK1_PRO
LGT_Disable_Enable_Screen_Button(ID_MENU_PRINT_TUNE, 1797, 1);
#else
LGT_Disable_Enable_Screen_Button(ID_MENU_PRINT_TUNE, 1541, 1);
#endif
LGT_Get_MYSERIAL1_Cmd();
delay(50);
LGT_Disable_Enable_Screen_Button(ID_MENU_PRINT_HOME, 517, 1);
}
}
void LGT_SCR_DW::writeData(uint16_t addr, const uint8_t *data, uint8_t size, bool isRead/* =false */)
{
// frame header
data_storage[0] = DW_FH_0;
data_storage[1] = DW_FH_1;
data_storage[2] = 3 + size;
data_storage[3] = isRead? DW_CMD_VAR_R : DW_CMD_VAR_W;
// address data store in Big-endian(high byte in low address)
data_storage[4] = (uint8_t)(addr >> 8); // get high byte
data_storage[5] = (uint8_t)(addr & 0x00FF); // get low byte
// write header to screen
for (uint8_t i = 0; i < 6; i++) {
MYSERIAL1.write(data_storage[i]);
// MYSERIAL0.print(data_storage[i]);
delayMicroseconds(1);
}
// write data to screen
for (uint8_t i = 0; i < size; i++) {
MYSERIAL1.write(data[i]);
// MYSERIAL0.print(data[i]);
delayMicroseconds(1);
}
}
/**
* @brief read user variable data from serial screen
*
* @param size number of word(2 byte)
*/
void LGT_SCR_DW::readData(uint16_t addr, uint8_t *data, uint8_t size)
{
constexpr uint8_t BUFFSIZE = 32;
uint16_t byteLength = size * 2 + 7; // wordSize * 2 + headSize
if (byteLength > BUFFSIZE)
return;
lgtLcdDw.writeData(addr, size, true);
// delay(1000); // wait sometime for serial screen response
bool finish = false;
uint8_t buff[BUFFSIZE];
uint8_t i = 0;
millis_t next = millis() + 2000;
while (!finish && PENDING(millis(), next)) {
while (i < BUFFSIZE && MYSERIAL1.available() > 0) {
uint8_t b = MYSERIAL1.read();
// MYSERIAL0.println(b, 16);
if (i == 0) { // found head 1
if (b == DW_FH_0)
buff[i++] = b;
} else if(i == 1) { // found head 2
if (b == DW_FH_1)
buff[i++] = b;
else
i = 0; // reset buffer
} else {
buff[i++] = b;
}
delayMicroseconds(10);
}
if (i == byteLength) { // check byte length at last
uint16_t readAddr = (uint16_t)buff[4] * 256 + buff[5]; // 2 byte >> 16
if (readAddr == addr && buff[6] == size) {
finish = true;
// MYSERIAL0.write((const uint8_t*)buff, (size_t)byteLength);
}
}
}
if (finish) {
for (uint8_t i = 0; i < size * 2; i++)
data[i] = buff[7+i];
}
// MYSERIAL0.print("i: ");
// MYSERIAL0.print((uint16_t)i);
// MYSERIAL0.write((const uint8_t*)buff, (size_t)byteLength);
}
void LGT_SCR_DW::readScreenModel()
{
uint8_t temp[8] = {0}; // screen firmware: #.#.#-XX
lgtLcdDw.readData(ADDR_TXT_ABOUT_FW_SCREEN, temp, 4);
// MYSERIAL0.print("fw: ");
// MYSERIAL0.println((char *)temp);
SERIAL_ECHOPGM("Detect touch screen: ");
if (temp[6] == 'D' && temp[7] == 'W') { // DWIN T5 screen / TJC DWIN emulation
SERIAL_ECHOLNPGM("DWIN T5");
_screenModel = SCREEN_DWIN_T5;
} else if (temp[6] == 'J' && temp[7] == 'X') { // JX screen
SERIAL_ECHOLNPGM("JX");
_screenModel = SCREEN_JX;
} else if (temp[6] == 'D' && temp[7] == 'L') {// DWIN T5L screen
SERIAL_ECHOLNPGM("DWIN T5L");
_screenModel = SCREEN_DWIN_T5L;
} else {
SERIAL_ECHOPGM("unknown");
SERIAL_ECHOLNPGM(", use default DWIN T5");
_screenModel = SCREEN_DWIN_T5;
}
}
void LGT_SCR_DW::test(){
// delay(1000);
// uint8_t temp[8] = {0};
// lgtLcdDw.readData(ADDR_TXT_ABOUT_FW_SCREEN, temp, 4);
// MYSERIAL0.print("fw: ");
// MYSERIAL0.println((char *)temp);
// MYSERIAL0.print("Touch Screen: ");
// if (temp[6] == 'D' && temp[7] == 'W') { // DWIN T5 screen
// MYSERIAL0.println("DWIN T5");
// } else if (temp[6] == 'J' && temp[7] == 'X') { // JX screen
// MYSERIAL0.println("JX");
// } else if (temp[6] == 'D' && temp[7] == 'L') {// DWIN T5L screen
// MYSERIAL0.println("DWIN T5L");
// } else {
// MYSERIAL0.println("unknown");
// }
// uint8_t str[] = "abcd";
// lgtLcdDw.writeData(0x1234, str, sizeof(str));
// uint16_t num16 = 0x5678;
// lgtLcdDw.writeData(0x1234, num16);
// uint8_t num1 = 0xab;
// lgtLcdDw.writeData(0x1234, num1);
}
static bool isEqual_PP(PGM_P s1, PGM_P s2)
{
size_t len = strlen_P(s1);
if (len != strlen_P(s2))
return false;
byte b1, b2;
while(len--) {
b1 = pgm_read_byte(s1++);
b2 = pgm_read_byte(s2++);
if (b1 != b2)
return false;
}
return true;
}
static int8_t errorIndex(const char *error, const char *component)
{
if (error == nullptr)
return -1;
#define IS_ERROR(e) (isEqual_PP(error, GET_TEXT(e)))
#define IS_E1() (isEqual_PP(component, PSTR(LCD_STR_E0)))
#define IS_BED() (isEqual_PP(component, GET_TEXT(MSG_BED)))
int8_t index;
if (IS_ERROR(MSG_ERR_MINTEMP)) {
if (IS_E1())
index = 0;
else if (IS_BED())
index = 1;
else
index = -1;
} else if (IS_ERROR(MSG_ERR_MAXTEMP)) {
if (IS_E1())
index = 2;
else if (IS_BED())
index = 3;
else
index = -1;
} else if (IS_ERROR(MSG_HEATING_FAILED_LCD)) {
if (IS_E1())
index = 4;
else if (IS_BED())
index = 5;
else
index = -1;
} else if (IS_ERROR(MSG_THERMAL_RUNAWAY)) {
if (IS_E1())
index = 6;
else if (IS_BED())
index = 7;
else
index = -1;
} else if (IS_ERROR(MSG_LCD_HOMING_FAILED)) {
index = 8;
} else if (IS_ERROR(MSG_LCD_PROBING_FAILED)) {
index = 9;
} else { // unknown error
index = -1;
}
return index;
}
void LGT_SCR_DW::LGT_Print_Cause_Of_Kill(const char* error, const char *component)
{
const char *errMsgKilled[] = {
TXT_ERR_MINTEMP,
TXT_ERR_MIN_TEMP_BED,
TXT_ERR_MAXTEMP,
TXT_ERR_MAX_TEMP_BED,
TXT_ERR_HEATING_FAILED,
TXT_ERR_HEATING_FAILED_BED,
TXT_ERR_TEMP_RUNAWAY,
TXT_ERR_TEMP_RUNAWAY_BED,
TXT_ERR_HOMING_FAILED,
TXT_ERR_PROBING_FAILED
};
DEBUG_PRINT_P(error);
DEBUG_ECHO(" ");
DEBUG_PRINT_P(component);
DEBUG_EOL();
int8_t errIndex = errorIndex(error, component);
char msg[32] = "";
if (errIndex > -1) {
sprintf_P(msg, PSTR("Error %i: %s"), errIndex + 1, errMsgKilled[errIndex]);
}
DEBUG_ECHOLN(msg);
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, msg);
LGT_Change_Page(ID_CRASH_KILLED);
}
void LGT_SCR_DW::pausePrint()
{
LGT_is_printing = false;
status_type = PRINTER_PAUSE;
}
/*
void LGT_SCR_DW::LGT_Print_Cause_Of_Kill()
{
switch (kill_type)
{
case E_TEMP_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON,E_TEMP_ERROR);
break;
case B_TEMP_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, B_TEMP_ERROR);
break;
case M112_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, M112_ERROR);
break;
case SDCARD_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON,SDCARD_ERROR);
break;
case HOME_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON,HOME_FAILE);
break;
case TIMEOUT_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON,TIMEOUT_ERROR);
break;
case EXTRUDER_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON,EXTRUDER_NUM_ERROR);
break;
case DRIVER_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON,DRIVER_ERROR);
break;
case E_MINTEMP_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, E_MINTEMP_ERROR);
break;
case B_MINTEMP_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, B_MINTEMP_ERROR);
break;
case E_MAXTEMP_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, E_MAXTEMP_ERROR);
break;
case B_MAXTEMP_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, B_MAXTEMP_ERROR);
break;
case E_RUNAWAY_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, E_RUNAWAY_ERROR);
break;
case B_RUNAWAY_KILL:
LGT_Send_Data_To_Screen1(ADDR_KILL_REASON, B_RUNAWAY_ERROR);
break;
default:
break;
}
}
*/
#endif // LGT_LCD_DW
| 65,836
|
C++
|
.cpp
| 2,140
| 26.941589
| 141
| 0.653653
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,871
|
M2000_M2008.cpp
|
LONGER3D_Marlin2_0-lgt/Marlin/src/lcd/M2000_M2008.cpp
|
#include "../inc/MarlinConfig.h"
#include "../gcode/gcode.h"
#if ENABLED(LGT_LCD_DW)
#include "lgtdwlcd.h"
#include "lgtdwdef.h"
#include "../module/motion.h"
#include "../feature/runout.h"
extern E_MENU_TYPE menu_type;
extern PRINTER_STATUS status_type;
extern char menu_move_dis_chk;
// #include "../../module/stepper.h"
// #include "../../module/endstops.h"
// #define DEBUG_M2000
#define DEBUG_OUT ENABLED(DEBUG_M2000)
#include "../core/debug_out.h"
// abort printing and return to home menu
void GcodeSuite::M2000()
{
DEBUG_ECHOLNPGM("run M2000");
M18_M84();
if (leveling_sta!=2)
{
lgtLcdDw.LGT_Change_Page(ID_MENU_HOME);
}
else
{
leveling_sta=0;
}
runout.reset();
}
// wait for printing pausing
void GcodeSuite::M2001()
{
DEBUG_ECHOLNPGM("run M2001");
lgtLcdDw.LGT_Pause_Move();
lgtLcdDw.LGT_Change_Page(ID_MENU_PRINT_HOME_PAUSE);
}
#if ENABLED(U20_PLUS)
// wait for auto-levelling measuring
void GcodeSuite::M2002()
{
planner.synchronize();
lgtLcdDw.LGT_Change_Page(ID_MENU_MEASU_S1 + 1);
}
#endif
// save position and filament runout move
void GcodeSuite::M2003()
{
DEBUG_ECHOLNPGM("run M2003");
lgtLcdDw.LGT_Change_Page(ID_DIALOG_NO_FILA);
status_type = PRINTER_PAUSE;
// if(all_axes_known()) {
lgtLcdDw.LGT_Pause_Move();
// }
}
// load filament
void GcodeSuite::M2004()
{
DEBUG_ECHOLNPGM("run M2004");
lgtLcdDw.LGT_Change_Filament(LOAD_FILA_LEN);
}
// unload filament
void GcodeSuite::M2005()
{
DEBUG_ECHOLNPGM("run M2005");
lgtLcdDw.LGT_Change_Filament(UNLOAD_FILA_LEN);
}
// filament change in printing
void GcodeSuite::M2006()
{
DEBUG_ECHOLNPGM("run M2006");
lgtLcdDw.LGT_Pause_Move();
lgtLcdDw.LGT_Change_Page(ID_MENU_HOME_FILA_0);
menu_type = eMENU_HOME_FILA;
}
void GcodeSuite::M2007()
{
// if (parser.seen('Z'))
// {
// current_position[Z_AXIS] = parser.value_linear_units();
// LGT_Line_To_Current(Z_AXIS);
// planner.set_z_position_mm((destination[Z_AXIS] = current_position[Z_AXIS] = 0));
// }
// else if (parser.seen('E'))
// {
// current_position[E_AXIS] = parser.value_linear_units();
// LGT_Line_To_Current(E_AXIS);
// planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = 0));
// }
}
// wait for homing in MOVE menu
void GcodeSuite::M2008()
{
if(menu_move_dis_chk==0)
lgtLcdDw.LGT_Change_Page(ID_MENU_MOVE_0);
else if(menu_move_dis_chk==1)
lgtLcdDw.LGT_Change_Page(ID_MENU_MOVE_1);
else
lgtLcdDw.LGT_Change_Page(ID_MENU_MOVE_1+1);
}
#endif // LGT_LCD_DW
| 2,750
|
C++
|
.cpp
| 101
| 22.90099
| 88
| 0.643783
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,881
|
Configuration.h
|
LONGER3D_Marlin2_0-lgt/Marlin/Configuration.h
|
/**
* 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
/**
* Configuration.h
*
* Basic settings such as:
*
* - Type of electronics
* - Type of temperature sensor
* - Printer geometry
* - Endstop configuration
* - LCD controller
* - Extra features
*
* Advanced settings can be found in Configuration_adv.h
*
*/
#define CONFIGURATION_H_VERSION 020005
//===========================================================================
//============================= Getting Started =============================
//===========================================================================
/**
* Here are some standard links for getting your machine calibrated:
*
* http://reprap.org/wiki/Calibration
* http://youtu.be/wAL9d7FgInk
* http://calculator.josefprusa.cz
* http://reprap.org/wiki/Triffid_Hunter%27s_Calibration_Guide
* http://www.thingiverse.com/thing:5573
* https://sites.google.com/site/repraplogphase/calibration-of-your-reprap
* http://www.thingiverse.com/thing:298812
*/
//===========================================================================
//============================= DELTA Printer ===============================
//===========================================================================
// For a Delta printer start with one of the configuration files in the
// config/examples/delta directory and customize for your machine.
//
//===========================================================================
//============================= SCARA Printer ===============================
//===========================================================================
// For a SCARA printer start with the configuration files in
// config/examples/SCARA and customize for your machine.
//
//===========================================================================
//============================= Longer 3D Printer ============================
//===========================================================================
// uncomment or comment LKx_PRO definition to change model
// NOTE: should only define one single model in the meantime
// #define LK4_PRO
#define LK5_PRO
// validate model definition for LKxPro printer
#if defined(LK1_PRO) && !defined(LK4_PRO) && !defined(LK5_PRO)
#elif !defined(LK1_PRO) && defined(LK4_PRO) && !defined(LK5_PRO)
#elif !defined(LK1_PRO) && !defined(LK4_PRO) && defined(LK5_PRO)
#elif !defined(LK1_PRO) && !defined(LK4_PRO) && !defined(LK5_PRO)
#error "Not define any one printer model"
#else
#error "Defined more than one printer model at the same time"
#endif
// LGT(longer 3D Technology) definition
#define LGT // comment to remove all code snippets from LGT(Longer 3D Technology)
#if ENABLED(LGT)
#define LGT_LCD_DW // DWIN 4.3 inch LCD serial touch screen
#endif
// #define FW_TEST_TAG "T005"
#ifndef FW_TEST_TAG
#define FW_TEST_TAG ""
#endif
#define SHORT_BUILD_VERSION "0.4.0" FW_TEST_TAG "-Marlin2.x"
#define DEFAULT_MACHINE_NAME "LONGER 3D Printer" // override by CUSTOM_MACHINE_NAME if any
#define SOURCE_CODE_URL "https://github.com/LONGER3D"
#define STRING_DISTRIBUTION_DATE "2022-02-18"
#define WEBSITE_URL "www.longer3d.com" // full url: https://www.longer3d.com
//===========================================================================
// @section info
// Author info of this build printed to the host during boot and M115
#define STRING_CONFIG_H_AUTHOR "Longer3D, Hobi, tpruvot" // Who made the changes.
//#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes)
/**
* *** VENDORS PLEASE READ ***
*
* Marlin allows you to add a custom boot image for Graphical LCDs.
* With this option Marlin will first show your custom screen followed
* by the standard Marlin logo with version number and web URL.
*
* We encourage you to take advantage of this new feature and we also
* respectfully request that you retain the unmodified Marlin boot screen.
*/
// Show the Marlin bootscreen on startup. ** ENABLE FOR PRODUCTION **
// #define SHOW_BOOTSCREEN
// Show the bitmap in Marlin/_Bootscreen.h on startup.
//#define SHOW_CUSTOM_BOOTSCREEN
// Show the bitmap in Marlin/_Statusscreen.h on the status screen.
// #define CUSTOM_STATUS_SCREEN_IMAGE
// @section machine
/**
* Select the serial port on the board to use for communication with the host.
* This allows the connection of wireless adapters (for instance) to non-default port pins.
* Serial port -1 is the USB emulated serial port, if available.
* Note: The first serial port (-1 or 0) will always be used by the Arduino bootloader.
*
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
*/
#define SERIAL_PORT 0
/**
* Select a secondary serial port on the board to use for communication with the host.
*
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
*/
// #define SERIAL_PORT_2 2
#ifdef LGT_LCD_DW
#ifdef SERIAL_PORT_2
#undef SERIAL_PORT_2
#endif
#define SERIAL_PORT_2 1
#endif
/**
* This setting determines the communication speed of the printer.
*
* 250000 works in most cases, but you might try a lower speed if
* you commonly experience drop-outs during host printing.
* You may try up to 1000000 to speed up SD file transfer.
*
* :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000]
*/
#define BAUDRATE 115200
// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
#if ANY(U20, U30, U20_PLUS, CUBE2, LK1, LK1_PLUS, LK2, LK4)
#define MOTHERBOARD BOARD_LONGER3D_LK // motherboard for LKx(except for LK5), CUBE2
#elif ANY(LK1_PRO, LK4_PRO, LK5_PRO, LK5)
#define MOTHERBOARD BOARD_LONGER_LGT_KIT_V1 // motherboard for LKxPro and LK5
#endif
#endif
#if MOTHERBOARD == BOARD_LONGER3D_LK
#define LONGER_LKX
#elif MOTHERBOARD == BOARD_LONGER_LGT_KIT_V1
#define LONGER_LKX_PRO
#endif
// Name displayed in the LCD "Ready" message and Info menu
//#define CUSTOM_MACHINE_NAME "3D Printer"
#if ENABLED(U20)
#define CUSTOM_MACHINE_NAME "Alfawise U20"
#elif ENABLED(U30)
#define CUSTOM_MACHINE_NAME "Alfawise U30"
#elif ENABLED(U20_PLUS)
#define CUSTOM_MACHINE_NAME "Alfawise U20 Plus"
#elif ENABLED(CUBE2)
#define CUSTOM_MACHINE_NAME "Longer3D CUBE2"
#elif ENABLED(LK1)
#define CUSTOM_MACHINE_NAME "Longer3D LK1"
#elif ENABLED(LK1_PLUS)
#define CUSTOM_MACHINE_NAME "Longer3D LK1 Plus"
#elif ENABLED(LK2)
#define CUSTOM_MACHINE_NAME "Longer3D LK2"
#elif ENABLED(LK4)
#define CUSTOM_MACHINE_NAME "Longer3D LK4"
//-----------------mega2560 board---------------------//
#elif ENABLED(LK1_PRO)
#define CUSTOM_MACHINE_NAME "Longer3D LK1 Pro"
#elif ENABLED(LK4_PRO)
#define CUSTOM_MACHINE_NAME "Longer3D LK4 Pro"
#elif ENABLED(LK5_PRO)
#define CUSTOM_MACHINE_NAME "Longer3D LK5 Pro"
#elif ENABLED(LK5)
#define CUSTOM_MACHINE_NAME "Longer3D LK5"
#endif
// Printer's unique ID, used by some programs to differentiate between machines.
// Choose your own or use a service like http://www.uuidgenerator.net/version4
//#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
// @section extruder
// This defines the number of extruders
// :[1, 2, 3, 4, 5, 6, 7, 8]
#define EXTRUDERS 1
// Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE
/**
* Průša MK2 Single Nozzle Multi-Material Multiplexer, and variants.
*
* This device allows one stepper driver on a control board to drive
* two to eight stepper motors, one at a time, in a manner suitable
* for extruders.
*
* This option only allows the multiplexer to switch on tool-change.
* Additional options to configure custom E moves are pending.
*/
//#define MK2_MULTIPLEXER
#if ENABLED(MK2_MULTIPLEXER)
// Override the default DIO selector pins here, if needed.
// Some pins files may provide defaults for these pins.
//#define E_MUX0_PIN 40 // Always Required
//#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs
//#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs
#endif
/**
* Prusa Multi-Material Unit v2
*
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
* Requires EXTRUDERS = 5
*
* For additional configuration see Configuration_adv.h
*/
//#define PRUSA_MMU2
// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
#define SWITCHING_EXTRUDER_SERVO_NR 0
#define SWITCHING_EXTRUDER_SERVO_ANGLES { 0, 90 } // Angles for E0, E1[, E2, E3]
#if EXTRUDERS > 3
#define SWITCHING_EXTRUDER_E23_SERVO_NR 1
#endif
#endif
// A dual-nozzle that uses a servomotor to raise/lower one (or both) of the nozzles
//#define SWITCHING_NOZZLE
#if ENABLED(SWITCHING_NOZZLE)
#define SWITCHING_NOZZLE_SERVO_NR 0
//#define SWITCHING_NOZZLE_E1_SERVO_NR 1 // If two servos are used, the index of the second
#define SWITCHING_NOZZLE_SERVO_ANGLES { 0, 90 } // Angles for E0, E1 (single servo) or lowered/raised (dual servo)
#endif
/**
* Two separate X-carriages with extruders that connect to a moving part
* via a solenoid docking mechanism. Requires SOL1_PIN and SOL2_PIN.
*/
//#define PARKING_EXTRUDER
/**
* Two separate X-carriages with extruders that connect to a moving part
* via a magnetic docking mechanism using movements and no solenoid
*
* project : https://www.thingiverse.com/thing:3080893
* movements : https://youtu.be/0xCEiG9VS3k
* https://youtu.be/Bqbcs0CU2FE
*/
//#define MAGNETIC_PARKING_EXTRUDER
#if EITHER(PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER)
#define PARKING_EXTRUDER_PARKING_X { -78, 184 } // X positions for parking the extruders
#define PARKING_EXTRUDER_GRAB_DISTANCE 1 // (mm) Distance to move beyond the parking point to grab the extruder
//#define MANUAL_SOLENOID_CONTROL // Manual control of docking solenoids with M380 S / M381
#if ENABLED(PARKING_EXTRUDER)
#define PARKING_EXTRUDER_SOLENOIDS_INVERT // If enabled, the solenoid is NOT magnetized with applied voltage
#define PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE LOW // LOW or HIGH pin signal energizes the coil
#define PARKING_EXTRUDER_SOLENOIDS_DELAY 250 // (ms) Delay for magnetic field. No delay if 0 or not defined.
//#define MANUAL_SOLENOID_CONTROL // Manual control of docking solenoids with M380 S / M381
#elif ENABLED(MAGNETIC_PARKING_EXTRUDER)
#define MPE_FAST_SPEED 9000 // (mm/m) Speed for travel before last distance point
#define MPE_SLOW_SPEED 4500 // (mm/m) Speed for last distance travel to park and couple
#define MPE_TRAVEL_DISTANCE 10 // (mm) Last distance point
#define MPE_COMPENSATION 0 // Offset Compensation -1 , 0 , 1 (multiplier) only for coupling
#endif
#endif
/**
* Switching Toolhead
*
* Support for swappable and dockable toolheads, such as
* the E3D Tool Changer. Toolheads are locked with a servo.
*/
//#define SWITCHING_TOOLHEAD
/**
* Magnetic Switching Toolhead
*
* Support swappable and dockable toolheads with a magnetic
* docking mechanism using movement and no servo.
*/
//#define MAGNETIC_SWITCHING_TOOLHEAD
/**
* Electromagnetic Switching Toolhead
*
* Parking for CoreXY / HBot kinematics.
* Toolheads are parked at one edge and held with an electromagnet.
* Supports more than 2 Toolheads. See https://youtu.be/JolbsAKTKf4
*/
//#define ELECTROMAGNETIC_SWITCHING_TOOLHEAD
#if ANY(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD, ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_POS 235 // (mm) Y position of the toolhead dock
#define SWITCHING_TOOLHEAD_Y_SECURITY 10 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_Y_CLEAR 60 // (mm) Minimum distance from dock for unobstructed X axis
#define SWITCHING_TOOLHEAD_X_POS { 215, 0 } // (mm) X positions for parking the extruders
#if ENABLED(SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_SERVO_NR 2 // Index of the servo connector
#define SWITCHING_TOOLHEAD_SERVO_ANGLES { 0, 180 } // (degrees) Angles for Lock, Unlock
#elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Y_RELEASE 5 // (mm) Security distance Y axis
#define SWITCHING_TOOLHEAD_X_SECURITY { 90, 150 } // (mm) Security distance X axis (T0,T1)
//#define PRIME_BEFORE_REMOVE // Prime the nozzle before release from the dock
#if ENABLED(PRIME_BEFORE_REMOVE)
#define SWITCHING_TOOLHEAD_PRIME_MM 20 // (mm) Extruder prime length
#define SWITCHING_TOOLHEAD_RETRACT_MM 10 // (mm) Retract after priming length
#define SWITCHING_TOOLHEAD_PRIME_FEEDRATE 300 // (mm/m) Extruder prime feedrate
#define SWITCHING_TOOLHEAD_RETRACT_FEEDRATE 2400 // (mm/m) Extruder retract feedrate
#endif
#elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
#define SWITCHING_TOOLHEAD_Z_HOP 2 // (mm) Z raise for switching
#endif
#endif
/**
* "Mixing Extruder"
* - Adds G-codes M163 and M164 to set and "commit" the current mix factors.
* - Extends the stepping routines to move multiple steppers in proportion to the mix.
* - Optional support for Repetier Firmware's 'M164 S<index>' supporting virtual tools.
* - This implementation supports up to two mixing extruders.
* - Enable DIRECT_MIXING_IN_G1 for M165 and mixing in G1 (from Pia Taubert's reference implementation).
*/
//#define MIXING_EXTRUDER
#if ENABLED(MIXING_EXTRUDER)
#define MIXING_STEPPERS 2 // Number of steppers in your mixing extruder
#define MIXING_VIRTUAL_TOOLS 16 // Use the Virtual Tool method with M163 and M164
//#define DIRECT_MIXING_IN_G1 // Allow ABCDHI mix factors in G1 movement commands
//#define GRADIENT_MIX // Support for gradient mixing with M166 and LCD
#if ENABLED(GRADIENT_MIX)
//#define GRADIENT_VTOOL // Add M166 T to use a V-tool index as a Gradient alias
#endif
#endif
// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
//#define HOTEND_OFFSET_X { 0.0, 20.00 } // (mm) relative X-offset for each nozzle
//#define HOTEND_OFFSET_Y { 0.0, 5.00 } // (mm) relative Y-offset for each nozzle
//#define HOTEND_OFFSET_Z { 0.0, 0.00 } // (mm) relative Z-offset for each nozzle
// @section machine
/**
* Power Supply Control
*
* Enable and connect the power supply to the PS_ON_PIN.
* Specify whether the power supply is active HIGH or active LOW.
*/
//#define PSU_CONTROL
#define PSU_NAME "360W 24V/15A"
#if ENABLED(PSU_CONTROL)
#define PSU_ACTIVE_HIGH false // Set 'false' for ATX, 'true' for X-Box
//#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80
//#define PSU_POWERUP_DELAY 100 // (ms) Delay for the PSU to warm up to full power
//#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power
#define AUTO_POWER_E_FANS
#define AUTO_POWER_CONTROLLERFAN
#define AUTO_POWER_CHAMBER_FAN
//#define AUTO_POWER_E_TEMP 50 // (°C) Turn on PSU over this temperature
//#define AUTO_POWER_CHAMBER_TEMP 30 // (°C) Turn on PSU over this temperature
#define POWER_TIMEOUT 30
#endif
#endif
// @section temperature
//===========================================================================
//============================= Thermal Settings ============================
//===========================================================================
/**
* --NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
*
* Temperature sensors available:
*
* -5 : PT100 / PT1000 with MAX31865 (only for sensors 0-1)
* -3 : thermocouple with MAX31855 (only for sensors 0-1)
* -2 : thermocouple with MAX6675 (only for sensors 0-1)
* -4 : thermocouple with AD8495
* -1 : thermocouple with AD595
* 0 : not used
* 1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
* 331 : (3.3V scaled thermistor 1 table for MEGA)
* 332 : (3.3V scaled thermistor 1 table for DUE)
* 2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
* 202 : 200k thermistor - Copymaster 3D
* 3 : Mendel-parts thermistor (4.7k pullup)
* 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
* 5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan & J-Head) (4.7k pullup)
* 501 : 100K Zonestar (Tronxy X3A) Thermistor
* 512 : 100k RPW-Ultra hotend thermistor (4.7k pullup)
* 6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
* 7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
* 71 : 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup)
* 8 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
* 9 : 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
* 10 : 100k RS thermistor 198-961 (4.7k pullup)
* 11 : 100k beta 3950 1% thermistor (4.7k pullup)
* 12 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
* 13 : 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
* 15 : 100k thermistor calibration for JGAurora A5 hotend
* 18 : ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327
* 20 : Pt100 with circuit in the Ultimainboard V2.x with 5v excitation (AVR)
* 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....)
* 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x
* 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
* 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup
* 66 : 4.7M High Temperature thermistor from Dyze Design
* 67 : 450C thermistor from SliceEngineering
* 70 : the 100K thermistor found in the bq Hephestos 2
* 75 : 100k Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor
* 99 : 100k thermistor with a 10K pull-up resistor (found on some Wanhao i3 machines)
*
* 1k ohm pullup tables - This is atypical, and requires changing out the 4.7k pullup for 1k.
* (but gives greater accuracy and more stable PID)
* 51 : 100k thermistor - EPCOS (1k pullup)
* 52 : 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
* 55 : 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup)
*
* 1047 : Pt1000 with 4k7 pullup
* 1010 : Pt1000 with 1k pullup (non standard)
* 147 : Pt100 with 4k7 pullup
* 110 : Pt100 with 1k pullup (non standard)
*
* 1000 : Custom - Specify parameters in Configuration_adv.h
*
* Use these for Testing or Development purposes. NEVER for production machine.
* 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below.
* 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below.
*/
#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
#define TEMP_SENSOR_6 0
#define TEMP_SENSOR_7 0
#define TEMP_SENSOR_BED 1
#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0
// Dummy thermistor constant temperature readings, for use with 998 and 999
#define DUMMY_THERMISTOR_998_VALUE 25
#define DUMMY_THERMISTOR_999_VALUE 100
// Use temp sensor 1 as a redundant sensor with sensor 0. If the readings
// from the two sensors differ too much the print will be aborted.
//#define TEMP_SENSOR_1_AS_REDUNDANT
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190
#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
// Below this temperature the heater will be switched off
// because it probably indicates a broken thermistor wire.
#define HEATER_0_MINTEMP 5
#define HEATER_1_MINTEMP 5
#define HEATER_2_MINTEMP 5
#define HEATER_3_MINTEMP 5
#define HEATER_4_MINTEMP 5
#define HEATER_5_MINTEMP 5
#define HEATER_6_MINTEMP 5
#define HEATER_7_MINTEMP 5
#define BED_MINTEMP 5
// Above this temperature the heater will be switched off.
// This can protect components from overheating, but NOT from shorts and failures.
// (Use MINTEMP for thermistor short/failure protection.)
#define HEATER_0_MAXTEMP 265
#define HEATER_1_MAXTEMP 275
#define HEATER_2_MAXTEMP 275
#define HEATER_3_MAXTEMP 275
#define HEATER_4_MAXTEMP 275
#define HEATER_5_MAXTEMP 275
#define HEATER_6_MAXTEMP 275
#define HEATER_7_MAXTEMP 275
#define BED_MAXTEMP 110
//===========================================================================
//============================= PID Settings ================================
//===========================================================================
// PID Tuning Guide here: http://reprap.org/wiki/PID_Tuning
// Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
#define PID_K1 0.95 // Smoothing factor within any PID loop
#if ENABLED(PIDTEMP)
//#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM)
//#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM)
//#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with gcode: M301 E[extruder number, 0-2]
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
// Alfawise U30/U20
// Please refine the PID settings for your own machine to avoid the E1 hotend error. These a basic settings allowing first startups.
// Use the command M303 E0 S200 C8 each time you make any changes to your extruder
#if ANY(LK5, LK5_PRO)
// have dual blower. send "M303 E0 S200 C8" command to get PID.
#define DEFAULT_Kp 28.44
#define DEFAULT_Ki 2.41
#define DEFAULT_Kd 83.88
#else
#define DEFAULT_Kp 17.22
#define DEFAULT_Ki 1.00
#define DEFAULT_Kd 74.22
#endif
// MakerGear
//#define DEFAULT_Kp 7.0
//#define DEFAULT_Ki 0.1
//#define DEFAULT_Kd 12
// Mendel Parts V9 on 12V
//#define DEFAULT_Kp 63.0
//#define DEFAULT_Ki 2.25
//#define DEFAULT_Kd 440
#endif // PIDTEMP
//===========================================================================
//====================== PID > Bed Temperature Control ======================
//===========================================================================
/**
* PID Bed Heating
*
* If this option is enabled set PID constants below.
* If this option is disabled, bang-bang will be used and BED_LIMIT_SWITCHING will enable hysteresis.
*
* The PID frequency will be the same as the extruder PWM.
* If PID_dT is the default, and correct for the hardware/configuration, that means 7.689Hz,
* which is fine for driving a square wave into a resistive load and does not significantly
* impact FET heating. This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W
* heater. If your configuration is significantly different than this and you don't understand
* the issues involved, don't use bed PID until someone else verifies that your hardware works.
*/
#define PIDTEMPBED
//#define BED_LIMIT_SWITCHING
/**
* Max Bed Power
* Applies to all forms of bed control (PID, bang-bang, and bang-bang with hysteresis).
* When set to any value below 255, enables a form of PWM to the bed that acts like a divider
* so don't use it unless you are OK with PWM on your bed. (See the comment on enabling PIDTEMPBED)
*/
#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
#if ENABLED(PIDTEMPBED)
//#define MIN_BED_POWER 0
//#define PID_BED_DEBUG // Sends debug data to the serial port.
//120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
//#define DEFAULT_bedKp 10.00
//#define DEFAULT_bedKi .023
//#define DEFAULT_bedKd 305.4
//120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from pidautotune
//#define DEFAULT_bedKp 97.1
//#define DEFAULT_bedKi 1.41
//#define DEFAULT_bedKd 1675.16
// 120x140 bed size
#if ENABLED(CUBE2)
// TODO: need update
#define DEFAULT_bedKp 338.46
#define DEFAULT_bedKi 63.96
#define DEFAULT_bedKd 447.78
// 220x220 size bed
#elif ANY(U30, LK2, LK4, LK4_PRO)
//From M303 command for Alfawise U30 :
#define DEFAULT_bedKp 338.46
#define DEFAULT_bedKi 63.96
#define DEFAULT_bedKd 447.78
// 300x300 bed size
#elif ANY(LK5, LK5_PRO)
// send "M303 E-1 S80 C8" command to get PID.
#define DEFAULT_bedKp 174.64
#define DEFAULT_bedKi 27.33
#define DEFAULT_bedKd 743.95
#elif ANY(U20, LK1, LK1_PRO)
//From M303 command for Alfawise U20 :
#define DEFAULT_bedKp 841.68
#define DEFAULT_bedKi 152.12
#define DEFAULT_bedKd 1164.25
// 400x400 bed size
#elif ANY(U20_PLUS, LK1_PLUS)
// These PID setting MUST be updated.
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#define DEFAULT_bedKp 841.68
#define DEFAULT_bedKi 152.12
#define DEFAULT_bedKd 1164.25
#endif
#endif // PIDTEMPBED
// @section extruder
/**
* Prevent extrusion if the temperature is below EXTRUDE_MINTEMP.
* Add M302 to set the minimum extrusion temperature and/or turn
* cold extrusion prevention on and off.
*
* *** IT IS HIGHLY RECOMMENDED TO LEAVE THIS OPTION ENABLED! ***
*/
#define PREVENT_COLD_EXTRUSION
#define EXTRUDE_MINTEMP 170
/**
* Prevent a single extrusion longer than EXTRUDE_MAXLENGTH.
* Note: For Bowden Extruders make this large enough to allow load/unload.
*/
#define PREVENT_LENGTHY_EXTRUDE
#define EXTRUDE_MAXLENGTH 600
//===========================================================================
//======================== Thermal Runaway Protection =======================
//===========================================================================
/**
* Thermal Protection provides additional protection to your printer from damage
* and fire. Marlin always includes safe min and max temperature ranges which
* protect against a broken or disconnected thermistor wire.
*
* The issue: If a thermistor falls out, it will report the much lower
* temperature of the air in the room, and the the firmware will keep
* the heater on.
*
* If you get "Thermal Runaway" or "Heating failed" errors the
* details can be tuned in Configuration_adv.h
*/
#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders
#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed
//#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber
//===========================================================================
//============================= Mechanical Settings =========================
//===========================================================================
// @section machine
// Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics
// either in the usual order or reversed
//#define COREXY
//#define COREXZ
//#define COREYZ
//#define COREYX
//#define COREZX
//#define COREZY
//===========================================================================
//============================== Endstop Settings ===========================
//===========================================================================
// @section homing
// Specify here all the endstop connectors that are connected to any endstop or probe.
// Almost all printers will be using one per axis. Probes will use one or more of the
// extra connectors. Leave undefined any used for non-endstop and non-probe purposes.
#define USE_XMIN_PLUG
#define USE_YMIN_PLUG
#define USE_ZMIN_PLUG
//#define USE_XMAX_PLUG
//#define USE_YMAX_PLUG
//#define USE_ZMAX_PLUG
// Enable pullup for all endstops to prevent a floating state
#define ENDSTOPPULLUPS
#if DISABLED(ENDSTOPPULLUPS)
// Disable ENDSTOPPULLUPS to set pullups individually
//#define ENDSTOPPULLUP_XMAX
//#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_XMIN
//#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
//#define ENDSTOPPULLUP_ZMIN_PROBE
#endif
// Enable pulldown for all endstops to prevent a floating state
//#define ENDSTOPPULLDOWNS
#if DISABLED(ENDSTOPPULLDOWNS)
// Disable ENDSTOPPULLDOWNS to set pulldowns individually
//#define ENDSTOPPULLDOWN_XMAX
//#define ENDSTOPPULLDOWN_YMAX
//#define ENDSTOPPULLDOWN_ZMAX
//#define ENDSTOPPULLDOWN_XMIN
//#define ENDSTOPPULLDOWN_YMIN
//#define ENDSTOPPULLDOWN_ZMIN
//#define ENDSTOPPULLDOWN_ZMIN_PROBE
#endif
// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
#define X_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe.
/**
* Stepper Drivers
*
* These settings allow Marlin to tune stepper driver timing and enable advanced options for
* stepper drivers that support them. You may also override timing options in Configuration_adv.h.
*
* A4988 is assumed for unspecified drivers.
*
* Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01,
* TB6560, TB6600, TMC2100,
* TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE,
* TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE,
* TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE,
* TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE
* :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
*/
#define X_DRIVER_TYPE A4988
#define Y_DRIVER_TYPE A4988
#define Z_DRIVER_TYPE A4988
//#define X2_DRIVER_TYPE A4988
//#define Y2_DRIVER_TYPE A4988
//#define Z2_DRIVER_TYPE A4988
//#define Z3_DRIVER_TYPE A4988
//#define Z4_DRIVER_TYPE A4988
#define E0_DRIVER_TYPE A4988
//#define E1_DRIVER_TYPE A4988
//#define E2_DRIVER_TYPE A4988
//#define E3_DRIVER_TYPE A4988
//#define E4_DRIVER_TYPE A4988
//#define E5_DRIVER_TYPE A4988
//#define E6_DRIVER_TYPE A4988
//#define E7_DRIVER_TYPE A4988
// Enable this feature if all enabled endstop pins are interrupt-capable.
// This will remove the need to poll the interrupt pins, saving many CPU cycles.
#ifdef LONGER_LKX
#define ENDSTOP_INTERRUPTS_FEATURE
#endif
/**
* Endstop Noise Threshold
*
* Enable if your probe or endstops falsely trigger due to noise.
*
* - Higher values may affect repeatability or accuracy of some bed probes.
* - To fix noise install a 100nF ceramic capacitor inline with the switch.
* - This feature is not required for common micro-switches mounted on PCBs
* based on the Makerbot design, which already have the 100nF capacitor.
*
* :[2,3,4,5,6,7]
*/
//#define ENDSTOP_NOISE_THRESHOLD 2
//=============================================================================
//============================== Movement Settings ============================
//=============================================================================
// @section motion
/**
* Default Settings
*
* These settings can be reset by M502
*
* Note that if EEPROM is enabled, saved values will override these.
*/
/**
* With this option each E stepper can have its own factors for the
* following movement settings. If fewer factors are given than the
* total number of extruders, the last value applies to the rest.
*/
//#define DISTINCT_E_FACTORS
/**
* Default Axis Steps Per Unit (steps/mm)
* Override with M92
* X, Y, Z, E0 [, E1[, E2...]]
*/
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 98 }
/**
* Default Max Feed Rate (mm/s)
* Override with M203
* X, Y, Z, E0 [, E1[, E2...]]
*/
#define DEFAULT_MAX_FEEDRATE { 200, 200, 5, 25 }
#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2
#if ENABLED(LIMITED_MAX_FR_EDITING)
#define MAX_FEEDRATE_EDIT_VALUES { 250, 250, 200, 50 } // ...or, set your own edit limits
#endif
/**
* Default Max Acceleration (change/s) change = mm/s
* (Maximum start speed for accelerated moves)
* Override with M201
* X, Y, Z, E0 [, E1[, E2...]]
*/
#define DEFAULT_MAX_ACCELERATION { 200, 200, 100, 3000 }
#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2
#if ENABLED(LIMITED_MAX_ACCEL_EDITING)
#define MAX_ACCEL_EDIT_VALUES { 600, 600, 400, 6000 } // ...or, set your own edit limits
#endif
/**
* Default Acceleration (change/s) change = mm/s
* Override with M204
*
* M204 P Acceleration
* M204 R Retract Acceleration
* M204 T Travel Acceleration
*/
#define DEFAULT_ACCELERATION 200 // X, Y, Z and E acceleration for printing moves
#define DEFAULT_RETRACT_ACCELERATION 500 // E acceleration for retracts
#define DEFAULT_TRAVEL_ACCELERATION 200 // X, Y, Z acceleration for travel (non printing) moves
/**
* Default Jerk limits (mm/s)
* Override with M205 X Y Z E
*
* "Jerk" specifies the minimum speed change that requires acceleration.
* When changing speed and direction, if the difference is less than the
* value set here, it may happen instantaneously.
*/
#define CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
#define DEFAULT_XJERK 10.0
#define DEFAULT_YJERK 10.0
#define DEFAULT_ZJERK 0.4
#define LIMITED_JERK_EDITING // Limit edit via M205 or LCD to DEFAULT_aJERK * 2
#if ENABLED(LIMITED_JERK_EDITING)
#define MAX_JERK_EDIT_VALUES { 20, 20, 0.6, 10 } // ...or, set your own edit limits
#endif
#endif
#define DEFAULT_EJERK 5.0 // May be used by Linear Advance
/**
* Junction Deviation Factor
*
* See:
* https://reprap.org/forum/read.php?1,739819
* http://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html
*/
#if DISABLED(CLASSIC_JERK)
#define JUNCTION_DEVIATION_MM 0.10 // (mm) Distance from real junction edge
#endif
/**
* S-Curve Acceleration
*
* This option eliminates vibration during printing by fitting a Bézier
* curve to move acceleration, producing much smoother direction changes.
*
* See https://github.com/synthetos/TinyG/wiki/Jerk-Controlled-Motion-Explained
*/
//#define S_CURVE_ACCELERATION
//===========================================================================
//============================= Z Probe Options =============================
//===========================================================================
// @section probes
//
// See http://marlinfw.org/docs/configuration/probes.html
//
/**
* Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
*
* Enable this option for a probe connected to the Z Min endstop pin.
*/
//#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
/**
* Z_MIN_PROBE_PIN
*
* Define this pin if the probe is not connected to Z_MIN_PIN.
* If not defined the default pin for the selected MOTHERBOARD
* will be used. Most of the time the default is what you want.
*
* - The simplest option is to use a free endstop connector.
* - Use 5V for powered (usually inductive) sensors.
*
* - RAMPS 1.3/1.4 boards may use the 5V, GND, and Aux4->D32 pin:
* - For simple switches connect...
* - normally-closed switches to GND and D32.
* - normally-open switches to 5V and D32.
*
*/
//#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default
/**
* Probe Type
*
* Allen Key Probes, Servo Probes, Z-Sled Probes, FIX_MOUNTED_PROBE, etc.
* Activate one of these to use Auto Bed Leveling below.
*/
/**
* The "Manual Probe" provides a means to do "Auto" Bed Leveling without a probe.
* Use G29 repeatedly, adjusting the Z height at each point with movement commands
* or (with LCD_BED_LEVELING) the LCD controller.
*/
// #define PROBE_MANUALLY
// #define MANUAL_PROBE_START_Z 0.2
/**
* A Fix-Mounted Probe either doesn't deploy or needs manual deployment.
* (e.g., an inductive probe or a nozzle-based probe-switch.)
*/
//#define FIX_MOUNTED_PROBE
/**
* Use the nozzle as the probe, as with a conductive
* nozzle system or a piezo-electric smart effector.
*/
//#define NOZZLE_AS_PROBE
/**
* Z Servo Probe, such as an endstop switch on a rotating arm.
*/
//#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector.
//#define Z_SERVO_ANGLES { 70, 0 } // Z Servo Deploy and Stow angles
/**
* The BLTouch probe uses a Hall effect sensor and emulates a servo.
*/
// #define BLTOUCH
/**
* Touch-MI Probe by hotends.fr
*
* This probe is deployed and activated by moving the X-axis to a magnet at the edge of the bed.
* By default, the magnet is assumed to be on the left and activated by a home. If the magnet is
* on the right, enable and set TOUCH_MI_DEPLOY_XPOS to the deploy position.
*
* Also requires: BABYSTEPPING, BABYSTEP_ZPROBE_OFFSET, Z_SAFE_HOMING,
* and a minimum Z_HOMING_HEIGHT of 10.
*/
//#define TOUCH_MI_PROBE
#if ENABLED(TOUCH_MI_PROBE)
#undef PROBE_MANUALLY
#define TOUCH_MI_RETRACT_Z 0.5 // Height at which the probe retracts
//#define TOUCH_MI_DEPLOY_XPOS (X_MAX_BED + 2) // For a magnet on the right side of the bed
//#define TOUCH_MI_MANUAL_DEPLOY // For manual deploy (LCD menu)
#endif
// A probe that is deployed and stowed with a solenoid pin (SOL1_PIN)
//#define SOLENOID_PROBE
// A sled-mounted probe like those designed by Charles Bell.
//#define Z_PROBE_SLED
//#define SLED_DOCKING_OFFSET 5 // The extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.
// A probe deployed by moving the x-axis, such as the Wilson II's rack-and-pinion probe designed by Marty Rice.
//#define RACK_AND_PINION_PROBE
#if ENABLED(RACK_AND_PINION_PROBE)
#define Z_PROBE_DEPLOY_X X_MIN_POS
#define Z_PROBE_RETRACT_X X_MAX_POS
#endif
// Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J
// When the pin is defined you can use M672 to set/reset the probe sensivity.
//#define DUET_SMART_EFFECTOR
#if ENABLED(DUET_SMART_EFFECTOR)
#define SMART_EFFECTOR_MOD_PIN -1 // Connect a GPIO pin to the Smart Effector MOD pin
#endif
/**
* Use StallGuard2 to probe the bed with the nozzle.
* Requires stallGuard-capable Trinamic stepper drivers.
* CAUTION: This can damage machines with Z lead screws.
* Take extreme care when setting up this feature.
*/
//#define SENSORLESS_PROBING
//
// For Z_PROBE_ALLEN_KEY see the Delta example configurations.
//
/**
* Z Probe to nozzle (X,Y) offset, relative to (0, 0).
*
* In the following example the X and Y offsets are both positive:
*
* #define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 }
*
* +-- BACK ---+
* | |
* L | (+) P | R <-- probe (20,20)
* E | | I
* F | (-) N (+) | G <-- nozzle (10,10)
* T | | H
* | (-) | T
* | |
* O-- FRONT --+
* (0,0)
*
* Specify a Probe position as { X, Y, Z }
*/
#define NOZZLE_TO_PROBE_OFFSET { -35, -6, -0.5 }
// Most probes should stay away from the edges of the bed, but
// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
#define MIN_PROBE_EDGE 10
// X and Y axis travel speed (mm/m) between probes
#define XY_PROBE_SPEED 8000
// Feedrate (mm/m) for the first approach when double-probing (MULTIPLE_PROBING == 2)
#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
// Feedrate (mm/m) for the "accurate" probe of each point
#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
/**
* Multiple Probing
*
* You may get improved results by probing 2 or more times.
* With EXTRA_PROBING the more atypical reading(s) will be disregarded.
*
* A total of 2 does fast/slow probes with a weighted average.
* A total of 3 or more adds more slow probes, taking the average.
*/
// #define MULTIPLE_PROBING 2
//#define EXTRA_PROBING 1
/**
* Z probes require clearance when deploying, stowing, and moving between
* probe points to avoid hitting the bed and other hardware.
* Servo-mounted probes require extra space for the arm to rotate.
* Inductive probes need space to keep from triggering early.
*
* Use these settings to specify the distance (mm) to raise the probe (or
* lower the bed). The values set here apply over and above any (negative)
* probe Z Offset set with NOZZLE_TO_PROBE_OFFSET, M851, or the LCD.
* Only integer values >= 1 are valid here.
*
* Example: `M851 Z-5` with a CLEARANCE of 4 => 9mm from bed to nozzle.
* But: `M851 Z+1` with a CLEARANCE of 2 => 2mm from bed to nozzle.
*/
#define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points
#define Z_CLEARANCE_MULTI_PROBE 5 // Z Clearance between multiple probes
//#define Z_AFTER_PROBING 5 // Z position after probing is done
#define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping
// For M851 give a range for adjusting the Z probe offset
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
// Enable the M48 repeatability test to test probe accuracy
//#define Z_MIN_PROBE_REPEATABILITY_TEST
// Before deploy/stow pause for user confirmation
//#define PAUSE_BEFORE_DEPLOY_STOW
#if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
//#define PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED // For Manual Deploy Allenkey Probe
#endif
/**
* Enable one or more of the following if probing seems unreliable.
* Heaters and/or fans can be disabled during probing to minimize electrical
* noise. A delay can also be added to allow noise and vibration to settle.
* These options are most useful for the BLTouch probe, but may also improve
* readings with inductive probes and piezo sensors.
*/
//#define PROBING_HEATERS_OFF // Turn heaters off when probing
#if ENABLED(PROBING_HEATERS_OFF)
//#define WAIT_FOR_BED_HEATER // Wait for bed to heat back up between probes (to improve accuracy)
#endif
//#define PROBING_FANS_OFF // Turn fans off when probing
//#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing
//#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
// :{ 0:'Low', 1:'High' }
#define X_ENABLE_ON 0
#define Y_ENABLE_ON 0
#define Z_ENABLE_ON 0
#define E_ENABLE_ON 0 // For all extruders
// Disables axis stepper immediately when it's not being used.
// WARNING: When motors turn off there is a chance of losing position accuracy!
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z false
// Warn on display about possibly reduced accuracy
//#define DISABLE_REDUCED_ACCURACY_WARNING
// @section extruder
#define DISABLE_E false // For all extruders
#define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled
// @section machine
// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
#if ANY(U20, U30, U20_PLUS, CUBE2, LK1, LK1_PLUS, LK2, LK4, LK1_PRO, LK4_PRO, LK5_PRO)
#define INVERT_X_DIR true
#define INVERT_Y_DIR false
#define INVERT_Z_DIR true
#elif ENABLED(LK5)
#define INVERT_X_DIR false
#define INVERT_Y_DIR true
#define INVERT_Z_DIR false
#endif
// @section extruder
// For direct drive extruder v9 set to true, for geared extruder set to false.
#if ANY(U20, U30, U20_PLUS, CUBE2, LK1, LK1_PLUS, LK2, LK4, LK1_PRO)
#define INVERT_E0_DIR false
#elif ANY(LK4_PRO, LK5_PRO, LK5)
#define INVERT_E0_DIR true
#endif
#define INVERT_E1_DIR false
#define INVERT_E2_DIR false
#define INVERT_E3_DIR false
#define INVERT_E4_DIR false
#define INVERT_E5_DIR false
#define INVERT_E6_DIR false
#define INVERT_E7_DIR false
// @section homing
//#define NO_MOTION_BEFORE_HOMING // Inhibit movement until all axes have been homed
//#define UNKNOWN_Z_NO_RAISE // Don't raise Z (lower the bed) if Z is "unknown." For beds that fall when Z is powered off.
//#define Z_HOMING_HEIGHT 10 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ...
// Be sure to have this much clearance over your Z_MAX_POS to prevent grinding.
//#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z
// Direction of endstops when homing; 1=MAX, -1=MIN
// :[-1,1]
#define X_HOME_DIR -1
#define Y_HOME_DIR -1
#define Z_HOME_DIR -1
// @section machine
#if ENABLED(CUBE2)
#define X_BED_SIZE 120
#define Y_BED_SIZE 140
#define Z_MACHINE_MAX 105
#elif ANY(U30, LK2, LK4, LK4_PRO)
#define X_BED_SIZE 220
#define Y_BED_SIZE 220
#define Z_MACHINE_MAX 250
#elif ANY(U20, LK1, LK1_PRO, LK5_PRO, LK5)
#define X_BED_SIZE 300
#define Y_BED_SIZE 300
#define Z_MACHINE_MAX 400
#elif ANY(U20_PLUS, LK1_PLUS)
#define X_BED_SIZE 400
#define Y_BED_SIZE 400
#define Z_MACHINE_MAX 500
#endif
// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS Z_MACHINE_MAX
/**
* Software Endstops
*
* - Prevent moves outside the set machine bounds.
* - Individual axes can be disabled, if desired.
* - X and Y only apply to Cartesian robots.
* - Use 'M211' to set software endstops on/off or report current state
*/
// Min software endstops constrain movement within minimum coordinate bounds
#define MIN_SOFTWARE_ENDSTOPS
#if ENABLED(MIN_SOFTWARE_ENDSTOPS)
#define MIN_SOFTWARE_ENDSTOP_X
#define MIN_SOFTWARE_ENDSTOP_Y
#define MIN_SOFTWARE_ENDSTOP_Z
#endif
// Max software endstops constrain movement within maximum coordinate bounds
#define MAX_SOFTWARE_ENDSTOPS
#if ENABLED(MAX_SOFTWARE_ENDSTOPS)
#define MAX_SOFTWARE_ENDSTOP_X
#define MAX_SOFTWARE_ENDSTOP_Y
#define MAX_SOFTWARE_ENDSTOP_Z
#endif
#if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
//#define SOFT_ENDSTOPS_MENU_ITEM // Enable/Disable software endstops from the LCD
#endif
/**
* Filament Runout Sensors
* Mechanical or opto endstops are used to check for the presence of filament.
*
* RAMPS-based boards use SERVO3_PIN for the first runout sensor.
* For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc.
* By default the firmware assumes HIGH=FILAMENT PRESENT.
*/
#define FILAMENT_RUNOUT_SENSOR
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
#define FIL_RUNOUT_INVERTING true // Set to true to invert the logic of the sensor.
//#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
//#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins.
// Set one or more commands to execute on filament runout.
// (After 'M412 H' Marlin will ask the host to handle the process.)
#if ENABLED(LGT_LCD_DW)
#define FILAMENT_RUNOUT_SCRIPT "M25\nM2003"
#elif ENABLED(LK5)
#define FILAMENT_RUNOUT_SCRIPT "M25 P\nM24"
#else
#define FILAMENT_RUNOUT_SCRIPT "M25"
#endif
// After a runout is detected, continue printing this length of filament
// before executing the runout script. Useful for a sensor at the end of
// a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead.
//#define FILAMENT_RUNOUT_DISTANCE_MM 25
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
// Enable this option to use an encoder disc that toggles the runout pin
// as the filament moves. (Be sure to set FILAMENT_RUNOUT_DISTANCE_MM
// large enough to avoid false positives.)
//#define FILAMENT_MOTION_SENSOR
#endif
#endif
//===========================================================================
//=============================== Bed Leveling ==============================
//===========================================================================
// @section calibrate
/**
* Choose one of the options below to enable G29 Bed Leveling. The parameters
* and behavior of G29 will change depending on your selection.
*
* If using a Probe for Z Homing, enable Z_SAFE_HOMING also!
*
* - AUTO_BED_LEVELING_3POINT
* Probe 3 arbitrary points on the bed (that aren't collinear)
* You specify the XY coordinates of all 3 points.
* The result is a single tilted plane. Best for a flat bed.
*
* - AUTO_BED_LEVELING_LINEAR
* Probe several points in a grid.
* You specify the rectangle and the density of sample points.
* The result is a single tilted plane. Best for a flat bed.
*
* - AUTO_BED_LEVELING_BILINEAR
* Probe several points in a grid.
* You specify the rectangle and the density of sample points.
* The result is a mesh, best for large or uneven beds.
*
* - AUTO_BED_LEVELING_UBL (Unified Bed Leveling)
* A comprehensive bed leveling system combining the features and benefits
* of other systems. UBL also includes integrated Mesh Generation, Mesh
* Validation and Mesh Editing systems.
*
* - MESH_BED_LEVELING
* Probe a grid manually
* The result is a mesh, suitable for large or uneven beds. (See BILINEAR.)
* For machines without a probe, Mesh Bed Leveling provides a method to perform
* leveling in steps so you can manually adjust the Z height at each grid-point.
* With an LCD controller the process is guided step-by-step.
*/
//#define AUTO_BED_LEVELING_3POINT
//#define AUTO_BED_LEVELING_LINEAR
// #define AUTO_BED_LEVELING_BILINEAR
//#define AUTO_BED_LEVELING_UBL
//#define MESH_BED_LEVELING
/**
* Normally G28 leaves leveling disabled on completion. Enable
* this option to have G28 restore the prior leveling state.
* If false, use M420 S1 after G28 in your slicer print start gcode
*/
#define RESTORE_LEVELING_AFTER_G28 false
/**
* Enable detailed logging of G28, G29, M48, etc.
* Turn on with the command 'M111 S32'.
* NOTE: Requires a lot of PROGMEM!
*/
//#define DEBUG_LEVELING_FEATURE
#if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL)
// Gradually reduce leveling correction until a set height is reached,
// at which point movement will be level to the machine's XY plane.
// The height can be set with M420 Z<height>
#define ENABLE_LEVELING_FADE_HEIGHT
// For Cartesian machines, instead of dividing moves on mesh boundaries,
// split up moves into short segments like a Delta. This follows the
// contours of the bed more closely than edge-to-edge straight moves.
#define SEGMENT_LEVELED_MOVES
#define LEVELED_SEGMENT_LENGTH 5.0 // (mm) Length of all segments (except the last one)
/**
* Enable the G26 Mesh Validation Pattern tool.
*/
//#define G26_MESH_VALIDATION
#if ENABLED(G26_MESH_VALIDATION)
#define MESH_TEST_NOZZLE_SIZE 0.4 // (mm) Diameter of primary nozzle.
#define MESH_TEST_LAYER_HEIGHT 0.2 // (mm) Default layer height for the G26 Mesh Validation Tool.
#define MESH_TEST_HOTEND_TEMP 205 // (°C) Default nozzle temperature for the G26 Mesh Validation Tool.
#define MESH_TEST_BED_TEMP 60 // (°C) Default bed temperature for the G26 Mesh Validation Tool.
#define G26_XY_FEEDRATE 20 // (mm/s) Feedrate for XY Moves for the G26 Mesh Validation Tool.
#define G26_RETRACT_MULTIPLIER 1.0 // G26 Q (retraction) used by default between mesh test elements.
#endif
#endif
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
// Set the number of grid points per dimension.
#define GRID_MAX_POINTS_X 4
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
// Probe along the Y axis, advancing X after each column
//#define PROBE_Y_FIRST
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
// Beyond the probed grid, continue the implied tilt?
// Default is to maintain the height of the nearest edge.
//#define EXTRAPOLATE_BEYOND_GRID
//
// Experimental Subdivision of the grid by Catmull-Rom method.
// Synthesizes intermediate points to produce a more detailed mesh.
//
//#define ABL_BILINEAR_SUBDIVISION
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
// Number of subdivisions between probe points
#define BILINEAR_SUBDIVISIONS 3
#endif
#endif
#elif ENABLED(AUTO_BED_LEVELING_UBL)
//===========================================================================
//========================= Unified Bed Leveling ============================
//===========================================================================
//#define MESH_EDIT_GFX_OVERLAY // Display a graphics overlay while editing the mesh
#define MESH_INSET 5 // Set Mesh bounds as an inset region of the bed
#define GRID_MAX_POINTS_X 5 // Don't use more than 15 points per axis, implementation limited.
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
#define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle
#define UBL_SAVE_ACTIVE_ON_M500 // Save the currently active mesh in the current slot on M500
//#define UBL_Z_RAISE_WHEN_OFF_MESH 2.5 // When the nozzle is off the mesh, this value is used
// as the Z-Height correction value.
#elif ENABLED(MESH_BED_LEVELING)
//===========================================================================
//=================================== Mesh ==================================
//===========================================================================
#define MESH_INSET 10 // Set Mesh bounds as an inset region of the bed
#define GRID_MAX_POINTS_X 3 // Don't use more than 7 points per axis, implementation limited.
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
#endif // BED_LEVELING
/**
* Add a bed leveling sub-menu for ABL or MBL.
* Include a guided procedure if manual probing is enabled.
*/
//#define LCD_BED_LEVELING
#if ENABLED(LCD_BED_LEVELING)
#define MESH_EDIT_Z_STEP 0.025 // (mm) Step size while manually probing Z axis.
#define LCD_PROBE_Z_RANGE 4 // (mm) Z Range centered on Z_MIN_POS for LCD Z adjustment
//#define MESH_EDIT_MENU // Add a menu to edit mesh points
#endif
// Add a menu item to move between bed corners for manual bed adjustment
#define LEVEL_BED_CORNERS
#if ENABLED(LEVEL_BED_CORNERS)
#define LEVEL_CORNERS_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets
#define LEVEL_CORNERS_HEIGHT 0.2 // (mm) Z height of nozzle at leveling points
#define LEVEL_CORNERS_Z_HOP 4.0 // (mm) Z height of nozzle between leveling points
//#define LEVEL_CENTER_TOO // Move to the center after the last corner
#endif
/**
* Commands to execute at the end of G29 probing.
* Useful to retract or move the Z probe out of the way.
*/
//#define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10"
// @section homing
// The center of the bed is at (X=0, Y=0)
//#define BED_CENTER_AT_0_0
// Manually set the home position. Leave these undefined for automatic settings.
// For DELTA this is the top-center of the Cartesian print volume.
//#define MANUAL_X_HOME_POS 0
//#define MANUAL_Y_HOME_POS 0
//#define MANUAL_Z_HOME_POS 0
// Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area.
//
// With this feature enabled:
//
// - Allow Z homing only after X and Y homing AND stepper drivers still enabled.
// - If stepper drivers time out, it will need X and Y homing again before Z homing.
// - Move the Z probe (or nozzle) to a defined XY point before Z Homing when homing all axes (G28).
// - Prevent Z homing when the Z probe is outside bed area.
//
//#define Z_SAFE_HOMING
#if ENABLED(Z_SAFE_HOMING)
#define Z_SAFE_HOMING_X_POINT ((X_BED_SIZE) / 2) // X point for Z homing when homing all axes (G28).
//#define Z_SAFE_HOMING_Y_POINT ((Y_BED_SIZE) / 2) // Y point for Z homing when homing all axes (G28).
#define Z_SAFE_HOMING_Y_POINT 4
#endif
// Homing speeds (mm/m)
#define HOMING_FEEDRATE_XY (40*60)
#define HOMING_FEEDRATE_Z (4*60)
// Validate that endstops are triggered on homing moves
#define VALIDATE_HOMING_ENDSTOPS
// @section calibrate
/**
* Bed Skew Compensation
*
* This feature corrects for misalignment in the XYZ axes.
*
* Take the following steps to get the bed skew in the XY plane:
* 1. Print a test square (e.g., https://www.thingiverse.com/thing:2563185)
* 2. For XY_DIAG_AC measure the diagonal A to C
* 3. For XY_DIAG_BD measure the diagonal B to D
* 4. For XY_SIDE_AD measure the edge A to D
*
* Marlin automatically computes skew factors from these measurements.
* Skew factors may also be computed and set manually:
*
* - Compute AB : SQRT(2*AC*AC+2*BD*BD-4*AD*AD)/2
* - XY_SKEW_FACTOR : TAN(PI/2-ACOS((AC*AC-AB*AB-AD*AD)/(2*AB*AD)))
*
* If desired, follow the same procedure for XZ and YZ.
* Use these diagrams for reference:
*
* Y Z Z
* ^ B-------C ^ B-------C ^ B-------C
* | / / | / / | / /
* | / / | / / | / /
* | A-------D | A-------D | A-------D
* +-------------->X +-------------->X +-------------->Y
* XY_SKEW_FACTOR XZ_SKEW_FACTOR YZ_SKEW_FACTOR
*/
//#define SKEW_CORRECTION
#if ENABLED(SKEW_CORRECTION)
// Input all length measurements here:
#define XY_DIAG_AC 282.8427124746
#define XY_DIAG_BD 282.8427124746
#define XY_SIDE_AD 200
// Or, set the default skew factors directly here
// to override the above measurements:
#define XY_SKEW_FACTOR 0.0
//#define SKEW_CORRECTION_FOR_Z
#if ENABLED(SKEW_CORRECTION_FOR_Z)
#define XZ_DIAG_AC 282.8427124746
#define XZ_DIAG_BD 282.8427124746
#define YZ_DIAG_AC 282.8427124746
#define YZ_DIAG_BD 282.8427124746
#define YZ_SIDE_AD 200
#define XZ_SKEW_FACTOR 0.0
#define YZ_SKEW_FACTOR 0.0
#endif
// Enable this option for M852 to set skew at runtime
//#define SKEW_CORRECTION_GCODE
#endif
//=============================================================================
//============================= Additional Features ===========================
//=============================================================================
// @section extras
/**
* EEPROM
*
* Persistent storage to preserve configurable settings across reboots.
*
* M500 - Store settings to EEPROM.
* M501 - Read settings from EEPROM. (i.e., Throw away unsaved changes)
* M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.)
*/
#define EEPROM_SETTINGS // Persistent storage with M500 and M501
//#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release!
#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM.
#if ENABLED(EEPROM_SETTINGS)
//#define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors.
#endif
//
// Host Keepalive
//
// When enabled Marlin will send a busy status message to the host
// every couple of seconds when it can't accept commands.
//
#define HOST_KEEPALIVE_FEATURE // Disable this if your host doesn't like keepalive messages
#define DEFAULT_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113.
#define BUSY_WHILE_HEATING // Some hosts require "busy" messages even during heating
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants
#define PREHEAT_1_LABEL "PLA"
#define PREHEAT_1_TEMP_HOTEND 200
#define PREHEAT_1_TEMP_BED 60
#define PREHEAT_1_FAN_SPEED 0 // Value from 0 to 255
#define PREHEAT_2_LABEL "ABS"
#define PREHEAT_2_TEMP_HOTEND 230
#define PREHEAT_2_TEMP_BED 80
#define PREHEAT_2_FAN_SPEED 0 // Value from 0 to 255
/**
* Nozzle Park
*
* Park the nozzle at the given XYZ position on idle or G27.
*
* The "P" parameter controls the action applied to the Z axis:
*
* P0 (Default) If Z is below park Z raise the nozzle.
* P1 Raise the nozzle always to Z-park height.
* P2 Raise the nozzle by Z-park amount, limited to Z_MAX_POS.
*/
#define NOZZLE_PARK_FEATURE
#if ENABLED(NOZZLE_PARK_FEATURE)
// Specify a park position as { X, Y, Z_raise }
#define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MAX_POS - 10), 20 }
#define NOZZLE_PARK_XY_FEEDRATE 100 // (mm/s) X and Y axes feedrate (also used for delta Z axis)
#define NOZZLE_PARK_Z_FEEDRATE 5 // (mm/s) Z axis feedrate (not used for delta printers)
#endif
/**
* Clean Nozzle Feature -- EXPERIMENTAL
*
* Adds the G12 command to perform a nozzle cleaning process.
*
* Parameters:
* P Pattern
* S Strokes / Repetitions
* T Triangles (P1 only)
*
* Patterns:
* P0 Straight line (default). This process requires a sponge type material
* at a fixed bed location. "S" specifies strokes (i.e. back-forth motions)
* between the start / end points.
*
* P1 Zig-zag pattern between (X0, Y0) and (X1, Y1), "T" specifies the
* number of zig-zag triangles to do. "S" defines the number of strokes.
* Zig-zags are done in whichever is the narrower dimension.
* For example, "G12 P1 S1 T3" will execute:
*
* --
* | (X0, Y1) | /\ /\ /\ | (X1, Y1)
* | | / \ / \ / \ |
* A | | / \ / \ / \ |
* | | / \ / \ / \ |
* | (X0, Y0) | / \/ \/ \ | (X1, Y0)
* -- +--------------------------------+
* |________|_________|_________|
* T1 T2 T3
*
* P2 Circular pattern with middle at NOZZLE_CLEAN_CIRCLE_MIDDLE.
* "R" specifies the radius. "S" specifies the stroke count.
* Before starting, the nozzle moves to NOZZLE_CLEAN_START_POINT.
*
* Caveats: The ending Z should be the same as starting Z.
* Attention: EXPERIMENTAL. G-code arguments may change.
*
*/
//#define NOZZLE_CLEAN_FEATURE
#if ENABLED(NOZZLE_CLEAN_FEATURE)
// Default number of pattern repetitions
#define NOZZLE_CLEAN_STROKES 12
// Default number of triangles
#define NOZZLE_CLEAN_TRIANGLES 3
// Specify positions for each tool as { { X, Y, Z }, { X, Y, Z } }
// Dual hotend system may use { { -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { 420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }}
#define NOZZLE_CLEAN_START_POINT { { 30, 30, (Z_MIN_POS + 1) } }
#define NOZZLE_CLEAN_END_POINT { { 100, 60, (Z_MIN_POS + 1) } }
// Circular pattern radius
#define NOZZLE_CLEAN_CIRCLE_RADIUS 6.5
// Circular pattern circle fragments number
#define NOZZLE_CLEAN_CIRCLE_FN 10
// Middle point of circle
#define NOZZLE_CLEAN_CIRCLE_MIDDLE NOZZLE_CLEAN_START_POINT
// Move the nozzle to the initial position after cleaning
#define NOZZLE_CLEAN_GOBACK
// Enable for a purge/clean station that's always at the gantry height (thus no Z move)
//#define NOZZLE_CLEAN_NO_Z
#endif
/**
* Print Job Timer
*
* Automatically start and stop the print job timer on M104/M109/M190.
*
* M104 (hotend, no wait) - high temp = none, low temp = stop timer
* M109 (hotend, wait) - high temp = start timer, low temp = stop timer
* M190 (bed, wait) - high temp = start timer, low temp = none
*
* The timer can also be controlled with the following commands:
*
* M75 - Start the print job timer
* M76 - Pause the print job timer
* M77 - Stop the print job timer
*/
#define PRINTJOB_TIMER_AUTOSTART
/**
* Print Counter
*
* Track statistical data such as:
*
* - Total print jobs
* - Total successful print jobs
* - Total failed print jobs
* - Total time printing
*
* View the current statistics with M78.
*/
//#define PRINTCOUNTER
//=============================================================================
//============================= LCD and SD support ============================
//=============================================================================
// @section lcd
/**
* LCD LANGUAGE
*
* Select the language to display on the LCD. These languages are available:
*
* en, an, bg, ca, cz, da, de, el, el_gr, es, eu, fi, fr, gl, hr, it, jp_kana,
* ko_KR, nl, pl, pt, pt_br, ru, sk, tr, uk, vi, zh_CN, zh_TW, test
*
* :{ 'en':'English', 'an':'Aragonese', 'bg':'Bulgarian', 'ca':'Catalan', 'cz':'Czech', 'da':'Danish', 'de':'German', 'el':'Greek', 'el_gr':'Greek (Greece)', 'es':'Spanish', 'eu':'Basque-Euskera', 'fi':'Finnish', 'fr':'French', 'gl':'Galician', 'hr':'Croatian', 'it':'Italian', 'jp_kana':'Japanese', 'ko_KR':'Korean (South Korea)', 'nl':'Dutch', 'pl':'Polish', 'pt':'Portuguese', 'pt_br':'Portuguese (Brazilian)', 'ru':'Russian', 'sk':'Slovak', 'tr':'Turkish', 'uk':'Ukrainian', 'vi':'Vietnamese', 'zh_CN':'Chinese (Simplified)', 'zh_TW':'Chinese (Traditional)', 'test':'TEST' }
*/
#define LCD_LANGUAGE en
/**
* LCD Character Set
*
* Note: This option is NOT applicable to Graphical Displays.
*
* All character-based LCDs provide ASCII plus one of these
* language extensions:
*
* - JAPANESE ... the most common
* - WESTERN ... with more accented characters
* - CYRILLIC ... for the Russian language
*
* To determine the language extension installed on your controller:
*
* - Compile and upload with LCD_LANGUAGE set to 'test'
* - Click the controller to view the LCD menu
* - The LCD will display Japanese, Western, or Cyrillic text
*
* See http://marlinfw.org/docs/development/lcd_language.html
*
* :['JAPANESE', 'WESTERN', 'CYRILLIC']
*/
#define DISPLAY_CHARSET_HD44780 JAPANESE
/**
* Info Screen Style (0:Classic, 1:Prusa)
*
* :[0:'Classic', 1:'Prusa']
*/
#define LCD_INFO_SCREEN_STYLE 0
/**
* SD CARD
*
* SD Card support is disabled by default. If your controller has an SD slot,
* you must uncomment the following option or it won't work.
*
*/
#define SDSUPPORT
/**
* SD CARD: SPI SPEED
*
* Enable one of the following items for a slower SPI transfer speed.
* This may be required to resolve "volume init" errors.
*/
//#define SPI_SPEED SPI_HALF_SPEED
//#define SPI_SPEED SPI_QUARTER_SPEED
//#define SPI_SPEED SPI_EIGHTH_SPEED
/**
* SD CARD: ENABLE CRC
*
* Use CRC checks and retries on the SD communication.
*/
//#define SD_CHECK_AND_RETRY
/**
* LCD Menu Items
*
* Disable all menus and only display the Status Screen, or
* just remove some extraneous menu items to recover space.
*/
//#define NO_LCD_MENUS
//#define SLIM_LCD_MENUS
//
// ENCODER SETTINGS
//
// This option overrides the default number of encoder pulses needed to
// produce one step. Should be increased for high-resolution encoders.
//
//#define ENCODER_PULSES_PER_STEP 4
//
// Use this option to override the number of step signals required to
// move between next/prev menu items.
//
//#define ENCODER_STEPS_PER_MENU_ITEM 1
/**
* Encoder Direction Options
*
* Test your encoder's behavior first with both options disabled.
*
* Reversed Value Edit and Menu Nav? Enable REVERSE_ENCODER_DIRECTION.
* Reversed Menu Navigation only? Enable REVERSE_MENU_DIRECTION.
* Reversed Value Editing only? Enable BOTH options.
*/
//
// This option reverses the encoder direction everywhere.
//
// Set this option if CLOCKWISE causes values to DECREASE
//
//#define REVERSE_ENCODER_DIRECTION
//
// This option reverses the encoder direction for navigating LCD menus.
//
// If CLOCKWISE normally moves DOWN this makes it go UP.
// If CLOCKWISE normally moves UP this makes it go DOWN.
//
//#define REVERSE_MENU_DIRECTION
//
// This option reverses the encoder direction for Select Screen.
//
// If CLOCKWISE normally moves LEFT this makes it go RIGHT.
// If CLOCKWISE normally moves RIGHT this makes it go LEFT.
//
//#define REVERSE_SELECT_DIRECTION
//
// Individual Axis Homing
//
// Add individual axis homing items (Home X, Home Y, and Home Z) to the LCD menu.
//
#define INDIVIDUAL_AXIS_HOMING_MENU
//
// SPEAKER/BUZZER
//
// If you have a speaker that can produce tones, enable it here.
// By default Marlin assumes you have a buzzer with a fixed frequency.
//
//#define SPEAKER
//
// The duration and frequency for the UI feedback sound.
// Set these to 0 to disable audio feedback in the LCD menus.
//
// Note: Test audio output with the G-Code:
// M300 S<frequency Hz> P<duration ms>
//
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 250
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000
//=============================================================================
//======================== LCD / Controller Selection =========================
//======================== (Character-based LCDs) =========================
//=============================================================================
//
// RepRapDiscount Smart Controller.
// http://reprap.org/wiki/RepRapDiscount_Smart_Controller
//
// Note: Usually sold with a white PCB.
//
//#define REPRAP_DISCOUNT_SMART_CONTROLLER
//
// Original RADDS LCD Display+Encoder+SDCardReader
// http://doku.radds.org/dokumentation/lcd-display/
//
//#define RADDS_DISPLAY
//
// ULTIMAKER Controller.
//
//#define ULTIMAKERCONTROLLER
//
// ULTIPANEL as seen on Thingiverse.
//
//#define ULTIPANEL
//
// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
// http://reprap.org/wiki/PanelOne
//
//#define PANEL_ONE
//
// GADGETS3D G3D LCD/SD Controller
// http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel
//
// Note: Usually sold with a blue PCB.
//
//#define G3D_PANEL
//
// RigidBot Panel V1.0
// http://www.inventapart.com/
//
//#define RIGIDBOT_PANEL
//
// Makeboard 3D Printer Parts 3D Printer Mini Display 1602 Mini Controller
// https://www.aliexpress.com/item/32765887917.html
//
//#define MAKEBOARD_MINI_2_LINE_DISPLAY_1602
//
// ANET and Tronxy 20x4 Controller
//
//#define ZONESTAR_LCD // Requires ADC_KEYPAD_PIN to be assigned to an analog pin.
// This LCD is known to be susceptible to electrical interference
// which scrambles the display. Pressing any button clears it up.
// This is a LCD2004 display with 5 analog buttons.
//
// Generic 16x2, 16x4, 20x2, or 20x4 character-based LCD.
//
//#define ULTRA_LCD
//=============================================================================
//======================== LCD / Controller Selection =========================
//===================== (I2C and Shift-Register LCDs) =====================
//=============================================================================
//
// CONTROLLER TYPE: I2C
//
// Note: These controllers require the installation of Arduino's LiquidCrystal_I2C
// library. For more info: https://github.com/kiyoshigawa/LiquidCrystal_I2C
//
//
// Elefu RA Board Control Panel
// http://www.elefu.com/index.php?route=product/product&product_id=53
//
//#define RA_CONTROL_PANEL
//
// Sainsmart (YwRobot) LCD Displays
//
// These require F.Malpartida's LiquidCrystal_I2C library
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
//
//#define LCD_SAINSMART_I2C_1602
//#define LCD_SAINSMART_I2C_2004
//
// Generic LCM1602 LCD adapter
//
//#define LCM1602
//
// PANELOLU2 LCD with status LEDs,
// separate encoder and click inputs.
//
// Note: This controller requires Arduino's LiquidTWI2 library v1.2.3 or later.
// For more info: https://github.com/lincomatic/LiquidTWI2
//
// Note: The PANELOLU2 encoder click input can either be directly connected to
// a pin (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1).
//
//#define LCD_I2C_PANELOLU2
//
// Panucatt VIKI LCD with status LEDs,
// integrated click & L/R/U/D buttons, separate encoder inputs.
//
//#define LCD_I2C_VIKI
//
// CONTROLLER TYPE: Shift register panels
//
//
// 2-wire Non-latching LCD SR from https://goo.gl/aJJ4sH
// LCD configuration: http://reprap.org/wiki/SAV_3D_LCD
//
//#define SAV_3DLCD
//
// 3-wire SR LCD with strobe using 74HC4094
// https://github.com/mikeshub/SailfishLCD
// Uses the code directly from Sailfish
//
//#define FF_INTERFACEBOARD
//=============================================================================
//======================= LCD / Controller Selection =======================
//========================= (Graphical LCDs) ========================
//=============================================================================
//
// CONTROLLER TYPE: Graphical 128x64 (DOGM)
//
// IMPORTANT: The U8glib library is required for Graphical Display!
// https://github.com/olikraus/U8glib_Arduino
//
//
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//
// ReprapWorld Graphical LCD
// https://reprapworld.com/?products_details&products_id/1218
//
//#define REPRAPWORLD_GRAPHICAL_LCD
//
// Activate one of these if you have a Panucatt Devices
// Viki 2.0 or mini Viki with Graphic LCD
// http://panucatt.com
//
//#define VIKI2
//#define miniVIKI
//
// MakerLab Mini Panel with graphic
// controller and SD support - http://reprap.org/wiki/Mini_panel
//
//#define MINIPANEL
//
// MaKr3d Makr-Panel with graphic controller and SD support.
// http://reprap.org/wiki/MaKr3d_MaKrPanel
//
//#define MAKRPANEL
//
// Adafruit ST7565 Full Graphic Controller.
// https://github.com/eboston/Adafruit-ST7565-Full-Graphic-Controller/
//
//#define ELB_FULL_GRAPHIC_CONTROLLER
//
// BQ LCD Smart Controller shipped by
// default with the BQ Hephestos 2 and Witbox 2.
//
//#define BQ_LCD_SMART_CONTROLLER
//
// Cartesio UI
// http://mauk.cc/webshop/cartesio-shop/electronics/user-interface
//
//#define CARTESIO_UI
//
// LCD for Melzi Card with Graphical LCD
//
//#define LCD_FOR_MELZI
//
// Original Ulticontroller from Ultimaker 2 printer with SSD1309 I2C display and encoder
// https://github.com/Ultimaker/Ultimaker2/tree/master/1249_Ulticontroller_Board_(x1)
//
//#define ULTI_CONTROLLER
//
// MKS MINI12864 with graphic controller and SD support
// https://reprap.org/wiki/MKS_MINI_12864
//
//#define MKS_MINI_12864
//
// FYSETC variant of the MINI12864 graphic controller with SD support
// https://wiki.fysetc.com/Mini12864_Panel/
//
//#define FYSETC_MINI_12864_X_X // Type C/D/E/F. No tunable RGB Backlight by default
//#define FYSETC_MINI_12864_1_2 // Type C/D/E/F. Simple RGB Backlight (always on)
//#define FYSETC_MINI_12864_2_0 // Type A/B. Discreet RGB Backlight
//#define FYSETC_MINI_12864_2_1 // Type A/B. Neopixel RGB Backlight
//#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight.
//
// Factory display for Creality CR-10
// https://www.aliexpress.com/item/32833148327.html
//
// This is RAMPS-compatible using a single 10-pin connector.
// (For CR-10 owners who want to replace the Melzi Creality board but retain the display)
//
//#define CR10_STOCKDISPLAY
//
// Ender-2 OEM display, a variant of the MKS_MINI_12864
//
//#define ENDER2_STOCKDISPLAY
//
// ANET and Tronxy Graphical Controller
//
// Anet 128x64 full graphics lcd with rotary encoder as used on Anet A6
// A clone of the RepRapDiscount full graphics display but with
// different pins/wiring (see pins_ANET_10.h).
//
//#define ANET_FULL_GRAPHICS_LCD
//
// AZSMZ 12864 LCD with SD
// https://www.aliexpress.com/item/32837222770.html
//
//#define AZSMZ_12864
//
// Silvergate GLCD controller
// http://github.com/android444/Silvergate
//
//#define SILVER_GATE_GLCD_CONTROLLER
//=============================================================================
//============================== OLED Displays ==============================
//=============================================================================
//
// SSD1306 OLED full graphics generic display
//
//#define U8GLIB_SSD1306
//
// SAV OLEd LCD module support using either SSD1306 or SH1106 based LCD modules
//
//#define SAV_3DGLCD
#if ENABLED(SAV_3DGLCD)
#define U8GLIB_SSD1306
//#define U8GLIB_SH1106
#endif
//
// TinyBoy2 128x64 OLED / Encoder Panel
//
//#define OLED_PANEL_TINYBOY2
//
// MKS OLED 1.3" 128 × 64 FULL GRAPHICS CONTROLLER
// http://reprap.org/wiki/MKS_12864OLED
//
// Tiny, but very sharp OLED display
//
//#define MKS_12864OLED // Uses the SH1106 controller (default)
//#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller
//
// Einstart S OLED SSD1306
//
//#define U8GLIB_SH1106_EINSTART
//
// Overlord OLED display/controller with i2c buzzer and LEDs
//
//#define OVERLORD_OLED
//=============================================================================
//========================== Extensible UI Displays ===========================
//=============================================================================
//
// DGUS Touch Display with DWIN OS. (Choose one.)
//
//#define DGUS_LCD_UI_ORIGIN
//#define DGUS_LCD_UI_FYSETC
//#define DGUS_LCD_UI_HIPRECY
//
// Touch-screen LCD for Malyan M200 printers
//
//#define MALYAN_LCD
//
// Touch UI for FTDI EVE (FT800/FT810) displays
// See Configuration_adv.h for all configuration options.
//
//#define TOUCH_UI_FTDI_EVE
//
// Third-party or vendor-customized controller interfaces.
// Sources should be installed in 'src/lcd/extensible_ui'.
//
//#define EXTENSIBLE_UI
//=============================================================================
//=============================== Graphical TFTs ==============================
//=============================================================================
//
// FSMC display (MKS Robin, Alfawise U20, JGAurora A5S, REXYZ A1, etc.)
//
// #define FSMC_GRAPHICAL_TFT
//=============================================================================
//============================ Other Controllers ============================
//=============================================================================
//
// ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
//
// #define TOUCH_BUTTONS
#if ENABLED(TOUCH_BUTTONS)
#define TOUCH_CALIBRATION // Include user calibration widget in menus (Alfawise)
#define BUTTON_DELAY_EDIT 75 // (ms) Button repeat delay for edit screens
#define BUTTON_DELAY_MENU 100 // (ms) Button repeat delay for menus
#if ENABLED(TS_V11)
// Alfawise U20 ILI9341 2.8 TP Ver 1.1 / Green PCB on the back of touchscreen
#define XPT2046_X_CALIBRATION 12000
#define XPT2046_Y_CALIBRATION 9000
#define XPT2046_X_OFFSET -24
#define XPT2046_Y_OFFSET -17
#endif
#if ENABLED(TS_V12)
// Alfawise U30 ILI9341 2.8 TP Ver 1.2 / Blue PCB on the back of touchscreen
#define XPT2046_X_CALIBRATION 12000
#define XPT2046_Y_CALIBRATION -9000
#define XPT2046_X_OFFSET -43
#define XPT2046_Y_OFFSET 257
#endif
#if ENABLED(TS_V19)
// Longer LK4/U30 2.8" Ver 2019 / Blue PCB, SID240x320-8PCB-D
#define XPT2046_X_CALIBRATION -12000
#define XPT2046_Y_CALIBRATION 9000
#define XPT2046_X_OFFSET 320
#define XPT2046_Y_OFFSET 0
#endif
#if ENABLED(TS_V20)
// 2020 feixinda clone std SID240x320-8PCB-D
#define XPT2046_X_CALIBRATION -11760
#define XPT2046_Y_CALIBRATION 8680
#define XPT2046_X_OFFSET 334
#define XPT2046_Y_OFFSET -14
#endif
#endif
//
// RepRapWorld REPRAPWORLD_KEYPAD v1.1
// http://reprapworld.com/?products_details&products_id=202&cPath=1591_1626
//
//#define REPRAPWORLD_KEYPAD
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
//=============================================================================
//=============================== Extra Features ==============================
//=============================================================================
// @section extras
// Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino
//#define FAST_PWM_FAN
// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
// which is not as annoying as with the hardware PWM. On the other hand, if this frequency
// is too low, you should also increment SOFT_PWM_SCALE.
#define FAN_SOFT_PWM
// Incrementing this by 1 will double the software PWM frequency,
// affecting heaters, and the fan if FAN_SOFT_PWM is enabled.
// However, control resolution will be halved for each increment;
// at zero value, there are 128 effective control positions.
// :[0,1,2,3,4,5,6,7]
#define SOFT_PWM_SCALE 0
// If SOFT_PWM_SCALE is set to a value higher than 0, dithering can
// be used to mitigate the associated resolution loss. If enabled,
// some of the PWM cycles are stretched so on average the desired
// duty cycle is attained.
//#define SOFT_PWM_DITHER
// Temperature status LEDs that display the hotend and bed temperature.
// If all hotends, bed temperature, and target temperature are under 54C
// then the BLUE led is on. Otherwise the RED led is on. (1C hysteresis)
//#define TEMP_STAT_LEDS
// SkeinForge sends the wrong arc g-codes when using Arc Point as fillet procedure
//#define SF_ARC_FIX
// Support for the BariCUDA Paste Extruder
//#define BARICUDA
// Support for BlinkM/CyzRgb
//#define BLINKM
// Support for PCA9632 PWM LED driver
//#define PCA9632
// Support for PCA9533 PWM LED driver
// https://github.com/mikeshub/SailfishRGB_LED
//#define PCA9533
/**
* RGB LED / LED Strip Control
*
* Enable support for an RGB LED connected to 5V digital pins, or
* an RGB Strip connected to MOSFETs controlled by digital pins.
*
* Adds the M150 command to set the LED (or LED strip) color.
* If pins are PWM capable (e.g., 4, 5, 6, 11) then a range of
* luminance values can be set from 0 to 255.
* For Neopixel LED an overall brightness parameter is also available.
*
* *** CAUTION ***
* LED Strips require a MOSFET Chip between PWM lines and LEDs,
* as the Arduino cannot handle the current the LEDs will require.
* Failure to follow this precaution can destroy your Arduino!
* NOTE: A separate 5V power supply is required! The Neopixel LED needs
* more current than the Arduino 5V linear regulator can produce.
* *** CAUTION ***
*
* LED Type. Enable only one of the following two options.
*
*/
//#define RGB_LED
//#define RGBW_LED
#if EITHER(RGB_LED, RGBW_LED)
//#define RGB_LED_R_PIN 34
//#define RGB_LED_G_PIN 43
//#define RGB_LED_B_PIN 35
//#define RGB_LED_W_PIN -1
#endif
// Support for Adafruit Neopixel LED driver
//#define NEOPIXEL_LED
#if ENABLED(NEOPIXEL_LED)
#define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h)
#define NEOPIXEL_PIN 4 // LED driving pin
//#define NEOPIXEL2_TYPE NEOPIXEL_TYPE
//#define NEOPIXEL2_PIN 5
#define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used
#define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.
#define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255)
//#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup
// Use a single Neopixel LED for static (background) lighting
//#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use
//#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W
#endif
/**
* Printer Event LEDs
*
* During printing, the LEDs will reflect the printer status:
*
* - Gradually change from blue to violet as the heated bed gets to target temp
* - Gradually change from violet to red as the hotend gets to temperature
* - Change to white to illuminate work surface
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED)
#define PRINTER_EVENT_LEDS
#endif
/**
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas
*/
/**
* Number of servos
*
* For some servo-related options NUM_SERVOS will be set automatically.
* Set this manually if there are extra servos needing manual control.
* Leave undefined or set to 0 to entirely disable the servo subsystem.
*/
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// (ms) Delay before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY { 300 }
// Only power servos during movement, otherwise leave off to prevent jitter
//#define DEACTIVATE_SERVOS_AFTER_MOVE
// Allow servo angle to be edited and saved to EEPROM
//#define EDITABLE_SERVO_ANGLES
| 88,636
|
C++
|
.h
| 2,104
| 40.014259
| 578
| 0.670554
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,882
|
Configuration_adv.h
|
LONGER3D_Marlin2_0-lgt/Marlin/Configuration_adv.h
|
/**
* 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
/**
* Configuration_adv.h
*
* Advanced settings.
* Only change these if you know exactly what you're doing.
* Some of these settings can damage your printer if improperly set!
*
* Basic settings can be found in Configuration.h
*
*/
#define CONFIGURATION_ADV_H_VERSION 020005
// @section temperature
//===========================================================================
//=============================Thermal Settings ============================
//===========================================================================
//
// Custom Thermistor 1000 parameters
//
#if TEMP_SENSOR_0 == 1000
#define HOTEND0_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND0_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND0_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_1 == 1000
#define HOTEND1_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND1_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND1_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_2 == 1000
#define HOTEND2_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND2_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND2_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_3 == 1000
#define HOTEND3_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND3_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND3_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_4 == 1000
#define HOTEND4_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND4_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND4_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_5 == 1000
#define HOTEND5_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND5_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND5_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_6 == 1000
#define HOTEND6_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND6_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND6_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_7 == 1000
#define HOTEND7_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND7_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND7_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_BED == 1000
#define BED_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define BED_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define BED_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_CHAMBER == 1000
#define CHAMBER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define CHAMBER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define CHAMBER_BETA 3950 // Beta value
#endif
//
// Hephestos 2 24V heated bed upgrade kit.
// https://store.bq.com/en/heated-bed-kit-hephestos2
//
//#define HEPHESTOS2_HEATED_BED_KIT
#if ENABLED(HEPHESTOS2_HEATED_BED_KIT)
#undef TEMP_SENSOR_BED
#define TEMP_SENSOR_BED 70
#define HEATER_BED_INVERTING true
#endif
/**
* Heated Chamber settings
*/
#if TEMP_SENSOR_CHAMBER
#define CHAMBER_MINTEMP 5
#define CHAMBER_MAXTEMP 60
#define TEMP_CHAMBER_HYSTERESIS 1 // (°C) Temperature proximity considered "close enough" to the target
//#define CHAMBER_LIMIT_SWITCHING
//#define HEATER_CHAMBER_PIN 44 // Chamber heater on/off pin
//#define HEATER_CHAMBER_INVERTING false
#endif
#if DISABLED(PIDTEMPBED)
#define BED_CHECK_INTERVAL 5000 // ms between checks in bang-bang control
#if ENABLED(BED_LIMIT_SWITCHING)
#define BED_HYSTERESIS 2 // Only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
#endif
#endif
/**
* Thermal Protection provides additional protection to your printer from damage
* and fire. Marlin always includes safe min and max temperature ranges which
* protect against a broken or disconnected thermistor wire.
*
* The issue: If a thermistor falls out, it will report the much lower
* temperature of the air in the room, and the the firmware will keep
* the heater on.
*
* The solution: Once the temperature reaches the target, start observing.
* If the temperature stays too far below the target (hysteresis) for too
* long (period), the firmware will halt the machine as a safety precaution.
*
* If you get false positives for "Thermal Runaway", increase
* THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD
*/
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#define THERMAL_PROTECTION_PERIOD 60 // Seconds
#define THERMAL_PROTECTION_HYSTERESIS 10 // Degrees Celsius
//#define ADAPTIVE_FAN_SLOWING // Slow part cooling fan if temperature drops
#if BOTH(ADAPTIVE_FAN_SLOWING, PIDTEMP)
//#define NO_FAN_SLOWING_IN_PID_TUNING // Don't slow fan speed during M303
#endif
/**
* Whenever an M104, M109, or M303 increases the target temperature, the
* firmware will wait for the WATCH_TEMP_PERIOD to expire. If the temperature
* hasn't increased by WATCH_TEMP_INCREASE degrees, the machine is halted and
* requires a hard reset. This test restarts with any M104/M109/M303, but only
* if the current temperature is far enough below the target for a reliable
* test.
*
* If you get false positives for "Heating failed", increase WATCH_TEMP_PERIOD
* and/or decrease WATCH_TEMP_INCREASE. WATCH_TEMP_INCREASE should not be set
* below 2.
*/
#define WATCH_TEMP_PERIOD 60 // Seconds
#define WATCH_TEMP_INCREASE 2 // Degrees Celsius
#endif
/**
* Thermal Protection parameters for the bed are just as above for hotends.
*/
#if ENABLED(THERMAL_PROTECTION_BED)
#define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds
#define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius
/**
* As described above, except for the bed (M140/M190/M303).
*/
#define WATCH_BED_TEMP_PERIOD 120 // Seconds
#define WATCH_BED_TEMP_INCREASE 2 // Degrees Celsius
#endif
/**
* Thermal Protection parameters for the heated chamber.
*/
#if ENABLED(THERMAL_PROTECTION_CHAMBER)
#define THERMAL_PROTECTION_CHAMBER_PERIOD 20 // Seconds
#define THERMAL_PROTECTION_CHAMBER_HYSTERESIS 2 // Degrees Celsius
/**
* Heated chamber watch settings (M141/M191).
*/
#define WATCH_CHAMBER_TEMP_PERIOD 60 // Seconds
#define WATCH_CHAMBER_TEMP_INCREASE 2 // Degrees Celsius
#endif
#if ENABLED(PIDTEMP)
// Add an experimental additional term to the heater power, proportional to the extrusion speed.
// A well-chosen Kc value should add just enough power to melt the increased material volume.
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif
/**
* Add an experimental additional term to the heater power, proportional to the fan speed.
* A well-chosen Kf value should add just enough power to compensate for power-loss from the cooling fan.
* You can either just add a constant compensation with the DEFAULT_Kf value
* or follow the instruction below to get speed-dependent compensation.
*
* Constant compensation (use only with fanspeeds of 0% and 100%)
* ---------------------------------------------------------------------
* A good starting point for the Kf-value comes from the calculation:
* kf = (power_fan * eff_fan) / power_heater * 255
* where eff_fan is between 0.0 and 1.0, based on fan-efficiency and airflow to the nozzle / heater.
*
* Example:
* Heater: 40W, Fan: 0.1A * 24V = 2.4W, eff_fan = 0.8
* Kf = (2.4W * 0.8) / 40W * 255 = 12.24
*
* Fan-speed dependent compensation
* --------------------------------
* 1. To find a good Kf value, set the hotend temperature, wait for it to settle, and enable the fan (100%).
* Make sure PID_FAN_SCALING_LIN_FACTOR is 0 and PID_FAN_SCALING_ALTERNATIVE_DEFINITION is not enabled.
* If you see the temperature drop repeat the test, increasing the Kf value slowly, until the temperature
* drop goes away. If the temperature overshoots after enabling the fan, the Kf value is too big.
* 2. Note the Kf-value for fan-speed at 100%
* 3. Determine a good value for PID_FAN_SCALING_MIN_SPEED, which is around the speed, where the fan starts moving.
* 4. Repeat step 1. and 2. for this fan speed.
* 5. Enable PID_FAN_SCALING_ALTERNATIVE_DEFINITION and enter the two identified Kf-values in
* PID_FAN_SCALING_AT_FULL_SPEED and PID_FAN_SCALING_AT_MIN_SPEED. Enter the minimum speed in PID_FAN_SCALING_MIN_SPEED
*/
//#define PID_FAN_SCALING
#if ENABLED(PID_FAN_SCALING)
//#define PID_FAN_SCALING_ALTERNATIVE_DEFINITION
#if ENABLED(PID_FAN_SCALING_ALTERNATIVE_DEFINITION)
// The alternative definition is used for an easier configuration.
// Just figure out Kf at fullspeed (255) and PID_FAN_SCALING_MIN_SPEED.
// DEFAULT_Kf and PID_FAN_SCALING_LIN_FACTOR are calculated accordingly.
#define PID_FAN_SCALING_AT_FULL_SPEED 13.0 //=PID_FAN_SCALING_LIN_FACTOR*255+DEFAULT_Kf
#define PID_FAN_SCALING_AT_MIN_SPEED 6.0 //=PID_FAN_SCALING_LIN_FACTOR*PID_FAN_SCALING_MIN_SPEED+DEFAULT_Kf
#define PID_FAN_SCALING_MIN_SPEED 10.0 // Minimum fan speed at which to enable PID_FAN_SCALING
#define DEFAULT_Kf (255.0*PID_FAN_SCALING_AT_MIN_SPEED-PID_FAN_SCALING_AT_FULL_SPEED*PID_FAN_SCALING_MIN_SPEED)/(255.0-PID_FAN_SCALING_MIN_SPEED)
#define PID_FAN_SCALING_LIN_FACTOR (PID_FAN_SCALING_AT_FULL_SPEED-DEFAULT_Kf)/255.0
#else
#define PID_FAN_SCALING_LIN_FACTOR (0) // Power loss due to cooling = Kf * (fan_speed)
#define DEFAULT_Kf 10 // A constant value added to the PID-tuner
#define PID_FAN_SCALING_MIN_SPEED 10 // Minimum fan speed at which to enable PID_FAN_SCALING
#endif
#endif
#endif
/**
* Automatic Temperature:
* The hotend target temperature is calculated by all the buffered lines of gcode.
* The maximum buffered steps/sec of the extruder motor is called "se".
* Start autotemp mode with M109 S<mintemp> B<maxtemp> F<factor>
* The target temperature is set to mintemp+factor*se[steps/sec] and is limited by
* mintemp and maxtemp. Turn this off by executing M109 without F*
* Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp.
* On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode
*/
#define AUTOTEMP
#if ENABLED(AUTOTEMP)
#define AUTOTEMP_OLDWEIGHT 0.98
#endif
// Extra options for the M114 "Current Position" report
//#define M114_DETAIL // Use 'M114` for details to check planner calculations
//#define M114_REALTIME // Real current position based on forward kinematics
//#define M114_LEGACY // M114 used to synchronize on every call. Enable if needed.
// Show Temperature ADC value
// Enable for M105 to include ADC values read from temperature sensors.
//#define SHOW_TEMP_ADC_VALUES
/**
* High Temperature Thermistor Support
*
* Thermistors able to support high temperature tend to have a hard time getting
* good readings at room and lower temperatures. This means HEATER_X_RAW_LO_TEMP
* will probably be caught when the heating element first turns on during the
* preheating process, which will trigger a min_temp_error as a safety measure
* and force stop everything.
* To circumvent this limitation, we allow for a preheat time (during which,
* min_temp_error won't be triggered) and add a min_temp buffer to handle
* aberrant readings.
*
* If you want to enable this feature for your hotend thermistor(s)
* uncomment and set values > 0 in the constants below
*/
// The number of consecutive low temperature errors that can occur
// before a min_temp_error is triggered. (Shouldn't be more than 10.)
//#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 0
// The number of milliseconds a hotend will preheat before starting to check
// the temperature. This value should NOT be set to the time it takes the
// hot end to reach the target temperature, but the time it takes to reach
// the minimum temperature your thermistor can read. The lower the better/safer.
// This shouldn't need to be more than 30 seconds (30000)
//#define MILLISECONDS_PREHEAT_TIME 0
// @section extruder
// Extruder runout prevention.
// If the machine is idle and the temperature over MINTEMP
// then extrude some filament every couple of SECONDS.
//#define EXTRUDER_RUNOUT_PREVENT
#if ENABLED(EXTRUDER_RUNOUT_PREVENT)
#define EXTRUDER_RUNOUT_MINTEMP 190
#define EXTRUDER_RUNOUT_SECONDS 30
#define EXTRUDER_RUNOUT_SPEED 1500 // (mm/m)
#define EXTRUDER_RUNOUT_EXTRUDE 5 // (mm)
#endif
// @section temperature
// Calibration for AD595 / AD8495 sensor to adjust temperature measurements.
// The final temperature is calculated as (measuredTemp * GAIN) + OFFSET.
#define TEMP_SENSOR_AD595_OFFSET 0.0
#define TEMP_SENSOR_AD595_GAIN 1.0
#define TEMP_SENSOR_AD8495_OFFSET 0.0
#define TEMP_SENSOR_AD8495_GAIN 1.0
/**
* Controller Fan
* To cool down the stepper drivers and MOSFETs.
*
* The fan turns on automatically whenever any driver is enabled and turns
* off (or reduces to idle speed) shortly after drivers are turned off.
*/
//#define USE_CONTROLLER_FAN
#if ENABLED(USE_CONTROLLER_FAN)
//#define CONTROLLER_FAN_PIN -1 // Set a custom pin for the controller fan
//#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered
#define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.)
#define CONTROLLERFAN_SPEED_ACTIVE 255 // (0-255) Active speed, used when any motor is enabled
#define CONTROLLERFAN_SPEED_IDLE 0 // (0-255) Idle speed, used when motors are disabled
#define CONTROLLERFAN_IDLE_TIME 60 // (seconds) Extra time to keep the fan running after disabling motors
//#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
#if ENABLED(CONTROLLER_FAN_EDITABLE)
#define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu
#endif
#endif
// When first starting the main fan, run it at full speed for the
// given number of milliseconds. This gets the fan spinning reliably
// before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
//#define FAN_KICKSTART_TIME 100
// Some coolers may require a non-zero "off" state.
//#define FAN_OFF_PWM 1
/**
* PWM Fan Scaling
*
* Define the min/max speeds for PWM fans (as set with M106).
*
* With these options the M106 0-255 value range is scaled to a subset
* to ensure that the fan has enough power to spin, or to run lower
* current fans with higher current. (e.g., 5V/12V fans with 12V/24V)
* Value 0 always turns off the fan.
*
* Define one or both of these to override the default 0-255 range.
*/
#define FAN_MIN_PWM 80
//#define FAN_MAX_PWM 128
/**
* FAST PWM FAN Settings
*
* Use to change the FAST FAN PWM frequency (if enabled in Configuration.h)
* Combinations of PWM Modes, prescale values and TOP resolutions are used internally to produce a
* frequency as close as possible to the desired frequency.
*
* FAST_PWM_FAN_FREQUENCY [undefined by default]
* Set this to your desired frequency.
* If left undefined this defaults to F = F_CPU/(2*255*1)
* i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers.
* These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required
* NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior.
*
* USE_OCR2A_AS_TOP [undefined by default]
* Boards that use TIMER2 for PWM have limitations resulting in only a few possible frequencies on TIMER2:
* 16MHz MCUs: [62.5KHz, 31.4KHz (default), 7.8KHz, 3.92KHz, 1.95KHz, 977Hz, 488Hz, 244Hz, 60Hz, 122Hz, 30Hz]
* 20MHz MCUs: [78.1KHz, 39.2KHz (default), 9.77KHz, 4.9KHz, 2.44KHz, 1.22KHz, 610Hz, 305Hz, 153Hz, 76Hz, 38Hz]
* A greater range can be achieved by enabling USE_OCR2A_AS_TOP. But note that this option blocks the use of
* PWM on pin OC2A. Only use this option if you don't need PWM on 0C2A. (Check your schematic.)
* USE_OCR2A_AS_TOP sacrifices duty cycle control resolution to achieve this broader range of frequencies.
*/
#if ENABLED(FAST_PWM_FAN)
//#define FAST_PWM_FAN_FREQUENCY 31400
//#define USE_OCR2A_AS_TOP
#endif
// @section extruder
/**
* Extruder cooling fans
*
* Extruder auto fans automatically turn on when their extruders'
* temperatures go above EXTRUDER_AUTO_FAN_TEMPERATURE.
*
* Your board's pins file specifies the recommended pins. Override those here
* or set to -1 to disable completely.
*
* Multiple extruders can be assigned to the same pin in which case
* the fan will turn on when any selected extruder is above the threshold.
*/
#define E0_AUTO_FAN_PIN -1
#define E1_AUTO_FAN_PIN -1
#define E2_AUTO_FAN_PIN -1
#define E3_AUTO_FAN_PIN -1
#define E4_AUTO_FAN_PIN -1
#define E5_AUTO_FAN_PIN -1
#define CHAMBER_AUTO_FAN_PIN -1
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // 255 == full speed
#define CHAMBER_AUTO_FAN_TEMPERATURE 30
#define CHAMBER_AUTO_FAN_SPEED 255
/**
* Part-Cooling Fan Multiplexer
*
* This feature allows you to digitally multiplex the fan output.
* The multiplexer is automatically switched at tool-change.
* Set FANMUX[012]_PINs below for up to 2, 4, or 8 multiplexed fans.
*/
#define FANMUX0_PIN -1
#define FANMUX1_PIN -1
#define FANMUX2_PIN -1
/**
* M355 Case Light on-off / brightness
*/
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
//#define CASE_LIGHT_PIN 4 // Override the default pin if needed
#define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW
#define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // Set default power-up brightness (0-255, requires PWM pin)
//#define CASE_LIGHT_MAX_PWM 128 // Limit pwm
//#define CASE_LIGHT_MENU // Add Case Light options to the LCD menu
//#define CASE_LIGHT_NO_BRIGHTNESS // Disable brightness control. Enable for non-PWM lighting.
//#define CASE_LIGHT_USE_NEOPIXEL // Use Neopixel LED as case light, requires NEOPIXEL_LED.
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
#define CASE_LIGHT_NEOPIXEL_COLOR { 255, 255, 255, 255 } // { Red, Green, Blue, White }
#endif
#endif
// @section homing
// If you want endstops to stay on (by default) even when not homing
// enable this option. Override at any time with M120, M121.
//#define ENDSTOPS_ALWAYS_ON_DEFAULT
// @section extras
//#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats.
// Employ an external closed loop controller. Override pins here if needed.
//#define EXTERNAL_CLOSED_LOOP_CONTROLLER
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
//#define CLOSED_LOOP_ENABLE_PIN -1
//#define CLOSED_LOOP_MOVE_COMPLETE_PIN -1
#endif
/**
* Dual Steppers / Dual Endstops
*
* This section will allow you to use extra E drivers to drive a second motor for X, Y, or Z axes.
*
* For example, set X_DUAL_STEPPER_DRIVERS setting to use a second motor. If the motors need to
* spin in opposite directions set INVERT_X2_VS_X_DIR. If the second motor needs its own endstop
* set X_DUAL_ENDSTOPS. This can adjust for "racking." Use X2_USE_ENDSTOP to set the endstop plug
* that should be used for the second endstop. Extra endstops will appear in the output of 'M119'.
*
* Use X_DUAL_ENDSTOP_ADJUSTMENT to adjust for mechanical imperfection. After homing both motors
* this offset is applied to the X2 motor. To find the offset home the X axis, and measure the error
* in X2. Dual endstop offsets can be set at runtime with 'M666 X<offset> Y<offset> Z<offset>'.
*/
//#define X_DUAL_STEPPER_DRIVERS
#if ENABLED(X_DUAL_STEPPER_DRIVERS)
#define INVERT_X2_VS_X_DIR true // Set 'true' if X motors should rotate in opposite directions
//#define X_DUAL_ENDSTOPS
#if ENABLED(X_DUAL_ENDSTOPS)
#define X2_USE_ENDSTOP _XMAX_
#define X2_ENDSTOP_ADJUSTMENT 0
#endif
#endif
//#define Y_DUAL_STEPPER_DRIVERS
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#define INVERT_Y2_VS_Y_DIR true // Set 'true' if Y motors should rotate in opposite directions
//#define Y_DUAL_ENDSTOPS
#if ENABLED(Y_DUAL_ENDSTOPS)
#define Y2_USE_ENDSTOP _YMAX_
#define Y2_ENDSTOP_ADJUSTMENT 0
#endif
#endif
//
// For Z set the number of stepper drivers
//
#define NUM_Z_STEPPER_DRIVERS 1 // (1-4) Z options change based on how many
#if NUM_Z_STEPPER_DRIVERS > 1
//#define Z_MULTI_ENDSTOPS
#if ENABLED(Z_MULTI_ENDSTOPS)
#define Z2_USE_ENDSTOP _XMAX_
#define Z2_ENDSTOP_ADJUSTMENT 0
#if NUM_Z_STEPPER_DRIVERS >= 3
#define Z3_USE_ENDSTOP _YMAX_
#define Z3_ENDSTOP_ADJUSTMENT 0
#endif
#if NUM_Z_STEPPER_DRIVERS >= 4
#define Z4_USE_ENDSTOP _ZMAX_
#define Z4_ENDSTOP_ADJUSTMENT 0
#endif
#endif
#endif
/**
* Dual X Carriage
*
* This setup has two X carriages that can move independently, each with its own hotend.
* The carriages can be used to print an object with two colors or materials, or in
* "duplication mode" it can print two identical or X-mirrored objects simultaneously.
* The inactive carriage is parked automatically to prevent oozing.
* X1 is the left carriage, X2 the right. They park and home at opposite ends of the X axis.
* By default the X2 stepper is assigned to the first unused E plug on the board.
*
* The following Dual X Carriage modes can be selected with M605 S<mode>:
*
* 0 : (FULL_CONTROL) The slicer has full control over both X-carriages and can achieve optimal travel
* results as long as it supports dual X-carriages. (M605 S0)
*
* 1 : (AUTO_PARK) The firmware automatically parks and unparks the X-carriages on tool-change so
* that additional slicer support is not required. (M605 S1)
*
* 2 : (DUPLICATION) The firmware moves the second X-carriage and extruder in synchronization with
* the first X-carriage and extruder, to print 2 copies of the same object at the same time.
* Set the constant X-offset and temperature differential with M605 S2 X[offs] R[deg] and
* follow with M605 S2 to initiate duplicated movement.
*
* 3 : (MIRRORED) Formbot/Vivedino-inspired mirrored mode in which the second extruder duplicates
* the movement of the first except the second extruder is reversed in the X axis.
* Set the initial X offset and temperature differential with M605 S2 X[offs] R[deg] and
* follow with M605 S3 to initiate mirrored movement.
*/
//#define DUAL_X_CARRIAGE
#if ENABLED(DUAL_X_CARRIAGE)
#define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS
#define X1_MAX_POS X_BED_SIZE // Set a maximum so the first X-carriage can't hit the parked second X-carriage
#define X2_MIN_POS 80 // Set a minimum to ensure the second X-carriage can't hit the parked first X-carriage
#define X2_MAX_POS 353 // Set this to the distance between toolheads when both heads are homed
#define X2_HOME_DIR 1 // Set to 1. The second X-carriage always homes to the maximum endstop position
#define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS.
// However: In this mode the HOTEND_OFFSET_X value for the second extruder provides a software
// override for X2_HOME_POS. This also allow recalibration of the distance between the two endstops
// without modifying the firmware (through the "M218 T1 X???" command).
// Remember: you should set the second extruder x-offset to 0 in your slicer.
// This is the default power-up mode which can be later using M605.
#define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE
// Default x offset in duplication mode (typically set to half print bed width)
#define DEFAULT_DUPLICATION_X_OFFSET 100
#endif // DUAL_X_CARRIAGE
// Activate a solenoid on the active extruder with M380. Disable all with M381.
// Define SOL0_PIN, SOL1_PIN, etc., for each extruder that has a solenoid.
//#define EXT_SOLENOID
// @section homing
// Homing hits each endstop, retracts by these distances, then does a slower bump.
#define X_HOME_BUMP_MM 5
#define Y_HOME_BUMP_MM 5
#define Z_HOME_BUMP_MM 2
#define HOMING_BUMP_DIVISOR { 4, 4, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)
//#define QUICK_HOME // If homing includes X and Y, do a diagonal move initially
//#define HOMING_BACKOFF_MM { 2, 2, 2 } // (mm) Move away from the endstops after homing
// When G28 is called, this option will make Y home before X
//#define HOME_Y_BEFORE_X
// Enable this if X or Y can't home without homing the other axis first.
//#define CODEPENDENT_XY_HOMING
#if ENABLED(BLTOUCH)
/**
* Either: Use the defaults (recommended) or: For special purposes, use the following DEFINES
* Do not activate settings that the probe might not understand. Clones might misunderstand
* advanced commands.
*
* Note: If the probe is not deploying, check a "Cmd: Reset" and "Cmd: Self-Test" and then
* check the wiring of the BROWN, RED and ORANGE wires.
*
* Note: If the trigger signal of your probe is not being recognized, it has been very often
* because the BLACK and WHITE wires needed to be swapped. They are not "interchangeable"
* like they would be with a real switch. So please check the wiring first.
*
* Settings for all BLTouch and clone probes:
*/
#undef PROBE_MANUALLY
// Safety: The probe needs time to recognize the command.
// Minimum command delay (ms). Enable and increase if needed.
//#define BLTOUCH_DELAY 500
/**
* Settings for BLTOUCH Classic 1.2, 1.3 or BLTouch Smart 1.0, 2.0, 2.2, 3.0, 3.1, and most clones:
*/
// Feature: Switch into SW mode after a deploy. It makes the output pulse longer. Can be useful
// in special cases, like noisy or filtered input configurations.
//#define BLTOUCH_FORCE_SW_MODE
/**
* Settings for BLTouch Smart 3.0 and 3.1
* Summary:
* - Voltage modes: 5V and OD (open drain - "logic voltage free") output modes
* - High-Speed mode
* - Disable LCD voltage options
*/
/**
* Danger: Don't activate 5V mode unless attached to a 5V-tolerant controller!
* V3.0 or 3.1: Set default mode to 5V mode at Marlin startup.
* If disabled, OD mode is the hard-coded default on 3.0
* On startup, Marlin will compare its eeprom to this vale. If the selected mode
* differs, a mode set eeprom write will be completed at initialization.
* Use the option below to force an eeprom write to a V3.1 probe regardless.
*/
//#define BLTOUCH_SET_5V_MODE
/**
* Safety: Activate if connecting a probe with an unknown voltage mode.
* V3.0: Set a probe into mode selected above at Marlin startup. Required for 5V mode on 3.0
* V3.1: Force a probe with unknown mode into selected mode at Marlin startup ( = Probe EEPROM write )
* To preserve the life of the probe, use this once then turn it off and re-flash.
*/
//#define BLTOUCH_FORCE_MODE_SET
/**
* Use "HIGH SPEED" mode for probing.
* Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems.
* This feature was designed for Delta's with very fast Z moves however higher speed cartesians may function
* If the machine cannot raise the probe fast enough after a trigger, it may enter a fault state.
*/
//#define BLTOUCH_HS_MODE
// Safety: Enable voltage mode settings in the LCD menu.
#define BLTOUCH_LCD_VOLTAGE_MENU
#endif // BLTOUCH
/**
* Z Steppers Auto-Alignment
* Add the G34 command to align multiple Z steppers using a bed probe.
*/
//#define Z_STEPPER_AUTO_ALIGN
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
// Define probe X and Y positions for Z1, Z2 [, Z3 [, Z4]]
// If not defined, probe limits will be used.
// Override with 'M422 S<index> X<pos> Y<pos>'
//#define Z_STEPPER_ALIGN_XY { { 10, 190 }, { 100, 10 }, { 190, 190 } }
/**
* Orientation for the automatically-calculated probe positions.
* Override Z stepper align points with 'M422 S<index> X<pos> Y<pos>'
*
* 2 Steppers: (0) (1)
* | | 2 |
* | 1 2 | |
* | | 1 |
*
* 3 Steppers: (0) (1) (2) (3)
* | 3 | 1 | 2 1 | 2 |
* | | 3 | | 3 |
* | 1 2 | 2 | 3 | 1 |
*
* 4 Steppers: (0) (1) (2) (3)
* | 4 3 | 1 4 | 2 1 | 3 2 |
* | | | | |
* | 1 2 | 2 3 | 3 4 | 4 1 |
*
*/
#ifndef Z_STEPPER_ALIGN_XY
//#define Z_STEPPERS_ORIENTATION 0
#endif
// Provide Z stepper positions for more rapid convergence in bed alignment.
// Requires triple stepper drivers (i.e., set NUM_Z_STEPPER_DRIVERS to 3)
//#define Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
// Define Stepper XY positions for Z1, Z2, Z3 corresponding to
// the Z screw positions in the bed carriage.
// Define one position per Z stepper in stepper driver order.
#define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } }
#else
// Amplification factor. Used to scale the correction step up or down.
// In case the stepper (spindle) position is further out than the test point.
// Use a value > 1. NOTE: This may cause instability
#define Z_STEPPER_ALIGN_AMP 1.0
#endif
#define G34_MAX_GRADE 5 // (%) Maximum incline that G34 will handle
#define Z_STEPPER_ALIGN_ITERATIONS 3 // Number of iterations to apply during alignment
#define Z_STEPPER_ALIGN_ACC 0.02 // Stop iterating early if the accuracy is better than this
#define RESTORE_LEVELING_AFTER_G34 // Restore leveling after G34 is done?
// After G34, re-home Z (G28 Z) or just calculate it from the last probe heights?
// Re-homing might be more precise in reproducing the actual 'G28 Z' homing height, especially on an uneven bed.
#define HOME_AFTER_G34
#endif
// @section motion
#define AXIS_RELATIVE_MODES { false, false, false, false }
// Add a Duplicate option for well-separated conjoined nozzles
//#define MULTI_NOZZLE_DUPLICATION
// By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
#define INVERT_X_STEP_PIN false
#define INVERT_Y_STEP_PIN false
#define INVERT_Z_STEP_PIN false
#define INVERT_E_STEP_PIN false
// Default stepper release if idle. Set to 0 to deactivate.
// Steppers will shut down DEFAULT_STEPPER_DEACTIVE_TIME seconds after the last move when DISABLE_INACTIVE_? is true.
// Time can be set by M18 and M84.
#define DEFAULT_STEPPER_DEACTIVE_TIME 120
#define DISABLE_INACTIVE_X true
#define DISABLE_INACTIVE_Y true
#define DISABLE_INACTIVE_Z true // Set to false if the nozzle will fall down on your printed part when print has finished.
#define DISABLE_INACTIVE_E true
#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
#define DEFAULT_MINTRAVELFEEDRATE 0.0
//#define HOME_AFTER_DEACTIVATE // Require rehoming after steppers are deactivated
// Minimum time that a segment needs to take if the buffer is emptied
#define DEFAULT_MINSEGMENTTIME 20000 // (ms)
// If defined the movements slow down when the look ahead buffer is only half full
// Slow down the machine if the look ahead buffer is (by default) half full.
// Increase the slowdown divisor for larger buffer sizes.
#define SLOWDOWN
#if ENABLED(SLOWDOWN)
#define SLOWDOWN_DIVISOR 2
#endif
// Frequency limit
// See nophead's blog for more info
// Not working O
//#define XY_FREQUENCY_LIMIT 15
// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
// of the buffer and all stops. This should not be much greater than zero and should only be changed
// if unwanted behavior is observed on a user's machine when running at very slow speeds.
#define MINIMUM_PLANNER_SPEED 0.05 // (mm/s)
//
// Backlash Compensation
// Adds extra movement to axes on direction-changes to account for backlash.
//
//#define BACKLASH_COMPENSATION
#if ENABLED(BACKLASH_COMPENSATION)
// Define values for backlash distance and correction.
// If BACKLASH_GCODE is enabled these values are the defaults.
#define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm)
#define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction
// Set BACKLASH_SMOOTHING_MM to spread backlash correction over multiple segments
// to reduce print artifacts. (Enabling this is costly in memory and computation!)
//#define BACKLASH_SMOOTHING_MM 3 // (mm)
// Add runtime configuration and tuning of backlash values (M425)
//#define BACKLASH_GCODE
#if ENABLED(BACKLASH_GCODE)
// Measure the Z backlash when probing (G29) and set with "M425 Z"
#define MEASURE_BACKLASH_WHEN_PROBING
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
// When measuring, the probe will move up to BACKLASH_MEASUREMENT_LIMIT
// mm away from point of contact in BACKLASH_MEASUREMENT_RESOLUTION
// increments while checking for the contact to be broken.
#define BACKLASH_MEASUREMENT_LIMIT 0.5 // (mm)
#define BACKLASH_MEASUREMENT_RESOLUTION 0.005 // (mm)
#define BACKLASH_MEASUREMENT_FEEDRATE Z_PROBE_SPEED_SLOW // (mm/m)
#endif
#endif
#endif
/**
* Automatic backlash, position and hotend offset calibration
*
* Enable G425 to run automatic calibration using an electrically-
* conductive cube, bolt, or washer mounted on the bed.
*
* G425 uses the probe to touch the top and sides of the calibration object
* on the bed and measures and/or correct positional offsets, axis backlash
* and hotend offsets.
*
* Note: HOTEND_OFFSET and CALIBRATION_OBJECT_CENTER must be set to within
* ±5mm of true values for G425 to succeed.
*/
//#define CALIBRATION_GCODE
#if ENABLED(CALIBRATION_GCODE)
#define CALIBRATION_MEASUREMENT_RESOLUTION 0.01 // mm
#define CALIBRATION_FEEDRATE_SLOW 60 // mm/m
#define CALIBRATION_FEEDRATE_FAST 1200 // mm/m
#define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/m
// The following parameters refer to the conical section of the nozzle tip.
#define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // mm
#define CALIBRATION_NOZZLE_OUTER_DIAMETER 2.0 // mm
// Uncomment to enable reporting (required for "G425 V", but consumes PROGMEM).
//#define CALIBRATION_REPORTING
// The true location and dimension the cube/bolt/washer on the bed.
#define CALIBRATION_OBJECT_CENTER { 264.0, -22.0, -2.0 } // mm
#define CALIBRATION_OBJECT_DIMENSIONS { 10.0, 10.0, 10.0 } // mm
// Comment out any sides which are unreachable by the probe. For best
// auto-calibration results, all sides must be reachable.
#define CALIBRATION_MEASURE_RIGHT
#define CALIBRATION_MEASURE_FRONT
#define CALIBRATION_MEASURE_LEFT
#define CALIBRATION_MEASURE_BACK
// Probing at the exact top center only works if the center is flat. If
// probing on a screwhead or hollow washer, probe near the edges.
//#define CALIBRATION_MEASURE_AT_TOP_EDGES
// Define the pin to read during calibration
#ifndef CALIBRATION_PIN
//#define CALIBRATION_PIN -1 // Define here to override the default pin
#define CALIBRATION_PIN_INVERTING false // Set to true to invert the custom pin
//#define CALIBRATION_PIN_PULLDOWN
#define CALIBRATION_PIN_PULLUP
#endif
#endif
/**
* Adaptive Step Smoothing increases the resolution of multi-axis moves, particularly at step frequencies
* below 1kHz (for AVR) or 10kHz (for ARM), where aliasing between axes in multi-axis moves causes audible
* vibration and surface artifacts. The algorithm adapts to provide the best possible step smoothing at the
* lowest stepping frequencies.
*/
//#define ADAPTIVE_STEP_SMOOTHING
/**
* Custom Microstepping
* Override as-needed for your setup. Up to 3 MS pins are supported.
*/
//#define MICROSTEP1 LOW,LOW,LOW
//#define MICROSTEP2 HIGH,LOW,LOW
//#define MICROSTEP4 LOW,HIGH,LOW
//#define MICROSTEP8 HIGH,HIGH,LOW
//#define MICROSTEP16 LOW,LOW,HIGH
//#define MICROSTEP32 HIGH,LOW,HIGH
// Microstep setting (Only functional when stepper driver microstep pins are connected to MCU.
#define MICROSTEP_MODES { 16, 16, 16, 16, 16, 16 } // [1,2,4,8,16]
/**
* @section stepper motor current
*
* Some boards have a means of setting the stepper motor current via firmware.
*
* The power on motor currents are set by:
* PWM_MOTOR_CURRENT - used by MINIRAMBO & ULTIMAIN_2
* known compatible chips: A4982
* DIGIPOT_MOTOR_CURRENT - used by BQ_ZUM_MEGA_3D, RAMBO & SCOOVO_X9H
* known compatible chips: AD5206
* DAC_MOTOR_CURRENT_DEFAULT - used by PRINTRBOARD_REVF & RIGIDBOARD_V2
* known compatible chips: MCP4728
* DIGIPOT_I2C_MOTOR_CURRENTS - used by 5DPRINT, AZTEEG_X3_PRO, AZTEEG_X5_MINI_WIFI, MIGHTYBOARD_REVE
* known compatible chips: MCP4451, MCP4018
*
* Motor currents can also be set by M907 - M910 and by the LCD.
* M907 - applies to all.
* M908 - BQ_ZUM_MEGA_3D, RAMBO, PRINTRBOARD_REVF, RIGIDBOARD_V2 & SCOOVO_X9H
* M909, M910 & LCD - only PRINTRBOARD_REVF & RIGIDBOARD_V2
*/
//#define PWM_MOTOR_CURRENT { 1300, 1300, 1250 } // Values in milliamps
//#define DIGIPOT_MOTOR_CURRENT { 135,135,135,135,135 } // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
//#define DAC_MOTOR_CURRENT_DEFAULT { 70, 80, 90, 80 } // Default drive percent - X, Y, Z, E axis
// Use an I2C based DIGIPOT (e.g., Azteeg X3 Pro)
//#define DIGIPOT_I2C
#if ENABLED(DIGIPOT_I2C) && !defined(DIGIPOT_I2C_ADDRESS_A)
/**
* Common slave addresses:
*
* A (A shifted) B (B shifted) IC
* Smoothie 0x2C (0x58) 0x2D (0x5A) MCP4451
* AZTEEG_X3_PRO 0x2C (0x58) 0x2E (0x5C) MCP4451
* AZTEEG_X5_MINI 0x2C (0x58) 0x2E (0x5C) MCP4451
* AZTEEG_X5_MINI_WIFI 0x58 0x5C MCP4451
* MIGHTYBOARD_REVE 0x2F (0x5E) MCP4018
*/
#define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for first DIGIPOT
#define DIGIPOT_I2C_ADDRESS_B 0x2D // unshifted slave address for second DIGIPOT
#endif
//#define DIGIPOT_MCP4018 // Requires library from https://github.com/stawel/SlowSoftI2CMaster
#define DIGIPOT_I2C_NUM_CHANNELS 8 // 5DPRINT: 4 AZTEEG_X3_PRO: 8 MKS SBASE: 5
// Actual motor currents in Amps. The number of entries must match DIGIPOT_I2C_NUM_CHANNELS.
// These correspond to the physical drivers, so be mindful if the order is changed.
#define DIGIPOT_I2C_MOTOR_CURRENTS { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 } // AZTEEG_X3_PRO
//===========================================================================
//=============================Additional Features===========================
//===========================================================================
// @section lcd
#if EITHER(ULTIPANEL, EXTENSIBLE_UI)
#define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 60 } // Feedrates for manual moves along X, Y, Z, E from panel
#define SHORT_MANUAL_Z_MOVE 0.025 // (mm) Smallest manual Z move (< 0.1mm)
#if ENABLED(ULTIPANEL)
#define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position"
#define ULTIPANEL_FEEDMULTIPLY // Encoder sets the feedrate multiplier on the Status Screen
#endif
#endif
// Change values more rapidly when the encoder is rotated faster
#define ENCODER_RATE_MULTIPLIER
#if ENABLED(ENCODER_RATE_MULTIPLIER)
#define ENCODER_10X_STEPS_PER_SEC 30 // (steps/s) Encoder rate for 10x speed
#define ENCODER_100X_STEPS_PER_SEC 80 // (steps/s) Encoder rate for 100x speed
#endif
// Play a beep when the feedrate is changed from the Status Screen
//#define BEEP_ON_FEEDRATE_CHANGE
#if ENABLED(BEEP_ON_FEEDRATE_CHANGE)
#define FEEDRATE_CHANGE_BEEP_DURATION 10
#define FEEDRATE_CHANGE_BEEP_FREQUENCY 440
#endif
#if HAS_LCD_MENU
// Include a page of printer information in the LCD Main Menu
#define LCD_INFO_MENU
#if ENABLED(LCD_INFO_MENU)
//#define LCD_PRINTER_INFO_IS_BOOTSCREEN // Show bootscreen(s) instead of Printer Info pages
#endif
// BACK menu items keep the highlight at the top
//#define TURBO_BACK_MENU_ITEM
/**
* LED Control Menu
* Add LED Control to the LCD menu
*/
//#define LED_CONTROL_MENU
#if ENABLED(LED_CONTROL_MENU)
#define LED_COLOR_PRESETS // Enable the Preset Color menu option
#if ENABLED(LED_COLOR_PRESETS)
#define LED_USER_PRESET_RED 255 // User defined RED value
#define LED_USER_PRESET_GREEN 128 // User defined GREEN value
#define LED_USER_PRESET_BLUE 0 // User defined BLUE value
#define LED_USER_PRESET_WHITE 255 // User defined WHITE value
#define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity
//#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup
#endif
#endif
#endif // HAS_LCD_MENU
// Scroll a longer status message into view
//#define STATUS_MESSAGE_SCROLLING
// On the Info Screen, display XY with one decimal place when possible
//#define LCD_DECIMAL_SMALL_XY
// The timeout (in ms) to return to the status screen from sub-menus
//#define LCD_TIMEOUT_TO_STATUS 15000
// Add an 'M73' G-code to set the current percentage
// #define LCD_SET_PROGRESS_MANUALLY
// Show the E position (filament used) during printing
//#define LCD_SHOW_E_TOTAL
#if ENABLED(SHOW_BOOTSCREEN)
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#endif
#if HAS_GRAPHICAL_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
//#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
//#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
#endif
#endif
#if HAS_CHARACTER_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
#if ENABLED(LCD_PROGRESS_BAR)
#define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
#define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message
#define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever)
//#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
//#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
#endif
#endif
#if ENABLED(SDSUPPORT)
// The standard SD detect circuit reads LOW when media is inserted and HIGH when empty.
// Enable this option and set to HIGH if your SD cards are incorrectly detected.
#define SD_DETECT_STATE HIGH
#define SD_FINISHED_STEPPERRELEASE true // Disable steppers when SD Print is finished
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the Z enabled so your bed stays in place.
// Reverse SD sort to show "more recent" files first, according to the card's FAT.
// Since the FAT gets out of order with usage, SDCARD_SORT_ALPHA is recommended.
#define SDCARD_RATHERRECENTFIRST
#define SD_MENU_CONFIRM_START // Confirm the selected SD file before printing
#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files
#define EVENT_GCODE_SD_STOP "G28X\nM84" // G-code to run on Stop Print (e.g., "G28XY" or "G27")
/**
* Continue after Power-Loss (Creality3D)
*
* Store the current state to the SD Card at the start of each layer
* during SD printing. If the recovery file is found at boot time, present
* an option on the LCD screen to continue the print from the last-known
* point in the file.
*/
#define POWER_LOSS_RECOVERY
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_ENABLED_DEFAULT true // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
//#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss
#define POWER_LOSS_ZRAISE 0 // (mm) Z axis raise on resume (on power loss with UPS)
//#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
//#define POWER_LOSS_STATE HIGH // State of pin indicating power loss
//#define POWER_LOSS_PULL // Set pullup / pulldown as appropriate
//#define POWER_LOSS_PURGE_LEN 20 // (mm) Length of filament to purge on resume
//#define POWER_LOSS_RETRACT_LEN 10 // (mm) Length of filament to retract on fail. Requires backup power.
// Without a POWER_LOSS_PIN the following option helps reduce wear on the SD card,
// especially with "vase mode" printing. Set too high and vases cannot be continued.
#define POWER_LOSS_MIN_Z_CHANGE 0.1 // (mm) Minimum Z change before saving power-loss data
#endif
/**
* Sort SD file listings in alphabetical order.
*
* With this option enabled, items on SD cards will be sorted
* by name for easier navigation.
*
* By default...
*
* - Use the slowest -but safest- method for sorting.
* - Folders are sorted to the top.
* - The sort key is statically allocated.
* - No added G-code (M34) support.
* - 40 item sorting limit. (Items after the first 40 are unsorted.)
*
* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
* compiler to calculate the worst-case usage and throw an error if the SRAM
* limit is exceeded.
*
* - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
* - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
* - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
* - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
*/
//#define SDCARD_SORT_ALPHA
// SD Card Sorting options
#if ENABLED(SDCARD_SORT_ALPHA)
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256). Costs 27 bytes each.
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
#define SDSORT_GCODE true // Allow turning sorting on/off with LCD and M34 g-code.
#define SDSORT_USES_RAM true // Pre-allocate a static array for faster pre-sorting.
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
#define SDSORT_CACHE_NAMES true // Keep sorted items in RAM longer for speedy performance. Most expensive option.
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
#define SDSORT_CACHE_VFATS 2 // Maximum number of 13-byte VFAT entries to use for sorting.
// Note: Only affects SCROLL_LONG_FILENAMES with SDSORT_CACHE_NAMES but not SDSORT_DYNAMIC_RAM.
#endif
// This allows hosts to request long names for files and folders with M33
#define LONG_FILENAME_HOST_SUPPORT
// Enable this option to scroll long filenames in the SD card menu
//#define SCROLL_LONG_FILENAMES
// Leave the heaters on after Stop Print (not recommended!)
//#define SD_ABORT_NO_COOLDOWN
/**
* This option allows you to abort SD printing when any endstop is triggered.
* This feature must be enabled with "M540 S1" or from the LCD menu.
* To have any effect, endstops must be enabled during SD printing.
*/
//#define SD_ABORT_ON_ENDSTOP_HIT
/**
* This option makes it easier to print the same SD Card file again.
* On print completion the LCD Menu will open with the file selected.
* You can just click to start the print, or navigate elsewhere.
*/
//#define SD_REPRINT_LAST_SELECTED_FILE
/**
* Auto-report SdCard status with M27 S<seconds>
*/
//#define AUTO_REPORT_SD_STATUS
/**
* Support for USB thumb drives using an Arduino USB Host Shield or
* equivalent MAX3421E breakout board. The USB thumb drive will appear
* to Marlin as an SD card.
*
* The MAX3421E can be assigned the same pins as the SD card reader, with
* the following pin mapping:
*
* SCLK, MOSI, MISO --> SCLK, MOSI, MISO
* INT --> SD_DETECT_PIN [1]
* SS --> SDSS
*
* [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
*/
//#define USB_FLASH_DRIVE_SUPPORT
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
#define USB_CS_PIN SDSS
#define USB_INTR_PIN SD_DETECT_PIN
/**
* USB Host Shield Library
*
* - UHS2 uses no interrupts and has been production-tested
* on a LulzBot TAZ Pro with a 32-bit Archim board.
*
* - UHS3 is newer code with better USB compatibility. But it
* is less tested and is known to interfere with Servos.
* [1] This requires USB_INTR_PIN to be interrupt-capable.
*/
//#define USE_UHS3_USB
#endif
/**
* When using a bootloader that supports SD-Firmware-Flashing,
* add a menu item to activate SD-FW-Update on the next reboot.
*
* Requires ATMEGA2560 (Arduino Mega)
*
* Tested with this bootloader:
* https://github.com/FleetProbe/MicroBridge-Arduino-ATMega2560
*/
//#define SD_FIRMWARE_UPDATE
#if ENABLED(SD_FIRMWARE_UPDATE)
#define SD_FIRMWARE_UPDATE_EEPROM_ADDR 0x1FF
#define SD_FIRMWARE_UPDATE_ACTIVE_VALUE 0xF0
#define SD_FIRMWARE_UPDATE_INACTIVE_VALUE 0xFF
#endif
// Add an optimized binary file transfer mode, initiated with 'M28 B1'
//#define BINARY_FILE_TRANSFER
/**
* Set this option to one of the following (or the board's defaults apply):
*
* LCD - Use the SD drive in the external LCD controller.
* ONBOARD - Use the SD drive on the control board. (No SD_DETECT_PIN. M21 to init.)
* CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file).
*
* :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ]
*/
//#define SDCARD_CONNECTION LCD
#endif // SDSUPPORT
/**
* By default an onboard SD card reader may be shared as a USB mass-
* storage device. This option hides the SD card from the host PC.
*/
//#define NO_SD_HOST_DRIVE // Disable SD Card access over USB (for security).
/**
* Additional options for Graphical Displays
*
* Use the optimizations here to improve printing performance,
* which can be adversely affected by graphical display drawing,
* especially when doing several short moves, and when printing
* on DELTA and SCARA machines.
*
* Some of these options may result in the display lagging behind
* controller events, as there is a trade-off between reliable
* printing performance versus fast display updates.
*/
#if HAS_GRAPHICAL_LCD
// Show SD percentage next to the progress bar
#define DOGM_SD_PERCENT
// Enable to save many cycles by drawing a hollow frame on the Info Screen
#define XYZ_HOLLOW_FRAME
// Enable to save many cycles by drawing a hollow frame on Menu Screens
#define MENU_HOLLOW_FRAME
// A bigger font is available for edit items. Costs 3120 bytes of PROGMEM.
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_BIG_EDIT_FONT
// A smaller font may be used on the Info Screen. Costs 2300 bytes of PROGMEM.
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_SMALL_INFOFONT
// Swap the CW/CCW indicators in the graphics overlay
//#define OVERLAY_GFX_REVERSE
/**
* ST7920-based LCDs can emulate a 16 x 4 character display using
* the ST7920 character-generator for very fast screen updates.
* Enable LIGHTWEIGHT_UI to use this special display mode.
*
* Since LIGHTWEIGHT_UI has limited space, the position and status
* message occupy the same line. Set STATUS_EXPIRE_SECONDS to the
* length of time to display the status message before clearing.
*
* Set STATUS_EXPIRE_SECONDS to zero to never clear the status.
* This will prevent position updates from being displayed.
*/
#if ENABLED(U8GLIB_ST7920)
// Enable this option and reduce the value to optimize screen updates.
// The normal delay is 10µs. Use the lowest value that still gives a reliable display.
//#define DOGM_SPI_DELAY_US 5
//#define LIGHTWEIGHT_UI
#if ENABLED(LIGHTWEIGHT_UI)
#define STATUS_EXPIRE_SECONDS 20
#endif
#endif
/**
* Status (Info) Screen customizations
* These options may affect code size and screen render time.
* Custom status screens can forcibly override these settings.
*/
//#define STATUS_COMBINE_HEATERS // Use combined heater images instead of separate ones
//#define STATUS_HOTEND_NUMBERLESS // Use plain hotend icons instead of numbered ones (with 2+ hotends)
#define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM)
#define STATUS_HOTEND_ANIM // Use a second bitmap to indicate hotend heating
#define STATUS_BED_ANIM // Use a second bitmap to indicate bed heating
#define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating
//#define STATUS_CUTTER_ANIM // Use a second bitmap to indicate spindle / laser active
//#define STATUS_ALT_BED_BITMAP // Use the alternative bed bitmap
//#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap
//#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames
#define STATUS_HEAT_PERCENT // Show heating in a progress bar
//#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving 399 bytes of flash)
//#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of PROGMEM.
// Frivolous Game Options
//#define MARLIN_BRICKOUT
//#define MARLIN_INVADERS
//#define MARLIN_SNAKE
//#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu
#endif // HAS_GRAPHICAL_LCD
//
// Additional options for DGUS / DWIN displays
//
#if HAS_DGUS_LCD
#define DGUS_SERIAL_PORT 3
#define DGUS_BAUDRATE 115200
#define DGUS_RX_BUFFER_SIZE 128
#define DGUS_TX_BUFFER_SIZE 48
//#define DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR)
#define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates
#if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
#define DGUS_PRINT_FILENAME // Display the filename during printing
#define DGUS_PREHEAT_UI // Display a preheat screen during heatup
#if ENABLED(DGUS_LCD_UI_FYSETC)
//#define DGUS_UI_MOVE_DIS_OPTION // Disabled by default for UI_FYSETC
#else
#define DGUS_UI_MOVE_DIS_OPTION // Enabled by default for UI_HIPRECY
#endif
#define DGUS_FILAMENT_LOADUNLOAD
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
#define DGUS_FILAMENT_PURGE_LENGTH 10
#define DGUS_FILAMENT_LOAD_LENGTH_PER_TIME 0.5 // (mm) Adjust in proportion to DGUS_UPDATE_INTERVAL_MS
#endif
#define DGUS_UI_WAITING // Show a "waiting" screen between some screens
#if ENABLED(DGUS_UI_WAITING)
#define DGUS_UI_WAITING_STATUS 10
#define DGUS_UI_WAITING_STATUS_PERIOD 8 // Increase to slower waiting status looping
#endif
#endif
#endif // HAS_DGUS_LCD
//
// Touch UI for the FTDI Embedded Video Engine (EVE)
//
#if ENABLED(TOUCH_UI_FTDI_EVE)
// Display board used
//#define LCD_FTDI_VM800B35A // FTDI 3.5" with FT800 (320x240)
//#define LCD_4DSYSTEMS_4DLCD_FT843 // 4D Systems 4.3" (480x272)
//#define LCD_HAOYU_FT800CB // Haoyu with 4.3" or 5" (480x272)
//#define LCD_HAOYU_FT810CB // Haoyu with 5" (800x480)
//#define LCD_ALEPHOBJECTS_CLCD_UI // Aleph Objects Color LCD UI
// Correct the resolution if not using the stock TFT panel.
//#define TOUCH_UI_320x240
//#define TOUCH_UI_480x272
//#define TOUCH_UI_800x480
// Mappings for boards with a standard RepRapDiscount Display connector
//#define AO_EXP1_PINMAP // AlephObjects CLCD UI EXP1 mapping
//#define AO_EXP2_PINMAP // AlephObjects CLCD UI EXP2 mapping
//#define CR10_TFT_PINMAP // Rudolph Riedel's CR10 pin mapping
//#define S6_TFT_PINMAP // FYSETC S6 pin mapping
//#define OTHER_PIN_LAYOUT // Define pins manually below
#if ENABLED(OTHER_PIN_LAYOUT)
// Pins for CS and MOD_RESET (PD) must be chosen
#define CLCD_MOD_RESET 9
#define CLCD_SPI_CS 10
// If using software SPI, specify pins for SCLK, MOSI, MISO
//#define CLCD_USE_SOFT_SPI
#if ENABLED(CLCD_USE_SOFT_SPI)
#define CLCD_SOFT_SPI_MOSI 11
#define CLCD_SOFT_SPI_MISO 12
#define CLCD_SOFT_SPI_SCLK 13
#endif
#endif
// Display Orientation. An inverted (i.e. upside-down) display
// is supported on the FT800. The FT810 and beyond also support
// portrait and mirrored orientations.
//#define TOUCH_UI_INVERTED
//#define TOUCH_UI_PORTRAIT
//#define TOUCH_UI_MIRRORED
// UTF8 processing and rendering.
// Unsupported characters are shown as '?'.
//#define TOUCH_UI_USE_UTF8
#if ENABLED(TOUCH_UI_USE_UTF8)
// Western accents support. These accented characters use
// combined bitmaps and require relatively little storage.
#define TOUCH_UI_UTF8_WESTERN_CHARSET
#if ENABLED(TOUCH_UI_UTF8_WESTERN_CHARSET)
// Additional character groups. These characters require
// full bitmaps and take up considerable storage:
//#define TOUCH_UI_UTF8_SUPERSCRIPTS // ¹ ² ³
//#define TOUCH_UI_UTF8_COPYRIGHT // © ®
//#define TOUCH_UI_UTF8_GERMANIC // ß
//#define TOUCH_UI_UTF8_SCANDINAVIAN // Æ Ð Ø Þ æ ð ø þ
//#define TOUCH_UI_UTF8_PUNCTUATION // « » ¿ ¡
//#define TOUCH_UI_UTF8_CURRENCY // ¢ £ ¤ ¥
//#define TOUCH_UI_UTF8_ORDINALS // º ª
//#define TOUCH_UI_UTF8_MATHEMATICS // ± × ÷
//#define TOUCH_UI_UTF8_FRACTIONS // ¼ ½ ¾
//#define TOUCH_UI_UTF8_SYMBOLS // µ ¶ ¦ § ¬
#endif
#endif
// Use a smaller font when labels don't fit buttons
#define TOUCH_UI_FIT_TEXT
// Allow language selection from menu at run-time (otherwise use LCD_LANGUAGE)
//#define LCD_LANGUAGE_1 en
//#define LCD_LANGUAGE_2 fr
//#define LCD_LANGUAGE_3 de
//#define LCD_LANGUAGE_4 es
//#define LCD_LANGUAGE_5 it
// Use a numeric passcode for "Screen lock" keypad.
// (recommended for smaller displays)
//#define TOUCH_UI_PASSCODE
// Output extra debug info for Touch UI events
//#define TOUCH_UI_DEBUG
// Developer menu (accessed by touching "About Printer" copyright text)
//#define TOUCH_UI_DEVELOPER_MENU
#endif
//
// FSMC Graphical TFT
//
#if ENABLED(FSMC_GRAPHICAL_TFT)
// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
#define TFT_MARLINUI_COLOR COLOR_WHITE
#define TFT_MARLINBG_COLOR COLOR_BLACK
#define TFT_DISABLED_COLOR 0x10A2 // almost black
#define TFT_BTCANCEL_COLOR COLOR_RED
#define TFT_BTARROWS_COLOR COLOR_WHITE
#define TFT_BTOKMENU_COLOR COLOR_BLUE
#endif
//
// ADC Button Debounce
//
#if HAS_ADC_BUTTONS
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // (ms) Increase if buttons bounce or repeat too fast
#endif
// @section safety
/**
* The watchdog hardware timer will do a reset and disable all outputs
* if the firmware gets too overloaded to read the temperature sensors.
*
* If you find that watchdog reboot causes your AVR board to hang forever,
* enable WATCHDOG_RESET_MANUAL to use a custom timer instead of WDTO.
* NOTE: This method is less reliable as it can only catch hangups while
* interrupts are enabled.
*/
#define USE_WATCHDOG
#if ENABLED(USE_WATCHDOG)
//#define WATCHDOG_RESET_MANUAL
#endif
// @section lcd
/**
* Babystepping enables movement of the axes by tiny increments without changing
* the current position values. This feature is used primarily to adjust the Z
* axis in the first layer of a print in real-time.
*
* Warning: Does not respect endstops!
*/
//#define BABYSTEPPING
#if ENABLED(BABYSTEPPING)
//#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR
//#define BABYSTEP_WITHOUT_HOMING
//#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA!
#define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way
#define BABYSTEP_MULTIPLICATOR_Z 1 // Babysteps are very small. Increase for faster motion.
#define BABYSTEP_MULTIPLICATOR_XY 1
//#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping.
#if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING)
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.
// Note: Extra time may be added to mitigate controller latency.
//#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement).
//#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on doubleclick when printer is idle.
#if ENABLED(MOVE_Z_WHEN_IDLE)
#define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size.
#endif
#endif
//#define BABYSTEP_DISPLAY_TOTAL // Display total babysteps since last G28
//#define BABYSTEP_ZPROBE_OFFSET // Combine M851 Z and Babystepping
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
//#define BABYSTEP_HOTEND_Z_OFFSET // For multiple hotends, babystep relative Z offsets
//#define BABYSTEP_ZPROBE_GFX_OVERLAY // Enable graphical overlay on Z-offset editor
#endif
#endif
// @section extruder
/**
* Linear Pressure Control v1.5
*
* Assumption: advance [steps] = k * (delta velocity [steps/s])
* K=0 means advance disabled.
*
* NOTE: K values for LIN_ADVANCE 1.5 differ from earlier versions!
*
* Set K around 0.22 for 3mm PLA Direct Drive with ~6.5cm between the drive gear and heatbreak.
* Larger K values will be needed for flexible filament and greater distances.
* If this algorithm produces a higher speed offset than the extruder can handle (compared to E jerk)
* print acceleration will be reduced during the affected moves to keep within the limit.
*
* See http://marlinfw.org/docs/features/lin_advance.html for full instructions.
* Mention @Sebastianv650 on GitHub to alert the author of any issues.
*/
//#define LIN_ADVANCE
#if ENABLED(LIN_ADVANCE)
//#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants
#define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed
//#define LA_DEBUG // If enabled, this will generate debug information output over USB.
#endif
// @section leveling
/**
* Points to probe for all 3-point Leveling procedures.
* Override if the automatically selected points are inadequate.
*/
#if EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL)
//#define PROBE_PT_1_X 15
//#define PROBE_PT_1_Y 180
//#define PROBE_PT_2_X 15
//#define PROBE_PT_2_Y 20
//#define PROBE_PT_3_X 170
//#define PROBE_PT_3_Y 20
#endif
/**
* Override MIN_PROBE_EDGE for each side of the build plate
* Useful to get probe points to exact positions on targets or
* to allow leveling to avoid plate clamps on only specific
* sides of the bed. With NOZZLE_AS_PROBE negative values are
* allowed, to permit probing outside the bed.
*
* If you are replacing the prior *_PROBE_BED_POSITION options,
* LEFT and FRONT values in most cases will map directly over
* RIGHT and REAR would be the inverse such as
* (X/Y_BED_SIZE - RIGHT/BACK_PROBE_BED_POSITION)
*
* This will allow all positions to match at compilation, however
* should the probe position be modified with M851XY then the
* probe points will follow. This prevents any change from causing
* the probe to be unable to reach any points.
*/
#if PROBE_SELECTED && !IS_KINEMATIC
//#define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
//#define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
//#define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
//#define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
#endif
#if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
// Override the mesh area if the automatic (max) area is too large
#define MESH_MIN_X _MAX(MESH_INSET, MIN_PROBE_EDGE)
#define MESH_MIN_Y _MAX(MESH_INSET, MIN_PROBE_EDGE)
#define MESH_MAX_X X_BED_SIZE - 35 // NOZZLE_TO_PROBE_OFFSET
#define MESH_MAX_Y Y_BED_SIZE - _MAX(MESH_INSET, MIN_PROBE_EDGE)
#endif
/**
* Repeatedly attempt G29 leveling until it succeeds.
* Stop after G29_MAX_RETRIES attempts.
*/
//#define G29_RETRY_AND_RECOVER
#if ENABLED(G29_RETRY_AND_RECOVER)
#define G29_MAX_RETRIES 3
#define G29_HALT_ON_FAILURE
/**
* Specify the GCODE commands that will be executed when leveling succeeds,
* between attempts, and after the maximum number of retries have been tried.
*/
#define G29_SUCCESS_COMMANDS "M117 Bed leveling done."
#define G29_RECOVER_COMMANDS "M117 Probe failed. Rewiping.\nG28\nG12 P0 S12 T0"
#define G29_FAILURE_COMMANDS "M117 Bed leveling failed.\nG0 Z10\nM300 P25 S880\nM300 P50 S0\nM300 P25 S880\nM300 P50 S0\nM300 P25 S880\nM300 P50 S0\nG4 S1"
#endif
/**
* Thermal Probe Compensation
* Probe measurements are adjusted to compensate for temperature distortion.
* Use G76 to calibrate this feature. Use M871 to set values manually.
* For a more detailed explanation of the process see G76_M871.cpp.
*/
#if HAS_BED_PROBE && TEMP_SENSOR_PROBE && TEMP_SENSOR_BED
// Enable thermal first layer compensation using bed and probe temperatures
#define PROBE_TEMP_COMPENSATION
// Add additional compensation depending on hotend temperature
// Note: this values cannot be calibrated and have to be set manually
#if ENABLED(PROBE_TEMP_COMPENSATION)
// Max temperature that can be reached by heated bed.
// This is required only for the calibration process.
#define PTC_MAX_BED_TEMP BED_MAXTEMP
// Park position to wait for probe cooldown
#define PTC_PARK_POS_X 0.0F
#define PTC_PARK_POS_Y 0.0F
#define PTC_PARK_POS_Z 100.0F
// Probe position to probe and wait for probe to reach target temperature
#define PTC_PROBE_POS_X 90.0F
#define PTC_PROBE_POS_Y 100.0F
// Enable additional compensation using hotend temperature
// Note: this values cannot be calibrated automatically but have to be set manually
//#define USE_TEMP_EXT_COMPENSATION
#endif
#endif
// @section extras
//
// G60/G61 Position Save and Return
//
//#define SAVED_POSITIONS 1 // Each saved position slot costs 12 bytes
//
// G2/G3 Arc Support
//
#define ARC_SUPPORT // Disable this feature to save ~3226 bytes
#if ENABLED(ARC_SUPPORT)
#define MM_PER_ARC_SEGMENT 1 // (mm) Length (or minimum length) of each arc segment
//#define ARC_SEGMENTS_PER_R 1 // Max segment length, MM_PER = Min
#define MIN_ARC_SEGMENTS 24 // Minimum number of segments in a complete circle
//#define ARC_SEGMENTS_PER_SEC 50 // Use feedrate to choose segment length (with MM_PER_ARC_SEGMENT as the minimum)
#define N_ARC_CORRECTION 25 // Number of interpolated segments between corrections
//#define ARC_P_CIRCLES // Enable the 'P' parameter to specify complete circles
//#define CNC_WORKSPACE_PLANES // Allow G2/G3 to operate in XY, ZX, or YZ planes
#endif
// Support for G5 with XYZE destination and IJPQ offsets. Requires ~2666 bytes.
//#define BEZIER_CURVE_SUPPORT
/**
* G38 Probe Target
*
* This option adds G38.2 and G38.3 (probe towards target)
* and optionally G38.4 and G38.5 (probe away from target).
* Set MULTIPLE_PROBING for G38 to probe more than once.
*/
//#define G38_PROBE_TARGET
#if ENABLED(G38_PROBE_TARGET)
//#define G38_PROBE_AWAY // Include G38.4 and G38.5 to probe away from target
#define G38_MINIMUM_MOVE 0.0275 // (mm) Minimum distance that will produce a move.
#endif
// Moves (or segments) with fewer steps than this will be joined with the next move
#define MIN_STEPS_PER_SEGMENT 6
/**
* Minimum delay before and after setting the stepper DIR (in ns)
* 0 : No delay (Expect at least 10µS since one Stepper ISR must transpire)
* 20 : Minimum for TMC2xxx drivers
* 200 : Minimum for A4988 drivers
* 400 : Minimum for A5984 drivers
* 500 : Minimum for LV8729 drivers (guess, no info in datasheet)
* 650 : Minimum for DRV8825 drivers
* 1500 : Minimum for TB6600 drivers (guess, no info in datasheet)
* 15000 : Minimum for TB6560 drivers (guess, no info in datasheet)
*
* Override the default value based on the driver type set in Configuration.h.
*/
//#define MINIMUM_STEPPER_POST_DIR_DELAY 650
//#define MINIMUM_STEPPER_PRE_DIR_DELAY 650
/**
* Minimum stepper driver pulse width (in µs)
* 0 : Smallest possible width the MCU can produce, compatible with TMC2xxx drivers
* 0 : Minimum 500ns for LV8729, adjusted in stepper.h
* 1 : Minimum for A4988 and A5984 stepper drivers
* 2 : Minimum for DRV8825 stepper drivers
* 3 : Minimum for TB6600 stepper drivers
* 30 : Minimum for TB6560 stepper drivers
*
* Override the default value based on the driver type set in Configuration.h.
*/
//#define MINIMUM_STEPPER_PULSE 2
/**
* Maximum stepping rate (in Hz) the stepper driver allows
* If undefined, defaults to 1MHz / (2 * MINIMUM_STEPPER_PULSE)
* 5000000 : Maximum for TMC2xxx stepper drivers
* 1000000 : Maximum for LV8729 stepper driver
* 500000 : Maximum for A4988 stepper driver
* 250000 : Maximum for DRV8825 stepper driver
* 150000 : Maximum for TB6600 stepper driver
* 15000 : Maximum for TB6560 stepper driver
*
* Override the default value based on the driver type set in Configuration.h.
*/
//#define MAXIMUM_STEPPER_RATE 250000
// @section temperature
// Control heater 0 and heater 1 in parallel.
//#define HEATERS_PARALLEL
//===========================================================================
//================================= Buffers =================================
//===========================================================================
// @section hidden
// The number of linear motions that can be in the plan at any give time.
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2 (e.g. 8, 16, 32) because shifts and ors are used to do the ring-buffering.
#if ENABLED(SDSUPPORT)
#define BLOCK_BUFFER_SIZE 16
#else
#define BLOCK_BUFFER_SIZE 16 // Marlin default
#endif
// @section serial
// The ASCII buffer for serial input
#define MAX_CMD_SIZE 96
#define BUFSIZE 8
// Transmission to Host Buffer Size
// To save 386 bytes of PROGMEM (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0.
// To buffer a simple "ok" you need 4 bytes.
// For ADVANCED_OK (M105) you need 32 bytes.
// For debug-echo: 128 bytes for the optimal speed.
// Other output doesn't need to be that speedy.
// :[0, 2, 4, 8, 16, 32, 64, 128, 256]
#define TX_BUFFER_SIZE 0
// Host Receive Buffer Size
// Without XON/XOFF flow control (see SERIAL_XON_XOFF below) 32 bytes should be enough.
// To use flow control, set this buffer size to at least 1024 bytes.
// :[0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
//#define RX_BUFFER_SIZE 1024
#if RX_BUFFER_SIZE >= 1024
// Enable to have the controller send XON/XOFF control characters to
// the host to signal the RX buffer is becoming full.
//#define SERIAL_XON_XOFF
#endif
// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE
#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
//#define SERIAL_STATS_MAX_RX_QUEUED
// Enable this option to collect and display the number
// of dropped bytes after a file transfer to SD.
//#define SERIAL_STATS_DROPPED_RX
#endif
// Enable an emergency-command parser to intercept certain commands as they
// enter the serial receive buffer, so they cannot be blocked.
// Currently handles M108, M112, M410
// Does not work on boards using AT90USB (USBCON) processors!
//#define EMERGENCY_PARSER
// Bad Serial-connections can miss a received command by sending an 'ok'
// Therefore some clients abort after 30 seconds in a timeout.
// Some other clients start sending commands while receiving a 'wait'.
// This "wait" is only sent when the buffer is empty. 1 second is a good value here.
//#define NO_TIMEOUTS 1000 // Milliseconds
// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary.
//#define ADVANCED_OK
// Printrun may have trouble receiving long strings all at once.
// This option inserts short delays between lines of serial output.
#define SERIAL_OVERRUN_PROTECTION
// @section extras
/**
* Extra Fan Speed
* Adds a secondary fan speed for each print-cooling fan.
* 'M106 P<fan> T3-255' : Set a secondary speed for <fan>
* 'M106 P<fan> T2' : Use the set secondary speed
* 'M106 P<fan> T1' : Restore the previous fan speed
*/
//#define EXTRA_FAN_SPEED
/**
* Firmware-based and LCD-controlled retract
*
* Add G10 / G11 commands for automatic firmware-based retract / recover.
* Use M207 and M208 to define parameters for retract / recover.
*
* Use M209 to enable or disable auto-retract.
* With auto-retract enabled, all G1 E moves within the set range
* will be converted to firmware-based retract/recover moves.
*
* Be sure to turn off auto-retract during filament change.
*
* Note that M207 / M208 / M209 settings are saved to EEPROM.
*
*/
//#define FWRETRACT
#if ENABLED(FWRETRACT)
#define FWRETRACT_AUTORETRACT // Override slicer retractions
#if ENABLED(FWRETRACT_AUTORETRACT)
#define MIN_AUTORETRACT 0.1 // (mm) Don't convert E moves under this length
#define MAX_AUTORETRACT 10.0 // (mm) Don't convert E moves over this length
#endif
#define RETRACT_LENGTH 3 // (mm) Default retract length (positive value)
#define RETRACT_LENGTH_SWAP 13 // (mm) Default swap retract length (positive value)
#define RETRACT_FEEDRATE 45 // (mm/s) Default feedrate for retracting
#define RETRACT_ZRAISE 0 // (mm) Default retract Z-raise
#define RETRACT_RECOVER_LENGTH 0 // (mm) Default additional recover length (added to retract length on recover)
#define RETRACT_RECOVER_LENGTH_SWAP 0 // (mm) Default additional swap recover length (added to retract length on recover from toolchange)
#define RETRACT_RECOVER_FEEDRATE 8 // (mm/s) Default feedrate for recovering from retraction
#define RETRACT_RECOVER_FEEDRATE_SWAP 8 // (mm/s) Default feedrate for recovering from swap retraction
#if ENABLED(MIXING_EXTRUDER)
//#define RETRACT_SYNC_MIXING // Retract and restore all mixing steppers simultaneously
#endif
#endif
/**
* Universal tool change settings.
* Applies to all types of extruders except where explicitly noted.
*/
#if EXTRUDERS > 1
// Z raise distance for tool-change, as needed for some extruders
#define TOOLCHANGE_ZRAISE 2 // (mm)
//#define TOOLCHANGE_NO_RETURN // Never return to the previous position on tool-change
#if ENABLED(TOOLCHANGE_NO_RETURN)
//#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // G-code to run after tool-change is complete
#endif
// Retract and prime filament on tool-change
//#define TOOLCHANGE_FILAMENT_SWAP
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
#define TOOLCHANGE_FIL_SWAP_LENGTH 12 // (mm)
#define TOOLCHANGE_FIL_EXTRA_PRIME 2 // (mm)
#define TOOLCHANGE_FIL_SWAP_RETRACT_SPEED 3600 // (mm/m)
#define TOOLCHANGE_FIL_SWAP_PRIME_SPEED 3600 // (mm/m)
#endif
/**
* Position to park head during tool change.
* Doesn't apply to SWITCHING_TOOLHEAD, DUAL_X_CARRIAGE, or PARKING_EXTRUDER
*/
//#define TOOLCHANGE_PARK
#if ENABLED(TOOLCHANGE_PARK)
#define TOOLCHANGE_PARK_XY { X_MIN_POS + 10, Y_MIN_POS + 10 }
#define TOOLCHANGE_PARK_XY_FEEDRATE 6000 // (mm/m)
#endif
#endif
/**
* Advanced Pause
* Experimental feature for filament change support and for parking the nozzle when paused.
* Adds the GCode M600 for initiating filament change.
* If PARK_HEAD_ON_PAUSE enabled, adds the GCode M125 to pause printing and park the nozzle.
*
* Requires an LCD display.
* Requires NOZZLE_PARK_FEATURE.
* This feature is required for the default FILAMENT_RUNOUT_SCRIPT.
*/
// #define ADVANCED_PAUSE_FEATURE
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#define PAUSE_PARK_RETRACT_FEEDRATE 60 // (mm/s) Initial retract feedrate.
#define PAUSE_PARK_RETRACT_LENGTH 2 // (mm) Initial retract.
// This short retract is done immediately, before parking the nozzle.
#define FILAMENT_CHANGE_UNLOAD_FEEDRATE 10 // (mm/s) Unload filament feedrate. This can be pretty fast.
#define FILAMENT_CHANGE_UNLOAD_ACCEL 25 // (mm/s^2) Lower acceleration may allow a faster feedrate.
#define FILAMENT_CHANGE_UNLOAD_LENGTH 100 // (mm) The length of filament for a complete unload.
// For Bowden, the full length of the tube and nozzle.
// For direct drive, the full length of the nozzle.
// Set to 0 for manual unloading.
#define FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE 6 // (mm/s) Slow move when starting load.
#define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0 // (mm) Slow length, to allow time to insert material.
// 0 to disable start loading and skip to fast load only
#define FILAMENT_CHANGE_FAST_LOAD_FEEDRATE 6 // (mm/s) Load filament feedrate. This can be pretty fast.
#define FILAMENT_CHANGE_FAST_LOAD_ACCEL 25 // (mm/s^2) Lower acceleration may allow a faster feedrate.
#define FILAMENT_CHANGE_FAST_LOAD_LENGTH 0 // (mm) Load length of filament, from extruder gear to nozzle.
// For Bowden, the full length of the tube and nozzle.
// For direct drive, the full length of the nozzle.
//#define ADVANCED_PAUSE_CONTINUOUS_PURGE // Purge continuously up to the purge length until interrupted.
#define ADVANCED_PAUSE_PURGE_FEEDRATE 3 // (mm/s) Extrude feedrate (after loading). Should be slower than load feedrate.
#define ADVANCED_PAUSE_PURGE_LENGTH 25 // (mm) Length to extrude after loading.
// Set to 0 for manual extrusion.
// Filament can be extruded repeatedly from the Filament Change menu
// until extrusion is consistent, and to purge old filament.
#define ADVANCED_PAUSE_RESUME_PRIME 0 // (mm) Extra distance to prime nozzle after returning from park.
//#define ADVANCED_PAUSE_FANS_PAUSE // Turn off print-cooling fans while the machine is paused.
// Filament Unload does a Retract, Delay, and Purge first:
#define FILAMENT_UNLOAD_PURGE_RETRACT 13 // (mm) Unload initial retract length.
#define FILAMENT_UNLOAD_PURGE_DELAY 5000 // (ms) Delay for the filament to cool after retract.
#define FILAMENT_UNLOAD_PURGE_LENGTH 8 // (mm) An unretract is done, then this length is purged.
#define FILAMENT_UNLOAD_PURGE_FEEDRATE 25 // (mm/s) feedrate to purge before unload
#define PAUSE_PARK_NOZZLE_TIMEOUT 45 // (seconds) Time limit before the nozzle is turned off for safety.
#define FILAMENT_CHANGE_ALERT_BEEPS 10 // Number of alert beeps to play when a response is needed.
#define PAUSE_PARK_NO_STEPPER_TIMEOUT // Enable for XYZ steppers to stay powered on during filament change.
//#define PARK_HEAD_ON_PAUSE // Park the nozzle during pause and filament change.
//#define HOME_BEFORE_FILAMENT_CHANGE // Ensure homing has been completed prior to parking for filament change
#define FILAMENT_LOAD_UNLOAD_GCODES // Add M701/M702 Load/Unload G-codes, plus Load/Unload in the LCD Prepare menu.
//#define FILAMENT_UNLOAD_ALL_EXTRUDERS // Allow M702 to unload all extruders above a minimum target temp (as set by M302)
#endif
// @section tmc
/**
* TMC26X Stepper Driver options
*
* The TMC26XStepper library is required for this stepper driver.
* https://github.com/trinamic/TMC26XStepper
*/
#if HAS_DRIVER(TMC26X)
#if AXIS_DRIVER_TYPE_X(TMC26X)
#define X_MAX_CURRENT 1000 // (mA)
#define X_SENSE_RESISTOR 91 // (mOhms)
#define X_MICROSTEPS 16 // Number of microsteps
#endif
#if AXIS_DRIVER_TYPE_X2(TMC26X)
#define X2_MAX_CURRENT 1000
#define X2_SENSE_RESISTOR 91
#define X2_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_Y(TMC26X)
#define Y_MAX_CURRENT 1000
#define Y_SENSE_RESISTOR 91
#define Y_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_Y2(TMC26X)
#define Y2_MAX_CURRENT 1000
#define Y2_SENSE_RESISTOR 91
#define Y2_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_Z(TMC26X)
#define Z_MAX_CURRENT 1000
#define Z_SENSE_RESISTOR 91
#define Z_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_Z2(TMC26X)
#define Z2_MAX_CURRENT 1000
#define Z2_SENSE_RESISTOR 91
#define Z2_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_Z3(TMC26X)
#define Z3_MAX_CURRENT 1000
#define Z3_SENSE_RESISTOR 91
#define Z3_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_Z4(TMC26X)
#define Z4_MAX_CURRENT 1000
#define Z4_SENSE_RESISTOR 91
#define Z4_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E0(TMC26X)
#define E0_MAX_CURRENT 1000
#define E0_SENSE_RESISTOR 91
#define E0_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E1(TMC26X)
#define E1_MAX_CURRENT 1000
#define E1_SENSE_RESISTOR 91
#define E1_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E2(TMC26X)
#define E2_MAX_CURRENT 1000
#define E2_SENSE_RESISTOR 91
#define E2_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E3(TMC26X)
#define E3_MAX_CURRENT 1000
#define E3_SENSE_RESISTOR 91
#define E3_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E4(TMC26X)
#define E4_MAX_CURRENT 1000
#define E4_SENSE_RESISTOR 91
#define E4_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E5(TMC26X)
#define E5_MAX_CURRENT 1000
#define E5_SENSE_RESISTOR 91
#define E5_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E6(TMC26X)
#define E6_MAX_CURRENT 1000
#define E6_SENSE_RESISTOR 91
#define E6_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E7(TMC26X)
#define E7_MAX_CURRENT 1000
#define E7_SENSE_RESISTOR 91
#define E7_MICROSTEPS 16
#endif
#endif // TMC26X
// @section tmc_smart
/**
* To use TMC2130, TMC2160, TMC2660, TMC5130, TMC5160 stepper drivers in SPI mode
* connect your SPI pins to the hardware SPI interface on your board and define
* the required CS pins in your `pins_MYBOARD.h` file. (e.g., RAMPS 1.4 uses AUX3
* pins `X_CS_PIN 53`, `Y_CS_PIN 49`, etc.).
* You may also use software SPI if you wish to use general purpose IO pins.
*
* To use TMC2208 stepper UART-configurable stepper drivers connect #_SERIAL_TX_PIN
* to the driver side PDN_UART pin with a 1K resistor.
* To use the reading capabilities, also connect #_SERIAL_RX_PIN to PDN_UART without
* a resistor.
* The drivers can also be used with hardware serial.
*
* TMCStepper library is required to use TMC stepper drivers.
* https://github.com/teemuatlut/TMCStepper
*/
#if HAS_TRINAMIC_CONFIG
#define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current
#define INTERPOLATE true // Interpolate X/Y/Z_MICROSTEPS to 256
#if AXIS_IS_TMC(X)
#define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current.
#define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing
#define X_MICROSTEPS 16 // 0..256
#define X_RSENSE 0.11
#define X_CHAIN_POS -1 // <=0 : Not chained. 1 : MCU MOSI connected. 2 : Next in chain, ...
#endif
#if AXIS_IS_TMC(X2)
#define X2_CURRENT 800
#define X2_CURRENT_HOME X2_CURRENT
#define X2_MICROSTEPS 16
#define X2_RSENSE 0.11
#define X2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Y)
#define Y_CURRENT 800
#define Y_CURRENT_HOME Y_CURRENT
#define Y_MICROSTEPS 16
#define Y_RSENSE 0.11
#define Y_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Y2)
#define Y2_CURRENT 800
#define Y2_CURRENT_HOME Y2_CURRENT
#define Y2_MICROSTEPS 16
#define Y2_RSENSE 0.11
#define Y2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z)
#define Z_CURRENT 800
#define Z_CURRENT_HOME Z_CURRENT
#define Z_MICROSTEPS 16
#define Z_RSENSE 0.11
#define Z_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z2)
#define Z2_CURRENT 800
#define Z2_CURRENT_HOME Z2_CURRENT
#define Z2_MICROSTEPS 16
#define Z2_RSENSE 0.11
#define Z2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z3)
#define Z3_CURRENT 800
#define Z3_CURRENT_HOME Z3_CURRENT
#define Z3_MICROSTEPS 16
#define Z3_RSENSE 0.11
#define Z3_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z4)
#define Z4_CURRENT 800
#define Z4_CURRENT_HOME Z4_CURRENT
#define Z4_MICROSTEPS 16
#define Z4_RSENSE 0.11
#define Z4_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E0)
#define E0_CURRENT 800
#define E0_MICROSTEPS 16
#define E0_RSENSE 0.11
#define E0_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E1)
#define E1_CURRENT 800
#define E1_MICROSTEPS 16
#define E1_RSENSE 0.11
#define E1_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E2)
#define E2_CURRENT 800
#define E2_MICROSTEPS 16
#define E2_RSENSE 0.11
#define E2_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E3)
#define E3_CURRENT 800
#define E3_MICROSTEPS 16
#define E3_RSENSE 0.11
#define E3_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E4)
#define E4_CURRENT 800
#define E4_MICROSTEPS 16
#define E4_RSENSE 0.11
#define E4_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E5)
#define E5_CURRENT 800
#define E5_MICROSTEPS 16
#define E5_RSENSE 0.11
#define E5_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E6)
#define E6_CURRENT 800
#define E6_MICROSTEPS 16
#define E6_RSENSE 0.11
#define E6_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E7)
#define E7_CURRENT 800
#define E7_MICROSTEPS 16
#define E7_RSENSE 0.11
#define E7_CHAIN_POS -1
#endif
/**
* Override default SPI pins for TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160 drivers here.
* The default pins can be found in your board's pins file.
*/
//#define X_CS_PIN -1
//#define Y_CS_PIN -1
//#define Z_CS_PIN -1
//#define X2_CS_PIN -1
//#define Y2_CS_PIN -1
//#define Z2_CS_PIN -1
//#define Z3_CS_PIN -1
//#define E0_CS_PIN -1
//#define E1_CS_PIN -1
//#define E2_CS_PIN -1
//#define E3_CS_PIN -1
//#define E4_CS_PIN -1
//#define E5_CS_PIN -1
//#define E6_CS_PIN -1
//#define E7_CS_PIN -1
/**
* Software option for SPI driven drivers (TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160).
* The default SW SPI pins are defined the respective pins files,
* but you can override or define them here.
*/
//#define TMC_USE_SW_SPI
//#define TMC_SW_MOSI -1
//#define TMC_SW_MISO -1
//#define TMC_SW_SCK -1
/**
* Four TMC2209 drivers can use the same HW/SW serial port with hardware configured addresses.
* Set the address using jumpers on pins MS1 and MS2.
* Address | MS1 | MS2
* 0 | LOW | LOW
* 1 | HIGH | LOW
* 2 | LOW | HIGH
* 3 | HIGH | HIGH
*
* Set *_SERIAL_TX_PIN and *_SERIAL_RX_PIN to match for all drivers
* on the same serial port, either here or in your board's pins file.
*/
#define X_SLAVE_ADDRESS 0
#define Y_SLAVE_ADDRESS 0
#define Z_SLAVE_ADDRESS 0
#define X2_SLAVE_ADDRESS 0
#define Y2_SLAVE_ADDRESS 0
#define Z2_SLAVE_ADDRESS 0
#define Z3_SLAVE_ADDRESS 0
#define Z4_SLAVE_ADDRESS 0
#define E0_SLAVE_ADDRESS 0
#define E1_SLAVE_ADDRESS 0
#define E2_SLAVE_ADDRESS 0
#define E3_SLAVE_ADDRESS 0
#define E4_SLAVE_ADDRESS 0
#define E5_SLAVE_ADDRESS 0
#define E6_SLAVE_ADDRESS 0
#define E7_SLAVE_ADDRESS 0
/**
* Software enable
*
* Use for drivers that do not use a dedicated enable pin, but rather handle the same
* function through a communication line such as SPI or UART.
*/
//#define SOFTWARE_DRIVER_ENABLE
/**
* TMC2130, TMC2160, TMC2208, TMC2209, TMC5130 and TMC5160 only
* Use Trinamic's ultra quiet stepping mode.
* When disabled, Marlin will use spreadCycle stepping mode.
*/
#define STEALTHCHOP_XY
#define STEALTHCHOP_Z
#define STEALTHCHOP_E
/**
* Optimize spreadCycle chopper parameters by using predefined parameter sets
* or with the help of an example included in the library.
* Provided parameter sets are
* CHOPPER_DEFAULT_12V
* CHOPPER_DEFAULT_19V
* CHOPPER_DEFAULT_24V
* CHOPPER_DEFAULT_36V
* CHOPPER_PRUSAMK3_24V // Imported parameters from the official Prusa firmware for MK3 (24V)
* CHOPPER_MARLIN_119 // Old defaults from Marlin v1.1.9
*
* Define you own with
* { <off_time[1..15]>, <hysteresis_end[-3..12]>, hysteresis_start[1..8] }
*/
#define CHOPPER_TIMING CHOPPER_DEFAULT_12V
/**
* Monitor Trinamic drivers for error conditions,
* like overtemperature and short to ground.
* In the case of overtemperature Marlin can decrease the driver current until error condition clears.
* Other detected conditions can be used to stop the current print.
* Relevant g-codes:
* M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given.
* M911 - Report stepper driver overtemperature pre-warn condition.
* M912 - Clear stepper driver overtemperature pre-warn condition flag.
* M122 - Report driver parameters (Requires TMC_DEBUG)
*/
//#define MONITOR_DRIVER_STATUS
#if ENABLED(MONITOR_DRIVER_STATUS)
#define CURRENT_STEP_DOWN 50 // [mA]
#define REPORT_CURRENT_CHANGE
#define STOP_ON_ERROR
#endif
/**
* TMC2130, TMC2160, TMC2208, TMC2209, TMC5130 and TMC5160 only
* The driver will switch to spreadCycle when stepper speed is over HYBRID_THRESHOLD.
* This mode allows for faster movements at the expense of higher noise levels.
* STEALTHCHOP_(XY|Z|E) must be enabled to use HYBRID_THRESHOLD.
* M913 X/Y/Z/E to live tune the setting
*/
//#define HYBRID_THRESHOLD
#define X_HYBRID_THRESHOLD 100 // [mm/s]
#define X2_HYBRID_THRESHOLD 100
#define Y_HYBRID_THRESHOLD 100
#define Y2_HYBRID_THRESHOLD 100
#define Z_HYBRID_THRESHOLD 3
#define Z2_HYBRID_THRESHOLD 3
#define Z3_HYBRID_THRESHOLD 3
#define Z4_HYBRID_THRESHOLD 3
#define E0_HYBRID_THRESHOLD 30
#define E1_HYBRID_THRESHOLD 30
#define E2_HYBRID_THRESHOLD 30
#define E3_HYBRID_THRESHOLD 30
#define E4_HYBRID_THRESHOLD 30
#define E5_HYBRID_THRESHOLD 30
#define E6_HYBRID_THRESHOLD 30
#define E7_HYBRID_THRESHOLD 30
/**
* Use StallGuard2 to home / probe X, Y, Z.
*
* TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only
* Connect the stepper driver's DIAG1 pin to the X/Y endstop pin.
* X, Y, and Z homing will always be done in spreadCycle mode.
*
* X/Y/Z_STALL_SENSITIVITY is the default stall threshold.
* Use M914 X Y Z to set the stall threshold at runtime:
*
* Sensitivity TMC2209 Others
* HIGHEST 255 -64 (Too sensitive => False positive)
* LOWEST 0 63 (Too insensitive => No trigger)
*
* It is recommended to set [XYZ]_HOME_BUMP_MM to 0.
*
* SPI_ENDSTOPS *** Beta feature! *** TMC2130 Only ***
* Poll the driver through SPI to determine load when homing.
* Removes the need for a wire from DIAG1 to an endstop pin.
*
* IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when
* homing and adds a guard period for endstop triggering.
*/
//#define SENSORLESS_HOMING // StallGuard capable drivers only
#if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING)
// TMC2209: 0...255. TMC2130: -64...63
#define X_STALL_SENSITIVITY 8
#define X2_STALL_SENSITIVITY X_STALL_SENSITIVITY
#define Y_STALL_SENSITIVITY 8
//#define Z_STALL_SENSITIVITY 8
//#define SPI_ENDSTOPS // TMC2130 only
//#define IMPROVE_HOMING_RELIABILITY
#endif
/**
* Beta feature!
* Create a 50/50 square wave step pulse optimal for stepper drivers.
*/
//#define SQUARE_WAVE_STEPPING
/**
* Enable M122 debugging command for TMC stepper drivers.
* M122 S0/1 will enable continous reporting.
*/
//#define TMC_DEBUG
/**
* You can set your own advanced settings by filling in predefined functions.
* A list of available functions can be found on the library github page
* https://github.com/teemuatlut/TMCStepper
*
* Example:
* #define TMC_ADV() { \
* stepperX.diag0_otpw(1); \
* stepperY.intpol(0); \
* }
*/
#define TMC_ADV() { }
#endif // HAS_TRINAMIC_CONFIG
// @section L64XX
/**
* L64XX Stepper Driver options
*
* Arduino-L6470 library (0.8.0 or higher) is required.
* https://github.com/ameyer/Arduino-L6470
*
* Requires the following to be defined in your pins_YOUR_BOARD file
* L6470_CHAIN_SCK_PIN
* L6470_CHAIN_MISO_PIN
* L6470_CHAIN_MOSI_PIN
* L6470_CHAIN_SS_PIN
* ENABLE_RESET_L64XX_CHIPS(Q) where Q is 1 to enable and 0 to reset
*/
#if HAS_L64XX
//#define L6470_CHITCHAT // Display additional status info
#if AXIS_IS_L64XX(X)
#define X_MICROSTEPS 128 // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128) - L6474 max is 16
#define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current
// L6470 & L6474 - VALID: 375 x (1 - 16) - 6A max - rounds down
// POWERSTEP01: VALID: 1000 x (1 - 32) - 32A max - rounds down
#define X_STALLCURRENT 1500 // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) - 4A max - rounds down)
// L6470 & L6474 - VALID: 31.25 * (1-128) - 4A max - rounds down
// POWERSTEP01: VALID: 200 x (1 - 32) - 6.4A max - rounds down
// L6474 - STALLCURRENT setting is used to set the nominal (TVAL) current
#define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper - not used by L6474
#define X_CHAIN_POS -1 // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI
#define X_SLEW_RATE 1 // 0-3, Slew 0 is slowest, 3 is fastest
#endif
#if AXIS_IS_L64XX(X2)
#define X2_MICROSTEPS 128
#define X2_OVERCURRENT 2000
#define X2_STALLCURRENT 1500
#define X2_MAX_VOLTAGE 127
#define X2_CHAIN_POS -1
#define X2_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(Y)
#define Y_MICROSTEPS 128
#define Y_OVERCURRENT 2000
#define Y_STALLCURRENT 1500
#define Y_MAX_VOLTAGE 127
#define Y_CHAIN_POS -1
#define Y_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(Y2)
#define Y2_MICROSTEPS 128
#define Y2_OVERCURRENT 2000
#define Y2_STALLCURRENT 1500
#define Y2_MAX_VOLTAGE 127
#define Y2_CHAIN_POS -1
#define Y2_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(Z)
#define Z_MICROSTEPS 128
#define Z_OVERCURRENT 2000
#define Z_STALLCURRENT 1500
#define Z_MAX_VOLTAGE 127
#define Z_CHAIN_POS -1
#define Z_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(Z2)
#define Z2_MICROSTEPS 128
#define Z2_OVERCURRENT 2000
#define Z2_STALLCURRENT 1500
#define Z2_MAX_VOLTAGE 127
#define Z2_CHAIN_POS -1
#define Z2_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(Z3)
#define Z3_MICROSTEPS 128
#define Z3_OVERCURRENT 2000
#define Z3_STALLCURRENT 1500
#define Z3_MAX_VOLTAGE 127
#define Z3_CHAIN_POS -1
#define Z3_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(Z4)
#define Z4_MICROSTEPS 128
#define Z4_OVERCURRENT 2000
#define Z4_STALLCURRENT 1500
#define Z4_MAX_VOLTAGE 127
#define Z4_CHAIN_POS -1
#define Z4_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E0)
#define E0_MICROSTEPS 128
#define E0_OVERCURRENT 2000
#define E0_STALLCURRENT 1500
#define E0_MAX_VOLTAGE 127
#define E0_CHAIN_POS -1
#define E0_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E1)
#define E1_MICROSTEPS 128
#define E1_OVERCURRENT 2000
#define E1_STALLCURRENT 1500
#define E1_MAX_VOLTAGE 127
#define E1_CHAIN_POS -1
#define E1_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E2)
#define E2_MICROSTEPS 128
#define E2_OVERCURRENT 2000
#define E2_STALLCURRENT 1500
#define E2_MAX_VOLTAGE 127
#define E2_CHAIN_POS -1
#define E2_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E3)
#define E3_MICROSTEPS 128
#define E3_OVERCURRENT 2000
#define E3_STALLCURRENT 1500
#define E3_MAX_VOLTAGE 127
#define E3_CHAIN_POS -1
#define E3_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E4)
#define E4_MICROSTEPS 128
#define E4_OVERCURRENT 2000
#define E4_STALLCURRENT 1500
#define E4_MAX_VOLTAGE 127
#define E4_CHAIN_POS -1
#define E4_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E5)
#define E5_MICROSTEPS 128
#define E5_OVERCURRENT 2000
#define E5_STALLCURRENT 1500
#define E5_MAX_VOLTAGE 127
#define E5_CHAIN_POS -1
#define E5_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E6)
#define E6_MICROSTEPS 128
#define E6_OVERCURRENT 2000
#define E6_STALLCURRENT 1500
#define E6_MAX_VOLTAGE 127
#define E6_CHAIN_POS -1
#define E6_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E7)
#define E7_MICROSTEPS 128
#define E7_OVERCURRENT 2000
#define E7_STALLCURRENT 1500
#define E7_MAX_VOLTAGE 127
#define E7_CHAIN_POS -1
#define E7_SLEW_RATE 1
#endif
/**
* Monitor L6470 drivers for error conditions like over temperature and over current.
* In the case of over temperature Marlin can decrease the drive until the error condition clears.
* Other detected conditions can be used to stop the current print.
* Relevant g-codes:
* M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given.
* I not present or I0 or I1 - X, Y, Z or E0
* I2 - X2, Y2, Z2 or E1
* I3 - Z3 or E3
* I4 - Z4 or E4
* I5 - E5
* M916 - Increase drive level until get thermal warning
* M917 - Find minimum current thresholds
* M918 - Increase speed until max or error
* M122 S0/1 - Report driver parameters
*/
//#define MONITOR_L6470_DRIVER_STATUS
#if ENABLED(MONITOR_L6470_DRIVER_STATUS)
#define KVAL_HOLD_STEP_DOWN 1
//#define L6470_STOP_ON_ERROR
#endif
#endif // HAS_L64XX
// @section i2cbus
//
// I2C Master ID for LPC176x LCD and Digital Current control
// Does not apply to other peripherals based on the Wire library.
//
//#define I2C_MASTER_ID 1 // Set a value from 0 to 2
/**
* TWI/I2C BUS
*
* This feature is an EXPERIMENTAL feature so it shall not be used on production
* machines. Enabling this will allow you to send and receive I2C data from slave
* devices on the bus.
*
* ; Example #1
* ; This macro send the string "Marlin" to the slave device with address 0x63 (99)
* ; It uses multiple M260 commands with one B<base 10> arg
* M260 A99 ; Target slave address
* M260 B77 ; M
* M260 B97 ; a
* M260 B114 ; r
* M260 B108 ; l
* M260 B105 ; i
* M260 B110 ; n
* M260 S1 ; Send the current buffer
*
* ; Example #2
* ; Request 6 bytes from slave device with address 0x63 (99)
* M261 A99 B5
*
* ; Example #3
* ; Example serial output of a M261 request
* echo:i2c-reply: from:99 bytes:5 data:hello
*/
//#define EXPERIMENTAL_I2CBUS
#if ENABLED(EXPERIMENTAL_I2CBUS)
#define I2C_SLAVE_ADDRESS 0 // Set a value from 8 to 127 to act as a slave
#endif
// @section extras
/**
* Photo G-code
* Add the M240 G-code to take a photo.
* The photo can be triggered by a digital pin or a physical movement.
*/
//#define PHOTO_GCODE
#if ENABLED(PHOTO_GCODE)
// A position to move to (and raise Z) before taking the photo
//#define PHOTO_POSITION { X_MAX_POS - 5, Y_MAX_POS, 0 } // { xpos, ypos, zraise } (M240 X Y Z)
//#define PHOTO_DELAY_MS 100 // (ms) Duration to pause before moving back (M240 P)
//#define PHOTO_RETRACT_MM 6.5 // (mm) E retract/recover for the photo move (M240 R S)
// Canon RC-1 or homebrew digital camera trigger
// Data from: http://www.doc-diy.net/photo/rc-1_hacked/
//#define PHOTOGRAPH_PIN 23
// Canon Hack Development Kit
// http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
//#define CHDK_PIN 4
// Optional second move with delay to trigger the camera shutter
//#define PHOTO_SWITCH_POSITION { X_MAX_POS, Y_MAX_POS } // { xpos, ypos } (M240 I J)
// Duration to hold the switch or keep CHDK_PIN high
//#define PHOTO_SWITCH_MS 50 // (ms) (M240 D)
/**
* PHOTO_PULSES_US may need adjustment depending on board and camera model.
* Pin must be running at 48.4kHz.
* Be sure to use a PHOTOGRAPH_PIN which can rise and fall quick enough.
* (e.g., MKS SBase temp sensor pin was too slow, so used P1.23 on J8.)
*
* Example pulse data for Nikon: https://bit.ly/2FKD0Aq
* IR Wiring: https://git.io/JvJf7
*/
//#define PHOTO_PULSES_US { 2000, 27850, 400, 1580, 400, 3580, 400 } // (µs) Durations for each 48.4kHz oscillation
#ifdef PHOTO_PULSES_US
#define PHOTO_PULSE_DELAY_US 13 // (µs) Approximate duration of each HIGH and LOW pulse in the oscillation
#endif
#endif
/**
* Spindle & Laser control
*
* Add the M3, M4, and M5 commands to turn the spindle/laser on and off, and
* to set spindle speed, spindle direction, and laser power.
*
* SuperPid is a router/spindle speed controller used in the CNC milling community.
* Marlin can be used to turn the spindle on and off. It can also be used to set
* the spindle speed from 5,000 to 30,000 RPM.
*
* You'll need to select a pin for the ON/OFF function and optionally choose a 0-5V
* hardware PWM pin for the speed control and a pin for the rotation direction.
*
* See http://marlinfw.org/docs/configuration/laser_spindle.html for more config details.
*/
//#define SPINDLE_FEATURE
//#define LASER_FEATURE
#if EITHER(SPINDLE_FEATURE, LASER_FEATURE)
#define SPINDLE_LASER_ACTIVE_HIGH false // Set to "true" if the on/off function is active HIGH
#define SPINDLE_LASER_PWM true // Set to "true" if your controller supports setting the speed/power
#define SPINDLE_LASER_PWM_INVERT true // Set to "true" if the speed/power goes up when you want it to go slower
#define SPINDLE_LASER_POWERUP_DELAY 5000 // (ms) Delay to allow the spindle/laser to come up to speed/power
#define SPINDLE_LASER_POWERDOWN_DELAY 5000 // (ms) Delay to allow the spindle to stop
#if ENABLED(SPINDLE_FEATURE)
//#define SPINDLE_CHANGE_DIR // Enable if your spindle controller can change spindle direction
#define SPINDLE_CHANGE_DIR_STOP // Enable if the spindle should stop before changing spin direction
#define SPINDLE_INVERT_DIR false // Set to "true" if the spin direction is reversed
/**
* The M3 & M4 commands use the following equation to convert PWM duty cycle to speed/power
*
* SPEED/POWER = PWM duty cycle * SPEED_POWER_SLOPE + SPEED_POWER_INTERCEPT
* where PWM duty cycle varies from 0 to 255
*
* set the following for your controller (ALL MUST BE SET)
*/
#define SPEED_POWER_SLOPE 118.4
#define SPEED_POWER_INTERCEPT 0
#define SPEED_POWER_MIN 5000
#define SPEED_POWER_MAX 30000 // SuperPID router controller 0 - 30,000 RPM
#else
#define SPEED_POWER_SLOPE 0.3922
#define SPEED_POWER_INTERCEPT 0
#define SPEED_POWER_MIN 10
#define SPEED_POWER_MAX 100 // 0-100%
#endif
#endif
/**
* Coolant Control
*
* Add the M7, M8, and M9 commands to turn mist or flood coolant on and off.
*
* Note: COOLANT_MIST_PIN and/or COOLANT_FLOOD_PIN must also be defined.
*/
//#define COOLANT_CONTROL
#if ENABLED(COOLANT_CONTROL)
#define COOLANT_MIST // Enable if mist coolant is present
#define COOLANT_FLOOD // Enable if flood coolant is present
#define COOLANT_MIST_INVERT false // Set "true" if the on/off function is reversed
#define COOLANT_FLOOD_INVERT false // Set "true" if the on/off function is reversed
#endif
/**
* Filament Width Sensor
*
* Measures the filament width in real-time and adjusts
* flow rate to compensate for any irregularities.
*
* Also allows the measured filament diameter to set the
* extrusion rate, so the slicer only has to specify the
* volume.
*
* Only a single extruder is supported at this time.
*
* 34 RAMPS_14 : Analog input 5 on the AUX2 connector
* 81 PRINTRBOARD : Analog input 2 on the Exp1 connector (version B,C,D,E)
* 301 RAMBO : Analog input 3
*
* Note: May require analog pins to be defined for other boards.
*/
//#define FILAMENT_WIDTH_SENSOR
#if ENABLED(FILAMENT_WIDTH_SENSOR)
#define FILAMENT_SENSOR_EXTRUDER_NUM 0 // Index of the extruder that has the filament sensor. :[0,1,2,3,4]
#define MEASUREMENT_DELAY_CM 14 // (cm) The distance from the filament sensor to the melting chamber
#define FILWIDTH_ERROR_MARGIN 1.0 // (mm) If a measurement differs too much from nominal width ignore it
#define MAX_MEASUREMENT_DELAY 20 // (bytes) Buffer size for stored measurements (1 byte per cm). Must be larger than MEASUREMENT_DELAY_CM.
#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA // Set measured to nominal initially
// Display filament width on the LCD status line. Status messages will expire after 5 seconds.
//#define FILAMENT_LCD_DISPLAY
#endif
/**
* CNC Coordinate Systems
*
* Enables G53 and G54-G59.3 commands to select coordinate systems
* and G92.1 to reset the workspace to native machine space.
*/
//#define CNC_COORDINATE_SYSTEMS
/**
* Auto-report temperatures with M155 S<seconds>
*/
#define AUTO_REPORT_TEMPERATURES
/**
* Include capabilities in M115 output
*/
#define EXTENDED_CAPABILITIES_REPORT
/**
* Expected Printer Check
* Add the M16 G-code to compare a string to the MACHINE_NAME.
* M16 with a non-matching string causes the printer to halt.
*/
//#define EXPECTED_PRINTER_CHECK
/**
* Disable all Volumetric extrusion options
*/
//#define NO_VOLUMETRICS
#if DISABLED(NO_VOLUMETRICS)
/**
* Volumetric extrusion default state
* Activate to make volumetric extrusion the default method,
* with DEFAULT_NOMINAL_FILAMENT_DIA as the default diameter.
*
* M200 D0 to disable, M200 Dn to set a new diameter.
*/
//#define VOLUMETRIC_DEFAULT_ON
#endif
/**
* Enable this option for a leaner build of Marlin that removes all
* workspace offsets, simplifying coordinate transformations, leveling, etc.
*
* - M206 and M428 are disabled.
* - G92 will revert to its behavior from Marlin 1.0.
*/
//#define NO_WORKSPACE_OFFSETS
/**
* Set the number of proportional font spaces required to fill up a typical character space.
* This can help to better align the output of commands like `G29 O` Mesh Output.
*
* For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0.
* Otherwise, adjust according to your client and font.
*/
#define PROPORTIONAL_FONT_RATIO 1.0
/**
* Spend 28 bytes of SRAM to optimize the GCode parser
*/
#define FASTER_GCODE_PARSER
#if ENABLED(FASTER_GCODE_PARSER)
//#define GCODE_QUOTED_STRINGS // Support for quoted string parameters
#endif
//#define GCODE_CASE_INSENSITIVE // Accept G-code sent to the firmware in lowercase
/**
* CNC G-code options
* Support CNC-style G-code dialects used by laser cutters, drawing machine cams, etc.
* Note that G0 feedrates should be used with care for 3D printing (if used at all).
* High feedrates may cause ringing and harm print quality.
*/
//#define PAREN_COMMENTS // Support for parentheses-delimited comments
//#define GCODE_MOTION_MODES // Remember the motion mode (G0 G1 G2 G3 G5 G38.X) and apply for X Y Z E F, etc.
// Enable and set a (default) feedrate for all G0 moves
//#define G0_FEEDRATE 3000 // (mm/m)
#ifdef G0_FEEDRATE
//#define VARIABLE_G0_FEEDRATE // The G0 feedrate is set by F in G0 motion mode
#endif
/**
* Startup commands
*
* Execute certain G-code commands immediately after power-on.
*/
//#define STARTUP_COMMANDS "M17 Z"
/**
* G-code Macros
*
* Add G-codes M810-M819 to define and run G-code macros.
* Macros are not saved to EEPROM.
*/
//#define GCODE_MACROS
#if ENABLED(GCODE_MACROS)
#define GCODE_MACROS_SLOTS 5 // Up to 10 may be used
#define GCODE_MACROS_SLOT_SIZE 50 // Maximum length of a single macro
#endif
/**
* User-defined menu items that execute custom GCode
*/
//#define CUSTOM_USER_MENUS
#if ENABLED(CUSTOM_USER_MENUS)
//#define CUSTOM_USER_MENU_TITLE "Custom Commands"
#define USER_SCRIPT_DONE "M117 User Script Done"
#define USER_SCRIPT_AUDIBLE_FEEDBACK
//#define USER_SCRIPT_RETURN // Return to status screen after a script
#define USER_DESC_1 "Home & UBL Info"
#define USER_GCODE_1 "G28\nG29 W"
#define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL
#define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
#define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL
#define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
#define USER_DESC_4 "Heat Bed/Home/Level"
#define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"
#define USER_DESC_5 "Home & Info"
#define USER_GCODE_5 "G28\nM503"
#endif
/**
* Host Action Commands
*
* Define host streamer action commands in compliance with the standard.
*
* See https://reprap.org/wiki/G-code#Action_commands
* Common commands ........ poweroff, pause, paused, resume, resumed, cancel
* G29_RETRY_AND_RECOVER .. probe_rewipe, probe_failed
*
* Some features add reason codes to extend these commands.
*
* Host Prompt Support enables Marlin to use the host for user prompts so
* filament runout and other processes can be managed from the host side.
*/
//#define HOST_ACTION_COMMANDS
#if ENABLED(HOST_ACTION_COMMANDS)
//#define HOST_PROMPT_SUPPORT
#endif
/**
* Cancel Objects
*
* Implement M486 to allow Marlin to skip objects
*/
//#define CANCEL_OBJECTS
/**
* I2C position encoders for closed loop control.
* Developed by Chris Barr at Aus3D.
*
* Wiki: http://wiki.aus3d.com.au/Magnetic_Encoder
* Github: https://github.com/Aus3D/MagneticEncoder
*
* Supplier: http://aus3d.com.au/magnetic-encoder-module
* Alternative Supplier: http://reliabuild3d.com/
*
* Reliabuild encoders have been modified to improve reliability.
*/
//#define I2C_POSITION_ENCODERS
#if ENABLED(I2C_POSITION_ENCODERS)
#define I2CPE_ENCODER_CNT 1 // The number of encoders installed; max of 5
// encoders supported currently.
#define I2CPE_ENC_1_ADDR I2CPE_PRESET_ADDR_X // I2C address of the encoder. 30-200.
#define I2CPE_ENC_1_AXIS X_AXIS // Axis the encoder module is installed on. <X|Y|Z|E>_AXIS.
#define I2CPE_ENC_1_TYPE I2CPE_ENC_TYPE_LINEAR // Type of encoder: I2CPE_ENC_TYPE_LINEAR -or-
// I2CPE_ENC_TYPE_ROTARY.
#define I2CPE_ENC_1_TICKS_UNIT 2048 // 1024 for magnetic strips with 2mm poles; 2048 for
// 1mm poles. For linear encoders this is ticks / mm,
// for rotary encoders this is ticks / revolution.
//#define I2CPE_ENC_1_TICKS_REV (16 * 200) // Only needed for rotary encoders; number of stepper
// steps per full revolution (motor steps/rev * microstepping)
//#define I2CPE_ENC_1_INVERT // Invert the direction of axis travel.
#define I2CPE_ENC_1_EC_METHOD I2CPE_ECM_MICROSTEP // Type of error error correction.
#define I2CPE_ENC_1_EC_THRESH 0.10 // Threshold size for error (in mm) above which the
// printer will attempt to correct the error; errors
// smaller than this are ignored to minimize effects of
// measurement noise / latency (filter).
#define I2CPE_ENC_2_ADDR I2CPE_PRESET_ADDR_Y // Same as above, but for encoder 2.
#define I2CPE_ENC_2_AXIS Y_AXIS
#define I2CPE_ENC_2_TYPE I2CPE_ENC_TYPE_LINEAR
#define I2CPE_ENC_2_TICKS_UNIT 2048
//#define I2CPE_ENC_2_TICKS_REV (16 * 200)
//#define I2CPE_ENC_2_INVERT
#define I2CPE_ENC_2_EC_METHOD I2CPE_ECM_MICROSTEP
#define I2CPE_ENC_2_EC_THRESH 0.10
#define I2CPE_ENC_3_ADDR I2CPE_PRESET_ADDR_Z // Encoder 3. Add additional configuration options
#define I2CPE_ENC_3_AXIS Z_AXIS // as above, or use defaults below.
#define I2CPE_ENC_4_ADDR I2CPE_PRESET_ADDR_E // Encoder 4.
#define I2CPE_ENC_4_AXIS E_AXIS
#define I2CPE_ENC_5_ADDR 34 // Encoder 5.
#define I2CPE_ENC_5_AXIS E_AXIS
// Default settings for encoders which are enabled, but without settings configured above.
#define I2CPE_DEF_TYPE I2CPE_ENC_TYPE_LINEAR
#define I2CPE_DEF_ENC_TICKS_UNIT 2048
#define I2CPE_DEF_TICKS_REV (16 * 200)
#define I2CPE_DEF_EC_METHOD I2CPE_ECM_NONE
#define I2CPE_DEF_EC_THRESH 0.1
//#define I2CPE_ERR_THRESH_ABORT 100.0 // Threshold size for error (in mm) error on any given
// axis after which the printer will abort. Comment out to
// disable abort behavior.
#define I2CPE_TIME_TRUSTED 10000 // After an encoder fault, there must be no further fault
// for this amount of time (in ms) before the encoder
// is trusted again.
/**
* Position is checked every time a new command is executed from the buffer but during long moves,
* this setting determines the minimum update time between checks. A value of 100 works well with
* error rolling average when attempting to correct only for skips and not for vibration.
*/
#define I2CPE_MIN_UPD_TIME_MS 4 // (ms) Minimum time between encoder checks.
// Use a rolling average to identify persistant errors that indicate skips, as opposed to vibration and noise.
#define I2CPE_ERR_ROLLING_AVERAGE
#endif // I2C_POSITION_ENCODERS
/**
* Analog Joystick(s)
*/
//#define JOYSTICK
#if ENABLED(JOYSTICK)
#define JOY_X_PIN 5 // RAMPS: Suggested pin A5 on AUX2
#define JOY_Y_PIN 10 // RAMPS: Suggested pin A10 on AUX2
#define JOY_Z_PIN 12 // RAMPS: Suggested pin A12 on AUX2
#define JOY_EN_PIN 44 // RAMPS: Suggested pin D44 on AUX2
//#define INVERT_JOY_X // Enable if X direction is reversed
//#define INVERT_JOY_Y // Enable if Y direction is reversed
//#define INVERT_JOY_Z // Enable if Z direction is reversed
// Use M119 with JOYSTICK_DEBUG to find reasonable values after connecting:
#define JOY_X_LIMITS { 5600, 8190-100, 8190+100, 10800 } // min, deadzone start, deadzone end, max
#define JOY_Y_LIMITS { 5600, 8250-100, 8250+100, 11000 }
#define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 }
#endif
/**
* MAX7219 Debug Matrix
*
* Add support for a low-cost 8x8 LED Matrix based on the Max7219 chip as a realtime status display.
* Requires 3 signal wires. Some useful debug options are included to demonstrate its usage.
*/
//#define MAX7219_DEBUG
#if ENABLED(MAX7219_DEBUG)
#define MAX7219_CLK_PIN 64
#define MAX7219_DIN_PIN 57
#define MAX7219_LOAD_PIN 44
//#define MAX7219_GCODE // Add the M7219 G-code to control the LED matrix
#define MAX7219_INIT_TEST 2 // Test pattern at startup: 0=none, 1=sweep, 2=spiral
#define MAX7219_NUMBER_UNITS 1 // Number of Max7219 units in chain.
#define MAX7219_ROTATE 0 // Rotate the display clockwise (in multiples of +/- 90°)
// connector at: right=0 bottom=-90 top=90 left=180
//#define MAX7219_REVERSE_ORDER // The individual LED matrix units may be in reversed order
//#define MAX7219_SIDE_BY_SIDE // Big chip+matrix boards can be chained side-by-side
/**
* Sample debug features
* If you add more debug displays, be careful to avoid conflicts!
*/
#define MAX7219_DEBUG_PRINTER_ALIVE // Blink corner LED of 8x8 matrix to show that the firmware is functioning
#define MAX7219_DEBUG_PLANNER_HEAD 3 // Show the planner queue head position on this and the next LED matrix row
#define MAX7219_DEBUG_PLANNER_TAIL 5 // Show the planner queue tail position on this and the next LED matrix row
#define MAX7219_DEBUG_PLANNER_QUEUE 0 // Show the current planner queue depth on this and the next LED matrix row
// If you experience stuttering, reboots, etc. this option can reveal how
// tweaks made to the configuration are affecting the printer in real-time.
#endif
/**
* NanoDLP Sync support
*
* Add support for Synchronized Z moves when using with NanoDLP. G0/G1 axis moves will output "Z_move_comp"
* string to enable synchronization with DLP projector exposure. This change will allow to use
* [[WaitForDoneMessage]] instead of populating your gcode with M400 commands
*/
//#define NANODLP_Z_SYNC
#if ENABLED(NANODLP_Z_SYNC)
//#define NANODLP_ALL_AXIS // Enables "Z_move_comp" output on any axis move.
// Default behavior is limited to Z axis only.
#endif
/**
* WiFi Support (Espressif ESP32 WiFi)
*/
//#define WIFISUPPORT // Marlin embedded WiFi managenent
//#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib)
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
//#define WEBSUPPORT // Start a webserver (which may include auto-discovery)
//#define OTASUPPORT // Support over-the-air firmware updates
//#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host
/**
* To set a default WiFi SSID / Password, create a file called Configuration_Secure.h with
* the following defines, customized for your network. This specific file is excluded via
* .gitignore to prevent it from accidentally leaking to the public.
*
* #define WIFI_SSID "WiFi SSID"
* #define WIFI_PWD "WiFi Password"
*/
//#include "Configuration_Secure.h" // External file with WiFi SSID / Password
#endif
/**
* Prusa Multi-Material Unit v2
* Enable in Configuration.h
*/
#if ENABLED(PRUSA_MMU2)
// Serial port used for communication with MMU2.
// For AVR enable the UART port used for the MMU. (e.g., internalSerial)
// For 32-bit boards check your HAL for available serial ports. (e.g., Serial2)
#define INTERNAL_SERIAL_PORT 2
#define MMU2_SERIAL internalSerial
// Use hardware reset for MMU if a pin is defined for it
//#define MMU2_RST_PIN 23
// Enable if the MMU2 has 12V stepper motors (MMU2 Firmware 1.0.2 and up)
//#define MMU2_MODE_12V
// G-code to execute when MMU2 F.I.N.D.A. probe detects filament runout
#define MMU2_FILAMENT_RUNOUT_SCRIPT "M600"
// Add an LCD menu for MMU2
//#define MMU2_MENUS
#if ENABLED(MMU2_MENUS)
// Settings for filament load / unload from the LCD menu.
// This is for Prusa MK3-style extruders. Customize for your hardware.
#define MMU2_FILAMENTCHANGE_EJECT_FEED 80.0
#define MMU2_LOAD_TO_NOZZLE_SEQUENCE \
{ 7.2, 562 }, \
{ 14.4, 871 }, \
{ 36.0, 1393 }, \
{ 14.4, 871 }, \
{ 50.0, 198 }
#define MMU2_RAMMING_SEQUENCE \
{ 1.0, 1000 }, \
{ 1.0, 1500 }, \
{ 2.0, 2000 }, \
{ 1.5, 3000 }, \
{ 2.5, 4000 }, \
{ -15.0, 5000 }, \
{ -14.0, 1200 }, \
{ -6.0, 600 }, \
{ 10.0, 700 }, \
{ -10.0, 400 }, \
{ -50.0, 2000 }
#endif
//#define MMU2_DEBUG // Write debug info to serial output
#endif // PRUSA_MMU2
/**
* Advanced Print Counter settings
*/
#if ENABLED(PRINTCOUNTER)
#define SERVICE_WARNING_BUZZES 3
// Activate up to 3 service interval watchdogs
//#define SERVICE_NAME_1 "Service S"
//#define SERVICE_INTERVAL_1 100 // print hours
//#define SERVICE_NAME_2 "Service L"
//#define SERVICE_INTERVAL_2 200 // print hours
//#define SERVICE_NAME_3 "Service 3"
//#define SERVICE_INTERVAL_3 1 // print hours
#endif
// @section develop
//
// M100 Free Memory Watcher to debug memory usage
//
//#define M100_FREE_MEMORY_WATCHER
//
// M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe
//
//#define PINS_DEBUGGING
// Enable Marlin dev mode which adds some special commands
//#define MARLIN_DEV_MODE
| 125,431
|
C++
|
.h
| 2,737
| 42.129704
| 157
| 0.688661
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,884
|
_Statusscreen.h
|
LONGER3D_Marlin2_0-lgt/Marlin/_Statusscreen.h
|
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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/>.
*
*/
/**
* Custom Status Screen bitmap
*
* Place this file in the root with your configuration files
* and enable CUSTOM_STATUS_SCREEN_IMAGE in Configuration.h.
*
* Use the Marlin Bitmap Converter to make your own:
* http://marlinfw.org/tools/u8glib/converter.html
*/
#pragma once
//
// Status Screen Logo bitmap
//
#define STATUS_LOGO_Y 0
#define STATUS_LOGO_WIDTH 38
static unsigned char status_logo_bmp[] PROGMEM = {
B11111111,B11111111,B11111111,B11111111,B11111100,
B10000000,B00000000,B00010000,B00000111,B11111100,
B10000000,B00000000,B00010000,B00000000,B11111100,
B10000000,B00000000,B00110000,B00000000,B01111100,
B10000000,B00000000,B00110000,B00000000,B00111100,
B10000000,B00000000,B01110000,B00000000,B00011100,
B11111111,B10000000,B01110000,B00000000,B00001100,
B11111111,B10000000,B11110000,B11100000,B00001100,
B11111111,B00000000,B11110000,B11111000,B00001100,
B11111111,B00000001,B11110000,B11111100,B00000100,
B11111110,B00000001,B11110000,B11010010,B00000100,
B11111110,B00000011,B11110000,B10101110,B00000100,
B11111100,B00000000,B11110000,B10101111,B00000100,
B11111100,B00000000,B00110000,B10000011,B00000100,
B11111000,B00000000,B00110000,B11111111,B00000100,
B11111000,B00000000,B00010000,B11111111,B00000100,
B11111111,B11100000,B00010000,B10111111,B00000100,
B11111111,B11110000,B00010000,B10101111,B00000100,
B11111111,B11110000,B00010000,B10101110,B00000100,
B11111111,B11110000,B00010000,B10000010,B00000100,
B10000011,B11110000,B00010000,B11111100,B00000100,
B10000001,B11110000,B00010000,B11111000,B00001100,
B10000001,B11100000,B00010000,B11100000,B00001100,
B10000000,B00000000,B00010000,B00000000,B00001100,
B10000000,B00000000,B00110000,B00000000,B00011100,
B11000000,B00000000,B00110000,B00000000,B00111100,
B11000000,B00000000,B01110000,B00000000,B01111100,
B11100000,B00000000,B11110000,B00000000,B11111100,
B11111000,B00000011,B11110000,B00000111,B11111100
};
//
// Use default bitmaps
//
#define STATUS_HOTEND_ANIM
#define STATUS_BED_ANIM
#define STATUS_LOGO_X 0
#define STATUS_HEATERS_X 50
#define STATUS_BED_X 74
| 2,933
|
C++
|
.h
| 72
| 38.513889
| 79
| 0.806022
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,890
|
boards.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/core/boards.h
|
/**
* 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
#define BOARD_COPYMASTER_3D 1150 // Copymaster 3D
#define BOARD_LONGER_LGT_KIT_V1 1151 // LONGER LGT_KIT_V1.0
//
// 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)
| 20,232
|
C++
|
.h
| 317
| 62.624606
| 130
| 0.653231
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,891
|
pins.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/pins/pins.h
|
/**
* 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 "../core/boards.h"
/**
* Include pins definitions
*
* Pins numbering schemes:
*
* - Digital I/O pin number if used by READ/WRITE macros. (e.g., X_STEP_DIR)
* The FastIO headers map digital pins to their ports and functions.
*
* - Analog Input number if used by analogRead or DAC. (e.g., TEMP_n_PIN)
* These numbers are the same in any pin mapping.
*/
#define MAX_EXTRUDERS 8
#if MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB)
#define IS_RAMPS_EFB
#elif MB(RAMPS_13_EEB, RAMPS_14_EEB, RAMPS_PLUS_EEB, RAMPS_14_RE_ARM_EEB, RAMPS_SMART_EEB, RAMPS_DUO_EEB, RAMPS4DUE_EEB)
#define IS_RAMPS_EEB
#elif MB(RAMPS_13_EFF, RAMPS_14_EFF, RAMPS_PLUS_EFF, RAMPS_14_RE_ARM_EFF, RAMPS_SMART_EFF, RAMPS_DUO_EFF, RAMPS4DUE_EFF)
#define IS_RAMPS_EFF
#elif MB(RAMPS_13_EEF, RAMPS_14_EEF, RAMPS_PLUS_EEF, RAMPS_14_RE_ARM_EEF, RAMPS_SMART_EEF, RAMPS_DUO_EEF, RAMPS4DUE_EEF)
#define IS_RAMPS_EEF
#elif MB(RAMPS_13_SF, RAMPS_14_SF, RAMPS_PLUS_SF, RAMPS_14_RE_ARM_SF, RAMPS_SMART_SF, RAMPS_DUO_SF, RAMPS4DUE_SF)
#define IS_RAMPS_SF
#endif
#define HAS_FREE_AUX2_PINS !(BOTH(ULTRA_LCD, NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, MINIPANEL, REPRAPWORLD_KEYPAD))
//
// RAMPS 1.3 / 1.4 - ATmega1280, ATmega2560
//
#if MB(RAMPS_OLD)
#include "ramps/pins_RAMPS_OLD.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_13_EFB)
#include "ramps/pins_RAMPS_13.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_13_EEB)
#include "ramps/pins_RAMPS_13.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_13_EFF)
#include "ramps/pins_RAMPS_13.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_13_EEF)
#include "ramps/pins_RAMPS_13.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_13_SF)
#include "ramps/pins_RAMPS_13.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_14_EFB)
#include "ramps/pins_RAMPS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_14_EEB)
#include "ramps/pins_RAMPS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_14_EFF)
#include "ramps/pins_RAMPS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_14_EEF)
#include "ramps/pins_RAMPS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_14_SF)
#include "ramps/pins_RAMPS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_PLUS_EFB)
#include "ramps/pins_RAMPS_PLUS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_PLUS_EEB)
#include "ramps/pins_RAMPS_PLUS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_PLUS_EFF)
#include "ramps/pins_RAMPS_PLUS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_PLUS_EEF)
#include "ramps/pins_RAMPS_PLUS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RAMPS_PLUS_SF)
#include "ramps/pins_RAMPS_PLUS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
//
// RAMPS Derivatives - ATmega1280, ATmega2560
//
#elif MB(3DRAG)
#include "ramps/pins_3DRAG.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(K8200)
#include "ramps/pins_K8200.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560 (3DRAG)
#elif MB(K8400)
#include "ramps/pins_K8400.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560 (3DRAG)
#elif MB(K8800)
#include "ramps/pins_K8800.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560 (3DRAG)
#elif MB(BAM_DICE)
#include "ramps/pins_RAMPS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(BAM_DICE_DUE)
#include "ramps/pins_BAM_DICE_DUE.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(MKS_BASE)
#include "ramps/pins_MKS_BASE_10.h" // ATmega2560 env:mega2560
#elif MB(MKS_BASE_14)
#include "ramps/pins_MKS_BASE_14.h" // ATmega2560 env:mega2560
#elif MB(MKS_BASE_15)
#include "ramps/pins_MKS_BASE_15.h" // ATmega2560 env:mega2560
#elif MB(MKS_BASE_16)
#include "ramps/pins_MKS_BASE_16.h" // ATmega2560 env:mega2560
#elif MB(MKS_BASE_HEROIC)
#include "ramps/pins_MKS_BASE_HEROIC.h" // ATmega2560 env:mega2560
#elif MB(MKS_GEN_13)
#include "ramps/pins_MKS_GEN_13.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(MKS_GEN_L)
#include "ramps/pins_MKS_GEN_L.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(KFB_2)
#include "ramps/pins_BIQU_KFB_2.h" // ATmega2560 env:mega2560
#elif MB(ZRIB_V20)
#include "ramps/pins_ZRIB_V20.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560 (MKS_GEN_13)
#elif MB(FELIX2)
#include "ramps/pins_FELIX2.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RIGIDBOARD)
#include "ramps/pins_RIGIDBOARD.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(RIGIDBOARD_V2)
#include "ramps/pins_RIGIDBOARD_V2.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(SAINSMART_2IN1)
#include "ramps/pins_SAINSMART_2IN1.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(ULTIMAKER)
#include "ramps/pins_ULTIMAKER.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(ULTIMAKER_OLD)
#include "ramps/pins_ULTIMAKER_OLD.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(AZTEEG_X3)
#include "ramps/pins_AZTEEG_X3.h" // ATmega2560 env:mega2560
#elif MB(AZTEEG_X3_PRO)
#include "ramps/pins_AZTEEG_X3_PRO.h" // ATmega2560 env:mega2560
#elif MB(ULTIMAIN_2)
#include "ramps/pins_ULTIMAIN_2.h" // ATmega2560 env:mega2560
#elif MB(FORMBOT_RAPTOR)
#include "ramps/pins_FORMBOT_RAPTOR.h" // ATmega2560 env:mega2560
#elif MB(FORMBOT_RAPTOR2)
#include "ramps/pins_FORMBOT_RAPTOR2.h" // ATmega2560 env:mega2560
#elif MB(FORMBOT_TREX2PLUS)
#include "ramps/pins_FORMBOT_TREX2PLUS.h" // ATmega2560 env:mega2560
#elif MB(FORMBOT_TREX3)
#include "ramps/pins_FORMBOT_TREX3.h" // ATmega2560 env:mega2560
#elif MB(RUMBA)
#include "ramps/pins_RUMBA.h" // ATmega2560 env:mega2560
#elif MB(RUMBA_RAISE3D)
#include "ramps/pins_RUMBA_RAISE3D.h" // ATmega2560 env:mega2560
#elif MB(RL200)
#include "ramps/pins_RL200.h" // ATmega2560 env:mega2560
#elif MB(BQ_ZUM_MEGA_3D)
#include "ramps/pins_BQ_ZUM_MEGA_3D.h" // ATmega2560 env:mega2560
#elif MB(MAKEBOARD_MINI)
#include "ramps/pins_MAKEBOARD_MINI.h" // ATmega2560 env:mega2560
#elif MB(TRIGORILLA_13)
#include "ramps/pins_TRIGORILLA_13.h" // ATmega2560 env:mega2560
#elif MB(TRIGORILLA_14)
#include "ramps/pins_TRIGORILLA_14.h" // ATmega2560 env:mega2560
#elif MB(TRIGORILLA_14_11)
#include "ramps/pins_TRIGORILLA_14.h" // ATmega2560 env:mega2560
#elif MB(RAMPS_ENDER_4)
#include "ramps/pins_RAMPS_ENDER_4.h" // ATmega2560 env:mega2560
#elif MB(RAMPS_CREALITY)
#include "ramps/pins_RAMPS_CREALITY.h" // ATmega2560 env:mega2560
#elif MB(RAMPS_DAGOMA)
#include "ramps/pins_RAMPS_DAGOMA.h" // ATmega2560 env:mega2560
#elif MB(FYSETC_F6_13)
#include "ramps/pins_FYSETC_F6_13.h" // ATmega2560 env:FYSETC_F6_13
#elif MB(FYSETC_F6_14)
#include "ramps/pins_FYSETC_F6_14.h" // ATmega2560 env:FYSETC_F6_14
#elif MB(DUPLICATOR_I3_PLUS)
#include "ramps/pins_DUPLICATOR_I3_PLUS.h" // ATmega2560 env:mega2560
#elif MB(VORON)
#include "ramps/pins_VORON.h" // ATmega2560 env:mega2560
#elif MB(TRONXY_V3_1_0)
#include "ramps/pins_TRONXY_V3_1_0.h" // ATmega2560 env:mega2560
#elif MB(Z_BOLT_X_SERIES)
#include "ramps/pins_Z_BOLT_X_SERIES.h" // ATmega2560 env:mega2560
#elif MB(TT_OSCAR)
#include "ramps/pins_TT_OSCAR.h" // ATmega2560 env:mega2560
#elif MB(TANGO)
#include "ramps/pins_TANGO.h" // ATmega2560 env:mega2560
#elif MB(MKS_GEN_L_V2)
#include "ramps/pins_MKS_GEN_L_V2.h" // ATmega2560 env:mega2560
#elif MB(COPYMASTER_3D)
#include "ramps/pins_COPYMASTER_3D.h" // ATmega2560 env:mega2560
#elif MB(LONGER_LGT_KIT_V1)
#include "ramps/pins_LONGER_LGT_KIT_V1.h" // ATmega2560 env:mega2560
//
// RAMBo and derivatives
//
#elif MB(RAMBO)
#include "rambo/pins_RAMBO.h" // ATmega2560 env:rambo
#elif MB(MINIRAMBO, MINIRAMBO_10A)
#include "rambo/pins_MINIRAMBO.h" // ATmega2560 env:rambo
#elif MB(EINSY_RAMBO)
#include "rambo/pins_EINSY_RAMBO.h" // ATmega2560 env:rambo
#elif MB(EINSY_RETRO)
#include "rambo/pins_EINSY_RETRO.h" // ATmega2560 env:rambo
#elif MB(SCOOVO_X9H)
#include "rambo/pins_SCOOVO_X9H.h" // ATmega2560 env:rambo
//
// Other ATmega1280, ATmega2560
//
#elif MB(CNCONTROLS_11)
#include "mega/pins_CNCONTROLS_11.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(CNCONTROLS_12)
#include "mega/pins_CNCONTROLS_12.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(CNCONTROLS_15)
#include "mega/pins_CNCONTROLS_15.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(MIGHTYBOARD_REVE)
#include "mega/pins_MIGHTYBOARD_REVE.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(CHEAPTRONIC)
#include "mega/pins_CHEAPTRONIC.h" // ATmega2560 env:mega2560
#elif MB(CHEAPTRONIC_V2)
#include "mega/pins_CHEAPTRONICv2.h" // ATmega2560 env:mega2560
#elif MB(MEGATRONICS)
#include "mega/pins_MEGATRONICS.h" // ATmega2560 env:mega2560
#elif MB(MEGATRONICS_2)
#include "mega/pins_MEGATRONICS_2.h" // ATmega2560 env:mega2560
#elif MB(MEGATRONICS_3, MEGATRONICS_31, MEGATRONICS_32)
#include "mega/pins_MEGATRONICS_3.h" // ATmega2560 env:mega2560
#elif MB(ELEFU_3)
#include "mega/pins_ELEFU_3.h" // ATmega2560 env:mega2560
#elif MB(LEAPFROG)
#include "mega/pins_LEAPFROG.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(MEGACONTROLLER)
#include "mega/pins_MEGACONTROLLER.h" // ATmega2560 env:mega2560
#elif MB(GT2560_REV_A)
#include "mega/pins_GT2560_REV_A.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(GT2560_REV_A_PLUS)
#include "mega/pins_GT2560_REV_A_PLUS.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(GT2560_V3)
#include "mega/pins_GT2560_V3.h" // ATmega2560 env:mega2560
#elif MB(GT2560_V3_MC2)
#include "mega/pins_GT2560_V3_MC2.h" // ATmega2560 env:mega2560
#elif MB(GT2560_V3_A20)
#include "mega/pins_GT2560_V3_A20.h" // ATmega2560 env:mega2560
#elif MB(EINSTART_S)
#include "mega/pins_EINSTART-S.h" // ATmega1280, ATmega2560 env:mega1280 env:mega2560
#elif MB(WANHAO_ONEPLUS)
#include "mega/pins_WANHAO_ONEPLUS.h" // ATmega2560 env:mega2560
#elif MB(OVERLORD)
#include "mega/pins_OVERLORD.h" // ATmega2560 env:mega2560
#elif MB(HJC2560C_REV2)
#include "mega/pins_HJC2560C_REV2.h" // ATmega2560 env:mega2560
#elif MB(LEAPFROG_XEED2015)
#include "mega/pins_LEAPFROG_XEED2015.h" // ATmega2560 env:mega2560
#elif MB(PICA)
#include "mega/pins_PICA.h" // ATmega2560 env:mega2560
#elif MB(PICA_REVB)
#include "mega/pins_PICAOLD.h" // ATmega2560 env:mega2560
//
// ATmega1281, ATmega2561
//
#elif MB(MINITRONICS)
#include "mega/pins_MINITRONICS.h" // ATmega1281 env:mega1280
#elif MB(SILVER_GATE)
#include "mega/pins_SILVER_GATE.h" // ATmega2561 env:mega2560
//
// Sanguinololu and Derivatives - ATmega644P, ATmega1284P
//
#elif MB(SANGUINOLOLU_11)
#include "sanguino/pins_SANGUINOLOLU_11.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(SANGUINOLOLU_12)
#include "sanguino/pins_SANGUINOLOLU_12.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(MELZI)
#include "sanguino/pins_MELZI.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(MELZI_MAKR3D)
#include "sanguino/pins_MELZI_MAKR3D.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(MELZI_CREALITY)
#include "sanguino/pins_MELZI_CREALITY.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(MELZI_MALYAN)
#include "sanguino/pins_MELZI_MALYAN.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(MELZI_TRONXY)
#include "sanguino/pins_MELZI_TRONXY.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(STB_11)
#include "sanguino/pins_STB_11.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(AZTEEG_X1)
#include "sanguino/pins_AZTEEG_X1.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
//
// Other ATmega644P, ATmega644, ATmega1284P
//
#elif MB(GEN3_MONOLITHIC)
#include "sanguino/pins_GEN3_MONOLITHIC.h" // ATmega644P env:sanguino644p
#elif MB(GEN3_PLUS)
#include "sanguino/pins_GEN3_PLUS.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(GEN6)
#include "sanguino/pins_GEN6.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(GEN6_DELUXE)
#include "sanguino/pins_GEN6_DELUXE.h" // ATmega644P, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(GEN7_CUSTOM)
#include "sanguino/pins_GEN7_CUSTOM.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(GEN7_12)
#include "sanguino/pins_GEN7_12.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(GEN7_13)
#include "sanguino/pins_GEN7_13.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(GEN7_14)
#include "sanguino/pins_GEN7_14.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino644p env:sanguino1284p
#elif MB(OMCA_A)
#include "sanguino/pins_OMCA_A.h" // ATmega644 env:sanguino644p
#elif MB(OMCA)
#include "sanguino/pins_OMCA.h" // ATmega644P, ATmega644 env:sanguino644p
#elif MB(ANET_10)
#include "sanguino/pins_ANET_10.h" // ATmega1284P env:sanguino1284p
#elif MB(SETHI)
#include "sanguino/pins_SETHI.h" // ATmega644P, ATmega644, ATmega1284P env:sanguino644p env:sanguino1284p
//
// Teensyduino - AT90USB1286, AT90USB1286P
//
#elif MB(TEENSYLU)
#include "teensy2/pins_TEENSYLU.h" // AT90USB1286, AT90USB1286P env:at90usb1286_cdc
#elif MB(PRINTRBOARD)
#include "teensy2/pins_PRINTRBOARD.h" // AT90USB1286 env:at90usb1286_dfu
#elif MB(PRINTRBOARD_REVF)
#include "teensy2/pins_PRINTRBOARD_REVF.h" // AT90USB1286 env:at90usb1286_dfu
#elif MB(BRAINWAVE)
#include "teensy2/pins_BRAINWAVE.h" // AT90USB646 env:at90usb1286_cdc
#elif MB(BRAINWAVE_PRO)
#include "teensy2/pins_BRAINWAVE_PRO.h" // AT90USB1286 env:at90usb1286_cdc
#elif MB(SAV_MKI)
#include "teensy2/pins_SAV_MKI.h" // AT90USB1286 env:at90usb1286_cdc
#elif MB(TEENSY2)
#include "teensy2/pins_TEENSY2.h" // AT90USB1286 env:teensy20
#elif MB(5DPRINT)
#include "teensy2/pins_5DPRINT.h" // AT90USB1286 env:at90usb1286_dfu
//
// LPC1768 ARM Cortex M3
//
#elif MB(RAMPS_14_RE_ARM_EFB)
#include "lpc1768/pins_RAMPS_RE_ARM.h" // LPC1768 env:LPC1768
#elif MB(RAMPS_14_RE_ARM_EEB)
#include "lpc1768/pins_RAMPS_RE_ARM.h" // LPC1768 env:LPC1768
#elif MB(RAMPS_14_RE_ARM_EFF)
#include "lpc1768/pins_RAMPS_RE_ARM.h" // LPC1768 env:LPC1768
#elif MB(RAMPS_14_RE_ARM_EEF)
#include "lpc1768/pins_RAMPS_RE_ARM.h" // LPC1768 env:LPC1768
#elif MB(RAMPS_14_RE_ARM_SF)
#include "lpc1768/pins_RAMPS_RE_ARM.h" // LPC1768 env:LPC1768
#elif MB(MKS_SBASE)
#include "lpc1768/pins_MKS_SBASE.h" // LPC1768 env:LPC1768
#elif MB(MKS_SGEN_L)
#include "lpc1768/pins_MKS_SGEN_L.h" // LPC1768 env:LPC1768
#elif MB(AZSMZ_MINI)
#include "lpc1768/pins_AZSMZ_MINI.h" // LPC1768 env:LPC1768
#elif MB(BIQU_BQ111_A4)
#include "lpc1768/pins_BIQU_BQ111_A4.h" // LPC1768 env:LPC1768
#elif MB(SELENA_COMPACT)
#include "lpc1768/pins_SELENA_COMPACT.h" // LPC1768 env:LPC1768
#elif MB(BIQU_B300_V1_0)
#include "lpc1768/pins_BIQU_B300_V1.0.h" // LPC1768 env:LPC1768
#elif MB(GMARSH_X6_REV1)
#include "lpc1768/pins_GMARSH_X6_REV1.h" // LPC1768 env:LPC1768
#elif MB(BTT_SKR_V1_1)
#include "lpc1768/pins_BTT_SKR_V1_1.h" // LPC1768 env:LPC1768
#elif MB(BTT_SKR_V1_3)
#include "lpc1768/pins_BTT_SKR_V1_3.h" // LPC1768 env:LPC1768
#elif MB(BTT_SKR_V1_4)
#include "lpc1768/pins_BTT_SKR_V1_4.h" // LPC1768 env:LPC1768
//
// LPC1769 ARM Cortex M3
//
#elif MB(MKS_SGEN)
#include "lpc1769/pins_MKS_SGEN.h" // LPC1769 env:LPC1769
#elif MB(AZTEEG_X5_GT)
#include "lpc1769/pins_AZTEEG_X5_GT.h" // LPC1769 env:LPC1769
#elif MB(AZTEEG_X5_MINI)
#include "lpc1769/pins_AZTEEG_X5_MINI.h" // LPC1769 env:LPC1769
#elif MB(AZTEEG_X5_MINI_WIFI)
#include "lpc1769/pins_AZTEEG_X5_MINI_WIFI.h" // LPC1769 env:LPC1769
#elif MB(COHESION3D_REMIX)
#include "lpc1769/pins_COHESION3D_REMIX.h" // LPC1769 env:LPC1769
#elif MB(COHESION3D_MINI)
#include "lpc1769/pins_COHESION3D_MINI.h" // LPC1769 env:LPC1769
#elif MB(SMOOTHIEBOARD)
#include "lpc1769/pins_SMOOTHIEBOARD.h" // LPC1769 env:LPC1769
#elif MB(TH3D_EZBOARD)
#include "lpc1769/pins_TH3D_EZBOARD.h" // LPC1769 env:LPC1769
#elif MB(BTT_SKR_V1_4_TURBO)
#include "lpc1769/pins_BTT_SKR_V1_4_TURBO.h" // LPC1769 env:LPC1769
//
// Due (ATSAM) boards
//
#elif MB(DUE3DOM)
#include "sam/pins_DUE3DOM.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(DUE3DOM_MINI)
#include "sam/pins_DUE3DOM_MINI.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RADDS)
#include "sam/pins_RADDS.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RURAMPS4D_11)
#include "sam/pins_RURAMPS4D_11.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RURAMPS4D_13)
#include "sam/pins_RURAMPS4D_13.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_FD_V1)
#include "sam/pins_RAMPS_FD_V1.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_FD_V2)
#include "sam/pins_RAMPS_FD_V2.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_SMART_EFB)
#include "sam/pins_RAMPS_SMART.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_SMART_EEB)
#include "sam/pins_RAMPS_SMART.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_SMART_EFF)
#include "sam/pins_RAMPS_SMART.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_SMART_EEF)
#include "sam/pins_RAMPS_SMART.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_SMART_SF)
#include "sam/pins_RAMPS_SMART.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_DUO_EFB)
#include "sam/pins_RAMPS_DUO.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_DUO_EEB)
#include "sam/pins_RAMPS_DUO.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_DUO_EFF)
#include "sam/pins_RAMPS_DUO.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_DUO_EEF)
#include "sam/pins_RAMPS_DUO.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS_DUO_SF)
#include "sam/pins_RAMPS_DUO.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS4DUE_EFB)
#include "sam/pins_RAMPS4DUE.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS4DUE_EEB)
#include "sam/pins_RAMPS4DUE.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS4DUE_EFF)
#include "sam/pins_RAMPS4DUE.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS4DUE_EEF)
#include "sam/pins_RAMPS4DUE.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(RAMPS4DUE_SF)
#include "sam/pins_RAMPS4DUE.h" // SAM3X8E env:DUE env:DUE_USB env:DUE_debug
#elif MB(ULTRATRONICS_PRO)
#include "sam/pins_ULTRATRONICS_PRO.h" // SAM3X8E env:DUE env:DUE_debug
#elif MB(ARCHIM1)
#include "sam/pins_ARCHIM1.h" // SAM3X8E env:DUE env:DUE_debug
#elif MB(ARCHIM2)
#include "sam/pins_ARCHIM2.h" // SAM3X8E env:DUE env:DUE_debug
#elif MB(ALLIGATOR)
#include "sam/pins_ALLIGATOR_R2.h" // SAM3X8E env:DUE env:DUE_debug
#elif MB(ADSK)
#include "sam/pins_ADSK.h" // SAM3X8E env:DUE env:DUE_debug
#elif MB(PRINTRBOARD_G2)
#include "sam/pins_PRINTRBOARD_G2.h" // SAM3X8C env:DUE_USB
#elif MB(CNCONTROLS_15D)
#include "sam/pins_CNCONTROLS_15D.h" // SAM3X8E env:DUE env:DUE_USB
//
// STM32 ARM Cortex-M3
//
#elif MB(STM32F103RE)
#include "stm32f1/pins_STM32F1R.h" // STM32F1 env:STM32F103RE
#elif MB(MALYAN_M200)
#include "stm32f1/pins_MALYAN_M200.h" // STM32F1 env:STM32F103CB_malyan
#elif MB(STM3R_MINI)
#include "stm32f1/pins_STM3R_MINI.h" // STM32F1 env:STM32F103RE
#elif MB(GTM32_PRO_VB)
#include "stm32f1/pins_GTM32_PRO_VB.h" // STM32F1 env:STM32F103RE
#elif MB(GTM32_MINI_A30)
#include "stm32f1/pins_GTM32_MINI_A30.h" // STM32F1 env:STM32F103RE
#elif MB(GTM32_MINI)
#include "stm32f1/pins_GTM32_MINI.h" // STM32F1 env:STM32F103RE
#elif MB(GTM32_REV_B)
#include "stm32f1/pins_GTM32_REV_B.h" // STM32F1 env:STM32F103RE
#elif MB(MORPHEUS)
#include "stm32f1/pins_MORPHEUS.h" // STM32F1 env:STM32F103RE
#elif MB(CHITU3D)
#include "stm32f1/pins_CHITU3D.h" // STM32F1 env:STM32F103RE
#elif MB(MKS_ROBIN)
#include "stm32f1/pins_MKS_ROBIN.h" // STM32F1 env:mks_robin
#elif MB(MKS_ROBIN_MINI)
#include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini
#elif MB(MKS_ROBIN_NANO)
#include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano
#elif MB(MKS_ROBIN_LITE)
#include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite
#elif MB(BTT_SKR_MINI_V1_1)
#include "stm32f1/pins_BTT_SKR_MINI_V1_1.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB
#elif MB(BTT_SKR_MINI_E3_V1_0)
#include "stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB
#elif MB(BTT_SKR_MINI_E3_V1_2)
#include "stm32f1/pins_BTT_SKR_MINI_E3_V1_2.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB
#elif MB(BTT_SKR_E3_DIP)
#include "stm32f1/pins_BTT_SKR_E3_DIP.h" // STM32F1 env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB
#elif MB(JGAURORA_A5S_A1)
#include "stm32f1/pins_JGAURORA_A5S_A1.h" // STM32F1 env:jgaurora_a5s_a1
#elif MB(FYSETC_AIO_II)
#include "stm32f1/pins_FYSETC_AIO_II.h" // STM32F1 env:STM32F103RC_fysetc
#elif MB(FYSETC_CHEETAH)
#include "stm32f1/pins_FYSETC_CHEETAH.h" // STM32F1 env:STM32F103RC_fysetc
#elif MB(FYSETC_CHEETAH_V12)
#include "stm32f1/pins_FYSETC_CHEETAH_V12.h" // STM32F1 env:STM32F103RC_fysetc
#elif MB(LONGER3D_LK)
#include "stm32f1/pins_LONGER3D_LK.h" // STM32F1 env:STM32F103VE_longer
#elif MB(MKS_ROBIN_LITE3)
#include "stm32f1/pins_MKS_ROBIN_LITE3.h" // STM32F1 env:mks_robin_lite3
#elif MB(MKS_ROBIN_PRO)
#include "stm32f1/pins_MKS_ROBIN_PRO.h" // STM32F1 env:mks_robin_pro
//
// ARM Cortex-M4F
//
#elif MB(TEENSY31_32)
#include "teensy3/pins_TEENSY31_32.h" // TEENSY31_32 env:teensy31
#elif MB(TEENSY35_36)
#include "teensy3/pins_TEENSY35_36.h" // TEENSY35_36 env:teensy35
//
// STM32 ARM Cortex-M4F
//
#elif MB(BEAST)
#include "stm32f4/pins_BEAST.h" // STM32F4 env:STM32F4
#elif MB(GENERIC_STM32F4)
#include "stm32f4/pins_GENERIC_STM32F4.h" // STM32F4 env:STM32F4
#elif MB(ARMED)
#include "stm32f4/pins_ARMED.h" // STM32F4 env:ARMED
#elif MB(RUMBA32_AUS3D)
#include "stm32f4/pins_RUMBA32_AUS3D.h" // STM32F4 env:rumba32_f446ve
#elif MB(RUMBA32_MKS)
#include "stm32f4/pins_RUMBA32_MKS.h" // STM32F4 env:rumba32_mks
#elif MB(BLACK_STM32F407VE)
#include "stm32f4/pins_BLACK_STM32F407VE.h" // STM32F4 env:STM32F407VE_black
#elif MB(STEVAL_3DP001V1)
#include "stm32f4/pins_STEVAL_3DP001V1.h" // STM32F4 env:STM32F401VE_STEVAL
#elif MB(BTT_SKR_PRO_V1_1)
#include "stm32f4/pins_BTT_SKR_PRO_V1_1.h" // STM32F4 env:BIGTREE_SKR_PRO
#elif MB(BTT_GTR_V1_0)
#include "stm32f4/pins_BTT_GTR_V1_0.h" // STM32F4 env:BIGTREE_GTR_V1_0
#elif MB(BTT_BTT002_V1_0)
#include "stm32f4/pins_BTT_BTT002_V1_0.h" // STM32F4 env:BIGTREE_BTT002
#elif MB(LERDGE_K)
#include "stm32f4/pins_LERDGE_K.h" // STM32F4 env:STM32F4
#elif MB(LERDGE_X)
#include "stm32f4/pins_LERDGE_X.h" // STM32F4 env:STM32F4
#elif MB(VAKE403D)
#include "stm32f4/pins_VAKE403D.h" // STM32F4 env:STM32F4
#elif MB(FYSETC_S6)
#include "stm32f4/pins_FYSETC_S6.h" // STM32F4 env:FYSETC_S6
#elif MB(FLYF407ZG)
#include "stm32f4/pins_FLYF407ZG.h" // STM32F4 env:FLYF407ZG
#elif MB(MKS_ROBIN2)
#include "stm32f4/pins_MKS_ROBIN2.h" // STM32F4 env:MKS_ROBIN2
//
// ARM Cortex M7
//
#elif MB(THE_BORG)
#include "stm32f7/pins_THE_BORG.h" // STM32F7 env:STM32F7
#elif MB(REMRAM_V1)
#include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:STM32F7
//
// Espressif ESP32
//
#elif MB(ESPRESSIF_ESP32)
#include "esp32/pins_ESP32.h" // ESP32 env:esp32
#elif MB(MRR_ESPA)
#include "esp32/pins_MRR_ESPA.h" // ESP32 env:esp32
#elif MB(MRR_ESPE)
#include "esp32/pins_MRR_ESPE.h" // ESP32 env:esp32
#elif MB(E4D_BOX)
#include "esp32/pins_E4D.h" // ESP32 env:esp32
//
// Adafruit Grand Central M4 (SAMD51 ARM Cortex-M4)
//
#elif MB(AGCM4_RAMPS_144)
#include "samd/pins_RAMPS_144.h" // SAMD51 env:SAMD51_grandcentral_m4
//
// Linux Native Debug board
//
#elif MB(LINUX_RAMPS)
#include "linux/pins_RAMPS_LINUX.h" // Linux env:linux_native
#else
//
// Obsolete or unknown board
//
#define BOARD_MKS_13 -1000
#define BOARD_TRIGORILLA -1001
#define BOARD_RURAMPS4D -1002
#define BOARD_FORMBOT_TREX2 -1003
#define BOARD_BIQU_SKR_V1_1 -1004
#define BOARD_STM32F1R -1005
#define BOARD_STM32F103R -1006
#define BOARD_ESP32 -1007
#define BOARD_STEVAL -1008
#define BOARD_BIGTREE_SKR_V1_1 -1009
#define BOARD_BIGTREE_SKR_V1_3 -1010
#define BOARD_BIGTREE_SKR_V1_4 -1011
#define BOARD_BIGTREE_SKR_V1_4_TURBO -1012
#define BOARD_BIGTREE_BTT002_V1_0 -1013
#define BOARD_BIGTREE_SKR_PRO_V1_1 -1014
#define BOARD_BIGTREE_SKR_MINI_V1_1 -1015
#define BOARD_BIGTREE_SKR_MINI_E3 -1016
#define BOARD_BIGTREE_SKR_E3_DIP -1017
#define BOARD_RUMBA32 -1018
#if MB(MKS_13)
#error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration."
#elif MB(TRIGORILLA)
#error "BOARD_TRIGORILLA has been renamed BOARD_TRIGORILLA_13. Please update your configuration."
#elif MB(RURAMPS4D)
#error "BOARD_RURAMPS4D has been renamed BOARD_RURAMPS4D_11. Please update your configuration."
#elif MB(FORMBOT_TREX2)
#error "FORMBOT_TREX2 has been renamed BOARD_FORMBOT_TREX2PLUS. Please update your configuration."
#elif MB(BIQU_SKR_V1_1)
#error "BOARD_BIQU_SKR_V1_1 has been renamed BOARD_BTT_SKR_V1_1. Please update your configuration."
#elif MB(BIGTREE_SKR_V1_1)
#error "BOARD_BIGTREE_SKR_V1_1 has been renamed BOARD_BTT_SKR_V1_1. Please update your configuration."
#elif MB(BIGTREE_SKR_V2_2)
#error "BOARD_BIGTREE_SKR_V1_2 has been renamed BOARD_BTT_SKR_V1_2. Please update your configuration."
#elif MB(BIGTREE_SKR_V1_3)
#error "BOARD_BIGTREE_SKR_V1_3 has been renamed BOARD_BTT_SKR_V1_3. Please update your configuration."
#elif MB(BIGTREE_SKR_V1_4)
#error "BOARD_BIGTREE_SKR_V1_4 has been renamed BOARD_BTT_SKR_V1_4. Please update your configuration."
#elif MB(BIGTREE_SKR_V1_4_TURBO)
#error "BOARD_BIGTREE_SKR_V1_4_TURBO has been renamed BOARD_BTT_SKR_V1_4_TURBO. Please update your configuration."
#elif MB(BIGTREE_BTT002_V1_0)
#error "BOARD_BIGTREE_BTT002_V1_0 has been renamed BOARD_BTT_BTT002_V1_0. Please update your configuration."
#elif MB(BIGTREE_SKR_PRO_V1_1)
#error "BOARD_BIGTREE_SKR_PRO_V1_1 has been renamed BOARD_BTT_SKR_PRO_V1_1. Please update your configuration."
#elif MB(BIGTREE_SKR_MINI_V1_1)
#error "BOARD_BIGTREE_SKR_MINI_V1_1 has been renamed BOARD_BTT_SKR_MINI_V1_1. Please update your configuration."
#elif MB(BIGTREE_SKR_MINI_E3)
#error "BOARD_BIGTREE_SKR_MINI_E3 has been renamed BOARD_BTT_SKR_MINI_E3_V1_0. Please update your configuration."
#elif MB(BIGTREE_SKR_E3_DIP)
#error "BOARD_BIGTREE_SKR_E3_DIP has been renamed BOARD_BTT_SKR_E3_DIP. Please update your configuration."
#elif MB(STM32F1R)
#error "BOARD_STM32F1R has been renamed BOARD_STM32F103RE. Please update your configuration."
#elif MB(STM32F103R)
#error "BOARD_STM32F103R has been renamed BOARD_STM32F103RE. Please update your configuration."
#elif MOTHERBOARD == BOARD_ESP32
#error "BOARD_ESP32 has been renamed BOARD_ESPRESSIF_ESP32. Please update your configuration."
#elif MB(STEVAL)
#error "BOARD_STEVAL has been renamed BOARD_STEVAL_3DP001V1. Please update your configuration."
#elif MB(RUMBA32)
#error "BOARD_RUMBA32 is now BOARD_RUMBA32_MKS or BOARD_RUMBA32_AUS3D. Please update your configuration."
#else
#error "Unknown MOTHERBOARD value set in Configuration.h"
#endif
#undef BOARD_MKS_13
#undef BOARD_TRIGORILLA
#undef BOARD_RURAMPS4D
#undef BOARD_FORMBOT_TREX2
#undef BOARD_BIQU_SKR_V1_1
#undef BOARD_STM32F1R
#undef BOARD_STM32F103R
#undef BOARD_ESP32
#undef BOARD_STEVAL
#undef BOARD_BIGTREE_SKR_MINI_E3
#undef BOARD_BIGTREE_SKR_V1_1
#undef BOARD_BIGTREE_SKR_V1_3
#undef BOARD_BIGTREE_SKR_V1_4
#undef BOARD_BIGTREE_SKR_V1_4_TURBO
#undef BOARD_BIGTREE_BTT002_V1_0
#undef BOARD_BIGTREE_SKR_PRO_V1_1
#undef BOARD_BIGTREE_SKR_MINI_V1_1
#undef BOARD_BIGTREE_SKR_E3_DIP
#undef BOARD_RUMBA32
#endif
// Define certain undefined pins
#ifndef X_MS1_PIN
#define X_MS1_PIN -1
#endif
#ifndef X_MS2_PIN
#define X_MS2_PIN -1
#endif
#ifndef X_MS3_PIN
#define X_MS3_PIN -1
#endif
#ifndef Y_MS1_PIN
#define Y_MS1_PIN -1
#endif
#ifndef Y_MS2_PIN
#define Y_MS2_PIN -1
#endif
#ifndef Y_MS3_PIN
#define Y_MS3_PIN -1
#endif
#ifndef Z_MS1_PIN
#define Z_MS1_PIN -1
#endif
#ifndef Z_MS2_PIN
#define Z_MS2_PIN -1
#endif
#ifndef Z_MS3_PIN
#define Z_MS3_PIN -1
#endif
#ifndef E0_MS1_PIN
#define E0_MS1_PIN -1
#endif
#ifndef E0_MS2_PIN
#define E0_MS2_PIN -1
#endif
#ifndef E0_MS3_PIN
#define E0_MS3_PIN -1
#endif
#ifndef E1_MS1_PIN
#define E1_MS1_PIN -1
#endif
#ifndef E1_MS2_PIN
#define E1_MS2_PIN -1
#endif
#ifndef E1_MS3_PIN
#define E1_MS3_PIN -1
#endif
#ifndef E2_MS1_PIN
#define E2_MS1_PIN -1
#endif
#ifndef E2_MS2_PIN
#define E2_MS2_PIN -1
#endif
#ifndef E2_MS3_PIN
#define E2_MS3_PIN -1
#endif
#ifndef E3_MS1_PIN
#define E3_MS1_PIN -1
#endif
#ifndef E3_MS2_PIN
#define E3_MS2_PIN -1
#endif
#ifndef E3_MS3_PIN
#define E3_MS3_PIN -1
#endif
#ifndef E4_MS1_PIN
#define E4_MS1_PIN -1
#endif
#ifndef E4_MS2_PIN
#define E4_MS2_PIN -1
#endif
#ifndef E4_MS3_PIN
#define E4_MS3_PIN -1
#endif
#ifndef E5_MS1_PIN
#define E5_MS1_PIN -1
#endif
#ifndef E5_MS2_PIN
#define E5_MS2_PIN -1
#endif
#ifndef E5_MS3_PIN
#define E5_MS3_PIN -1
#endif
#ifndef E6_MS1_PIN
#define E6_MS1_PIN -1
#endif
#ifndef E6_MS2_PIN
#define E6_MS2_PIN -1
#endif
#ifndef E6_MS3_PIN
#define E6_MS3_PIN -1
#endif
#ifndef E7_MS1_PIN
#define E7_MS1_PIN -1
#endif
#ifndef E7_MS2_PIN
#define E7_MS2_PIN -1
#endif
#ifndef E7_MS3_PIN
#define E7_MS3_PIN -1
#endif
#ifndef E0_STEP_PIN
#define E0_STEP_PIN -1
#endif
#ifndef E0_DIR_PIN
#define E0_DIR_PIN -1
#endif
#ifndef E0_ENABLE_PIN
#define E0_ENABLE_PIN -1
#endif
#ifndef E1_STEP_PIN
#define E1_STEP_PIN -1
#endif
#ifndef E1_DIR_PIN
#define E1_DIR_PIN -1
#endif
#ifndef E1_ENABLE_PIN
#define E1_ENABLE_PIN -1
#endif
#ifndef E2_STEP_PIN
#define E2_STEP_PIN -1
#endif
#ifndef E2_DIR_PIN
#define E2_DIR_PIN -1
#endif
#ifndef E2_ENABLE_PIN
#define E2_ENABLE_PIN -1
#endif
#ifndef E3_STEP_PIN
#define E3_STEP_PIN -1
#endif
#ifndef E3_DIR_PIN
#define E3_DIR_PIN -1
#endif
#ifndef E3_ENABLE_PIN
#define E3_ENABLE_PIN -1
#endif
#ifndef E4_STEP_PIN
#define E4_STEP_PIN -1
#endif
#ifndef E4_DIR_PIN
#define E4_DIR_PIN -1
#endif
#ifndef E4_ENABLE_PIN
#define E4_ENABLE_PIN -1
#endif
#ifndef E5_STEP_PIN
#define E5_STEP_PIN -1
#endif
#ifndef E5_DIR_PIN
#define E5_DIR_PIN -1
#endif
#ifndef E5_ENABLE_PIN
#define E5_ENABLE_PIN -1
#endif
#ifndef E6_STEP_PIN
#define E6_STEP_PIN -1
#endif
#ifndef E6_DIR_PIN
#define E6_DIR_PIN -1
#endif
#ifndef E6_ENABLE_PIN
#define E6_ENABLE_PIN -1
#endif
#ifndef E7_STEP_PIN
#define E7_STEP_PIN -1
#endif
#ifndef E7_DIR_PIN
#define E7_DIR_PIN -1
#endif
#ifndef E7_ENABLE_PIN
#define E7_ENABLE_PIN -1
#endif
//
// Destroy unused CS pins
//
#if !AXIS_HAS_SPI(X)
#undef X_CS_PIN
#endif
#if !AXIS_HAS_SPI(Y)
#undef Y_CS_PIN
#endif
#if !AXIS_HAS_SPI(Z)
#undef Z_CS_PIN
#endif
#if E_STEPPERS && !AXIS_HAS_SPI(E0)
#undef E0_CS_PIN
#endif
#if E_STEPPERS > 1 && !AXIS_HAS_SPI(E1)
#undef E1_CS_PIN
#endif
#if E_STEPPERS > 2 && !AXIS_HAS_SPI(E2)
#undef E2_CS_PIN
#endif
#if E_STEPPERS > 3 && !AXIS_HAS_SPI(E3)
#undef E3_CS_PIN
#endif
#if E_STEPPERS > 4 && !AXIS_HAS_SPI(E4)
#undef E4_CS_PIN
#endif
#if E_STEPPERS > 5 && !AXIS_HAS_SPI(E5)
#undef E5_CS_PIN
#endif
#if E_STEPPERS > 6 && !AXIS_HAS_SPI(E6)
#undef E6_CS_PIN
#endif
#if E_STEPPERS > 7 && !AXIS_HAS_SPI(E7)
#undef E7_CS_PIN
#endif
#ifndef X_CS_PIN
#define X_CS_PIN -1
#endif
#ifndef Y_CS_PIN
#define Y_CS_PIN -1
#endif
#ifndef Z_CS_PIN
#define Z_CS_PIN -1
#endif
#ifndef E0_CS_PIN
#define E0_CS_PIN -1
#endif
#ifndef E1_CS_PIN
#define E1_CS_PIN -1
#endif
#ifndef E2_CS_PIN
#define E2_CS_PIN -1
#endif
#ifndef E3_CS_PIN
#define E3_CS_PIN -1
#endif
#ifndef E4_CS_PIN
#define E4_CS_PIN -1
#endif
#ifndef E5_CS_PIN
#define E5_CS_PIN -1
#endif
#ifndef E6_CS_PIN
#define E6_CS_PIN -1
#endif
#ifndef E7_CS_PIN
#define E7_CS_PIN -1
#endif
#ifndef FAN_PIN
#define FAN_PIN -1
#endif
#define FAN0_PIN FAN_PIN
#ifndef FAN1_PIN
#define FAN1_PIN -1
#endif
#ifndef FAN2_PIN
#define FAN2_PIN -1
#endif
#ifndef CONTROLLER_FAN_PIN
#define CONTROLLER_FAN_PIN -1
#endif
#ifndef FANMUX0_PIN
#define FANMUX0_PIN -1
#endif
#ifndef FANMUX1_PIN
#define FANMUX1_PIN -1
#endif
#ifndef FANMUX2_PIN
#define FANMUX2_PIN -1
#endif
#ifndef HEATER_0_PIN
#define HEATER_0_PIN -1
#endif
#ifndef HEATER_1_PIN
#define HEATER_1_PIN -1
#endif
#ifndef HEATER_2_PIN
#define HEATER_2_PIN -1
#endif
#ifndef HEATER_3_PIN
#define HEATER_3_PIN -1
#endif
#ifndef HEATER_4_PIN
#define HEATER_4_PIN -1
#endif
#ifndef HEATER_5_PIN
#define HEATER_5_PIN -1
#endif
#ifndef HEATER_6_PIN
#define HEATER_6_PIN -1
#endif
#ifndef HEATER_7_PIN
#define HEATER_7_PIN -1
#endif
#ifndef HEATER_BED_PIN
#define HEATER_BED_PIN -1
#endif
#ifndef TEMP_0_PIN
#define TEMP_0_PIN -1
#endif
#ifndef TEMP_1_PIN
#define TEMP_1_PIN -1
#endif
#ifndef TEMP_2_PIN
#define TEMP_2_PIN -1
#endif
#ifndef TEMP_3_PIN
#define TEMP_3_PIN -1
#endif
#ifndef TEMP_4_PIN
#define TEMP_4_PIN -1
#endif
#ifndef TEMP_5_PIN
#define TEMP_5_PIN -1
#endif
#ifndef TEMP_6_PIN
#define TEMP_6_PIN -1
#endif
#ifndef TEMP_7_PIN
#define TEMP_7_PIN -1
#endif
#ifndef TEMP_BED_PIN
#define TEMP_BED_PIN -1
#endif
#ifndef SD_DETECT_PIN
#define SD_DETECT_PIN -1
#endif
#ifndef SDPOWER_PIN
#define SDPOWER_PIN -1
#endif
#ifndef SDSS
#define SDSS -1
#endif
#ifndef LED_PIN
#define LED_PIN -1
#endif
#if DISABLED(PSU_CONTROL) || !defined(PS_ON_PIN)
#undef PS_ON_PIN
#define PS_ON_PIN -1
#endif
#ifndef KILL_PIN
#define KILL_PIN -1
#endif
#ifndef SUICIDE_PIN
#define SUICIDE_PIN -1
#endif
#ifndef SUICIDE_PIN_INVERTING
#define SUICIDE_PIN_INVERTING false
#endif
#ifndef NUM_SERVO_PLUGS
#define NUM_SERVO_PLUGS 4
#endif
//
// Assign auto fan pins if needed
//
#ifndef E0_AUTO_FAN_PIN
#ifdef ORIG_E0_AUTO_FAN_PIN
#define E0_AUTO_FAN_PIN ORIG_E0_AUTO_FAN_PIN
#else
#define E0_AUTO_FAN_PIN -1
#endif
#endif
#ifndef E1_AUTO_FAN_PIN
#ifdef ORIG_E1_AUTO_FAN_PIN
#define E1_AUTO_FAN_PIN ORIG_E1_AUTO_FAN_PIN
#else
#define E1_AUTO_FAN_PIN -1
#endif
#endif
#ifndef E2_AUTO_FAN_PIN
#ifdef ORIG_E2_AUTO_FAN_PIN
#define E2_AUTO_FAN_PIN ORIG_E2_AUTO_FAN_PIN
#else
#define E2_AUTO_FAN_PIN -1
#endif
#endif
#ifndef E3_AUTO_FAN_PIN
#ifdef ORIG_E3_AUTO_FAN_PIN
#define E3_AUTO_FAN_PIN ORIG_E3_AUTO_FAN_PIN
#else
#define E3_AUTO_FAN_PIN -1
#endif
#endif
#ifndef E4_AUTO_FAN_PIN
#ifdef ORIG_E4_AUTO_FAN_PIN
#define E4_AUTO_FAN_PIN ORIG_E4_AUTO_FAN_PIN
#else
#define E4_AUTO_FAN_PIN -1
#endif
#endif
#ifndef E5_AUTO_FAN_PIN
#ifdef ORIG_E5_AUTO_FAN_PIN
#define E5_AUTO_FAN_PIN ORIG_E5_AUTO_FAN_PIN
#else
#define E5_AUTO_FAN_PIN -1
#endif
#endif
#ifndef E6_AUTO_FAN_PIN
#ifdef ORIG_E6_AUTO_FAN_PIN
#define E6_AUTO_FAN_PIN ORIG_E6_AUTO_FAN_PIN
#else
#define E6_AUTO_FAN_PIN -1
#endif
#endif
#ifndef E7_AUTO_FAN_PIN
#ifdef ORIG_E7_AUTO_FAN_PIN
#define E7_AUTO_FAN_PIN ORIG_E7_AUTO_FAN_PIN
#else
#define E7_AUTO_FAN_PIN -1
#endif
#endif
#ifndef CHAMBER_AUTO_FAN_PIN
#ifdef ORIG_CHAMBER_AUTO_FAN_PIN
#define CHAMBER_AUTO_FAN_PIN ORIG_CHAMBER_AUTO_FAN_PIN
#else
#define CHAMBER_AUTO_FAN_PIN -1
#endif
#endif
//
// Assign endstop pins for boards with only 3 connectors
//
#ifdef X_STOP_PIN
#if X_HOME_DIR < 0
#define X_MIN_PIN X_STOP_PIN
#ifndef X_MAX_PIN
#define X_MAX_PIN -1
#endif
#else
#define X_MAX_PIN X_STOP_PIN
#ifndef X_MIN_PIN
#define X_MIN_PIN -1
#endif
#endif
#elif X_HOME_DIR < 0
#define X_STOP_PIN X_MIN_PIN
#else
#define X_STOP_PIN X_MAX_PIN
#endif
#ifdef Y_STOP_PIN
#if Y_HOME_DIR < 0
#define Y_MIN_PIN Y_STOP_PIN
#ifndef Y_MAX_PIN
#define Y_MAX_PIN -1
#endif
#else
#define Y_MAX_PIN Y_STOP_PIN
#ifndef Y_MIN_PIN
#define Y_MIN_PIN -1
#endif
#endif
#elif Y_HOME_DIR < 0
#define Y_STOP_PIN Y_MIN_PIN
#else
#define Y_STOP_PIN Y_MAX_PIN
#endif
#ifdef Z_STOP_PIN
#if Z_HOME_DIR < 0
#define Z_MIN_PIN Z_STOP_PIN
#ifndef Z_MAX_PIN
#define Z_MAX_PIN -1
#endif
#else
#define Z_MAX_PIN Z_STOP_PIN
#ifndef Z_MIN_PIN
#define Z_MIN_PIN -1
#endif
#endif
#elif Z_HOME_DIR < 0
#define Z_STOP_PIN Z_MIN_PIN
#else
#define Z_STOP_PIN Z_MAX_PIN
#endif
//
// Disable unused endstop / probe pins
//
#if !HAS_CUSTOM_PROBE_PIN
#undef Z_MIN_PROBE_PIN
#define Z_MIN_PROBE_PIN -1
#endif
#if DISABLED(USE_XMAX_PLUG)
#undef X_MAX_PIN
#define X_MAX_PIN -1
#endif
#if DISABLED(USE_YMAX_PLUG)
#undef Y_MAX_PIN
#define Y_MAX_PIN -1
#endif
#if DISABLED(USE_ZMAX_PLUG)
#undef Z_MAX_PIN
#define Z_MAX_PIN -1
#endif
#if DISABLED(USE_XMIN_PLUG)
#undef X_MIN_PIN
#define X_MIN_PIN -1
#endif
#if DISABLED(USE_YMIN_PLUG)
#undef Y_MIN_PIN
#define Y_MIN_PIN -1
#endif
#if DISABLED(USE_ZMIN_PLUG)
#undef Z_MIN_PIN
#define Z_MIN_PIN -1
#endif
#if HAS_FILAMENT_SENSOR
#define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
#else
#undef FIL_RUNOUT_PIN
#undef FIL_RUNOUT1_PIN
#endif
#ifndef LCD_PINS_D4
#define LCD_PINS_D4 -1
#endif
#if HAS_CHARACTER_LCD || TOUCH_UI_ULTIPANEL
#ifndef LCD_PINS_D5
#define LCD_PINS_D5 -1
#endif
#ifndef LCD_PINS_D6
#define LCD_PINS_D6 -1
#endif
#ifndef LCD_PINS_D7
#define LCD_PINS_D7 -1
#endif
#endif
/**
* Auto-Assignment for Dual X, Dual Y, Multi-Z Steppers
*
* By default X2 is assigned to the next open E plug
* on the board, then in order, Y2, Z2, Z3. These can be
* overridden in Configuration.h or Configuration_adv.h.
*/
#define __PEXI(p,q) PIN_EXISTS(E##p##_##q)
#define _PEXI(p,q) __PEXI(p,q)
#define __EPIN(p,q) E##p##_##q##_PIN
#define _EPIN(p,q) __EPIN(p,q)
#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)
// The X2 axis, if any, should be the next open extruder port
#define X2_E_INDEX E_STEPPERS
#if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS)
#ifndef X2_STEP_PIN
#define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP)
#define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR)
#define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE)
#if X2_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(X2_STEP)
#error "No E stepper plug left for X2!"
#endif
#endif
#ifndef X2_MS1_PIN
#define X2_MS1_PIN _EPIN(X2_E_INDEX, MS1)
#endif
#ifndef X2_MS2_PIN
#define X2_MS2_PIN _EPIN(X2_E_INDEX, MS2)
#endif
#ifndef X2_MS3_PIN
#define X2_MS3_PIN _EPIN(X2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(X2) && !defined(X2_CS_PIN)
#define X2_CS_PIN _EPIN(X2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(X2)
#ifndef X2_SERIAL_TX_PIN
#define X2_SERIAL_TX_PIN _EPIN(X2_E_INDEX, SERIAL_TX)
#endif
#ifndef X2_SERIAL_RX_PIN
#define X2_SERIAL_RX_PIN _EPIN(X2_E_INDEX, SERIAL_RX)
#endif
#endif
//
// Auto-assign pins for stallGuard sensorless homing
//
#if X2_STALL_SENSITIVITY && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG)
#define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG)
#if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file...
#define X2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(X2, Y_MIN)
#define X2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(X2, Z_MIN)
#define X2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(X2, X_MAX)
#define X2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(X2, Y_MAX)
#define X2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(X2, Z_MAX)
#define X2_USE_ENDSTOP _ZMAX_
#else // Otherwise use the driver DIAG_PIN directly
#define _X2_USE_ENDSTOP(P) _E##P##_DIAG_
#define X2_USE_ENDSTOP _X2_USE_ENDSTOP(X2_E_INDEX)
#endif
#undef X2_DIAG_PIN
#endif
#define Y2_E_INDEX INCREMENT(X2_E_INDEX)
#else
#define Y2_E_INDEX X2_E_INDEX
#endif
#ifndef X2_CS_PIN
#define X2_CS_PIN -1
#endif
#ifndef X2_MS1_PIN
#define X2_MS1_PIN -1
#endif
#ifndef X2_MS2_PIN
#define X2_MS2_PIN -1
#endif
#ifndef X2_MS3_PIN
#define X2_MS3_PIN -1
#endif
// The Y2 axis, if any, should be the next open extruder port
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#ifndef Y2_STEP_PIN
#define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP)
#define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR)
#define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
#if Y2_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(Y2_STEP)
#error "No E stepper plug left for Y2!"
#endif
#endif
#ifndef Y2_MS1_PIN
#define Y2_MS1_PIN _EPIN(Y2_E_INDEX, MS1)
#endif
#ifndef Y2_MS2_PIN
#define Y2_MS2_PIN _EPIN(Y2_E_INDEX, MS2)
#endif
#ifndef Y2_MS3_PIN
#define Y2_MS3_PIN _EPIN(Y2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(Y2) && !defined(Y2_CS_PIN)
#define Y2_CS_PIN _EPIN(Y2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(Y2)
#ifndef Y2_SERIAL_TX_PIN
#define Y2_SERIAL_TX_PIN _EPIN(Y2_E_INDEX, SERIAL_TX)
#endif
#ifndef Y2_SERIAL_RX_PIN
#define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX)
#endif
#endif
#if Y2_STALL_SENSITIVITY && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG)
#define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG)
#if DIAG_REMAPPED(Y2, X_MIN)
#define Y2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Y2, Y_MIN)
#define Y2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Y2, Z_MIN)
#define Y2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Y2, X_MAX)
#define Y2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Y2, Y_MAX)
#define Y2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Y2, Z_MAX)
#define Y2_USE_ENDSTOP _ZMAX_
#else
#define _Y2_USE_ENDSTOP(P) _E##P##_DIAG_
#define Y2_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX)
#endif
#undef Y2_DIAG_PIN
#endif
#define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
#else
#define Z2_E_INDEX Y2_E_INDEX
#endif
#ifndef Y2_CS_PIN
#define Y2_CS_PIN -1
#endif
#ifndef Y2_MS1_PIN
#define Y2_MS1_PIN -1
#endif
#ifndef Y2_MS2_PIN
#define Y2_MS2_PIN -1
#endif
#ifndef Y2_MS3_PIN
#define Y2_MS3_PIN -1
#endif
// The Z2 axis, if any, should be the next open extruder port
#if NUM_Z_STEPPER_DRIVERS >= 2
#ifndef Z2_STEP_PIN
#define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP)
#define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR)
#define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
#if Z2_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(Z2_STEP)
#error "No E stepper plug left for Z2!"
#endif
#endif
#ifndef Z2_MS1_PIN
#define Z2_MS1_PIN _EPIN(Z2_E_INDEX, MS1)
#endif
#ifndef Z2_MS2_PIN
#define Z2_MS2_PIN _EPIN(Z2_E_INDEX, MS2)
#endif
#ifndef Z2_MS3_PIN
#define Z2_MS3_PIN _EPIN(Z2_E_INDEX, MS3)
#endif
#if AXIS_HAS_SPI(Z2) && !defined(Z2_CS_PIN)
#define Z2_CS_PIN _EPIN(Z2_E_INDEX, CS)
#endif
#if AXIS_HAS_UART(Z2)
#ifndef Z2_SERIAL_TX_PIN
#define Z2_SERIAL_TX_PIN _EPIN(Z2_E_INDEX, SERIAL_TX)
#endif
#ifndef Z2_SERIAL_RX_PIN
#define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX)
#endif
#endif
#if Z2_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG)
#define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z2, X_MIN)
#define Z2_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z2, Y_MIN)
#define Z2_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z2, Z_MIN)
#define Z2_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z2, X_MAX)
#define Z2_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z2, Y_MAX)
#define Z2_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z2, Z_MAX)
#define Z2_USE_ENDSTOP _ZMAX_
#else
#define _Z2_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z2_USE_ENDSTOP _Z2_USE_ENDSTOP(Z2_E_INDEX)
#endif
#undef Z2_DIAG_PIN
#endif
#define Z3_E_INDEX INCREMENT(Z2_E_INDEX)
#else
#define Z3_E_INDEX Z2_E_INDEX
#endif
#ifndef Z2_CS_PIN
#define Z2_CS_PIN -1
#endif
#ifndef Z2_MS1_PIN
#define Z2_MS1_PIN -1
#endif
#ifndef Z2_MS2_PIN
#define Z2_MS2_PIN -1
#endif
#ifndef Z2_MS3_PIN
#define Z2_MS3_PIN -1
#endif
#if NUM_Z_STEPPER_DRIVERS >= 3
#ifndef Z3_STEP_PIN
#define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP)
#define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR)
#define Z3_ENABLE_PIN _EPIN(Z3_E_INDEX, ENABLE)
#if Z3_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(Z3_STEP)
#error "No E stepper plug left for Z3!"
#endif
#endif
#if AXIS_HAS_SPI(Z3)
#ifndef Z3_CS_PIN
#define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS)
#endif
#endif
#ifndef Z3_MS1_PIN
#define Z3_MS1_PIN _EPIN(Z3_E_INDEX, MS1)
#endif
#ifndef Z3_MS2_PIN
#define Z3_MS2_PIN _EPIN(Z3_E_INDEX, MS2)
#endif
#ifndef Z3_MS3_PIN
#define Z3_MS3_PIN _EPIN(Z3_E_INDEX, MS3)
#endif
#if AXIS_HAS_UART(Z3)
#ifndef Z3_SERIAL_TX_PIN
#define Z3_SERIAL_TX_PIN _EPIN(Z3_E_INDEX, SERIAL_TX)
#endif
#ifndef Z3_SERIAL_RX_PIN
#define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX)
#endif
#endif
#if Z3_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG)
#define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z3, X_MIN)
#define Z3_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z3, Y_MIN)
#define Z3_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z3, Z_MIN)
#define Z3_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z3, X_MAX)
#define Z3_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z3, Y_MAX)
#define Z3_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z3, Z_MAX)
#define Z3_USE_ENDSTOP _ZMAX_
#else
#define _Z3_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z3_USE_ENDSTOP _Z3_USE_ENDSTOP(Z3_E_INDEX)
#endif
#undef Z3_DIAG_PIN
#endif
#define Z4_E_INDEX INCREMENT(Z3_E_INDEX)
#endif
#ifndef Z3_CS_PIN
#define Z3_CS_PIN -1
#endif
#ifndef Z3_MS1_PIN
#define Z3_MS1_PIN -1
#endif
#ifndef Z3_MS2_PIN
#define Z3_MS2_PIN -1
#endif
#ifndef Z3_MS3_PIN
#define Z3_MS3_PIN -1
#endif
#if NUM_Z_STEPPER_DRIVERS >= 4
#ifndef Z4_STEP_PIN
#define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP)
#define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR)
#define Z4_ENABLE_PIN _EPIN(Z4_E_INDEX, ENABLE)
#if Z4_E_INDEX >= MAX_EXTRUDERS || !PIN_EXISTS(Z4_STEP)
#error "No E stepper plug left for Z4!"
#endif
#endif
#if AXIS_HAS_SPI(Z4)
#ifndef Z4_CS_PIN
#define Z4_CS_PIN _EPIN(Z4_E_INDEX, CS)
#endif
#endif
#ifndef Z4_MS1_PIN
#define Z4_MS1_PIN _EPIN(Z4_E_INDEX, MS1)
#endif
#ifndef Z4_MS2_PIN
#define Z4_MS2_PIN _EPIN(Z4_E_INDEX, MS2)
#endif
#ifndef Z4_MS3_PIN
#define Z4_MS3_PIN _EPIN(Z4_E_INDEX, MS3)
#endif
#if AXIS_HAS_UART(Z4)
#ifndef Z4_SERIAL_TX_PIN
#define Z4_SERIAL_TX_PIN _EPIN(Z4_E_INDEX, SERIAL_TX)
#endif
#ifndef Z4_SERIAL_RX_PIN
#define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX)
#endif
#endif
#if Z4_STALL_SENSITIVITY && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG)
#define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG)
#if DIAG_REMAPPED(Z4, X_MIN)
#define Z4_USE_ENDSTOP _XMIN_
#elif DIAG_REMAPPED(Z4, Y_MIN)
#define Z4_USE_ENDSTOP _YMIN_
#elif DIAG_REMAPPED(Z4, Z_MIN)
#define Z4_USE_ENDSTOP _ZMIN_
#elif DIAG_REMAPPED(Z4, X_MAX)
#define Z4_USE_ENDSTOP _XMAX_
#elif DIAG_REMAPPED(Z4, Y_MAX)
#define Z4_USE_ENDSTOP _YMAX_
#elif DIAG_REMAPPED(Z4, Z_MAX)
#define Z4_USE_ENDSTOP _ZMAX_
#else
#define _Z4_USE_ENDSTOP(P) _E##P##_DIAG_
#define Z4_USE_ENDSTOP _Z4_USE_ENDSTOP(Z4_E_INDEX)
#endif
#undef Z4_DIAG_PIN
#endif
#endif
#ifndef Z4_CS_PIN
#define Z4_CS_PIN -1
#endif
#ifndef Z4_MS1_PIN
#define Z4_MS1_PIN -1
#endif
#ifndef Z4_MS2_PIN
#define Z4_MS2_PIN -1
#endif
#ifndef Z4_MS3_PIN
#define Z4_MS3_PIN -1
#endif
#if HAS_GRAPHICAL_LCD
#if !defined(ST7920_DELAY_1) && defined(BOARD_ST7920_DELAY_1)
#define ST7920_DELAY_1 BOARD_ST7920_DELAY_1
#endif
#if !defined(ST7920_DELAY_2) && defined(BOARD_ST7920_DELAY_2)
#define ST7920_DELAY_2 BOARD_ST7920_DELAY_2
#endif
#if !defined(ST7920_DELAY_3) && defined(BOARD_ST7920_DELAY_3)
#define ST7920_DELAY_3 BOARD_ST7920_DELAY_3
#endif
#else
#undef ST7920_DELAY_1
#undef ST7920_DELAY_2
#undef ST7920_DELAY_3
#endif
#undef HAS_FREE_AUX2_PINS
#undef DIAG_REMAPPED
| 58,468
|
C++
|
.h
| 1,521
| 35.865878
| 231
| 0.615797
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,892
|
pins_LONGER3D_LK.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h
|
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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
/**
* Longer3D LK1/LK2 & Alfawise U20/U30 (STM32F103VET6) board pin assignments
*/
#if !defined(__STM32F1__) && !defined(STM32F1xx)
#error "Oops! Select a STM32F1 board in 'Tools > Board.'"
#elif HOTENDS > 1 || E_STEPPERS > 1
#error "Longer3D board only supports 1 hotend / E-stepper. Comment out this line to continue."
#endif
#define BOARD_INFO_NAME "Longer3D"
#define ALFAWISE_UX0 // Common to all Longer3D STM32F1 boards (used for Open drain mosfets)
//#define DISABLE_DEBUG // We still want to debug with STLINK...
#define DISABLE_JTAG // We free the jtag pins (PA15) but keep STLINK
// Release PB4 (STEP_X_PIN) from JTAG NRST role.
//
// Limit Switches
//
#define X_MIN_PIN PC1 // pin 16
#define X_MAX_PIN PC0 // pin 15 (Filament sensor on Alfawise setup)
#define Y_MIN_PIN PC15 // pin 9
#define Y_MAX_PIN PC14 // pin 8 (Unused in stock Alfawise setup)
#define Z_MIN_PIN PE6 // pin 5 Standard Endstop or Z_Probe endstop function
#define Z_MAX_PIN PE5 // pin 4 (Unused in stock Alfawise setup)
// May be used for BLTouch Servo function on older variants (<= V08)
#define ONBOARD_ENDSTOPPULLUPS
//
// Filament Sensor
//
#ifndef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN PC0 // XMAX plug on PCB used as filament runout sensor on Alfawise boards (inverting true)
#endif
//
// Steppers
//
#define X_ENABLE_PIN PB5 // pin 91
#define X_STEP_PIN PB4 // pin 90
#define X_DIR_PIN PB3 // pin 89
#define Y_ENABLE_PIN PB8 // pin 95
#define Y_STEP_PIN PB7 // pin 93
#define Y_DIR_PIN PB6 // pin 92
#define Z_ENABLE_PIN PE1 // pin 98
#define Z_STEP_PIN PE0 // pin 97
#define Z_DIR_PIN PB9 // pin 96
#define E0_ENABLE_PIN PE4 // pin 3
#define E0_STEP_PIN PE3 // pin 2
#define E0_DIR_PIN PE2 // pin 1
//
// Temperature Sensors
//
#define TEMP_0_PIN PA0 // pin 23 (Nozzle 100K/3950 thermistor)
#define TEMP_BED_PIN PA1 // pin 24 (Hot Bed 100K/3950 thermistor)
//
// Heaters / Fans
//
#define HEATER_0_PIN PD3 // pin 84 (Nozzle Heat Mosfet)
#define HEATER_BED_PIN PA8 // pin 67 (Hot Bed Mosfet)
#define FAN_PIN PA15 // pin 77 (4cm Fan)
#define FAN_SOFT_PWM // Required to avoid issues with heating or STLink
#define FAN_MIN_PWM 35 // Fan will not start in 1-30 range
#define FAN_MAX_PWM 255
//#define BEEPER_PIN PD13 // pin 60 (Servo PWM output 5V/GND on Board V0G+) made for BL-Touch sensor
// Can drive a PC Buzzer, if connected between PWM and 5V pins
#define LED_PIN PC2 // pin 17
//
// PWM for a servo probe
// Other servo devices are not supported on this board!
//
#if HAS_Z_SERVO_PROBE
#define SERVO0_PIN PD13 // Open drain PWM pin on the V0G (GND or floating 5V)
#define SERVO0_PWM_OD // Comment this if using PE5
//#define SERVO0_PIN PE5 // Pulled up PWM pin on the V08 (3.3V or 0)
//#undef Z_MAX_PIN // Uncomment if using ZMAX connector (PE5)
#endif
/**
* Note: Alfawise screens use various TFT controllers. Supported screens
* are based on the ILI9341, ILI9328 and ST7798V. Define init sequences for
* other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp
*
* If the screen stays white, disable 'LCD_RESET_PIN' to let the bootloader
* init the screen.
*
* Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu
* because Marlin uses the reset as a failsafe to revive a glitchy LCD.
*/
#define LCD_RESET_PIN PC4 // pin 33
#define LCD_BACKLIGHT_PIN PD12 // pin 59
#define FSMC_CS_PIN PD7 // pin 88 = FSMC_NE1
#define FSMC_RS_PIN PD11 // pin 58 A16 Register. Only one address needed
#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT
#define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5
#define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h
#define DOGLCD_SCK -1
/**
* Note: Alfawise U20/U30 boards DON'T use SPI2, as the hardware designer
* mixed up MOSI and MISO pins. SPI is managed in SW, and needs pins
* declared below.
*/
#if ENABLED(TOUCH_BUTTONS)
#define TOUCH_CS_PIN PB12 // pin 51 SPI2_NSS
#define TOUCH_SCK_PIN PB13 // pin 52
#define TOUCH_MOSI_PIN PB14 // pin 53
#define TOUCH_MISO_PIN PB15 // pin 54
#define TOUCH_INT_PIN PC6 // pin 63 (PenIRQ coming from ADS7843)
#endif
//
// Persistent Storage
// If no option is selected below the SD Card will be used
//
//#define SPI_EEPROM
#define FLASH_EEPROM_EMULATION
// SPI flash - w25qxx
#define SPI_FLASH
// SPI1 pins are already defined in the core
// SPI1 cs pin definition for spi flash
#define SPI_CS_PIN PC5
#undef E2END
#if ENABLED(SPI_EEPROM)
// SPI1 EEPROM Winbond W25Q64 (8MB/64Mbits)
#define SPI_CHAN_EEPROM1 1
#define SPI_EEPROM1_CS PC5 // pin 34
#define EEPROM_SCK BOARD_SPI1_SCK_PIN // PA5 pin 30
#define EEPROM_MISO BOARD_SPI1_MISO_PIN // PA6 pin 31
#define EEPROM_MOSI BOARD_SPI1_MOSI_PIN // PA7 pin 32
#define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet)
#define E2END ((16 * EEPROM_PAGE_SIZE)-1) // Limit to 64KB for now...
#elif ENABLED(FLASH_EEPROM_EMULATION)
// SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h)
#define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE)
#define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB)
#define E2END (EEPROM_PAGE_SIZE - 1)
#else
#define E2END (0x7FFU) // On SD, Limit to 2KB, require this amount of RAM
#endif
//
// SD support
//
#define SDIO_SUPPORT
// #define SD_DETECT_PIN // reserved
| 7,579
|
C++
|
.h
| 157
| 45.847134
| 136
| 0.588887
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
1,537,893
|
pins_RAMPS_144.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/pins/samd/pins_RAMPS_144.h
|
/**
* 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
/**
* AGCM4 with RAMPS v1.4.4 pin assignments
*/
#ifndef ARDUINO_GRAND_CENTRAL_M4
#error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'"
#endif
#ifndef BOARD_INFO_NAME
#define BOARD_INFO_NAME "AGCM4 RAMPS 1.4.4"
#endif
//
// Servos
//
#define SERVO0_PIN 11
#define SERVO1_PIN 6
#define SERVO2_PIN 5
#define SERVO3_PIN 4
//
// EEPROM
//
#define E2END 0x7FFF // 32Kb (24lc256)
#define I2C_EEPROM // EEPROM on I2C-0
//
// Limit Switches
//
#define X_MIN_PIN 3
#define X_MAX_PIN 2
#define Y_MIN_PIN 14
#define Y_MAX_PIN 15
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19
//
// Z Probe (when not Z_MIN_PIN)
//
#ifndef Z_MIN_PROBE_PIN
#define Z_MIN_PROBE_PIN 18
#endif
//
// Steppers
//
#define X_STEP_PIN 67 // Mega/Due:54 - AGCM4:67
#define X_DIR_PIN 68 // Mega/Due:55 - AGCM4:68
#define X_ENABLE_PIN 38
#ifndef X_CS_PIN
#define X_CS_PIN 47
#endif
#define Y_STEP_PIN 73 // Mega/Due:60 - AGCM4:73
#define Y_DIR_PIN 74 // Mega/Due:61 - AGCM4:74
#define Y_ENABLE_PIN 69 // Mega/Due:56 - AGCM4:69
#ifndef Y_CS_PIN
#define Y_CS_PIN 45
#endif
#define Z_STEP_PIN 46
#define Z_DIR_PIN 48
#define Z_ENABLE_PIN 54 // Mega/Due:62 - AGCM4:54
#ifndef Z_CS_PIN
#define Z_CS_PIN 32
#endif
#define Z2_STEP_PIN 36
#define Z2_DIR_PIN 34
#define Z2_ENABLE_PIN 30
#ifndef Z2_CS_PIN
#define Z2_CS_PIN 22
#endif
#define E0_STEP_PIN 26
#define E0_DIR_PIN 28
#define E0_ENABLE_PIN 24
#ifndef E0_CS_PIN
#define E0_CS_PIN 43
#endif
//
// Temperature Sensors
//
#define TEMP_0_PIN 13
#define TEMP_BED_PIN 14
#define TEMP_CHAMBER_PIN 15
//
// Heaters / Fans
//
#define HEATER_0_PIN 10
#define HEATER_BED_PIN 8
#define FAN_PIN 9
#define FAN1_PIN 7
#define FAN2_PIN 12
//
// 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 39
#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
#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
#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 58 // Mega/Due:66 - AGCM4:58
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO 44
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK 56 // Mega/Due:64 - AGCM4:56
#endif
#endif
#if HAS_TMC_UART
/**
* 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 47
#endif
#ifndef X_SERIAL_RX_PIN
#define X_SERIAL_RX_PIN 47
#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 45
#endif
#ifndef Y_SERIAL_RX_PIN
#define Y_SERIAL_RX_PIN 45
#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 32
#endif
#ifndef Z_SERIAL_RX_PIN
#define Z_SERIAL_RX_PIN 32
#endif
#ifndef Z2_SERIAL_TX_PIN
#define Z2_SERIAL_TX_PIN 22
#endif
#ifndef Z2_SERIAL_RX_PIN
#define Z2_SERIAL_RX_PIN 22
#endif
#ifndef E0_SERIAL_TX_PIN
#define E0_SERIAL_TX_PIN 43
#endif
#ifndef E0_SERIAL_RX_PIN
#define E0_SERIAL_RX_PIN 43
#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
//////////////////////////
// LCDs and Controllers //
//////////////////////////
#if HAS_SPI_LCD
//
// LCD Display output pins
//
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
// TO TEST
// #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)
// TO TEST
// #define LCD_PINS_RS 40
// #define LCD_PINS_ENABLE 42
// #define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57
// #define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58
// #define LCD_PINS_D6 44
// #define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56
#else
#if ENABLED(CR10_STOCKDISPLAY)
// TO TEST
// #define LCD_PINS_RS 27
// #define LCD_PINS_ENABLE 29
// #define LCD_PINS_D4 25
#if DISABLED(NEWPANEL)
// TO TEST
// #define BEEPER_PIN 37
#endif
#elif ENABLED(ZONESTAR_LCD)
// TO TEST
// #define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56
// #define LCD_PINS_ENABLE 44
// #define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55
// #define LCD_PINS_D5 40
// #define LCD_PINS_D6 42
// #define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57
#else
#if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306)
// TO TEST
// #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)
// TO TEST
// #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
#define KILL_PIN 41
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
// TO TEST
// #define LCD_BACKLIGHT_PIN 39
#endif
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
// TO TEST
// #define BTN_EN1 56 // Mega/Due:64 - AGCM4:56
// #define BTN_EN2 72 // Mega/Due:59 - AGCM4:72
// #define BTN_ENC 55
// #define SD_DETECT_PIN 42
#elif ENABLED(LCD_I2C_PANELOLU2)
// TO TEST
// #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)
// TO TEST
// #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)
// TO TEST
// #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)
// TO TEST
// #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)
// TO TEST
//#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
// TO TEST
// #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 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57)
// #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
// TO TEST
// #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
// TO TEST
// #define RGB_LED_R_PIN 25
#endif
#ifndef RGB_LED_G_PIN
// TO TEST
// #define RGB_LED_G_PIN 27
#endif
#ifndef RGB_LED_B_PIN
// TO TEST
// #define RGB_LED_B_PIN 29
#endif
#elif ENABLED(FYSETC_MINI_12864_2_1)
// TO TEST
// #define NEOPIXEL_PIN 25
#endif
#endif
#elif ENABLED(MINIPANEL)
// TO TEST
// #define BEEPER_PIN 42
// not connected to a pin
// #define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57)
// #define DOGLCD_A0 44
// #define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58
// 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 55 // Mega/Due:63 - AGCM4:55
// #define BTN_ENC 72 // Mega/Due:59 - AGCM4:72
// #define SD_DETECT_PIN 49
// #define KILL_PIN 56 // Mega/Due:64 - AGCM4:56
#elif ENABLED(ZONESTAR_LCD)
// TO TEST
// #define ADC_KEYPAD_PIN 12
#elif ENABLED(AZSMZ_12864)
// TO TEST
#else
// Beeper on AUX-4
// #define BEEPER_PIN 33
// Buttons are directly attached to AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
// TO TEST
// #define SHIFT_OUT 40
// #define SHIFT_CLK 44
// #define SHIFT_LD 42
// #define BTN_EN1 56 // Mega/Due:64 - AGCM4:56
// #define BTN_EN2 72 // Mega/Due:59 - AGCM4:72
// #define BTN_ENC 55 // Mega/Due:63 - AGCM4:55
#elif ENABLED(PANEL_ONE)
// TO TEST
// #define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72)
// #define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55)
// #define BTN_ENC 49 // AUX3 PIN 7
#else
// TO TEST
// #define BTN_EN1 37
// #define BTN_EN2 35
// #define BTN_ENC 31
#endif
#if ENABLED(G3D_PANEL)
// TO TEST
// #define SD_DETECT_PIN 49
// #define KILL_PIN 41
#endif
#endif
#endif // NEWPANEL
#endif // HAS_SPI_LCD
//
// SD Support
//
#ifndef SDCARD_CONNECTION
#define SDCARD_CONNECTION ONBOARD
#endif
#if SD_CONNECTION_IS(ONBOARD)
#undef SDSS
#define SDSS 83
#undef SD_DETECT_PIN
#define SD_DETECT_PIN 95
#endif
| 17,617
|
C++
|
.h
| 508
| 29.702756
| 125
| 0.515289
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,894
|
pins_FORMBOT_TREX2PLUS.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h
|
/**
* 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
/**
* Formbot pin assignments
*/
#ifndef __AVR_ATmega2560__
#error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'"
#elif HOTENDS > 2 || E_STEPPERS > 2
#error "Formbot supports up to 2 hotends / E-steppers. Comment out this line to continue."
#endif
#define BOARD_INFO_NAME "Formbot"
#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
//
// Servos
//
#define SERVO0_PIN 11
#define SERVO1_PIN -1 // was 6
#define SERVO2_PIN -1 // was 5
#define SERVO3_PIN -1
//
// Limit Switches
//
#define X_MIN_PIN 3
#ifndef X_MAX_PIN
#define X_MAX_PIN 2
#endif
#define Y_MIN_PIN 14
#define Y_MAX_PIN 15
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19
//
// 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
#define E2_STEP_PIN 42
#define E2_DIR_PIN 43
#define E2_ENABLE_PIN 44
//
// Temperature Sensors
//
#define TEMP_0_PIN 13 // Analog Input
#define TEMP_1_PIN 15 // Analog Input
#define TEMP_BED_PIN 3 // Analog Input
// 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
//
#define HEATER_0_PIN 10
#define HEATER_1_PIN 7
#define HEATER_BED_PIN 58
#define FAN_PIN 9
#if HAS_FILAMENT_SENSOR
#define FIL_RUNOUT_PIN 4
//#define FIL_RUNOUT2_PIN -1
#else
// Though defined as a fan pin, it is utilized as a dedicated laser pin by Formbot.
#define FAN1_PIN 4
#endif
//
// Misc. Functions
//
#define SDSS 53
#ifndef LED_PIN
#define LED_PIN 13 // The Formbot v 1 board has almost no unassigned pins on it. The Board's LED
#endif // is a good place to get a signal to control the Max7219 LED Matrix.
// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector
#define FILWIDTH_PIN 5 // Analog Input
#ifndef PS_ON_PIN
#define PS_ON_PIN 12
#endif
#define CASE_LIGHT_PIN 8
//
// LCD / Controller
//
// Formbot only supports REPRAP_DISCOUNT_SMART_CONTROLLER
//
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
#ifndef BEEPER_PIN
#define BEEPER_PIN 37
#endif
#define BTN_EN1 31
#define BTN_EN2 33
#define BTN_ENC 35
#define SD_DETECT_PIN 49
// Allow MAX7219 to steal the KILL pin
#if !defined(KILL_PIN) && MAX7219_CLK_PIN != 41 && MAX7219_DIN_PIN != 41 && MAX7219_LOAD_PIN != 41
#define KILL_PIN 41
#endif
#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
#define LCD_PINS_D7 29
#endif
| 6,040
|
C++
|
.h
| 171
| 33.391813
| 128
| 0.522074
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,895
|
pins_LONGER_LGT_KIT_V1.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/pins/ramps/pins_LONGER_LGT_KIT_V1.h
|
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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
/**
* LONGER LKx Pro board (mega2560) pin assignments
*/
#if HOTENDS > 1 || E_STEPPERS > 1
#error " LONGER LKx Pro board (mega2560) only supports 1 hotend / E-stepper. Comment out this line to continue."
#endif
#define BOARD_INFO_NAME "LONGER LGT KIT V1.0"
//
// Servos
//
#if defined(LK1_PRO)
#define SERVO0_PIN 11
#elif defined(LK4_PRO) || defined(LK5_PRO)
#define SERVO0_PIN 7
#endif
//
// Limit Switches
//
#if defined(LK1_PRO)
#define Z_STOP_PIN 11
#elif defined(LK4_PRO) || defined(LK5_PRO)
#define Z_STOP_PIN 35
#endif
#define SD_DETECT_PIN 49
#define FIL_RUNOUT_PIN 2
#include "pins_RAMPS.h"
| 1,439
|
C++
|
.h
| 45
| 30.222222
| 114
| 0.724188
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,896
|
HAL.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/HAL/AVR/HAL.h
|
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
*
* 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 "../shared/Marduino.h"
#include "../shared/HAL_SPI.h"
#include "fastio.h"
#include "watchdog.h"
#include "math.h"
#ifdef USBCON
#include <HardwareSerial.h>
#else
#define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion
#include "MarlinSerial.h"
#endif
#include <stdint.h>
#include <util/delay.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#ifndef pgm_read_ptr
// Compatibility for avr-libc 1.8.0-4.1 included with Ubuntu for
// Windows Subsystem for Linux on Windows 10 as of 10/18/2019
#define pgm_read_ptr_far(address_long) (void*)__ELPM_word((uint32_t)(address_long))
#define pgm_read_ptr_near(address_short) (void*)__LPM_word((uint16_t)(address_short))
#define pgm_read_ptr(address_short) pgm_read_ptr_near(address_short)
#endif
// ------------------------
// Defines
// ------------------------
//#define analogInputToDigitalPin(IO) IO
#ifndef CRITICAL_SECTION_START
#define CRITICAL_SECTION_START() unsigned char _sreg = SREG; cli()
#define CRITICAL_SECTION_END() SREG = _sreg
#endif
#define ISRS_ENABLED() TEST(SREG, SREG_I)
#define ENABLE_ISRS() sei()
#define DISABLE_ISRS() cli()
// On AVR this is in math.h?
//#define square(x) ((x)*(x))
// ------------------------
// Types
// ------------------------
typedef uint16_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFF
typedef int8_t pin_t;
#define SHARED_SERVOS HAS_SERVOS
#define HAL_SERVO_LIB Servo
// ------------------------
// Public Variables
// ------------------------
//extern uint8_t MCUSR;
// Serial ports
#ifdef USBCON
#if ENABLED(BLUETOOTH)
#define MYSERIAL0 bluetoothSerial
#else
#define MYSERIAL0 Serial
#endif
#define NUM_SERIAL 1
#else
#if !WITHIN(SERIAL_PORT, -1, 3)
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#define MYSERIAL0 customizedSerial1
#ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3)
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#endif
#define MYSERIAL1 customizedSerial2
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#endif
#ifdef LGT_LCD_DW
#ifdef NUM_SERIAL
#undef NUM_SERIAL
#endif
#define NUM_SERIAL 1
#endif
#ifdef DGUS_SERIAL_PORT
#if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#endif
#define DGUS_SERIAL internalDgusSerial
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
#endif
// ------------------------
// Public functions
// ------------------------
void HAL_init();
//void cli();
//void _delay_ms(const int delay);
inline void HAL_clear_reset_source() { MCUSR = 0; }
inline uint8_t HAL_get_reset_source() { return MCUSR; }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
extern "C" {
int freeMemory();
}
#pragma GCC diagnostic pop
// timers
#define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz
#define STEP_TIMER_NUM 1
#define TEMP_TIMER_NUM 0
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0)
#define STEPPER_TIMER_RATE HAL_TIMER_RATE
#define STEPPER_TIMER_PRESCALE 8
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() SBI(TIMSK1, OCIE1A)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A)
#define STEPPER_ISR_ENABLED() TEST(TIMSK1, OCIE1A)
#define ENABLE_TEMPERATURE_INTERRUPT() SBI(TIMSK0, OCIE0B)
#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
#define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0B)
FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
switch (timer_num) {
case STEP_TIMER_NUM:
// waveform generation = 0100 = CTC
SET_WGM(1, CTC_OCRnA);
// output mode = 00 (disconnected)
SET_COMA(1, NORMAL);
// Set the timer pre-scaler
// Generally we use a divider of 8, resulting in a 2MHz timer
// frequency on a 16MHz MCU. If you are going to change this, be
// sure to regenerate speed_lookuptable.h with
// create_speed_lookuptable.py
SET_CS(1, PRESCALER_8); // CS 2 = 1/8 prescaler
// Init Stepper ISR to 122 Hz for quick starting
// (F_CPU) / (STEPPER_TIMER_PRESCALE) / frequency
OCR1A = 0x4000;
TCNT1 = 0;
break;
case TEMP_TIMER_NUM:
// Use timer0 for temperature measurement
// Interleave temperature interrupt with millies interrupt
OCR0B = 128;
break;
}
}
#define TIMER_OCR_1 OCR1A
#define TIMER_COUNTER_1 TCNT1
#define TIMER_OCR_0 OCR0A
#define TIMER_COUNTER_0 TCNT0
#define _CAT(a,V...) a##V
#define HAL_timer_set_compare(timer, compare) (_CAT(TIMER_OCR_, timer) = compare)
#define HAL_timer_get_compare(timer) _CAT(TIMER_OCR_, timer)
#define HAL_timer_get_count(timer) _CAT(TIMER_COUNTER_, timer)
/**
* On AVR there is no hardware prioritization and preemption of
* interrupts, so this emulates it. The UART has first priority
* (otherwise, characters will be lost due to UART overflow).
* Then: Stepper, Endstops, Temperature, and -finally- all others.
*/
#define HAL_timer_isr_prologue(TIMER_NUM)
#define HAL_timer_isr_epilogue(TIMER_NUM)
/* 18 cycles maximum latency */
#define HAL_STEP_TIMER_ISR() \
extern "C" void TIMER1_COMPA_vect() __attribute__ ((signal, naked, used, externally_visible)); \
extern "C" void TIMER1_COMPA_vect_bottom() asm ("TIMER1_COMPA_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
void TIMER1_COMPA_vect() { \
__asm__ __volatile__ ( \
A("push r16") /* 2 Save R16 */ \
A("in r16, __SREG__") /* 1 Get SREG */ \
A("push r16") /* 2 Save SREG into stack */ \
A("lds r16, %[timsk0]") /* 2 Load into R0 the Temperature timer Interrupt mask register */ \
A("push r16") /* 2 Save TIMSK0 into the stack */ \
A("andi r16,~%[msk0]") /* 1 Disable the temperature ISR */ \
A("sts %[timsk0], r16") /* 2 And set the new value */ \
A("lds r16, %[timsk1]") /* 2 Load into R0 the stepper timer Interrupt mask register [TIMSK1] */ \
A("andi r16,~%[msk1]") /* 1 Disable the stepper ISR */ \
A("sts %[timsk1], r16") /* 2 And set the new value */ \
A("push r16") /* 2 Save TIMSK1 into stack */ \
A("in r16, 0x3B") /* 1 Get RAMPZ register */ \
A("push r16") /* 2 Save RAMPZ into stack */ \
A("in r16, 0x3C") /* 1 Get EIND register */ \
A("push r0") /* C runtime can modify all the following registers without restoring them */ \
A("push r1") \
A("push r18") \
A("push r19") \
A("push r20") \
A("push r21") \
A("push r22") \
A("push r23") \
A("push r24") \
A("push r25") \
A("push r26") \
A("push r27") \
A("push r30") \
A("push r31") \
A("clr r1") /* C runtime expects this register to be 0 */ \
A("call TIMER1_COMPA_vect_bottom") /* Call the bottom handler - No inlining allowed, otherwise registers used are not saved */ \
A("pop r31") \
A("pop r30") \
A("pop r27") \
A("pop r26") \
A("pop r25") \
A("pop r24") \
A("pop r23") \
A("pop r22") \
A("pop r21") \
A("pop r20") \
A("pop r19") \
A("pop r18") \
A("pop r1") \
A("pop r0") \
A("out 0x3C, r16") /* 1 Restore EIND register */ \
A("pop r16") /* 2 Get the original RAMPZ register value */ \
A("out 0x3B, r16") /* 1 Restore RAMPZ register to its original value */ \
A("pop r16") /* 2 Get the original TIMSK1 value but with stepper ISR disabled */ \
A("ori r16,%[msk1]") /* 1 Reenable the stepper ISR */ \
A("cli") /* 1 Disable global interrupts - Reenabling Stepper ISR can reenter amd temperature can reenter, and we want that, if it happens, after this ISR has ended */ \
A("sts %[timsk1], r16") /* 2 And restore the old value - This reenables the stepper ISR */ \
A("pop r16") /* 2 Get the temperature timer Interrupt mask register [TIMSK0] */ \
A("sts %[timsk0], r16") /* 2 And restore the old value - This reenables the temperature ISR */ \
A("pop r16") /* 2 Get the old SREG value */ \
A("out __SREG__, r16") /* 1 And restore the SREG value */ \
A("pop r16") /* 2 Restore R16 value */ \
A("reti") /* 4 Return from interrupt */ \
: \
: [timsk0] "i" ((uint16_t)&TIMSK0), \
[timsk1] "i" ((uint16_t)&TIMSK1), \
[msk0] "M" ((uint8_t)(1<<OCIE0B)),\
[msk1] "M" ((uint8_t)(1<<OCIE1A)) \
: \
); \
} \
void TIMER1_COMPA_vect_bottom()
/* 14 cycles maximum latency */
#define HAL_TEMP_TIMER_ISR() \
extern "C" void TIMER0_COMPB_vect() __attribute__ ((signal, naked, used, externally_visible)); \
extern "C" void TIMER0_COMPB_vect_bottom() asm ("TIMER0_COMPB_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
void TIMER0_COMPB_vect() { \
__asm__ __volatile__ ( \
A("push r16") /* 2 Save R16 */ \
A("in r16, __SREG__") /* 1 Get SREG */ \
A("push r16") /* 2 Save SREG into stack */ \
A("lds r16, %[timsk0]") /* 2 Load into R0 the Temperature timer Interrupt mask register */ \
A("andi r16,~%[msk0]") /* 1 Disable the temperature ISR */ \
A("sts %[timsk0], r16") /* 2 And set the new value */ \
A("sei") /* 1 Enable global interrupts - It is safe, as the temperature ISR is disabled, so we cannot reenter it */ \
A("push r16") /* 2 Save TIMSK0 into stack */ \
A("in r16, 0x3B") /* 1 Get RAMPZ register */ \
A("push r16") /* 2 Save RAMPZ into stack */ \
A("in r16, 0x3C") /* 1 Get EIND register */ \
A("push r0") /* C runtime can modify all the following registers without restoring them */ \
A("push r1") \
A("push r18") \
A("push r19") \
A("push r20") \
A("push r21") \
A("push r22") \
A("push r23") \
A("push r24") \
A("push r25") \
A("push r26") \
A("push r27") \
A("push r30") \
A("push r31") \
A("clr r1") /* C runtime expects this register to be 0 */ \
A("call TIMER0_COMPB_vect_bottom") /* Call the bottom handler - No inlining allowed, otherwise registers used are not saved */ \
A("pop r31") \
A("pop r30") \
A("pop r27") \
A("pop r26") \
A("pop r25") \
A("pop r24") \
A("pop r23") \
A("pop r22") \
A("pop r21") \
A("pop r20") \
A("pop r19") \
A("pop r18") \
A("pop r1") \
A("pop r0") \
A("out 0x3C, r16") /* 1 Restore EIND register */ \
A("pop r16") /* 2 Get the original RAMPZ register value */ \
A("out 0x3B, r16") /* 1 Restore RAMPZ register to its original value */ \
A("pop r16") /* 2 Get the original TIMSK0 value but with temperature ISR disabled */ \
A("ori r16,%[msk0]") /* 1 Enable temperature ISR */ \
A("cli") /* 1 Disable global interrupts - We must do this, as we will reenable the temperature ISR, and we don't want to reenter this handler until the current one is done */ \
A("sts %[timsk0], r16") /* 2 And restore the old value */ \
A("pop r16") /* 2 Get the old SREG */ \
A("out __SREG__, r16") /* 1 And restore the SREG value */ \
A("pop r16") /* 2 Restore R16 */ \
A("reti") /* 4 Return from interrupt */ \
: \
: [timsk0] "i"((uint16_t)&TIMSK0), \
[msk0] "M" ((uint8_t)(1<<OCIE0B)) \
: \
); \
} \
void TIMER0_COMPB_vect_bottom()
// ADC
#ifdef DIDR2
#define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0)
#else
#define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind);
#endif
inline void HAL_adc_init() {
ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07;
DIDR0 = 0;
#ifdef DIDR2
DIDR2 = 0;
#endif
}
#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC)
#ifdef MUX5
#define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#else
#define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#endif
#define HAL_ADC_RESOLUTION 10
#define HAL_READ_ADC() ADC
#define HAL_ADC_READY() !TEST(ADCSRA, ADSC)
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
#define HAL_SENSITIVE_PINS 0, 1
#ifdef __AVR_AT90USB1286__
#define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0)
#endif
// AVR compatibility
#define strtof strtod
/**
* set_pwm_frequency
* Sets the frequency of the timer corresponding to the provided pin
* as close as possible to the provided desired frequency. Internally
* calculates the required waveform generation mode, prescaler and
* resolution values required and sets the timer registers accordingly.
* NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B)
* NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST FAN PWM Settings)
*/
void set_pwm_frequency(const pin_t pin, int f_desired);
/**
* set_pwm_duty
* Sets the PWM duty cycle of the provided pin to the provided value
* Optionally allows inverting the duty cycle [default = false]
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
*/
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
| 17,164
|
C++
|
.h
| 368
| 43.288043
| 207
| 0.565498
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,897
|
Conditionals_post.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/HAL/STM32/inc/Conditionals_post.h
|
/**
* 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
// If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation
#if ENABLED(EEPROM_SETTINGS) && NONE(USE_REAL_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION)
#define SDCARD_EEPROM_EMULATION
#endif
| 1,113
|
C++
|
.h
| 26
| 40.923077
| 100
| 0.764273
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,898
|
persistent_store_api.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/HAL/LPC1768/persistent_store_api.h
|
/**
* 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 "../shared/persistent_store_api.h"
#define FLASH_EEPROM_EMULATION
| 951
|
C++
|
.h
| 24
| 37.708333
| 79
| 0.758919
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,899
|
Conditionals_post.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h
|
/**
* 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
#if USE_EMULATED_EEPROM && NONE(SDCARD_EEPROM_EMULATION, SRAM_EEPROM_EMULATION)
#define FLASH_EEPROM_EMULATION
#endif
| 995
|
C++
|
.h
| 25
| 37.88
| 79
| 0.76161
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,900
|
sdio.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/HAL/STM32F1/sdio.h
|
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2017 Victor Perez
*
* 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 "../shared/Marduino.h"
#include <libmaple/sdio.h>
#include <libmaple/dma.h>
// ------------------------
// Defines
// ------------------------
#define SDMMC_CMD_GO_IDLE_STATE ((uint8_t)0) /* Resets the SD memory card. */
#define SDMMC_CMD_ALL_SEND_CID ((uint8_t)2) /* Asks any card connected to the host to send the CID numbers on the CMD line. */
#define SDMMC_CMD_SET_REL_ADDR ((uint8_t)3) /* Asks the card to publish a new relative address (RCA). */
#define SDMMC_CMD_SEL_DESEL_CARD ((uint8_t)7) /* Selects the card by its own relative address and gets deselected by any other address */
#define SDMMC_CMD_HS_SEND_EXT_CSD ((uint8_t)8) /* Sends SD Memory Card interface condition, which includes host supply voltage information and asks the card whether card supports voltage. */
#define SDMMC_CMD_SEND_CSD ((uint8_t)9) /* Addressed card sends its card specific data (CSD) on the CMD line. */
#define SDMMC_CMD_SEND_STATUS ((uint8_t)13) /*!< Addressed card sends its status register. */
#define SDMMC_CMD_READ_SINGLE_BLOCK ((uint8_t)17) /* Reads single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC. */
#define SDMMC_CMD_WRITE_SINGLE_BLOCK ((uint8_t)24) /* Writes single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC. */
#define SDMMC_CMD_APP_CMD ((uint8_t)55) /* Indicates to the card that the next command is an application specific command rather than a standard command. */
#define SDMMC_ACMD_APP_SD_SET_BUSWIDTH ((uint8_t)6) /* (ACMD6) Defines the data bus width to be used for data transfer. The allowed data bus widths are given in SCR register. */
#define SDMMC_ACMD_SD_APP_OP_COND ((uint8_t)41) /* (ACMD41) Sends host capacity support information (HCS) and asks the accessed card to send its operating condition register (OCR) content in the response on the CMD line. */
#define SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT ((uint8_t)42) /* (ACMD42) Connect/Disconnect the 50 KOhm pull-up resistor on CD/DAT3 (pin 1) of the card */
#define CMD0_GO_IDLE_STATE (uint16_t)(SDMMC_CMD_GO_IDLE_STATE | SDIO_CMD_WAIT_NO_RESP)
#define CMD2_ALL_SEND_CID (uint16_t)(SDMMC_CMD_ALL_SEND_CID | SDIO_CMD_WAIT_LONG_RESP)
#define CMD3_SET_REL_ADDR (uint16_t)(SDMMC_CMD_SET_REL_ADDR | SDIO_CMD_WAIT_SHORT_RESP)
#define CMD7_SEL_DESEL_CARD (uint16_t)(SDMMC_CMD_SEL_DESEL_CARD | SDIO_CMD_WAIT_SHORT_RESP)
#define CMD8_HS_SEND_EXT_CSD (uint16_t)(SDMMC_CMD_HS_SEND_EXT_CSD | SDIO_CMD_WAIT_SHORT_RESP)
#define CMD9_SEND_CSD (uint16_t)(SDMMC_CMD_SEND_CSD | SDIO_CMD_WAIT_LONG_RESP)
#define CMD13_SEND_STATUS (uint16_t)(SDMMC_CMD_SEND_STATUS | SDIO_CMD_WAIT_SHORT_RESP)
#define CMD17_READ_SINGLE_BLOCK (uint16_t)(SDMMC_CMD_READ_SINGLE_BLOCK | SDIO_CMD_WAIT_SHORT_RESP)
#define CMD24_WRITE_SINGLE_BLOCK (uint16_t)(SDMMC_CMD_WRITE_SINGLE_BLOCK | SDIO_CMD_WAIT_SHORT_RESP)
#define CMD55_APP_CMD (uint16_t)(SDMMC_CMD_APP_CMD | SDIO_CMD_WAIT_SHORT_RESP)
#define ACMD6_APP_SD_SET_BUSWIDTH (uint16_t)(SDMMC_ACMD_APP_SD_SET_BUSWIDTH | SDIO_CMD_WAIT_SHORT_RESP)
#define ACMD41_SD_APP_OP_COND (uint16_t)(SDMMC_ACMD_SD_APP_OP_COND | SDIO_CMD_WAIT_SHORT_RESP)
#define ACMD42_SD_APP_SET_CLR_CARD_DETECT (uint16_t)(SDMMC_ACMD_SD_APP_SET_CLR_CARD_DETECT | SDIO_CMD_WAIT_SHORT_RESP)
#define SDMMC_ALLZERO 0x00000000U
#define SDMMC_OCR_ERRORBITS 0xFDFFE008U
#define SDMMC_R6_GENERAL_UNKNOWN_ERROR 0x00002000U
#define SDMMC_R6_ILLEGAL_CMD 0x00004000U
#define SDMMC_R6_COM_CRC_FAILED 0x00008000U
#define SDMMC_VOLTAGE_WINDOW_SD 0x80100000U
#define SDMMC_HIGH_CAPACITY 0x40000000U
#define SDMMC_STD_CAPACITY 0x00000000U
#define SDMMC_CHECK_PATTERN 0x000001AAU
#define SDIO_TRANSFER_MODE_BLOCK 0x00000000U
#define SDIO_DPSM_ENABLE 0x00000001U
#define SDIO_TRANSFER_DIR_TO_CARD 0x00000000U
#define SDIO_DATABLOCK_SIZE_512B 0x00000090U
#define SDIO_TRANSFER_DIR_TO_SDIO 0x00000100U
#define SDIO_DMA_ENABLE 0x00001000U
#define CARD_V1_X 0x00000000U
#define CARD_V2_X 0x00000001U
#define CARD_SDSC 0x00000000U
#define CARD_SDHC_SDXC 0x00000001U
#define SDIO_RESP1 0
#define SDIO_RESP2 1
#define SDIO_RESP3 2
#define SDIO_RESP4 3
#define SDIO_GET_FLAG(__FLAG__) !!((SDIO->STA) & (__FLAG__))
#define SDIO_CLEAR_FLAG(__FLAG__) (SDIO->ICR = (__FLAG__))
#define SDMMC_MAX_VOLT_TRIAL 0x000000FFU /* shorten attempt time; original value: 0x00000FFFU */
#define SDIO_CARD_TRANSFER 0x00000004U /* Card is in transfer state */
#define SDIO_CARD_ERROR 0x000000FFU /* Card response Error */
#define SDIO_CMDTIMEOUT 200U /* Command send and response timeout */
#define SDIO_DATA_TIMEOUT 100U /* Read data transfer timeout */
#define SDIO_WRITE_TIMEOUT 200U /* Write data transfer timeout */
#define SDIO_CLOCK 18000000 /* 18 MHz */
// ------------------------
// Types
// ------------------------
typedef struct {
uint32_t CardType; // Card Type
uint32_t CardVersion; // Card version
uint32_t Class; // Class of the card class
uint32_t RelCardAdd; // Relative Card Address
uint32_t BlockNbr; // Card Capacity in blocks
uint32_t BlockSize; // One block size in bytes
uint32_t LogBlockNbr; // Card logical Capacity in blocks
uint32_t LogBlockSize; // Logical block size in bytes
} SDIO_CardInfoTypeDef;
// ------------------------
// Public functions
// ------------------------
inline uint32_t SDIO_GetCardState();
bool SDIO_CmdGoIdleState();
bool SDIO_CmdSendCID();
bool SDIO_CmdSetRelAdd(uint32_t *rca);
bool SDIO_CmdSelDesel(uint32_t address);
bool SDIO_CmdOperCond();
bool SDIO_CmdSendCSD(uint32_t argument);
bool SDIO_CmdSendStatus(uint32_t argument);
bool SDIO_CmdReadSingleBlock(uint32_t address);
bool SDIO_CmdWriteSingleBlock(uint32_t address);
bool SDIO_CmdAppCommand(uint32_t rsa);
bool SDIO_CmdAppSetBusWidth(uint32_t rsa, uint32_t argument);
bool SDIO_CmdAppOperCommand(uint32_t sdType);
bool SDIO_CmdAppSetClearCardDetect(uint32_t rsa);
void SDIO_SendCommand(uint16_t command, uint32_t argument);
uint8_t SDIO_GetCommandResponse();
uint32_t SDIO_GetResponse(uint32_t response);
bool SDIO_GetCmdError();
bool SDIO_GetCmdResp1(uint8_t command);
bool SDIO_GetCmdResp2();
bool SDIO_GetCmdResp3();
bool SDIO_GetCmdResp6(uint8_t command, uint32_t *rca);
bool SDIO_GetCmdResp7();
| 8,376
|
C++
|
.h
| 125
| 65.528
| 244
| 0.634375
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,901
|
Conditionals_post.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/HAL/STM32_F4_F7/inc/Conditionals_post.h
|
/**
* 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
#if ENABLED(EEPROM_SETTINGS) && defined(STM32F7)
#undef USE_REAL_EEPROM
#undef SRAM_EEPROM_EMULATION
#undef SDCARD_EEPROM_EMULATION
#define FLASH_EEPROM_EMULATION
#endif
| 1,053
|
C++
|
.h
| 28
| 35.571429
| 79
| 0.761719
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,902
|
Conditionals_post.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/HAL/DUE/inc/Conditionals_post.h
|
/**
* 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
#if USE_EMULATED_EEPROM
#undef SRAM_EEPROM_EMULATION
#undef SDCARD_EEPROM_EMULATION
#define FLASH_EEPROM_EMULATION
#endif
| 1,003
|
C++
|
.h
| 27
| 35.148148
| 79
| 0.763077
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,903
|
lgtstore.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgtstore.h
|
#pragma once
#include "../module/planner.h"
#if ENABLED(LGT_LCD_TFT)
#define SPIFLASH_SIZE 0x400000 // 4MB
#define SPIFLASH_DATA_SIZE 0x1000 // 4KB(4096Bytes)
#define SPIFLASH_ADDR_DATA_START (SPIFLASH_SIZE - SPIFLASH_DATA_SIZE)
#define SPIFLASH_ADDR_TOUCH SPIFLASH_ADDR_DATA_START
#define SPIFLASH_ADDR_RECOVERY (SPIFLASH_ADDR_TOUCH + 16)
#define SPIFLASH_ADDR_SETTINGS (SPIFLASH_ADDR_RECOVERY + 64)
#define TOUCH_VERSION "V01" // change value when default touch data is changed(e.g. touch screen batch is changed)
#define SETTINGS_VERSION "V01" // change value when lgt(custom) settings is changed
#ifndef LIST_ITEM_MAX
#define LIST_ITEM_MAX 5
#endif
#define SETTINGS_MAX_LEN 23 // ** it must sync with settings struct
#if (SETTINGS_MAX_LEN % 5) == 0
#define SETTINGS_MAX_PAGE (SETTINGS_MAX_LEN / 5)
#else
#define SETTINGS_MAX_PAGE (SETTINGS_MAX_LEN / 5 + 1)
#endif
struct Settings
{
float max_x_jerk;
float max_y_jerk;
float max_z_jerk;
float max_e_jerk;
float max_feedrate[XYZE];
float minimumfeedrate;
float mintravelfeedrate;
uint32_t max_acceleration_units_per_sq_second[XYZE];
float retract_acceleration;
float axis_steps_per_unit[XYZE];
float acceleration;
// start to store in spiflash
char version[4]; // Vxx\0
// uint16_t crc; // checksum for data below
bool listOrder; // need to store in spiflash
bool enabledRunout;
bool enabledPowerloss;
};
class LgtStore
{
private:
Settings m_settings; // store temp setttings data
uint8_t m_currentPage; // current page
uint8_t m_currentItem; // select item index
uint8_t m_currentSetting; // select index
bool m_isSelectSetting;
bool m_settingsModified;
private:
float distanceMultiplier(uint8_t i);
void *settingPointer(uint8_t i);
bool validate(const char *current, const char*stored);
void _reset();
public:
LgtStore();
inline void clear()
{
m_currentPage = 0; // current page
m_currentItem = 0; // select item index
m_currentSetting = 0; // select index
m_isSelectSetting = false;
}
void applySettings();
void syncSettings();
void save();
bool load();
void reset();
void settingString(uint8_t i, char* p);
inline void settingString(char *p) { settingString(settingIndex(), p); }
void changeSetting(uint8_t i, int8_t distance);
inline void changeSetting(int8_t d)
{
if (!isSettingSelected()) return;
changeSetting(settingIndex(), d);
}
inline uint8_t page() { return m_currentPage;}
inline uint8_t nextPage()
{
if (m_currentPage < SETTINGS_MAX_PAGE - 1) {
m_currentPage++;
return 1;
} else {
return 0;
}
}
inline uint8_t previousPage()
{
if (m_currentPage > 0) {
m_currentPage--;
return 1;
} else {
return 0;
}
}
inline uint8_t settingIndex() {return m_currentSetting;} // get current selected setting
inline uint8_t item() {return m_currentItem;}
inline bool isSettingSelected() {return m_isSelectSetting;}
inline uint8_t selectedPage()
{
if (isSettingSelected())
return m_currentSetting / LIST_ITEM_MAX;
else
return 0;
}
bool selectSetting(uint16_t item);
inline bool isModified() { return m_settingsModified; }
inline void setModified(bool b) { m_settingsModified = b; }
void saveTouch();
bool loadTouch();
void saveRecovery();
bool loadRecovery();
void clearSettings();
void clearTouch();
};
extern LgtStore lgtStore;
#endif
| 3,803
|
C++
|
.h
| 117
| 27.25641
| 122
| 0.650602
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,904
|
lgttftlanguage.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgttftlanguage.h
|
#pragma once
#define TEST_TAG "T009" // used for test release, formal release should be commented
#if !defined(TEST_TAG)
#define TEST_TAG ""
#endif
#define FW_VERSION "V3.0" TEST_TAG "-" SHORT_BUILD_VERSION
#define LGT_LANGUAGE "eng" // choose language for lcd. Optional: eng, chn
#if defined(LK1) || defined(U20)
#define MAC_SIZE "300mm x 300mm x 400mm"
#elif defined(LK2) || defined(LK4) || defined(U30)
#define MAC_SIZE "220mm x 220mm x 250mm"
#elif defined(LK1_PLUS) || defined(U20_PLUS)
#define MAC_SIZE "400mm x 400mm x 500mm"
#endif
#ifndef Chinese
//main page
#define TXT_MENU_HOME_MOVE "Move head"
#define TXT_MENU_HOME_FILE "Files"
#define TXT_MENU_HOME_EXTRUDE "Extrude"
#define TXT_MENU_HOME_PREHEAT "Preheating"
#define TXT_MENU_HOME_RECOVERY "Recovery"
#define TXT_MENU_HOME_MORE "More"
//File page
#define TXT_MENU_FILE_SD_ERROR "SD card error!"
#define TXT_MENU_FILE_EMPTY "This folder is empty."
//Extrude page
#define TXT_MENU_EXTRUDE_MANUAL "JOG"
#define TXT_MENU_EXTRUDE_AUTOMATIC "AUTO"
//More page
#define TXT_MENU_HOME_MORE_LEVELING "Leveling"
#define TXT_MENU_HOME_MORE_SETTINGS "Settings"
#define TXT_MENU_HOME_MORE_ABOUT "About"
#define TXT_MENU_HOME_MORE_RETURN "Return"
#define TXT_MENU_LEVELING_UNLOCK "Unlock X-Y"
//About page
#define TXT_MENU_ABOUT_MAX_SIZE_LABEL "Max Buildable Size(LxWxH):"
#define TXT_MENU_ABOUT_FW_VER_LABLE "Firmware Version:"
//settings
#define TXT_MENU_SETTS_JERK_X "Vx-jerk(mm/s):"
#define TXT_MENU_SETTS_JERK_Y "Vy-jerk(mm/s):"
#define TXT_MENU_SETTS_JERK_Z "Vz-jerk(mm/s):"
#define TXT_MENU_SETTS_JERK_E "Ve-jerk(mm/s):"
#define TXT_MENU_SETTS_VMAX_X "Vmax x(mm/s):"
#define TXT_MENU_SETTS_VMAX_Y "Vmax y(mm/s):"
#define TXT_MENU_SETTS_VMAX_Z "Vmax z(mm/s):"
#define TXT_MENU_SETTS_VMAX_E "Vmax e(mm/s):"
#define TXT_MENU_SETTS_VMIN "Vmin(mm/s):"
#define TXT_MENU_SETTS_VTRAVEL "Vtrav min(mm/s):"
#define TXT_MENU_SETTS_AMAX_X "Amax x(mm/s^2):"
#define TXT_MENU_SETTS_AMAX_Y "Amax y(mm/s^2):"
#define TXT_MENU_SETTS_AMAX_Z "Amax z(mm/s^2):"
#define TXT_MENU_SETTS_AMAX_E "Amax e(mm/s^2):"
#define TXT_MENU_SETTS_ARETRACT "A-retract(mm/s^2):"
//#define TXT_MENU_SETTS_ATRAVEL "A-travel:"
#define TXT_MENU_SETTS_STEP_X "X(steps/mm):"
#define TXT_MENU_SETTS_STEP_Y "Y(steps/mm):"
#define TXT_MENU_SETTS_STEP_Z "Z(steps/mm):"
#define TXT_MENU_SETTS_STEP_E "E(steps/mm):"
#define TXT_MENU_SETTS_ACCL "Accel(mm/s^2):"
#define TXT_MENU_SETTS_LIST_ORDER "File list order:"
#define TXT_MENU_SETTS_CHECK_FILA "Filament check:"
#define TXT_MENU_SETTS_RECOVERY "powerloss recovery:"
#define TXT_MENU_SETTS_VALUE_ON "ON"
#define TXT_MENU_SETTS_VALUE_OFF "OFF"
#define TXT_MENU_SETTS_VALUE_FORWARD "FORWARD"
#define TXT_MENU_SETTS_VALUE_INVERSE "INVERSE"
//Printing page
#define TXT_MENU_PRINT_STATUS_HEATING "Heating..."
#define TXT_MENU_PRINT_STATUS_PAUSING "Pause printing..."
#define TXT_MENU_PRINT_STATUS_RUNNING "Printing..."
#define TXT_MENU_PRINT_STATUS_RECOVERY "Recovering..."
#define TXT_MENU_PRINT_STATUS_FINISH "Printing finished!"
#define TXT_MENU_PRINT_STATUS_NO_FILAMENT "No enough materials!"
#define TXT_MENU_PRINT_CD_TIMER_NULL "-- H -- M"
#define TXT_MENU_PRINT_CD_TIMER "%d H %d M"
#define TXT_MENU_PRINT_TEMP_NULL "B: --/--"
#define TXT_DIALOG_CAPTION_START "Start"
#define TXT_DIALOG_CAPTION_EXIT "Exit"
#define TXT_DIALOG_CAPTION_ABORT "Stop"
#define TXT_DIALOG_CAPTION_ABORT_WAIT "Wait Stop"
#define TXT_DIALOG_CAPTION_RECOVERY "Recovery"
#define TXT_DIALOG_CAPTION_ERROR "Error"
#define TXT_DIALOG_CAPTION_RESTORE "Restore"
#define TXT_DIALOG_CAPTION_SAVE "Save"
#define TXT_DIALOG_CAPTION_NO_FIALMENT "No Filament"
#define TXT_DIALOG_CAPTION_OPEN_FOLER "Open Folder"
#define TXT_DIALOG_CAPTION_WAIT "Wait"
// touch calibration
#define TXT_TFT_CONTROLLER_ID "ControllerID: %04X" //"ControllerID:"
#define TXT_TFT_CONTROLLER "Controller: %s"
#define TXT_TOUCH_CALIBRATION "Touch calibration"
#define TXT_TOP_LEFT "Top Left"
#define TXT_BOTTOM_LEFT "Bottom Left"
#define TXT_TOP_RIGHT "Top Right"
#define TXT_BOTTOM_RIGHT "Bottom Right"
#define TXT_CALI_COMPLETED "Touch calibration completed"
#define TXT_X_CALIBRATION "X_CALIBRATION:"
#define TXT_Y_CALIBRATION "Y_CALIBRATION:"
#define TXT_X_OFFSET "X_OFFSET:"
#define TXT_Y_OFFSET "Y_OFFSET:"
#define TXT_PROMPT_INFO1 "Please reboot the printer manually"
// #define TXT_PROMPT_INFO2 "return to the main home page!"
//Printer killed
#define TXT_PRINTER_KILLED_INFO1 "Printer halted."
#define TXT_PRINTER_KILLED_INFO2 "Please restart your printer."
// killed error message
#define TXT_ERR_MINTEMP "E0 MINTEMP"
#define TXT_ERR_MIN_TEMP_BED "Bed MINTEMP"
#define TXT_ERR_MAXTEMP "E0 MAXTEMP"
#define TXT_ERR_MAX_TEMP_BED "Bed MAXTEMP"
#define TXT_ERR_HEATING_FAILED "E0 Heating Failed"
#define TXT_ERR_HEATING_FAILED_BED "Bed Heating Failed"
#define TXT_ERR_TEMP_RUNAWAY "E0 Thermal Runaway"
#define TXT_ERR_TEMP_RUNAWAY_BED "Bed Thermal Runaway"
#define TXT_ERR_HOMING_FAILED "Homing Failed"
#define TXT_ERR_PROBING_FAILED "Probing Failed"
//Dialog
#define DIALOG_PROMPT_PRINT_START1 "Are you sure to"//"Are you sure to start printing?"
#define DIALOG_PROMPT_PRINT_START2 "start printing?"
#define DIALOG_PROMPT_PRINT_START3
#define DIALOG_PROMPT_PRINT_EXIT1 "Job's done. Do"//"Job's done. Do you want to exit?"
#define DIALOG_PROMPT_PRINT_EXIT2 "you want to exit?"
#define DIALOG_PROMPT_PRINT_EXIT3
#define DIALOG_PROMPT_PRINT_ABORT1 "Job isn't done. Do"//"Job's not done. Do you want to stop it?"
#define DIALOG_PROMPT_PRINT_ABORT2 "you want to stop?"
#define DIALOG_PROMPT_PRINT_ABORT3
#define DIALOG_PROMPT_PRINT_RECOVERY1 "Do you want to"//"Are you sure to recovery printing?"
#define DIALOG_PROMPT_PRINT_RECOVERY2 "recovery print-"
#define DIALOG_PROMPT_PRINT_RECOVERY3 "ing?"
#define DIALOG_PROMPT_ERROR_READ1 "Failed to read file," //"Failed to read file, please try again."
#define DIALOG_PROMPT_ERROR_READ2 "please try again."
#define DIALOG_PROMPT_ERROR_READ3
#define DIALOG_PROMPT_SETTS_RESTORE1 "Are you sure to " // "Are you sure to reset factory settings?"
#define DIALOG_PROMPT_SETTS_RESTORE2 "reset factory se-"
#define DIALOG_PROMPT_SETTS_RESTORE3 "ttings?"
#define DIALOG_PROMPT_SETTS_SAVE_OK1 "Current settings" //"Current settings has been saved."
#define DIALOG_PROMPT_SETTS_SAVE_OK2 "has been saved."
#define DIALOG_PROMPT_SETTS_SAVE_OK3
#define DIALOG_PROMPT_SETTS_SAVE1 "Do you want to " //"Do you want to save current settings?"
#define DIALOG_PROMPT_SETTS_SAVE2 "save current se-"
#define DIALOG_PROMPT_SETTS_SAVE3 "ttings?"
#define DIALOG_PROMPT_NO_FILAMENT1 "Do you want to" //"Do you want to change filament?"
#define DIALOG_PROMPT_NO_FILAMENT2 "change filament?"
#define DIALOG_PROMPT_NO_FILAMENT3
#define DIALOG_ERROR_FILE_TYPE1 "Failed to open file." // "Failed to open file. Unsupported file type."
#define DIALOG_ERROR_FILE_TYPE2 " Unsupported file type."
#define DIALOG_ERROR_FILE_TYPE3
#define DIALOG_ERROR_TEMP_BED1 "Abnormal bed tem-"
#define DIALOG_ERROR_TEMP_BED2 "perature is dete-"
#define DIALOG_ERROR_TEMP_BED3 "cted."
#define DIALOG_ERROR_TEMP_HEAD1 "Abnormal head te-"
#define DIALOG_ERROR_TEMP_HEAD2 "mperature is det-"
#define DIALOG_ERROR_TEMP_HEAD3 "ected."
#define DIALOG_PROMPT_MAX_FOLDER1 "Sorry, multi-level"
#define DIALOG_PROMPT_MAX_FOLDER2 "folders are not supported."
#define DIALOG_PROMPT_MAX_FOLDER3
#define DIALOG_START_PRINT_NOFILA1 "No filament, do" //No filament,please change filament and start printing
#define DIALOG_START_PRINT_NOFILA2 "you want to change"
#define DIALOG_START_PRINT_NOFILA3 "it?"
#define DIALOG_PROMPT_WAIT "Please wait..."
#else
#endif // Chinese
| 8,969
|
C++
|
.h
| 162
| 52.333333
| 129
| 0.644824
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,905
|
lgttouch.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgttouch.h
|
#pragma once
#include "../feature/touch/xpt2046.h"
// init value in load touch
struct TouchCalibration
{
char version[4]; // Vxx/0
int16_t xCalibration;
int16_t yCalibration;
int16_t xOffset;
int16_t yOffset;
};
class LgtTouch
{
private:
TouchCalibration calib;
private:
uint8_t readTouchXY(uint16_t &x,uint16_t &y);
uint8_t readTouchXY2(uint16_t &x,uint16_t &y);
public:
inline bool isTouched() { return touch.isTouched(); }
inline void waitForRelease() { touch.waitForRelease();}
// inline void waitForTouch(uint16_t &x, uint16_t &y) { touch.waitForTouch(x, y); }
uint8_t readTouchPoint(uint16_t &x, uint16_t &y);
uint8_t calibrate(bool needKill=true);
TouchCalibration &calibrationData() { return calib; }
void resetCalibration();
};
extern LgtTouch lgtTouch;
| 831
|
C++
|
.h
| 28
| 26.321429
| 87
| 0.712673
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,906
|
w25qxx.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/w25qxx.h
|
#pragma once
#include "stdint.h"
#define FLASH_WRITE_VAR(addr, value) spiFlash.W25QXX_Write(reinterpret_cast<uint8_t *>(&value), uint32_t(addr), sizeof(value))
#define FLASH_READ_VAR(addr, value) spiFlash.W25QXX_Read(reinterpret_cast<uint8_t *>(&value), uint32_t(addr), sizeof(value))
class W25QXX
{
public:
void W25QXX_Init(void);
uint16_t W25QXX_ReadID();
void W25QXX_Write(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite); //write data to flash
void W25QXX_Read(uint8_t* pBuffer,uint32_t ReadAddr,uint16_t NumByteToRead); //read data in flash
void W25QXX_Erase_Sector(uint32_t Dst_Addr); //erase sector
void W25QXX_Write_NoCheck(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite); //write data to falsh is not check
void W25QXX_Write_Enable(void); //write enable
void W25QXX_Write_Disable(void); //write disable (protect)
void W25QXX_Wait_Busy(void); //wait for idle
uint8_t W25QXX_ReadSR(void); //read status register
void W25QXX_Write_SR(uint8_t sr); //write status register
void W25QXX_Write_Page(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite);
void W25QXX_Erase_Chip(void); //wipe the whole piece
void W25QXX_WAKEUP(void); //wake up
void W25QXX_PowerDown(void); //go into power loss protection
};
extern W25QXX spiFlash;
| 1,375
|
C++
|
.h
| 24
| 53.333333
| 127
| 0.719911
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,907
|
lgtsdcard.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgtsdcard.h
|
#pragma once
#include "../sd/cardreader.h"
#if ENABLED(LGT_LCD_TFT)
#ifndef LIST_ITEM_MAX
#define LIST_ITEM_MAX 5
#endif
#define GCOMMENT_SIZE 64
enum CardUpdate : uint8_t {
NOCHANGED,
MOUNTED,
ERROR,
REMOVED
};
class LgtSdCard {
public:
LgtSdCard();
uint16_t count();
void _clear();
void clear();
inline uint16_t fileCount() { return m_fileCount; }
inline uint16_t pageCount() { return m_pageCount; }
inline void setPage(uint16_t page)
{
if (page < m_pageCount)
m_currentPage = page;
}
inline int16_t page(void) { return m_currentPage; }
inline uint8_t nextPage()
{
if (m_currentPage < m_pageCount - 1) {
m_currentPage++;
return 1;
} else {
return 0;
}
}
inline uint8_t previousPage()
{
if (m_currentPage > 0) {
m_currentPage--;
return 1;
} else {
return 0;
}
}
uint8_t selectFile(uint16_t item); // page_index_num
inline uint16_t item() {return m_currentItem;}
inline bool isReverseList() {return m_isReverseList;}
inline void setListOrder(bool order) {m_isReverseList = order;}
bool isDir();
const char *shortFilename();
const char *longFilename();
const char *filename(uint16_t i);
const char *filename();
inline uint16_t fileIndex() {return m_currentFile;} // get current selected file
inline bool isFileSelected() {return m_isSelectFile;}
uint16_t selectedPage();
uint16_t selectedItem();
inline uint8_t dirDepth() { return m_dirDepth;}
void changeDir(const char *relpath);
int8_t upDir();
bool isMaxDirDepth();
bool isRootDir();
inline void pushSelectedFile()
{
if (dirDepth() < MAX_DIR_DEPTH) {
SERIAL_ECHOLNPAIR("save file", m_currentFile);
parentSelectFile[m_dirDepth++] = m_currentFile;
}
}
inline bool popSelectedFile()
{
if (dirDepth() > 0) {
m_currentFile = parentSelectFile[--m_dirDepth];
SERIAL_ECHOLNPAIR("current depth:", m_dirDepth);
return true;
}
return false;
}
/**
* @brief resume file variable after up directory
*/
inline void reselectFile()
{
if (popSelectedFile()) {
m_isSelectFile = true;
m_currentPage = selectedPage();
m_currentItem = selectedItem();
SERIAL_ECHOLNPAIR("pop file:", m_currentFile);
SERIAL_ECHOLNPAIR("pop page:", m_currentPage);
SERIAL_ECHOLNPAIR("pop item:", m_currentItem);
}
}
void downTime(char *);
void upTime(char *);
inline void writeComment(char c)
{
if (indexGc < GCOMMENT_SIZE)
gComment[indexGc++] = c;
}
inline void endComment()
{
gComment[indexGc] = '\0';
indexGc = 0;
}
void parseComment();
void setPrintTime(uint16_t t) { m_printTime = t; }
uint16_t &printTime() { return m_printTime; }
CardUpdate update();
bool isCardInserted() { return m_cardState; }
inline void setCardState(bool state) { m_cardState = state; }
private:
void parseCura();
void parseLegacyCura();
private:
uint16_t m_fileCount;
uint16_t m_pageCount;
uint16_t m_currentPage; // current page
uint16_t m_currentItem; // select item index
uint16_t m_currentFile; // select file index
bool m_isReverseList; // if is reverse list, init in LgtStore::load()
bool m_isSelectFile; // if file is selected
static char gComment[GCOMMENT_SIZE];
static uint8_t indexGc;
uint16_t m_printTime; // total print time. minute unit
bool m_cardState;
uint16_t parentSelectFile[MAX_DIR_DEPTH];
uint8_t m_dirDepth;
};
extern LgtSdCard lgtCard;
#endif // LGT_LCD_TFT
| 3,921
|
C++
|
.h
| 131
| 23.374046
| 84
| 0.615795
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,908
|
lgttftlcd.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgttftlcd.h
|
#pragma once
// #include "../inc/MarlinConfigPre.h"
#if ENABLED(LGT_LCD_TFT)
typedef enum{
eMENU_HOME = 0,
eMENU_HOME_MORE,
eMENU_MOVE,
eMENU_FILE,
eMENU_FILE1, //next_window_id=eMENU_FILE1 when click eBT_DIALOG_PRINT_NO
eMENU_PRINT,
eMENU_ADJUST,
eMENU_ADJUST_MORE,
eMENU_PREHEAT,
eMENU_LEVELING,
eMENU_EXTRUDE,
eMENU_SETTINGS,
eMENU_SETTINGS2,
eMENU_SETTINGS_RETURN,
eMENU_ABOUT,
eMENU_DIALOG_START, //print or not print
eMENU_DIALOG_END, //stop print or not stop print
eMENU_DIALOG_NO_FIL, // no filament page
eMENU_DIALOG_NO_FIL_PRINT,
eMENU_DIALOG_RECOVERY,
eMENU_DIALOG_REFACTORY,
eMENU_DIALOG_SAVE,
eMENU_DIALOG_SAVE_OK,
eMENU_DIALOG_ERRORTEMPBED,
eMENU_DIALOG_ERRORTEMPE,
eMENU_DIALOG_WAIT,
// eMENU_PCB_TEST,
// eMENU_SCREEN_CALIBRATION,
// eMENU_AGING_TEST,
// #ifdef LCD_COLOR_TEST
// eMENU_SCREEN_COLOR_TEST,
// #endif
eWINDOW_MAX ,
eWINDOW_NONE
}E_WINDOW_ID;
enum E_BUTTON_KEY {
/*******************Move page****************************/
eBT_BUTTON_NONE=0,
eBT_MOVE_X_MINUS,eBT_MOVE_X_PLUS,eBT_MOVE_X_HOME,
eBT_MOVE_Y_MINUS,eBT_MOVE_Y_PLUS,eBT_MOVE_Y_HOME,
eBT_MOVE_Z_MINUS,eBT_MOVE_Z_PLUS,eBT_MOVE_Z_HOME,
eBT_MOVE_ALL_HOME,
/*******************Leveling page****************************/
eBT_MOVE_L0,eBT_MOVE_L1,eBT_MOVE_L2,eBT_MOVE_L3,eBT_MOVE_L4, eBT_MOVE_RETURN,
/*******************preheating page****************************/
eBT_PR_PLA,eBT_PR_ABS,eBT_PR_PETG,eBT_PR_COOL,
eBT_PR_E_PLUS,eBT_PR_E_MINUS,eBT_PR_B_PLUS,EBT_PR_B_MINUS,
/*******************Extrude page****************************/
eBT_TEMP_PLUS,eBT_TEMP_MINUS,//eBT_BED_PLUS,eBT_BED_MINUS,
eBT_JOG_EPLUS,eBT_JOG_EMINUS,eBT_AUTO_EPLUS,eBT_AUTO_EMINUS,eBT_STOP,eBT_BED_E,
/*******************File page****************************/
eBT_FILE_NEXT,eBT_FILE_LAST,eBT_FILE_OPEN,eBT_FILE_FOLDER,
eBT_FILE_LIST1,eBT_FILE_LIST2,eBT_FILE_LIST3,eBT_FILE_LIST4,eBT_FILE_LIST5,
/*******************printing page****************************/
eBT_PRINT_PAUSE,eBT_PRINT_ADJUST,eBT_PRINT_END,
/*******************Adjust page****************************/
eBT_ADJUSTE_PLUS,eBT_ADJUSTE_MINUS,eBT_ADJUSTBED_PLUS,eBT_ADJUSTBED_MINUS,
eBT_ADJUSTFAN_PLUS,eBT_ADJUSTFAN_MINUS,eBT_ADJUSTSPEED_PLUS,eBT_ADJUSTSPEED_MINUS,
/****************************Dialog page*******************************/
eBT_DIALOG_PRINT_START,eBT_DIALOG_PRINT_NO,eBT_DIALOG_REFACTORY_YES,eBT_DIALOG_SAVE_YES, eBT_DIALOG_ABORT_YES,
eBT_DIALOG_NOFILANET_YES, eBT_DIALOG_NOFILANET_NO, eBT_DIALOG_NOFILANET_PRINT_YES, eBT_DIALOG_NOFILANET_PRINT_NO,
eBT_DIALOG_RECOVERY_OK, eBT_DIALOG_RECOVERY_NO,
/****************************Settings page*******************************/
eBT_SETTING_MODIFY,eBT_SETTING_REFACTORY,eBT_SETTING_SAVE,eBT_SETTING_LAST,eBT_SETTING_NEXT,eBT_SETTING_ADD,eBT_SETTING_SUB,
eBT_DISTANCE_CHANGE
};
typedef enum{
eDIALOG_PRINT_START = 0,
eDIALOG_PRINT_EXIT,
eDIALOG_PRINT_ABORT,
eDIALOG_PRINT_RECOVERY,
eDIALOG_ERROR_READ,
eDIALOG_SETTS_RESTORE,
eDIALOG_SETTS_SAVE_OK,
eDIALOG_SETTS_SAVE,
eDIALOG_NO_FILAMENT,
eDIALOG_ERROR_FILE_TYPE,
eDIALOG_ERROR_TEMP_BED,
eDIALOG_ERROR_TEMP_HEAD,
eDIALOG_FILE_MAX_FOLDER,
eDIALOG_START_JOB_NOFILA,
eDIALOG_WAIT,
eDIALOG_MAX
}EDIALOG;
enum E_PRINT_CMD{
E_PRINT_CMD_NONE=0,
E_PRINT_DISPAUSE, //disable pause
E_PRINT_PAUSE,
E_PRINT_RESUME,
};
class LgtLcdTft {
public:
LgtLcdTft();
void init();
void loop();
void setPrintState(int8_t state);
uint8_t printState();
bool isPrinting();
void setPrintCommand(E_PRINT_CMD cmd);
void pausePrint();
void changeToPageRecovery();
void changeToPageKilled(const char* error, const char *component);
void setRecoveryStatus(bool status);
void actAfterRecovery();
void changePageAtOnce(E_WINDOW_ID page);
private:
void LGT_MainScanWindow(void);
void LGT_Ui_Update(void);
void LGT_Printer_Data_Update(void);
void LGT_Ui_Buttoncmd(void);
void moveOnPause();
void changeToPageRunout();
void resumePrint();
void startAutoFeed(int8_t dir);
bool setTemperatureInWindow(bool is_bed, bool sign);
// void LGT_Tempabnormal_Warning(const char* info); //is_printing=false
void refreshScreen();
// /***************************launch page*******************************************/
void displayStartUpLogo(void);
// /***************************home page*******************************************/
void displayWindowHome(void);
void scanWindowHome(uint16_t rv_x, uint16_t rv_y);
// /***************************Move page*******************************************/
void displayWindowMove(void);
void scanWindowMove( uint16_t rv_x, uint16_t rv_y );
void changeMoveDistance(uint16_t pos_x, uint16_t pos_y);
void initialMoveDistance(uint16_t pos_x, uint16_t pos_y);
void displayMoveCoordinate(void);
// /***************************File page*******************************************/
void displayWindowFiles(void);
void displayFilePageNumber(void);
void displayFileList();
void updateFilelist();
bool updateCard();
void chooseFile(uint16_t item);
void highlightChosenFile();
void displayPromptSDCardError(void);
void displayPromptEmptyFolder(void);
void scanWindowFile( uint16_t rv_x, uint16_t rv_y );
// /***************************Extrude page*******************************************/
void displayWindowExtrude(void);
void scanWindowExtrude( uint16_t rv_x, uint16_t rv_y );
void dispalyExtrudeTemp(void);
void dispalyExtrudeTemp(uint16_t Color);
void displayRunningAutoFeed(void);
// /***************************preheating page*******************************************/
void displayWindowPreheat(void);
void scanWindowPreheating( uint16_t rv_x, uint16_t rv_y );
void updatePreheatingTemp(void);
// /***************************home More page*******************************************/
void displayWindowHomeMore(void);
void scanWindowMoreHome(uint16_t rv_x, uint16_t rv_y);
// /***************************leveling page*******************************************/
void displayWindowLeveling(void);
void scanWindowLeveling( uint16_t rv_x, uint16_t rv_y );
// /***************************about page*******************************************/
void displayWindowAbout(void);
void scanWindowAbout(uint16_t rv_x, uint16_t rv_y);
// /***************************settings page*******************************************/
void displayWindowSettings(void);
void displayArugumentPageNumber(void);
void displayArgumentList(void);
void scanWindowSettings(uint16_t rv_x, uint16_t rv_y);
void chooseSetting(uint16_t item);
void highlightSetting();
// /***************************settings modify page*******************************************/
void displayWindowSettings2(void);
void displayModifyArgument(void);
void scanWindowSettings2(uint16_t rv_x, uint16_t rv_y);
// /***************************Printing page*******************************************/
void displayWindowPrint(void);
void displayPrintInformation(void);
void displayRunningFan(uint16_t pos_x, uint16_t pos_y);
void displayFanSpeed(void);
void displayPrintTemperature(void);
void displayPrintProgress(void);
void displayHeightValue(void);
void dispalyCurrentStatus(void);
void displayCountUpTime(void);
void displayCountDownTime(void);
void displayHeating(void);
void displayPrinting(void);
void displayPause(void);
// void displayNofilament(void);
void scanWindowPrint( uint16_t rv_x, uint16_t rv_y );
// /***************************Adjust page*******************************************/
void displayWindowAdjust(void);
void dispalyAdjustTemp(void);
void dispalyAdjustFanSpeed(void);
void dispalyAdjustMoveSpeed(void);
void scanWindowAdjust(uint16_t rv_x,uint16_t rv_y);
void displayWindowAdjustMore(void);
void dispalyAdjustFlow(void);
void scanWindowAdjustMore(uint16_t rv_x,uint16_t rv_y);
// /***************************dialog page*******************************************/
void displayWaitDialog();
void dispalyDialogYesNo(uint8_t dialog_index);
void dispalyDialogYes(uint8_t dialog_index);
void displayDialogText(uint8_t dialog_index);
void scanDialogStart(uint16_t rv_x, uint16_t rv_y );
void scanDialogEnd( uint16_t rv_x, uint16_t rv_y );
void scanDialogNoFilament(uint16_t rv_x, uint16_t rv_y );
void scanDialogNoFilamentInPrint(uint16_t rv_x, uint16_t rv_y );
void scanDialogRecovery( uint16_t rv_x, uint16_t rv_y);
void scanDialogRefactory(uint16_t rv_x, uint16_t rv_y);
void scanDialogSave(uint16_t rv_x, uint16_t rv_y);
void scanDialogSaveOk(uint16_t rv_x, uint16_t rv_y);
// void scanDialogYes(uint16_t rv_x, uint16_t rv_y);
// /***************************other page*******************************************/
void displayWindowKilled(const char* error, const char *component);
private:
// bool extrude2file = false;
};
extern LgtLcdTft lgtlcdtft;
// extern bool is_printing;
// extern char cur_pstatus;
#endif
| 9,236
|
C++
|
.h
| 221
| 37.950226
| 125
| 0.613738
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,909
|
lgttftdef.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lgttftdef.h
|
#pragma once
enum eAxis : uint8_t { X=0, Y, Z };
enum eExtruder : uint8_t { E0=0, E1, E2, E3, E4, E5, E6, E7 };
enum eHeater : uint8_t { H0=0, H1, H2, H3, H4, H5, BED, CHAMBER };
enum eFan : uint8_t { FAN0=0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 };
// filament UI definition
#define CHANGE_FILA_LENGTH 500
#define UNLOAD_FILA_FEEDRATE 600 // mm/s
#define FILAMENT_RUNOUT_MOVE_X 10
#define FILAMENT_RUNOUT_MOVE_Y 200
#define FILAMENT_RUNOUT_MOVE_F 50 // mm/s
// temperture UI definition
#define MAX_ADJUST_TEMP_EXTRUDE (HEATER_0_MAXTEMP-10)//(heater_maxtemp[0]-10)
#define MAX_ADJUST_TEMP_BED (BED_MAXTEMP-10)//(bed_maxtemp-10)//BED_MAXTEMP
#define MIN_ADJUST_TEMP_EXTRUDE (0)
#define MIN_ADJUST_TEMP_BED (0)
#define NORMAL_ADJUST_TEMP_EXTRUDE (200) // used for max distance
#define NORMAL_ADJUST_TEMP_BED (60) // used for max distance
#define PREHEAT_PLA_TEMP_EXTRUDE (PREHEAT_1_TEMP_HOTEND)
#define PREHEAT_PLA_TEMP_BED (PREHEAT_1_TEMP_BED)
#define PREHEAT_ABS_TEMP_EXTRUDE (PREHEAT_2_TEMP_HOTEND)
#define PREHEAT_ABS_TEMP_BED (PREHEAT_2_TEMP_BED)
#define PREHEAT_PETG_TEMP_EXTRUDE (215)
#define PREHEAT_PETG_TEMP_BED (70)
#define PREHEAT_TEMP_EXTRUDE PREHEAT_PLA_TEMP_EXTRUDE
// other UI definition
#define POS_MOVE_COL_TXT (40)
#define POS_MOVE_TXT_INTERVAL (90)
#define POS_MOVE_COL_0 (5)
#define POS_MOVE_COL_1 (65)
#define POS_MOVE_COL_2 (125)
#define POS_MOVE_COL_3 (193)
#define POS_MOVE_COL_4 (260)
#define POS_MOVE_ROW_0 (32)
#define POS_MOVE_ROW_1 (55)
#define POS_MOVE_ROW_2 (110)
#define POS_MOVE_ROW_3 (180)
#define POS_MOVE_COL_DISTANCE POS_MOVE_COL_4
#define POS_MOVE_ROW_DISTANCE POS_MOVE_ROW_1
#if defined(MANUAL_FEEDRATE)
#undef MANUAL_FEEDRATE
#endif
#define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 60 } // (mm/min)Feedrates for manual moves along X, Y, Z, E from panel
// image UI definiion
/* image size definition */
#define IMG_SIZE_LOGO0 20008 /* 200*50 logo alfawise */
#define IMG_SIZE_LOGO1 48008 /* 200*120 logo iformer */
#define IMG_SIZE_LOGO2 18408 /* 230*40 logo longer */
#define IMG_SIZE_CAPTION 2888 /* 90*16 caption */
//#define pic_size_button_home 11208 /* 70*80 home button */
#define IMG_SIZE_WARNING_TEMP 2922 /* 31*47 temper warning */
#define IMG_SIZE_BUTTON_NORMAL 6058 /* 55*55 normal button */
#define IMG_SIZE_BUTTON_ARROW 7158 /* 65*55 arrow button */
#define IMG_SIZE_BUTTON_DISTANCE 4408 /* 55*40 distance button */
#define IMG_SIZE_ICON_MINI 1808 /* 30*30 mini icon */
//#define pic_size_button_leveling 13608 /* 85*80 leveling button */
#define IMG_SIZE_BUTTON_FEED 7378 /* 67*55 feed button */
#define IMG_SIZE_DIALOG_BODY 60008 /* 200*150 dialog body */
#define IMG_SIZE_BUTTON_BED 4108 /* 50*41 bed_on/off button */
/* image address definition */
/* launch logo */
#define IMG_ADDR_STARTUP_LOGO_0 (0u)
/* menu home */
#define IMG_ADDR_CAPTION_HOME (IMG_ADDR_STARTUP_LOGO_0 + IMG_SIZE_LOGO0)
#define IMG_ADDR_BUTTON_MOVE (IMG_ADDR_CAPTION_HOME + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_MOVE_PRESSED (IMG_ADDR_BUTTON_MOVE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_FILE (IMG_ADDR_BUTTON_MOVE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_FILE_PRESSED (IMG_ADDR_BUTTON_FILE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_EXTRUDE (IMG_ADDR_BUTTON_FILE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_EXTRUDE_PRESSED (IMG_ADDR_BUTTON_EXTRUDE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_PREHEAT (IMG_ADDR_BUTTON_EXTRUDE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_PREHEAT_PRESSED (IMG_ADDR_BUTTON_PREHEAT + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING (IMG_ADDR_BUTTON_PREHEAT_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING_PRESSED (IMG_ADDR_BUTTON_LEVELING + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RECOVERY (IMG_ADDR_BUTTON_LEVELING_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RECOVERY_PRESSED (IMG_ADDR_BUTTON_RECOVERY + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RECOVERY_DISABLE (IMG_ADDR_BUTTON_RECOVERY_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_MORE (IMG_ADDR_BUTTON_RECOVERY_DISABLE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_MORE_PRESSED (IMG_ADDR_BUTTON_MORE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_SETTINGS (IMG_ADDR_BUTTON_MORE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_SETTINGS_PRESSED (IMG_ADDR_BUTTON_SETTINGS + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_ABOUT (IMG_ADDR_BUTTON_SETTINGS_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_ABOUT_PRESSED (IMG_ADDR_BUTTON_ABOUT + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LANGUAGE (IMG_ADDR_BUTTON_ABOUT_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LANGUAGE_PRESSED (IMG_ADDR_BUTTON_LANGUAGE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RETURN (IMG_ADDR_BUTTON_LANGUAGE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RETURN_PRESSED (IMG_ADDR_BUTTON_RETURN + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_WARNING_COLD_BED (IMG_ADDR_BUTTON_RETURN_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_WARNING_COLD_HEAD (IMG_ADDR_WARNING_COLD_BED + IMG_SIZE_WARNING_TEMP)
#define IMG_ADDR_WARNING_HOT_BED (IMG_ADDR_WARNING_COLD_HEAD + IMG_SIZE_WARNING_TEMP)
#define IMG_ADDR_WARNING_HOT_HEAD (IMG_ADDR_WARNING_HOT_BED + IMG_SIZE_WARNING_TEMP)
/* menu move */
#define IMG_ADDR_CAPTION_MOVE (IMG_ADDR_WARNING_HOT_HEAD + IMG_SIZE_WARNING_TEMP)
#define IMG_ADDR_BUTTON_HOME_ALL (IMG_ADDR_CAPTION_MOVE + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_HOME_ALL_PRESSED (IMG_ADDR_BUTTON_HOME_ALL + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_HOME_X (IMG_ADDR_BUTTON_HOME_ALL_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_HOME_X_PRESSED (IMG_ADDR_BUTTON_HOME_X + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_HOME_Y (IMG_ADDR_BUTTON_HOME_X_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_HOME_Y_PRESSED (IMG_ADDR_BUTTON_HOME_Y + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_HOME_Z (IMG_ADDR_BUTTON_HOME_Y_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_HOME_Z_PRESSED (IMG_ADDR_BUTTON_HOME_Z + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_MINUS_X (IMG_ADDR_BUTTON_HOME_Z_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_MINUS_X_PRESSED (IMG_ADDR_BUTTON_MINUS_X + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_MINUS_Y (IMG_ADDR_BUTTON_MINUS_X_PRESSED + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_MINUS_Y_PRESSED (IMG_ADDR_BUTTON_MINUS_Y + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_MINUS_Z (IMG_ADDR_BUTTON_MINUS_Y_PRESSED + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_MINUS_Z_PRESSED (IMG_ADDR_BUTTON_MINUS_Z + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_PLUS_X (IMG_ADDR_BUTTON_MINUS_Z_PRESSED + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_PLUS_X_PRESSED (IMG_ADDR_BUTTON_PLUS_X + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_PLUS_Y (IMG_ADDR_BUTTON_PLUS_X_PRESSED + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_PLUS_Y_PRESSED (IMG_ADDR_BUTTON_PLUS_Y + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_PLUS_Z (IMG_ADDR_BUTTON_PLUS_Y_PRESSED + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_PLUS_Z_PRESSED (IMG_ADDR_BUTTON_PLUS_Z + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_DISTANCE_1 (IMG_ADDR_BUTTON_PLUS_Z_PRESSED + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_DISTANCE_1_PRESSED (IMG_ADDR_BUTTON_DISTANCE_1 + IMG_SIZE_BUTTON_DISTANCE)
#define IMG_ADDR_BUTTON_DISTANCE_5 (IMG_ADDR_BUTTON_DISTANCE_1_PRESSED + IMG_SIZE_BUTTON_DISTANCE)
#define IMG_ADDR_BUTTON_DISTANCE_5_PRESSED (IMG_ADDR_BUTTON_DISTANCE_5 + IMG_SIZE_BUTTON_DISTANCE)
#define IMG_ADDR_BUTTON_DISTANCE_10 (IMG_ADDR_BUTTON_DISTANCE_5_PRESSED + IMG_SIZE_BUTTON_DISTANCE)
#define IMG_ADDR_BUTTON_DISTANCE_10_PRESSED (IMG_ADDR_BUTTON_DISTANCE_10 + IMG_SIZE_BUTTON_DISTANCE)
#define IMG_ADDR_BUTTON_DISTANCE_MAX (IMG_ADDR_BUTTON_DISTANCE_10_PRESSED + IMG_SIZE_BUTTON_DISTANCE)
#define IMG_ADDR_BUTTON_DISTANCE_MAX_PRESSED (IMG_ADDR_BUTTON_DISTANCE_MAX + IMG_SIZE_BUTTON_DISTANCE)
#define IMG_ADDR_BUTTON_UNLOCK (IMG_ADDR_BUTTON_DISTANCE_MAX_PRESSED + IMG_SIZE_BUTTON_DISTANCE)
#define IMG_ADDR_BUTTON_UNLOCK_PRESSED (IMG_ADDR_BUTTON_UNLOCK + IMG_SIZE_BUTTON_NORMAL)
/* menu file */
#define IMG_ADDR_CAPTION_FILE (IMG_ADDR_BUTTON_UNLOCK_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_PAGE_NEXT (IMG_ADDR_CAPTION_FILE + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_PAGE_NEXT_PRESSED (IMG_ADDR_BUTTON_PAGE_NEXT + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_PAGE_LAST (IMG_ADDR_BUTTON_PAGE_NEXT_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_PAGE_LAST_PRESSED (IMG_ADDR_BUTTON_PAGE_LAST + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_START (IMG_ADDR_BUTTON_PAGE_LAST_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_START_PRESSED (IMG_ADDR_BUTTON_START + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_OPEN (IMG_ADDR_BUTTON_START_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_OPEN_PRESSED (IMG_ADDR_BUTTON_OPEN + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RETURN_FOLDER (IMG_ADDR_BUTTON_OPEN_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RETURN_FOLDER_PRESSED (IMG_ADDR_BUTTON_RETURN_FOLDER + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_PROMPT_ERROR (IMG_ADDR_BUTTON_RETURN_FOLDER_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_INDICATOR_FILE (IMG_ADDR_PROMPT_ERROR + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_INDICATOR_FOLDER (IMG_ADDR_INDICATOR_FILE + IMG_SIZE_ICON_MINI)
/* menu print */
#define IMG_ADDR_INDICATOR_HEAD (IMG_ADDR_INDICATOR_FOLDER + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_INDICATOR_FAN_0 (IMG_ADDR_INDICATOR_HEAD + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_INDICATOR_FAN_1 (IMG_ADDR_INDICATOR_FAN_0 + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_INDICATOR_BED (IMG_ADDR_INDICATOR_FAN_1 + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_INDICATOR_HEIGHT (IMG_ADDR_INDICATOR_BED + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_INDICATOR_TIMER_CD (IMG_ADDR_INDICATOR_HEIGHT + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_INDICATOR_TIMER_CU (IMG_ADDR_INDICATOR_TIMER_CD + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_BUTTON_PAUSE (IMG_ADDR_INDICATOR_TIMER_CU + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_BUTTON_PAUSE_PRESSED (IMG_ADDR_BUTTON_PAUSE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_PAUSE_DISABLE (IMG_ADDR_BUTTON_PAUSE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RESUME (IMG_ADDR_BUTTON_PAUSE_DISABLE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RESUME_PRESSED (IMG_ADDR_BUTTON_RESUME + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RESUME_DISABLE (IMG_ADDR_BUTTON_RESUME_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_ADJUST (IMG_ADDR_BUTTON_RESUME_DISABLE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_ADJUST_PRESSED (IMG_ADDR_BUTTON_ADJUST + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_END (IMG_ADDR_BUTTON_ADJUST_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_END_PRESSED (IMG_ADDR_BUTTON_END + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_PROMPT_COMPLETE (IMG_ADDR_BUTTON_END_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_PROMPT_PAUSE (IMG_ADDR_PROMPT_COMPLETE + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_PROMPT_PRINTING (IMG_ADDR_PROMPT_PAUSE + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_PROMPT_RECOVERY (IMG_ADDR_PROMPT_PRINTING + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_PROMPT_WARNING (IMG_ADDR_PROMPT_RECOVERY + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_PROMPT_HEATING (IMG_ADDR_PROMPT_WARNING + IMG_SIZE_ICON_MINI)
/* menu adjust */
#define IMG_ADDR_CAPTION_ADJUST (IMG_ADDR_PROMPT_HEATING + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_BUTTON_ADD (IMG_ADDR_CAPTION_ADJUST + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_ADD_PRESSED (IMG_ADDR_BUTTON_ADD + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_SUB (IMG_ADDR_BUTTON_ADD_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_SUB_PRESSED (IMG_ADDR_BUTTON_SUB + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_INDICATOR_SPEED (IMG_ADDR_BUTTON_SUB_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_INDICATOR_FLOW (IMG_ADDR_INDICATOR_SPEED + IMG_SIZE_ICON_MINI)
/* menu preheating */
#define IMG_ADDR_CAPTION_PREHEAT (IMG_ADDR_INDICATOR_FLOW + IMG_SIZE_ICON_MINI)
#define IMG_ADDR_BUTTON_COOLING (IMG_ADDR_CAPTION_PREHEAT + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_COOLING_PRESSED (IMG_ADDR_BUTTON_COOLING + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_FILAMENT_0 (IMG_ADDR_BUTTON_COOLING_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_FILAMENT_0_PRESSED (IMG_ADDR_BUTTON_FILAMENT_0 + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_FILAMENT_1 (IMG_ADDR_BUTTON_FILAMENT_0_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_FILAMENT_1_PRESSED (IMG_ADDR_BUTTON_FILAMENT_1 + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_FILAMENT_2 (IMG_ADDR_BUTTON_FILAMENT_1_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_FILAMENT_2_PRESSED (IMG_ADDR_BUTTON_FILAMENT_2 + IMG_SIZE_BUTTON_NORMAL)
/* menu leveling */
#define IMG_ADDR_CAPTION_LEVELING (IMG_ADDR_BUTTON_FILAMENT_2_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING0 (IMG_ADDR_CAPTION_LEVELING + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_LEVELING0_PRESSED (IMG_ADDR_BUTTON_LEVELING0 + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING1 (IMG_ADDR_BUTTON_LEVELING0_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING1_PRESSED (IMG_ADDR_BUTTON_LEVELING1 + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING2 (IMG_ADDR_BUTTON_LEVELING1_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING2_PRESSED (IMG_ADDR_BUTTON_LEVELING2 + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING3 (IMG_ADDR_BUTTON_LEVELING2_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING3_PRESSED (IMG_ADDR_BUTTON_LEVELING3 + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING4 (IMG_ADDR_BUTTON_LEVELING3_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_LEVELING4_PRESSED (IMG_ADDR_BUTTON_LEVELING4 + IMG_SIZE_BUTTON_NORMAL)
/* menu extrude */
#define IMG_ADDR_CAPTION_EXTRUDE (IMG_ADDR_BUTTON_LEVELING4_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_MINUS_E (IMG_ADDR_CAPTION_EXTRUDE + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_MINUS_E_PRESSED (IMG_ADDR_BUTTON_MINUS_E + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_PLUS_E (IMG_ADDR_BUTTON_MINUS_E_PRESSED + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_PLUS_E_PRESSED (IMG_ADDR_BUTTON_PLUS_E + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_FEED_IN_0 (IMG_ADDR_BUTTON_PLUS_E_PRESSED + IMG_SIZE_BUTTON_ARROW)
#define IMG_ADDR_BUTTON_FEED_IN_0_PRESSED (IMG_ADDR_BUTTON_FEED_IN_0 + IMG_SIZE_BUTTON_FEED)
#define IMG_ADDR_BUTTON_FEED_IN_1 (IMG_ADDR_BUTTON_FEED_IN_0_PRESSED + IMG_SIZE_BUTTON_FEED)
#define IMG_ADDR_BUTTON_FEED_IN_1_PRESSED (IMG_ADDR_BUTTON_FEED_IN_1 + IMG_SIZE_BUTTON_FEED)
#define IMG_ADDR_BUTTON_FEED_OUT_0 (IMG_ADDR_BUTTON_FEED_IN_1_PRESSED + IMG_SIZE_BUTTON_FEED)
#define IMG_ADDR_BUTTON_FEED_OUT_0_PRESSED (IMG_ADDR_BUTTON_FEED_OUT_0 + IMG_SIZE_BUTTON_FEED)
#define IMG_ADDR_BUTTON_FEED_OUT_1 (IMG_ADDR_BUTTON_FEED_OUT_0_PRESSED + IMG_SIZE_BUTTON_FEED)
#define IMG_ADDR_BUTTON_FEED_OUT_1_PRESSED (IMG_ADDR_BUTTON_FEED_OUT_1 + IMG_SIZE_BUTTON_FEED)
#define IMG_ADDR_BUTTON_FEED_STOP (IMG_ADDR_BUTTON_FEED_OUT_1_PRESSED + IMG_SIZE_BUTTON_FEED)
#define IMG_ADDR_BUTTON_FEED_STOP_PRESSED (IMG_ADDR_BUTTON_FEED_STOP + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_BED_ON (IMG_ADDR_BUTTON_FEED_STOP_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_BED_ON_PRESSED (IMG_ADDR_BUTTON_BED_ON + IMG_SIZE_BUTTON_BED)
#define IMG_ADDR_BUTTON_BED_OFF (IMG_ADDR_BUTTON_BED_ON_PRESSED + IMG_SIZE_BUTTON_BED)
#define IMG_ADDR_BUTTON_BED_OFF_PRESSED (IMG_ADDR_BUTTON_BED_OFF + IMG_SIZE_BUTTON_BED)
/* menu settings */
#define IMG_ADDR_CAPTION_SETTINGS (IMG_ADDR_BUTTON_BED_OFF_PRESSED + IMG_SIZE_BUTTON_BED)
#define IMG_ADDR_BUTTON_MODIFY (IMG_ADDR_CAPTION_SETTINGS + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_MODIFY_PRESSED (IMG_ADDR_BUTTON_MODIFY + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RESTORE (IMG_ADDR_BUTTON_MODIFY_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_RESTORE_PRESSED (IMG_ADDR_BUTTON_RESTORE + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_SAVE (IMG_ADDR_BUTTON_RESTORE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_SAVE_PRESSED (IMG_ADDR_BUTTON_SAVE + IMG_SIZE_BUTTON_NORMAL)
/* menu about */
#define IMG_ADDR_CAPTION_ABOUT (IMG_ADDR_BUTTON_SAVE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_AIMING (IMG_ADDR_CAPTION_ABOUT + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_AIMING_PRESSED (IMG_ADDR_BUTTON_AIMING + IMG_SIZE_BUTTON_NORMAL)
/* menu language */
#define IMG_ADDR_CAPTION_LANGUAGE (IMG_ADDR_BUTTON_AIMING_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_ENGLISH (IMG_ADDR_CAPTION_LANGUAGE + IMG_SIZE_CAPTION)
#define IMG_ADDR_BUTTON_ENGLISH_PRESSED (IMG_ADDR_BUTTON_ENGLISH + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_CHINESE (IMG_ADDR_BUTTON_ENGLISH_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_CHINESE_PRESSED (IMG_ADDR_BUTTON_CHINESE + IMG_SIZE_BUTTON_NORMAL)
/* dialog */
#define IMG_ADDR_DIALOG_BODY (IMG_ADDR_BUTTON_CHINESE_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_YES (IMG_ADDR_DIALOG_BODY + IMG_SIZE_DIALOG_BODY)
#define IMG_ADDR_BUTTON_YES_PRESSED (IMG_ADDR_BUTTON_YES + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_NO (IMG_ADDR_BUTTON_YES_PRESSED + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_BUTTON_NO_PRESSED (IMG_ADDR_BUTTON_NO + IMG_SIZE_BUTTON_NORMAL)
#define IMG_ADDR_PROMPT_QUESTION (IMG_ADDR_BUTTON_NO_PRESSED + IMG_SIZE_BUTTON_NORMAL)
/* launch logo "iFormer" */
#define IMG_ADDR_STARTUP_LOGO_1 (IMG_ADDR_PROMPT_QUESTION + IMG_SIZE_ICON_MINI)
/* launch logo "LONGER" */
#define IMG_ADDR_STARTUP_LOGO_2 (IMG_ADDR_STARTUP_LOGO_1 + IMG_SIZE_LOGO1) //991586
//#define FONT16_ADDR_GBK (0x000F6950 ) //992000 = 0x000F2300
/* image address definition end */
//#define IMG_MAX_ADDR (IMG_ADDR_STARTUP_LOGO_2 + IMG_SIZE_LOGO2) //1009994
// define color of captions background
#define BG_COLOR_CAPTION_HOME 0x045D
#define BG_COLOR_CAPTION_MOVE 0xDC01
#define BG_COLOR_CAPTION_FILE 0x057A
#define BG_COLOR_CAPTION_PRINT 0x045D
#define BG_COLOR_CAPTION_ADJUST 0x0DB7
#define BG_COLOR_CAPTION_PREHEAT 0x018B
#define BG_COLOR_CAPTION_LEVELING 0xEAA5
#define BG_COLOR_CAPTION_EXTRUDE 0x2CAC
#define BG_COLOR_CAPTION_SETTINGS 0x0209
#define BG_COLOR_CAPTION_ABOUT 0xEA0A
#define BG_COLOR_CAPTION_DIALOG 0x0233
#define BG_COLOR_KILL_MENU 0x2104
#define PT_COLOR_DISABLE 0xBDD7
| 21,066
|
C++
|
.h
| 258
| 80.523256
| 116
| 0.677576
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,910
|
ili9341.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lcddrive/ili9341.h
|
#pragma once
#include <stdint.h>
/**
* @brief ILI9341 Registers
*/
#define ILI9341_SWRESET 0x01 /* Software Reset */
#define ILI9341_LCD_ID 0xD3
#define ILI9341_SLEEP_IN 0x10
#define ILI9341_SLEEP_OUT 0x11
#define ILI9341_PARTIAL_DISPLAY 0x12
#define ILI9341_DISPLAY_INVERSION 0x21
#define ILI9341_DISPLAY_OFF 0x28
#define ILI9341_DISPLAY_ON 0x29
#define ILI9341_WRITE_RAM 0x2C
#define ILI9341_READ_RAM 0x2E
#define ILI9341_CASET 0x2A
#define ILI9341_RASET 0x2B
#define ILI9341_VSCRDEF 0x33 /* Vertical Scroll Definition */
#define ILI9341_VSCSAD 0x37 /* Vertical Scroll Start Address of RAM */
#define ILI9341_TEARING_EFFECT 0x35
#define ILI9341_NORMAL_DISPLAY 0x36
#define ILI9341_IDLE_MODE_OFF 0x38
#define ILI9341_IDLE_MODE_ON 0x39
#define ILI9341_COLOR_MODE 0x3A
#define ILI9341_ID4 0xD3 // real ID register for 9341
#define ILI9341_BLKING_PORCH_CTRL 0xB5
#define ILI9341_VCOM_CTRL1 0xC5
#define ILI9341_VCOM_CTRL2 0xC7
#define ILI9341_FR_CTRL 0xB1
#define ILI9341_POWER_CTRL1 0xC0
#define ILI9341_POWER_CTRL2 0xC1
#define ILI9341_ID 0x9341
void ILI9341_Init(void);
void ILI9341_DisplayOn(void);
void ILI9341_WriteRam(void);
void ILI9341_SetCursor(uint16_t Xpos, uint16_t Ypos);
void ILI9341_SetWindow(uint16_t Xmin, uint16_t Ymin, uint16_t XMax = 319, uint16_t Ymax = 239);
| 1,534
|
C++
|
.h
| 37
| 40.054054
| 95
| 0.677658
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,912
|
st7789v.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lcddrive/st7789v.h
|
#pragma once
#include <stdint.h>
/**
* @brief ST7789V Registers
*/
#define ST7789V_LCD_ID 0x04
#define ST7789V_SLEEP_IN 0x10
#define ST7789V_SLEEP_OUT 0x11
#define ST7789V_PARTIAL_DISPLAY 0x12
#define ST7789V_DISPLAY_INVERSION 0x21
#define ST7789V_DISPLAY_ON 0x29
#define ST7789V_WRITE_RAM 0x2C
#define ST7789V_READ_RAM 0x2E
#define ST7789V_CASET 0x2A
#define ST7789V_RASET 0x2B
#define ST7789V_VSCRDEF 0x33 /* Vertical Scroll Definition */
#define ST7789V_VSCSAD 0x37 /* Vertical Scroll Start Address of RAM */
#define ST7789V_TEARING_EFFECT 0x35
#define ST7789V_NORMAL_DISPLAY 0x36
#define ST7789V_IDLE_MODE_OFF 0x38
#define ST7789V_IDLE_MODE_ON 0x39
#define ST7789V_COLOR_MODE 0x3A
#define ST7789V_PORCH_CTRL 0xB2
#define ST7789V_GATE_CTRL 0xB7
#define ST7789V_VCOM_SET 0xBB
#define ST7789V_DISPLAY_OFF 0xBD
#define ST7789V_LCM_CTRL 0xC0
#define ST7789V_VDV_VRH_EN 0xC2
#define ST7789V_VDV_SET 0xC4
#define ST7789V_VCOMH_OFFSET_SET 0xC5
#define ST7789V_FR_CTRL 0xC6
#define ST7789V_POWER_CTRL 0xD0
#define ST7789V_PV_GAMMA_CTRL 0xE0
#define ST7789V_NV_GAMMA_CTRL 0xE1
#define ST7789V_SWRESET 0x01 /* Software Reset */
#define ST7789V_ID 0x8552
void ST7789V_Init(void);
void ST7789V_DisplayOn(void);
void ST7789V_WriteRam(void);
void ST7789V_SetCursor(uint16_t Xpos, uint16_t Ypos);
void ST7789V_SetWindow(uint16_t Xmin, uint16_t Ymin, uint16_t XMax = 319, uint16_t Ymax = 239);
| 1,653
|
C++
|
.h
| 41
| 39.073171
| 95
| 0.67746
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,913
|
lcdapi.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lcddrive/lcdapi.h
|
#pragma once
#if ENABLED(LGT_LCD_TFT)
#include "stdint.h"
#define LCD_WIDTH 320u
#define LCD_HIGHT 240u
#define LCD_PIXELS_COUNT (LCD_WIDTH * LCD_HIGHT)
// color definition for lcd
#define BLACK 0x0000
#define NAVY 0x000F
#define DARKGREEN 0x03E0
#define DARKCYAN 0x03EF
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
#define LIGHTGREY 0xC618
#define DARKGREY 0x7BEF
#define BLUE 0x001F
#define GREEN 0x07E0
#define CYAN 0x07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define ORANGE 0xFD20
#define GREENYELLOW 0xAFE5
#define PINK 0xF81F
#define DARKBLUE 0X01CF
#define LIGHTBLUE 0X7D7C
#define GRAYBLUE 0X5458
#define GRAY 0X8430//0xF7DE
#define IMAGE_BUFF_SIZE 4096 // store image data from spiflash
// #define SLOW_SHOW_IMAGE // using slowly io write method
struct imageHeader {
uint8_t scan;
uint8_t gray;
uint16_t w;
uint16_t h;
uint8_t is565;
uint8_t rgb;
};
class LgtLcdApi {
public:
LgtLcdApi();
uint8_t init();
inline void clear(uint16_t color=WHITE) {
fill(0, 0, LCD_WIDTH-1, LCD_HIGHT-1, color);
}
void fill(uint16_t sx,uint16_t sy,uint16_t ex,uint16_t ey,uint16_t color);
void backLightOff();
void backLightOn();
inline void setColor(uint16_t c)
{
m_color = c;
}
inline void setBgColor(uint16_t c)
{
m_bgColor = c;
}
inline uint16_t lcdId()
{
return m_lcdID;
}
void print(uint16_t x, uint16_t y, const char *text);
void showImage(uint16_t x_st, uint16_t y_st, uint32_t addr);
void showRawImage(uint16_t xsta,uint16_t ysta,uint16_t width,uint16_t high, uint32_t addr);
void drawCross(uint16_t x, uint16_t y, uint16_t color);
inline void drawHVLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
{
#define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))
if (x1 > x2)
SWAP(x1, x2);
if (y1 > y2)
SWAP(y1, y2);
fill(x1, y1, x2, y2, m_color);
}
inline void drawRect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
{
fill(x1, y1, x2, y1, m_color);
fill(x2, y1, x2, y2, m_color);
fill(x1, y2, x2, y2, m_color);
fill(x1, y1, x1, y2, m_color);
}
public:
void prepareWriteRAM();
void setCursor(uint16_t Xpos, uint16_t Ypos);
void setWindow(uint16_t Xmin, uint16_t Ymin, uint16_t XMax=LCD_WIDTH-1, uint16_t Ymax=LCD_HIGHT-1);
private:
uint16_t m_lcdID;
public:
uint16_t m_color;
uint16_t m_bgColor;
};
extern LgtLcdApi lgtlcd;
#endif
| 2,723
|
C++
|
.h
| 94
| 24.829787
| 107
| 0.638729
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,914
|
lcdio.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/longer3d/lcddrive/lcdio.h
|
#pragma once
#include "../../inc/MarlinConfig.h"
#if ENABLED(LGT_LCD_TFT)
#define LCD_Delay(ms) _delay_ms(ms)
void LCD_IO_Init(uint8_t cs, uint8_t rs);
void LCD_IO_WriteData(uint16_t RegValue);
void LCD_IO_WriteReg(uint16_t Reg);
uint16_t LCD_IO_ReadData(uint16_t RegValue);
uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize);
#ifdef LCD_USE_DMA_FSMC
void LCD_IO_WriteMultiple(uint16_t data, uint32_t count);
void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);
void LCD_IO_WriteSequence_Async(uint16_t *data, uint16_t length);
void LCD_IO_WaitSequence_Async();
#endif
#endif
| 606
|
C++
|
.h
| 16
| 36.125
| 67
| 0.759386
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,915
|
lgtdwdef.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/lcd/lgtdwdef.h
|
#pragma once
#if ENABLED(LGT_LCD_DW)
#define RECOVER_E_ADD 4//8
#define LOAD_FILA_LEN 500
#define UNLOAD_FILA_LEN -500
#define STARTUP_COUNTER 3000
#define LED_RED 4
#define LED_GREEN 5
#define LED_BLUE 6
#define DATA_SIZE 37 //the size of ScreenData and Receive_Cmd
#define FILE_LIST_NUM 25
#define EEPROM_INDEX 4000
//Printer kill reason
#define E_TEMP_ERROR "Error 0: abnormal E temp" //Heating failed
#define B_TEMP_ERROR "Error 1: abnormal B temp" //Heating failed
#define M112_ERROR "Error 2: emergency stop"
#define SDCARD_ERROR "Error 3: SD card error"
#define HOME_FAILE "Error 4: homing failed"
#define TIMEOUT_ERROR "Error 5: timeout error"
#define EXTRUDER_NUM_ERROR "Error 6: E number error"
#define DRIVER_ERROR "Error 7: driver error"
#define E_MINTEMP_ERROR "Error 8: E mintemp triggered"
#define B_MINTEMP_ERROR "Error 9: B mintemp triggered"
#define E_MAXTEMP_ERROR "Error 10: E maxtemp triggered"
#define B_MAXTEMP_ERROR "Error 11: B maxtemp triggered"
#define E_RUNAWAY_ERROR "Error 12: E thermal runaway" // Heated, then temperature fell too far
#define B_RUNAWAY_ERROR "Error 13: B thermal runaway"
// new killed error message
#define TXT_ERR_MINTEMP "E1 MINTEMP"
#define TXT_ERR_MIN_TEMP_BED "Bed MINTEMP"
#define TXT_ERR_MAXTEMP "E1 MAXTEMP"
#define TXT_ERR_MAX_TEMP_BED "Bed MAXTEMP"
#define TXT_ERR_HEATING_FAILED "E1 Heating Failed"
#define TXT_ERR_HEATING_FAILED_BED "Bed Heating Failed"
#define TXT_ERR_TEMP_RUNAWAY "E1 Thermal Runaway"
#define TXT_ERR_TEMP_RUNAWAY_BED "Bed Thermal Runaway"
#define TXT_ERR_HOMING_FAILED "Homing Failed"
#define TXT_ERR_PROBING_FAILED "Probing Failed"
// DWIN serial transfer protocol
#define DW_FH_0 0x5A
#define DW_FH_1 0xA5
#define DW_CMD_VAR_W 0x82
#define DW_CMD_VAR_R 0x83
#define JX_CMD_REG_W 0x80
#define JX_CMD_REG_R 0x81
#define JX_ADDR_REG_PAGE 0x03
#define LEN_FILE_NAME 32
#define LEN_WORD 2
#define LEN_DWORD 4
#define LEN_4_CHR 4
#define LEN_6_CHR 6
#define TEMP_RANGE 2
#define PLA_E_TEMP PREHEAT_1_TEMP_HOTEND //200
#define PLA_B_TEMP PREHEAT_1_TEMP_BED //60
#define ABS_E_TEMP PREHEAT_2_TEMP_HOTEND //230
#define ABS_B_TEMP PREHEAT_2_TEMP_BED //80
#define MAC_LENGTH X_BED_SIZE
#define MAC_WIDTH Y_BED_SIZE
#define MAC_HEIGHT Z_MAX_POS
#ifdef LK1_PRO
#define MAC_MODEL "LK1 Pro"
#define MAC_SIZE "300*300*400(mm)"
//#define FILAMENT_RUNOUT_MOVE "G1 X10 Y260 F3000"
#define FILAMENT_RUNOUT_MOVE_X 10
#define FILAMENT_RUNOUT_MOVE_Y 260
#define FILAMENT_RUNOUT_MOVE_F 50
#elif defined(LK5_PRO)
#define MAC_MODEL "LK5 Pro"
#define MAC_SIZE "300*300*400(mm)"
//#define FILAMENT_RUNOUT_MOVE "G1 X10 Y260 F3000"
#define FILAMENT_RUNOUT_MOVE_X 10
#define FILAMENT_RUNOUT_MOVE_Y 260
#define FILAMENT_RUNOUT_MOVE_F 50
#else // LK4 PRO
#define MAC_MODEL "LK4 Pro"
#define MAC_SIZE "220*220*250(mm)"
//#define FILAMENT_RUNOUT_MOVE "G1 X10 Y200 F3000"
#define FILAMENT_RUNOUT_MOVE_X 10
#define FILAMENT_RUNOUT_MOVE_Y 200
#define FILAMENT_RUNOUT_MOVE_F 50
#endif // LK1_Pro
#if defined(MANUAL_FEEDRATE)
#undef MANUAL_FEEDRATE
#endif
#define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 60 } // Feedrates for manual moves along X, Y, Z, E from panel
#define BOARD_FW_VER SHORT_BUILD_VERSION
// DWIN system variable address
#define DW_ADDR_CHANGE_PAGE 0x0084
#define DW_PAGE_VAR_BASE 0x5A010000UL
// user defined variable address
#define ADDR_USER_VAR_BASE (0x1000)
#define ADDR_VAL_MENU_TYPE ADDR_USER_VAR_BASE // 1000
#define ADDR_VAL_BUTTON_KEY (ADDR_VAL_MENU_TYPE + LEN_WORD) // 1002
#define ADDR_VAL_LOADING (ADDR_VAL_BUTTON_KEY + LEN_WORD) // 1004
#define ADDR_VAL_LAUNCH_LOGO (ADDR_VAL_LOADING + LEN_WORD) // 1006
#define ADDR_TXT_ABOUT_MAC_TIME (ADDR_VAL_LAUNCH_LOGO+LEN_WORD) //1008
// HOME
#define ADDR_VAL_CUR_E (0x1010) // 1010
#define ADDR_VAL_TAR_E (ADDR_VAL_CUR_E + LEN_WORD) // 1012
#define ADDR_VAL_CUR_B (ADDR_VAL_TAR_E + LEN_WORD) // 1014
#define ADDR_VAL_TAR_B (ADDR_VAL_CUR_B + LEN_WORD) // 1016
#define ADDR_VAL_ICON_HIDE (ADDR_VAL_TAR_B+LEN_WORD) //1018
// TUNE
#define ADDR_VAL_FAN (0x1030) // 1030
#define ADDR_VAL_FEED (ADDR_VAL_FAN + LEN_WORD) // 1032
#define ADDR_VAL_FLOW (ADDR_VAL_FEED + LEN_WORD) // 1034
#define ADDR_VAL_LEDS_SWITCH (ADDR_VAL_FLOW + LEN_WORD) // 1036
#define ADDR_VAL_CUR_FEED (ADDR_VAL_LEDS_SWITCH+LEN_WORD) //1038
// LEVELING
#define ADDR_VAL_LEVEL_Z_UP_DOWN (ADDR_VAL_CUR_FEED+LEN_WORD) //103A
// MOVE
#define ADDR_VAL_MOVE_POS_X (0x1050) // 1050
#define ADDR_VAL_MOVE_POS_Y (ADDR_VAL_MOVE_POS_X + LEN_WORD) // 1052
#define ADDR_VAL_MOVE_POS_Z (ADDR_VAL_MOVE_POS_Y + LEN_WORD) // 1054
#define ADDR_VAL_MOVE_POS_E (ADDR_VAL_MOVE_POS_Z + LEN_WORD) // 1056
// PRINT
//... FILE
#define ADDR_TXT_PRINT_FILE_ITEM_0 (0x1070) // 1070
#define ADDR_TXT_PRINT_FILE_ITEM_1 (ADDR_TXT_PRINT_FILE_ITEM_0 + LEN_FILE_NAME) // 1090
#define ADDR_TXT_PRINT_FILE_ITEM_2 (ADDR_TXT_PRINT_FILE_ITEM_1 + LEN_FILE_NAME) // 10B0
#define ADDR_TXT_PRINT_FILE_ITEM_3 (ADDR_TXT_PRINT_FILE_ITEM_2 + LEN_FILE_NAME) // 10D0
#define ADDR_TXT_PRINT_FILE_ITEM_4 (ADDR_TXT_PRINT_FILE_ITEM_3 + LEN_FILE_NAME) // 10F0
#define ADDR_TXT_PRINT_FILE_ITEM_5 (ADDR_TXT_PRINT_FILE_ITEM_4 + LEN_FILE_NAME) // 1110
#define ADDR_TXT_PRINT_FILE_ITEM_6 (ADDR_TXT_PRINT_FILE_ITEM_5 + LEN_FILE_NAME) // 1130
#define ADDR_TXT_PRINT_FILE_ITEM_7 (ADDR_TXT_PRINT_FILE_ITEM_6 + LEN_FILE_NAME) // 1150
#define ADDR_TXT_PRINT_FILE_ITEM_8 (ADDR_TXT_PRINT_FILE_ITEM_7 + LEN_FILE_NAME) // 1170
#define ADDR_TXT_PRINT_FILE_ITEM_9 (ADDR_TXT_PRINT_FILE_ITEM_8 + LEN_FILE_NAME) // 1190
#define ADDR_TXT_PRINT_FILE_ITEM_10 (ADDR_TXT_PRINT_FILE_ITEM_9 + LEN_FILE_NAME) // 11B0
#define ADDR_TXT_PRINT_FILE_ITEM_11 (ADDR_TXT_PRINT_FILE_ITEM_10 + LEN_FILE_NAME) // 11D0
#define ADDR_TXT_PRINT_FILE_ITEM_12 (ADDR_TXT_PRINT_FILE_ITEM_11 + LEN_FILE_NAME) // 11F0
#define ADDR_TXT_PRINT_FILE_ITEM_13 (ADDR_TXT_PRINT_FILE_ITEM_12 + LEN_FILE_NAME) // 1210
#define ADDR_TXT_PRINT_FILE_ITEM_14 (ADDR_TXT_PRINT_FILE_ITEM_13 + LEN_FILE_NAME) // 1230
#define ADDR_TXT_PRINT_FILE_ITEM_15 (ADDR_TXT_PRINT_FILE_ITEM_14 + LEN_FILE_NAME) // 1250
#define ADDR_TXT_PRINT_FILE_ITEM_16 (ADDR_TXT_PRINT_FILE_ITEM_15 + LEN_FILE_NAME) // 1270
#define ADDR_TXT_PRINT_FILE_ITEM_17 (ADDR_TXT_PRINT_FILE_ITEM_16 + LEN_FILE_NAME) // 1290
#define ADDR_TXT_PRINT_FILE_ITEM_18 (ADDR_TXT_PRINT_FILE_ITEM_17 + LEN_FILE_NAME) // 12B0
#define ADDR_TXT_PRINT_FILE_ITEM_19 (ADDR_TXT_PRINT_FILE_ITEM_18 + LEN_FILE_NAME) // 12D0
#define ADDR_TXT_PRINT_FILE_ITEM_20 (ADDR_TXT_PRINT_FILE_ITEM_19 + LEN_FILE_NAME) // 12F0
#define ADDR_TXT_PRINT_FILE_ITEM_21 (ADDR_TXT_PRINT_FILE_ITEM_20 + LEN_FILE_NAME) // 1310
#define ADDR_TXT_PRINT_FILE_ITEM_22 (ADDR_TXT_PRINT_FILE_ITEM_21 + LEN_FILE_NAME) // 1330
#define ADDR_TXT_PRINT_FILE_ITEM_23 (ADDR_TXT_PRINT_FILE_ITEM_22 + LEN_FILE_NAME) // 1350
#define ADDR_TXT_PRINT_FILE_ITEM_24 (ADDR_TXT_PRINT_FILE_ITEM_23 + LEN_FILE_NAME) // 1370
// PRINT home
#define ADDR_TXT_HOME_FILE_NAME (0x1400) // 1400
#define ADDR_TXT_HOME_ELAP_TIME (ADDR_TXT_HOME_FILE_NAME + LEN_FILE_NAME) // 1420
#define ADDR_VAL_HOME_PROGRESS (ADDR_TXT_HOME_ELAP_TIME + LEN_6_CHR) // 1426
#define ADDR_VAL_HOME_Z_HEIGHT (ADDR_VAL_HOME_PROGRESS + LEN_WORD) // 1428
// UTILITIES
// filament
#define ADDR_VAL_UTILI_FILA_CHANGE_LEN (0x1440) // 1440
#define ADDR_VAL_FILA_CHANGE_TEMP (ADDR_VAL_UTILI_FILA_CHANGE_LEN + LEN_WORD) // 1442
// DIALOG NO TEMP
#define ADDR_VAL_EXTRUDE_TEMP (0x1460) // 1460
// ABOUT
#define ADDR_TXT_ABOUT_MODEL (0x1480) // 1480
#define ADDR_TXT_ABOUT_SIZE (ADDR_TXT_ABOUT_MODEL + LEN_FILE_NAME) // 14A0
#define ADDR_TXT_ABOUT_FW_SCREEN (ADDR_TXT_ABOUT_SIZE + LEN_FILE_NAME) // 14C0
#define ADDR_TXT_ABOUT_FW_BOARD (ADDR_TXT_ABOUT_FW_SCREEN + LEN_FILE_NAME) // 14E0
#define ADDR_TXT_ABOUT_WORK_TIME_MAC (ADDR_TXT_ABOUT_FW_BOARD+LEN_FILE_NAME) //1500
// FILE SELECT
#define ADDR_VAL_PRINT_FILE_SELECT (0x1550) // 1550
#define ADDR_TXT_PRINT_FILE_SELECT (ADDR_VAL_PRINT_FILE_SELECT + LEN_WORD) // 1552
#define ADDR_KILL_REASON (0x2000)
// SP definition
#define SP_TXT_PRINT_FILE_ITEM_0 (0x6000) // 6000
#define SP_COLOR_TXT_PRINT_FILE_ITEM_0 (SP_TXT_PRINT_FILE_ITEM_0 + 3) // 6003
// ...
#define SP_TXT_PRINT_FILE_ITEM_24 (0x6300) // 6300
#define SP_COLOR_TXT_PRINT_FILE_ITEM_24 (SP_TXT_PRINT_FILE_ITEM_24 + 3) // 6303
// color
#define COLOR_LIGHT_RED (0xA001)
#define COLOR_WHITE (0xFFFF)
// color_change(SP_TXT_PRINT_FILE_ITEM_0 + i*LEN_FILE_NAME, COLOR_LIGHT_RED)
enum E_BUTTON_KEY {
eBT_MOVE_XY_HOME, //0 0000
eBT_MOVE_Z_HOME,
eBT_MOVE_X_PLUS_0,
eBT_MOVE_X_MINUS_0,
eBT_MOVE_Y_PLUS_0,
eBT_MOVE_Y_MINUS_0, //5 0005
eBT_MOVE_Z_PLUS_0,
eBT_MOVE_Z_MINUS_0,
eBT_MOVE_E_PLUS_0,
eBT_MOVE_E_MINUS_0,
eBT_MOVE_X_PLUS_1, // 10 000A
eBT_MOVE_X_MINUS_1,
eBT_MOVE_Y_PLUS_1,
eBT_MOVE_Y_MINUS_1,
eBT_MOVE_Z_PLUS_1,
eBT_MOVE_Z_MINUS_1, //15 000F
eBT_MOVE_E_PLUS_1,
eBT_MOVE_E_MINUS_1,
eBT_MOVE_X_PLUS_2,
eBT_MOVE_X_MINUS_2,
eBT_MOVE_Y_PLUS_2, //20 0014
eBT_MOVE_Y_MINUS_2,
eBT_MOVE_Z_PLUS_2,
eBT_MOVE_Z_MINUS_2,
eBT_MOVE_E_PLUS_2,
eBT_MOVE_E_MINUS_2, //25 0019
eBT_MOVE_DISABLE,
eBT_MOVE_ENABLE,
eBT_PRINT_FILE_OPEN,
eBT_PRINT_FILE_OPEN_YES,
eBT_PRINT_HOME_PAUSE, //30 001E
eBT_PRINT_HOME_RESUME,
eBT_PRINT_HOME_ABORT,
eBT_PRINT_HOME_FINISH,
eBT_UTILI_FILA_PLA,
eBT_UTILI_FILA_ABS, //35 0023
eBT_UTILI_FILA_LOAD,
eBT_UTILI_FILA_UNLOAD,
eBT_HOME_RECOVERY_YES,
eBT_HOME_RECOVERY_NO,
eBT_DIAL_FILA_NO_TEMP_RET, //40 0028
eBT_DIAL_MOVE_NO_TEMP_RET,
eBT_PRINT_FILE_CLEAN,
eBT_UTILI_LEVEL_MEASU_START, // == PREVIOUS
eBT_UTILI_LEVEL_CORNER_POS_1,
eBT_UTILI_LEVEL_CORNER_POS_2, //45 002D
eBT_UTILI_LEVEL_CORNER_POS_3,
eBT_UTILI_LEVEL_CORNER_POS_4,
eBT_UTILI_LEVEL_CORNER_POS_5,
eBT_UTILI_LEVEL_MEASU_DIS_0,
eBT_UTILI_LEVEL_MEASU_DIS_1, //50 0032
eBT_UTILI_LEVEL_MEASU_S1_NEXT,
eBT_UTILI_LEVEL_MEASU_S2_NEXT,
eBT_UTILI_LEVEL_MEASU_S1_EXIT_NO,
eBT_UTILI_LEVEL_MEASU_S2_EXIT_NO,
eBT_UTILI_LEVEL_MEASU_EXIT_OK, //55 0037
eBT_UTILI_LEVEL_MEASU_S3_EXIT_NO,
eBT_MOVE_P0,
eBT_MOVE_P1,
eBT_MOVE_P2,
eBT_TUNE_SWITCH_LEDS, //60 003C
eBT_UTILI_LEVEL_MEASU_STOP_MOVE,
eBT_UTILI_LEVEL_CORNER_BACK,
eBT_PRINT_FILA_CHANGE_YES,
eBT_PRINT_FILA_HEAT_NO,
eBT_PRINT_FILA_UNLOAD_OK, //65 0041
eBT_PRINT_FILA_LOAD_OK,
eBT_PRINT_HOME_FILAMENT, // added for JX scrren
eBT_PRINT_TUNE_FILAMENT // added for JX scrren
};
enum E_MENU_TYPE {
eMENU_IDLE, // 0
eMENU_HOME,
eMENU_TUNE, // 2
eMENU_MOVE,
eMENU_TUNE_E, // 4
eMENU_TUNE_B,
eMENU_TUNE_FAN, // 6
eMENU_TUNE_SPEED,
eMENU_TUNE_FLOW, // 8
eMENU_UTILI_FILA,
eMENU_PRINT_HOME, // 10
eMENU_HOME_FILA,
eMENU_FILE //12
};
#define ID_MENU_HOME (1)
#define ID_MENU_PRINT_HOME (45)
#define ID_MENU_PRINT_HOME_PAUSE (46)
#define ID_MENU_PRINT_TUNE (47)
#define ID_MENU_PRINT_FILES_O (21)
#define ID_DIALOG_PRINT_RECOVERY (93)
#define ID_DIALOG_NO_FILA (85)
#define ID_DIALOG_PRINT_START_0 (26)
#define ID_DIALOG_PRINT_START_1 (96)
#define ID_DIALOG_PRINT_FINISH (81)
#define ID_DIALOG_FILA_NO_TEMP (91)
#define ID_DIALOG_MOVE_NO_TEMP (94)
#define ID_DIALOG_MOVE_WAIT (126)
#define ID_DIALOG_PRINT_WAIT (127)
#define ID_DIALOG_PRINT_TUNE_WAIT (133)
#define ID_DIALOG_LEVEL_WAIT (128)
#define ID_DIALOG_LEVEL_FAILE (129)
#define ID_DIALOG_PRINT_LEVEL_FAILE (146)
#define ID_DIALOG_UTILI_FILA_WAIT (139)
#define ID_DIALOG_UTILI_FILA_LOAD (140)
#define ID_DIALOG_UTILI_FILA_UNLOAD (141)
#define ID_DIALOG_LOAD_FINISH (144)
#define ID_DIALOG_PRINT_FILA_WAIT (134)
#define ID_DIALOG_PRINT_FILA_LOAD (135)
#define ID_DIALOG_PRINT_FILA_UNLOAD (136)
#define ID_MENU_UTILI_FILA_0 (87)
#define ID_MENU_HOME_FILA_0 (100)
#define ID_MENU_MOVE_0 (3)
#define ID_MENU_MOVE_1 (36)
#define ID_CRASH_KILLED (107)
#define ID_MENU_MEASU_S1 (112)
#define ID_MENU_MEASU_S2 (114)
#define ID_MENU_MEASU_S3 (116)
#define ID_MENU_MEASU_FINISH (123)
#define ID_DIALOG_CHANGE_FILA_0 (130) // added for JX screen
#define ID_DIALOG_CHANGE_FILA_1 (131) // added for JX screen
enum eAxis : uint8_t { X=0, Y, Z };
enum eExtruder : uint8_t { E0=0, E1, E2, E3, E4, E5, E6, E7 };
enum eHeater : uint8_t { H0=0, H1, H2, H3, H4, H5, BED, CHAMBER };
enum eFan : uint8_t { FAN0=0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 };
#endif // LGT_LCD_DW
| 14,149
|
C++
|
.h
| 300
| 45.49
| 117
| 0.626214
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,916
|
lgtdwlcd.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/lcd/lgtdwlcd.h
|
#pragma once
#include "../inc/MarlinConfigPre.h"
#if ENABLED(LGT_LCD_DW)
#include "../MarlinCore.h"
// #include "lgtdwdef.h"
// #include "Marlin.h"
// #include "cardreader.h"
// #include "printcounter.h"
// #include "temperature.h"
// #include "duration_t.h"
// #include"LGT_MACRO.h"
// #include "power_loss_recovery.h"
// #include "planner.h"
// #include "parser.h"
// #include "stopwatch.h"
// #include "macros.h"
// #include "endstops.h"
// #include "configuration_store.h"
// extern uint8_t target_extruder;
// extern int ii_setup;
// #if ENABLED(SDSUPPORT)
// extern CardReader card;
// #endif
// extern void DWIN_MAIN_FUNCTIONS();
// extern bool enqueue_and_echo_command(const char* cmd);
// extern bool check_recovery;
typedef struct Data_Buffer
{
unsigned char head[2];
unsigned char cmd;
unsigned long addr;
unsigned long datalen;
unsigned int data[30];
char data_num[6];
}DATA;
enum PRINTER_STATUS
{
PRINTER_SETUP,
PRINTER_STANDBY,
PRINTER_HEAT,
PRINTER_PRINTING,
PRINTER_PAUSE,
PRINTER_PRINTING_F
};
enum PRINTER_KILL_STATUS
{
PRINTER_NORMAL = 0,
E_TEMP_KILL,
B_TEMP_KILL,
M112_KILL,
SDCARD_KILL, //trying to call sub - gcode files with too many levels
HOME_KILL, //homing failed
TIMEOUT_KILL, //KILL caused by too much inactive time
EXTRUDER_KILL, //Invalid extruder number !
DRIVER_KILL, //driver kill
E_MINTEMP_KILL,
B_MINTEMP_KILL,
E_MAXTEMP_KILL,
B_MAXTEMP_KILL,
E_RUNAWAY_KILL,
B_RUNAWAY_KILL
};
enum ScreenModel {
SCREEN_DWIN_T5,
SCREEN_DWIN_T5L,
SCREEN_JX
};
class LGT_SCR_DW
{
public:
LGT_SCR_DW();
void begin();
void processButton();
void hideButtonsBeforeHeating();
void showButtonsAfterHeating();
void LGT_Pause_Move();
void goFinishPage();
void saveFinishTime();
void LGT_LCD_startup_settings();
// void LED_Bright_State(uint8_t LED, uint16_t per, uint8_t mod);
void LGT_MAC_Send_Filename(uint16_t Addr, uint16_t i);
void LGT_Print_Cause_Of_Kill(const char* error, const char *component);
void LGT_Get_MYSERIAL1_Cmd();
void LGT_Analysis_DWIN_Screen_Cmd();
void LGT_Send_Data_To_Screen(uint16_t Addr, int16_t Num);
void LGT_Send_Data_To_Screen(unsigned int addr, float num,char axis);
void LGT_Send_Data_To_Screen(unsigned int addr,char* buf);
void LGT_Send_Data_To_Screen1(unsigned int addr,const char* buf);
void LGT_Main_Function();
void LGT_Display_Filename();
void LGT_Clean_DW_Display_Data(unsigned int addr);
void LGT_SDCard_Status_Update();
void LGT_Change_Page(unsigned int pageid);
void LGT_Power_Loss_Recovery_Resume();
void LGT_Disable_Enable_Screen_Button(unsigned int pageid, unsigned int buttonid, unsigned int sta);
void LGT_Screen_System_Reset();
void LGT_Stop_Printing();
void LGT_Exit_Print_Page();
int LGT_Get_Extrude_Temp();
void LGT_Save_Recovery_Filename(unsigned char cmd, unsigned char sys_cmd, /*unsigned int sys_addr,*/unsigned int addr, unsigned int length);
// void LGT_Printer_Status_Light();
// void LGT_Printer_Light_Update();
void LGT_Printer_Data_Updata();
void LGT_DW_Setup();
void LGT_Change_Filament(int fila_len);
public:
void readScreenModel();
static void test();
inline bool hasDwScreen() { return ((_screenModel == SCREEN_DWIN_T5) || (_screenModel == SCREEN_DWIN_T5L)); }
inline bool hasJxScreen() { return (_screenModel == SCREEN_JX); }
void pausePrint();
private:
void writeData(uint16_t addr, const uint8_t *data, uint8_t size, bool isRead=false);
inline void writeData(uint16_t addr, uint8_t byteData, bool isRead=false)
{
writeData(addr, &byteData, 1, isRead);
}
inline void writeData(uint16_t addr, uint16_t wordData, bool isRead=false)
{
uint8_t *byte = (uint8_t *)(&wordData); // reinterpret word to byte
uint8_t data[2] = {byte[1], byte[0]}; // little-endian to big-endian
writeData(addr, data, 2, isRead);
}
void readData(uint16_t addr, uint8_t *data, uint8_t size);
private:
ScreenModel _screenModel;
// button enable for JX screen
bool _btnPauseEnabled;
bool _btnFilamentEnabled1;
bool _btnFilamentEnabled2;
};
#define CHANGE_TXT_COLOR(addr,color) LGT_Send_Data_To_Screen((uint16_t)addr,(int16_t)color)
#define SP_COLOR_SEL_FILE_NAME (SP_COLOR_TXT_PRINT_FILE_ITEM_0 + sel_fileid*LEN_FILE_NAME)
#define HILIGHT_FILE_NAME() CHANGE_TXT_COLOR(SP_COLOR_SEL_FILE_NAME, COLOR_LIGHT_RED)
#define DEHILIGHT_FILE_NAME() CHANGE_TXT_COLOR(SP_COLOR_SEL_FILE_NAME, COLOR_WHITE)
extern LGT_SCR_DW lgtLcdDw; // extern interface
extern bool LGT_is_printing;
extern char leveling_sta;
extern bool check_recovery; // for recovery dialog
extern bool is_abort_recovery_resume; // for abort recovery resume
extern bool is_recovery_resuming; // recovery resume
#endif // LGT_LCD_DW
| 4,692
|
C++
|
.h
| 142
| 31.204225
| 141
| 0.741117
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,919
|
Conditionals_LCD.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/inc/Conditionals_LCD.h
|
/**
* 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
/**
* Conditionals_LCD.h
* Conditionals that need to be set before Configuration_adv.h or pins.h
*/
#if ENABLED(MORGAN_SCARA)
#define IS_SCARA 1
#define IS_KINEMATIC 1
#elif ENABLED(DELTA)
#define IS_KINEMATIC 1
#else
#define IS_CARTESIAN 1
#endif
#if ENABLED(CARTESIO_UI)
#define DOGLCD
#define IS_ULTIPANEL
#elif ENABLED(ZONESTAR_LCD)
#define ADC_KEYPAD
#define IS_RRW_KEYPAD
#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0
#define ADC_KEY_NUM 8
#define IS_ULTIPANEL
// This helps to implement ADC_KEYPAD menus
#define REVERSE_MENU_DIRECTION
#define ENCODER_PULSES_PER_STEP 1
#define ENCODER_STEPS_PER_MENU_ITEM 1
#define ENCODER_FEEDRATE_DEADZONE 2
#elif ENABLED(RADDS_DISPLAY)
#define IS_ULTIPANEL
#define ENCODER_PULSES_PER_STEP 2
#elif EITHER(ANET_FULL_GRAPHICS_LCD, BQ_LCD_SMART_CONTROLLER)
#define IS_RRD_FG_SC
#elif ANY(miniVIKI, VIKI2, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864)
#define IS_ULTRA_LCD
#define DOGLCD
#define IS_ULTIPANEL
#if ENABLED(miniVIKI)
#define U8GLIB_ST7565_64128N
#elif ENABLED(VIKI2)
#define U8GLIB_ST7565_64128N
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define U8GLIB_LM6059_AF
#elif ENABLED(AZSMZ_12864)
#define U8GLIB_ST7565_64128N
#endif
#elif ENABLED(OLED_PANEL_TINYBOY2)
#define IS_U8GLIB_SSD1306
#define IS_ULTIPANEL
#elif ENABLED(RA_CONTROL_PANEL)
#define LCD_I2C_TYPE_PCA8574
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#define IS_ULTIPANEL
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define DOGLCD
#define U8GLIB_ST7920
#define IS_ULTIPANEL
#elif ENABLED(CR10_STOCKDISPLAY)
#define IS_RRD_FG_SC
#ifndef ST7920_DELAY_1
#define ST7920_DELAY_1 DELAY_NS(125)
#endif
#ifndef ST7920_DELAY_2
#define ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef ST7920_DELAY_3
#define ST7920_DELAY_3 DELAY_NS(125)
#endif
#elif ENABLED(MKS_12864OLED)
#define IS_RRD_SC
#define U8GLIB_SH1106
#elif ENABLED(MKS_12864OLED_SSD1306)
#define IS_RRD_SC
#define IS_U8GLIB_SSD1306
#elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY)
#define MINIPANEL
#elif ANY(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1)
#define FYSETC_MINI_12864
#define DOGLCD
#define IS_ULTIPANEL
#define LED_COLORS_REDUCE_GREEN
#if ENABLED(PSU_CONTROL) && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1)
#define LED_BACKLIGHT_TIMEOUT 10000
#endif
// Require LED backlighting enabled
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
#define RGB_LED
#elif ENABLED(FYSETC_MINI_12864_2_1)
#define LED_CONTROL_MENU
#define NEOPIXEL_LED
#undef NEOPIXEL_TYPE
#define NEOPIXEL_TYPE NEO_RGB
#if NEOPIXEL_PIXELS < 3
#undef NEOPIXELS_PIXELS
#define NEOPIXEL_PIXELS 3
#endif
#ifndef NEOPIXEL_BRIGHTNESS
#define NEOPIXEL_BRIGHTNESS 127
#endif
//#define NEOPIXEL_STARTUP_TEST
#endif
#elif ENABLED(ULTI_CONTROLLER)
#define IS_ULTIPANEL
#define U8GLIB_SSD1309
#define LCD_RESET_PIN LCD_PINS_D6 // This controller need a reset pin
#define ENCODER_PULSES_PER_STEP 2
#define ENCODER_STEPS_PER_MENU_ITEM 2
#elif ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602)
#define IS_RRD_SC
#define LCD_WIDTH 16
#define LCD_HEIGHT 2
#endif
#if ENABLED(IS_RRD_FG_SC)
#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
#endif
#if EITHER(MAKRPANEL, MINIPANEL)
#define IS_ULTIPANEL
#define DOGLCD
#if ENABLED(MAKRPANEL)
#define U8GLIB_ST7565_64128N
#endif
#endif
#if ENABLED(IS_U8GLIB_SSD1306)
#define U8GLIB_SSD1306
#endif
#if ENABLED(OVERLORD_OLED)
#define IS_ULTIPANEL
#define U8GLIB_SH1106
/**
* PCA9632 for buzzer and LEDs via i2c
* No auto-inc, red and green leds switched, buzzer
*/
#define PCA9632
#define PCA9632_NO_AUTO_INC
#define PCA9632_GRN 0x00
#define PCA9632_RED 0x02
#define PCA9632_BUZZER
#define PCA9632_BUZZER_DATA { 0x09, 0x02 }
#define ENCODER_PULSES_PER_STEP 1 // Overlord uses buttons
#define ENCODER_STEPS_PER_MENU_ITEM 1
#endif
// 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106
#if ANY(U8GLIB_SSD1306, U8GLIB_SSD1309, U8GLIB_SH1106)
#define HAS_SSD1306_OLED_I2C 1
#endif
#if HAS_SSD1306_OLED_I2C
#define IS_ULTRA_LCD
#define DOGLCD
#endif
// ST7920-based graphical displays
#if ANY(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, LCD_FOR_MELZI, SILVER_GATE_GLCD_CONTROLLER)
#define DOGLCD
#define U8GLIB_ST7920
#define IS_RRD_SC
#endif
// RepRapDiscount LCD or Graphical LCD with rotary click encoder
#if ENABLED(IS_RRD_SC)
#define REPRAP_DISCOUNT_SMART_CONTROLLER
#endif
/**
* SPI Ultipanels
*/
// Basic Ultipanel-like displays
#if ANY(ULTIMAKERCONTROLLER, REPRAP_DISCOUNT_SMART_CONTROLLER, G3D_PANEL, RIGIDBOT_PANEL, PANEL_ONE, U8GLIB_SH1106)
#define IS_ULTIPANEL
#endif
// Einstart OLED has Cardinal nav via pins defined in pins_EINSTART-S.h
#if ENABLED(U8GLIB_SH1106_EINSTART)
#define DOGLCD
#define IS_ULTIPANEL
#endif
// FSMC/SPI TFT Panels
#if ENABLED(FSMC_GRAPHICAL_TFT)
// #define DOGLCD
// #define IS_ULTIPANEL
#define DELAYED_BACKLIGHT_INIT
#endif
/**
* I2C Panels
*/
#if EITHER(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004)
#define LCD_I2C_TYPE_PCF8575
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#if ENABLED(LCD_SAINSMART_I2C_2004)
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#endif
#elif ENABLED(LCD_I2C_PANELOLU2)
// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
#define LCD_I2C_TYPE_MCP23017
#define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
#define LCD_USE_I2C_BUZZER // Enable buzzer on LCD (optional)
#define IS_ULTIPANEL
#elif ENABLED(LCD_I2C_VIKI)
/**
* Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
*
* This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
* Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
* Note: The pause/stop/resume LCD button pin should be connected to the Arduino
* BTN_ENC pin (or set BTN_ENC to -1 if not used)
*/
#define LCD_I2C_TYPE_MCP23017
#define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
#define LCD_USE_I2C_BUZZER // Enable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
#define IS_ULTIPANEL
#define ENCODER_FEEDRATE_DEADZONE 4
#define STD_ENCODER_PULSES_PER_STEP 1
#define STD_ENCODER_STEPS_PER_MENU_ITEM 2
#elif ENABLED(G3D_PANEL)
#define STD_ENCODER_PULSES_PER_STEP 2
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1
#elif ANY(REPRAP_DISCOUNT_SMART_CONTROLLER, miniVIKI, VIKI2, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864, OLED_PANEL_TINYBOY2, BQ_LCD_SMART_CONTROLLER, LCD_I2C_PANELOLU2)
#define STD_ENCODER_PULSES_PER_STEP 4
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1
#endif
#ifndef STD_ENCODER_PULSES_PER_STEP
#if ENABLED(TOUCH_BUTTONS)
#define STD_ENCODER_PULSES_PER_STEP 2
#else
#define STD_ENCODER_PULSES_PER_STEP 5
#endif
#endif
#ifndef STD_ENCODER_STEPS_PER_MENU_ITEM
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1
#endif
#ifndef ENCODER_PULSES_PER_STEP
#define ENCODER_PULSES_PER_STEP STD_ENCODER_PULSES_PER_STEP
#endif
#ifndef ENCODER_STEPS_PER_MENU_ITEM
#define ENCODER_STEPS_PER_MENU_ITEM STD_ENCODER_STEPS_PER_MENU_ITEM
#endif
#ifndef ENCODER_FEEDRATE_DEADZONE
#define ENCODER_FEEDRATE_DEADZONE 6
#endif
// Shift register panels
// ---------------------
// 2 wire Non-latching LCD SR from:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
#if ENABLED(FF_INTERFACEBOARD)
#define SR_LCD_3W_NL // Non latching 3 wire shift register
#define IS_ULTIPANEL
#elif ENABLED(SAV_3DLCD)
#define SR_LCD_2W_NL // Non latching 2 wire shift register
#define IS_ULTIPANEL
#endif
#if ENABLED(IS_ULTIPANEL)
#define ULTIPANEL
#endif
#if ENABLED(ULTIPANEL)
#define IS_ULTRA_LCD
#ifndef NEWPANEL
#define NEWPANEL
#endif
#endif
#if ENABLED(IS_ULTRA_LCD)
#define ULTRA_LCD
#endif
#if ENABLED(IS_RRW_KEYPAD)
#define REPRAPWORLD_KEYPAD
#endif
// Keypad needs a move step
#if ENABLED(REPRAPWORLD_KEYPAD)
#define NEWPANEL
#ifndef REPRAPWORLD_KEYPAD_MOVE_STEP
#define REPRAPWORLD_KEYPAD_MOVE_STEP 1.0
#endif
#endif
// Aliases for LCD features
#if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
#define HAS_DGUS_LCD 1
#endif
// Extensible UI serial touch screens. (See src/lcd/extensible_ui)
#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE)
#define IS_EXTUI
#define EXTENSIBLE_UI
#endif
// Aliases for LCD features
#if EITHER(ULTRA_LCD, EXTENSIBLE_UI)
#define HAS_DISPLAY 1
#if ENABLED(ULTRA_LCD)
#define HAS_SPI_LCD 1
#if ENABLED(DOGLCD)
#define HAS_GRAPHICAL_LCD 1
#else
#define HAS_CHARACTER_LCD 1
#endif
#endif
#endif
#if ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS)
#define HAS_LCD_MENU 1
#endif
#if ENABLED(ADC_KEYPAD)
#define HAS_ADC_BUTTONS 1
#endif
#if HAS_GRAPHICAL_LCD
#ifndef LCD_PIXEL_WIDTH
#define LCD_PIXEL_WIDTH 128
#endif
#ifndef LCD_PIXEL_HEIGHT
#define LCD_PIXEL_HEIGHT 64
#endif
#endif
/**
* Extruders have some combination of stepper motors and hotends
* so we separate these concepts into the defines:
*
* EXTRUDERS - Number of Selectable Tools
* HOTENDS - Number of hotends, whether connected or separate
* E_STEPPERS - Number of actual E stepper motors
* E_MANUAL - Number of E steppers for LCD move options
*
*/
#if EXTRUDERS == 0
#undef DISTINCT_E_FACTORS
#undef SINGLENOZZLE
#undef SWITCHING_EXTRUDER
#undef SWITCHING_NOZZLE
#undef MIXING_EXTRUDER
#undef MK2_MULTIPLEXER
#undef PRUSA_MMU2
#endif
#if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS
#if EXTRUDERS > 4
#define E_STEPPERS 3
#elif EXTRUDERS > 2
#define E_STEPPERS 2
#else
#define E_STEPPERS 1
#endif
#if DISABLED(SWITCHING_NOZZLE)
#define HOTENDS E_STEPPERS
#endif
#elif ENABLED(MIXING_EXTRUDER)
#define E_STEPPERS MIXING_STEPPERS
#define E_MANUAL 1
#define DUAL_MIXING_EXTRUDER (MIXING_STEPPERS == 2)
#elif ENABLED(SWITCHING_TOOLHEAD)
#define E_STEPPERS EXTRUDERS
#define E_MANUAL EXTRUDERS
#elif ENABLED(PRUSA_MMU2)
#define E_STEPPERS 1
#endif
// No inactive extruders with MK2_MULTIPLEXER or SWITCHING_NOZZLE
#if EITHER(MK2_MULTIPLEXER, SWITCHING_NOZZLE)
#undef DISABLE_INACTIVE_EXTRUDER
#endif
// Prusa MK2 Multiplexer and MMU 2.0 force SINGLENOZZLE
#if EITHER(MK2_MULTIPLEXER, PRUSA_MMU2)
#define SINGLENOZZLE
#endif
#if EITHER(SINGLENOZZLE, MIXING_EXTRUDER) // One hotend, one thermistor, no XY offset
#undef HOTENDS
#define HOTENDS 1
#undef HOTEND_OFFSET_X
#undef HOTEND_OFFSET_Y
#endif
#ifndef HOTENDS
#define HOTENDS EXTRUDERS
#endif
#ifndef E_STEPPERS
#define E_STEPPERS EXTRUDERS
#endif
#ifndef E_MANUAL
#define E_MANUAL EXTRUDERS
#endif
// Helper macros for extruder and hotend arrays
#define HOTEND_LOOP() for (int8_t e = 0; e < HOTENDS; e++)
#define ARRAY_BY_EXTRUDERS(V...) ARRAY_N(EXTRUDERS, V)
#define ARRAY_BY_EXTRUDERS1(v1) ARRAY_BY_EXTRUDERS(v1, v1, v1, v1, v1, v1, v1, v1)
#define ARRAY_BY_HOTENDS(V...) ARRAY_N(HOTENDS, V)
#define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1, v1, v1, v1, v1)
#if ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR)
#define DO_SWITCH_EXTRUDER 1
#endif
#ifdef SWITCHING_NOZZLE_E1_SERVO_NR
#define SWITCHING_NOZZLE_TWO_SERVOS 1
#endif
#if HOTENDS > 1
#define HAS_HOTEND_OFFSET 1
#endif
/**
* Default hotend offsets, if not defined
*/
#if HAS_HOTEND_OFFSET
#ifndef HOTEND_OFFSET_X
#define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
#endif
#ifndef HOTEND_OFFSET_Y
#define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
#endif
#ifndef HOTEND_OFFSET_Z
#define HOTEND_OFFSET_Z { 0 } // Z offsets for each extruder
#endif
#endif
/**
* DISTINCT_E_FACTORS affects how some E factors are accessed
*/
#if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1
#define XYZE_N (XYZ + E_STEPPERS)
#define E_AXIS_N(E) AxisEnum(E_AXIS + E)
#define UNUSED_E(E) NOOP
#else
#undef DISTINCT_E_FACTORS
#define XYZE_N XYZE
#define E_AXIS_N(E) E_AXIS
#define UNUSED_E(E) UNUSED(E)
#endif
/**
* The BLTouch Probe emulates a servo probe
* and uses "special" angles for its state.
*/
#if ENABLED(BLTOUCH)
#ifndef Z_PROBE_SERVO_NR
#define Z_PROBE_SERVO_NR 0
#endif
#ifndef NUM_SERVOS
#define NUM_SERVOS (Z_PROBE_SERVO_NR + 1)
#endif
#undef DEACTIVATE_SERVOS_AFTER_MOVE
#if NUM_SERVOS == 1
#undef SERVO_DELAY
#define SERVO_DELAY { 50 }
#endif
// Always disable probe pin inverting for BLTouch
#undef Z_MIN_PROBE_ENDSTOP_INVERTING
#define Z_MIN_PROBE_ENDSTOP_INVERTING false
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
#undef Z_MIN_ENDSTOP_INVERTING
#define Z_MIN_ENDSTOP_INVERTING false
#endif
#endif
#ifndef NUM_SERVOS
#define NUM_SERVOS 0
#endif
#ifndef PREHEAT_1_LABEL
#define PREHEAT_1_LABEL "PLA"
#endif
#ifndef PREHEAT_2_LABEL
#define PREHEAT_2_LABEL "ABS"
#endif
/**
* Set a flag for a servo probe (or BLTouch)
*/
#if defined(Z_PROBE_SERVO_NR) && Z_PROBE_SERVO_NR >= 0
#define HAS_Z_SERVO_PROBE 1
#endif
#if HAS_Z_SERVO_PROBE || EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
#define HAS_SERVO_ANGLES 1
#endif
#if !HAS_SERVO_ANGLES
#undef EDITABLE_SERVO_ANGLES
#endif
/**
* Set flags for enabled probes
*/
#if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE)
#define HAS_BED_PROBE 1
#endif
#if HAS_BED_PROBE || EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)
#define PROBE_SELECTED 1
#endif
#if HAS_BED_PROBE
#if DISABLED(NOZZLE_AS_PROBE)
#define HAS_PROBE_XY_OFFSET 1
#endif
#if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
#define HAS_CUSTOM_PROBE_PIN 1
#endif
#if Z_HOME_DIR < 0 && !HAS_CUSTOM_PROBE_PIN
#define HOMING_Z_WITH_PROBE 1
#endif
#ifndef Z_PROBE_LOW_POINT
#define Z_PROBE_LOW_POINT -5
#endif
#if ENABLED(Z_PROBE_ALLEN_KEY)
#define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe
#endif
#if MULTIPLE_PROBING > 1
#if EXTRA_PROBING
#define TOTAL_PROBING (MULTIPLE_PROBING + EXTRA_PROBING)
#else
#define TOTAL_PROBING MULTIPLE_PROBING
#endif
#endif
#else
// Clear probe pin settings when no probe is selected
#undef Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
#endif
/**
* Set granular options based on the specific type of leveling
*/
#if ENABLED(AUTO_BED_LEVELING_UBL)
#undef LCD_BED_LEVELING
#if ENABLED(DELTA)
#define UBL_SEGMENTED 1
#endif
#endif
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT)
#define ABL_PLANAR 1
#endif
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
#define ABL_GRID 1
#endif
#if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT)
#define HAS_ABL_NOT_UBL 1
#endif
#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
#define HAS_MESH 1
#endif
#if EITHER(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_3POINT)
#define NEEDS_THREE_PROBE_POINTS 1
#endif
#if EITHER(HAS_ABL_NOT_UBL, AUTO_BED_LEVELING_UBL)
#define HAS_ABL_OR_UBL 1
#if DISABLED(PROBE_MANUALLY)
#define HAS_AUTOLEVEL 1
#endif
#endif
#if EITHER(HAS_ABL_OR_UBL, MESH_BED_LEVELING)
#define HAS_LEVELING 1
#if DISABLED(AUTO_BED_LEVELING_UBL)
#define PLANNER_LEVELING 1
#endif
#endif
#if EITHER(HAS_ABL_OR_UBL, Z_MIN_PROBE_REPEATABILITY_TEST)
#define HAS_PROBING_PROCEDURE 1
#endif
#if !HAS_LEVELING
#undef RESTORE_LEVELING_AFTER_G28
#endif
#ifdef GRID_MAX_POINTS_X
#define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y))
#define GRID_LOOP(A,B) LOOP_L_N(A, GRID_MAX_POINTS_X) LOOP_L_N(B, GRID_MAX_POINTS_Y)
#endif
#ifndef INVERT_X_DIR
#define INVERT_X_DIR false
#endif
#ifndef INVERT_Y_DIR
#define INVERT_Y_DIR false
#endif
#ifndef INVERT_Z_DIR
#define INVERT_Z_DIR false
#endif
#ifndef INVERT_E_DIR
#define INVERT_E_DIR false
#endif
#if ENABLED(SLIM_LCD_MENUS)
#define BOOT_MARLIN_LOGO_SMALL
#endif
// This flag indicates some kind of jerk storage is needed
#if ENABLED(CLASSIC_JERK) || IS_KINEMATIC
#define HAS_CLASSIC_JERK 1
#endif
// E jerk exists with JD disabled (of course) but also when Linear Advance is disabled on Delta/SCARA
#if ENABLED(CLASSIC_JERK) || (IS_KINEMATIC && DISABLED(LIN_ADVANCE))
#define HAS_CLASSIC_E_JERK 1
#endif
#ifndef SPI_SPEED
#define SPI_SPEED SPI_FULL_SPEED
#endif
#if SERIAL_PORT == -1 || SERIAL_PORT_2 == -1
#define HAS_USB_SERIAL 1
#endif
/**
* This setting is also used by M109 when trying to calculate
* a ballpark safe margin to prevent wait-forever situation.
*/
#ifndef EXTRUDE_MINTEMP
#define EXTRUDE_MINTEMP 170
#endif
// LGT LCD
#if ENABLED(LGT)
#if BOTH(LGT_LCD_28, LGT_LCD_DW)
#error "Can't use two LGT LCD at same time"
#endif
#endif
| 18,141
|
C++
|
.h
| 597
| 27.767169
| 170
| 0.74686
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,920
|
Conditionals_post.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/inc/Conditionals_post.h
|
/**
* 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
/**
* Conditionals_post.h
* Defines that depend on configuration but are not editable.
*/
#ifdef GITHUB_ACTIONS
// Extras for CI testing
#endif
// Linear advance uses Jerk since E is an isolated axis
#if DISABLED(CLASSIC_JERK) && ENABLED(LIN_ADVANCE)
#define HAS_LINEAR_E_JERK 1
#endif
// If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation
#if ENABLED(EEPROM_SETTINGS)
#if NONE(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION) && EITHER(I2C_EEPROM, SPI_EEPROM)
#define USE_REAL_EEPROM 1
#else
#define USE_EMULATED_EEPROM 1
#endif
#else
#undef I2C_EEPROM
#undef SPI_EEPROM
#undef SDCARD_EEPROM_EMULATION
#undef SRAM_EEPROM_EMULATION
#undef FLASH_EEPROM_EMULATION
#endif
#ifdef TEENSYDUINO
#undef max
#define max(a,b) ((a)>(b)?(a):(b))
#undef min
#define min(a,b) ((a)<(b)?(a):(b))
#undef NOT_A_PIN // Override Teensyduino legacy CapSense define work-around
#define NOT_A_PIN 0 // For PINS_DEBUGGING
#endif
/**
* Axis lengths and center
*/
#define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS))
#define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
#define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
// Defined only if the sanity-check is bypassed
#ifndef X_BED_SIZE
#define X_BED_SIZE X_MAX_LENGTH
#endif
#ifndef Y_BED_SIZE
#define Y_BED_SIZE Y_MAX_LENGTH
#endif
// Require 0,0 bed center for Delta and SCARA
#if IS_KINEMATIC
#define BED_CENTER_AT_0_0
#endif
// Define center values for future use
#define _X_HALF_BED ((X_BED_SIZE) / 2)
#define _Y_HALF_BED ((Y_BED_SIZE) / 2)
#define X_CENTER TERN(BED_CENTER_AT_0_0, 0, _X_HALF_BED)
#define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED)
// Get the linear boundaries of the bed
#define X_MIN_BED (X_CENTER - _X_HALF_BED)
#define X_MAX_BED (X_MIN_BED + X_BED_SIZE)
#define Y_MIN_BED (Y_CENTER - _Y_HALF_BED)
#define Y_MAX_BED (Y_MIN_BED + Y_BED_SIZE)
/**
* Dual X Carriage
*/
#if ENABLED(DUAL_X_CARRIAGE)
#ifndef X1_MIN_POS
#define X1_MIN_POS X_MIN_POS
#endif
#ifndef X1_MAX_POS
#define X1_MAX_POS X_BED_SIZE
#endif
#endif
/**
* CoreXY, CoreXZ, and CoreYZ - and their reverse
*/
#if EITHER(COREXY, COREYX)
#define CORE_IS_XY 1
#endif
#if EITHER(COREXZ, COREZX)
#define CORE_IS_XZ 1
#endif
#if EITHER(COREYZ, COREZY)
#define CORE_IS_YZ 1
#endif
#if CORE_IS_XY || CORE_IS_XZ || CORE_IS_YZ
#define IS_CORE 1
#endif
#if IS_CORE
#if CORE_IS_XY
#define CORE_AXIS_1 A_AXIS
#define CORE_AXIS_2 B_AXIS
#define NORMAL_AXIS Z_AXIS
#elif CORE_IS_XZ
#define CORE_AXIS_1 A_AXIS
#define NORMAL_AXIS Y_AXIS
#define CORE_AXIS_2 C_AXIS
#elif CORE_IS_YZ
#define NORMAL_AXIS X_AXIS
#define CORE_AXIS_1 B_AXIS
#define CORE_AXIS_2 C_AXIS
#endif
#define CORESIGN(n) (ANY(COREYX, COREZX, COREZY) ? (-(n)) : (n))
#endif
/**
* No adjustable bed on non-cartesians
*/
#if IS_KINEMATIC
#undef LEVEL_BED_CORNERS
#endif
/**
* SCARA cannot use SLOWDOWN and requires QUICKHOME
* Printable radius assumes joints can fully extend
*/
#if IS_SCARA
#undef SLOWDOWN
#define QUICK_HOME
#define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2)
#endif
/**
* Set the home position based on settings or manual overrides
*/
#ifdef MANUAL_X_HOME_POS
#define X_HOME_POS MANUAL_X_HOME_POS
#else
#define X_END_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
#if ENABLED(BED_CENTER_AT_0_0)
#define X_HOME_POS TERN(DELTA, 0, X_END_POS)
#else
#define X_HOME_POS TERN(DELTA, X_MIN_POS + (X_BED_SIZE) * 0.5, X_END_POS)
#endif
#endif
#ifdef MANUAL_Y_HOME_POS
#define Y_HOME_POS MANUAL_Y_HOME_POS
#else
#define Y_END_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
#if ENABLED(BED_CENTER_AT_0_0)
#define Y_HOME_POS TERN(DELTA, 0, Y_END_POS)
#else
#define Y_HOME_POS TERN(DELTA, Y_MIN_POS + (Y_BED_SIZE) * 0.5, Y_END_POS)
#endif
#endif
#ifdef MANUAL_Z_HOME_POS
#define Z_HOME_POS MANUAL_Z_HOME_POS
#else
#define Z_HOME_POS (Z_HOME_DIR < 0 ? Z_MIN_POS : Z_MAX_POS)
#endif
/**
* If DELTA_HEIGHT isn't defined use the old setting
*/
#if ENABLED(DELTA) && !defined(DELTA_HEIGHT)
#define DELTA_HEIGHT Z_HOME_POS
#endif
/**
* Z Sled Probe requires Z_SAFE_HOMING
*/
#if ENABLED(Z_PROBE_SLED)
#define Z_SAFE_HOMING
#endif
/**
* DELTA should ignore Z_SAFE_HOMING and SLOWDOWN
*/
#if ENABLED(DELTA)
#undef Z_SAFE_HOMING
#undef SLOWDOWN
#endif
#ifndef MESH_INSET
#define MESH_INSET 0
#endif
/**
* Safe Homing Options
*/
#if ENABLED(Z_SAFE_HOMING)
#if ENABLED(AUTO_BED_LEVELING_UBL)
// Home close to center so grid points have z heights very close to 0
#define _SAFE_POINT(A) (((GRID_MAX_POINTS_##A) / 2) * (A##_BED_SIZE - 2 * (MESH_INSET)) / (GRID_MAX_POINTS_##A - 1) + MESH_INSET)
#else
#define _SAFE_POINT(A) A##_CENTER
#endif
#ifndef Z_SAFE_HOMING_X_POINT
#define Z_SAFE_HOMING_X_POINT _SAFE_POINT(X)
#endif
#ifndef Z_SAFE_HOMING_Y_POINT
#define Z_SAFE_HOMING_Y_POINT _SAFE_POINT(Y)
#endif
#endif
/**
* Host keep alive
*/
#ifndef DEFAULT_KEEPALIVE_INTERVAL
#define DEFAULT_KEEPALIVE_INTERVAL 2
#endif
/**
* Provide a MAX_AUTORETRACT for older configs
*/
#if ENABLED(FWRETRACT) && !defined(MAX_AUTORETRACT)
#define MAX_AUTORETRACT 99
#endif
/**
* LCD Contrast for Graphical Displays
*/
#if ENABLED(CARTESIO_UI)
#define _LCD_CONTRAST_MIN 60
#define _LCD_CONTRAST_INIT 90
#define _LCD_CONTRAST_MAX 140
#elif ENABLED(miniVIKI)
#define _LCD_CONTRAST_MIN 75
#define _LCD_CONTRAST_INIT 95
#define _LCD_CONTRAST_MAX 115
#elif ENABLED(VIKI2)
#define _LCD_CONTRAST_INIT 140
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define _LCD_CONTRAST_MIN 90
#define _LCD_CONTRAST_INIT 110
#define _LCD_CONTRAST_MAX 130
#elif ENABLED(AZSMZ_12864)
#define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 190
#elif ENABLED(MKS_LCD12864B)
#define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 205
#elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY)
#define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 195
#elif ENABLED(FYSETC_MINI_12864)
#define _LCD_CONTRAST_INIT 220
#elif ENABLED(ULTI_CONTROLLER)
#define _LCD_CONTRAST_INIT 127
#define _LCD_CONTRAST_MAX 254
#elif EITHER(MAKRPANEL, MINIPANEL)
#define _LCD_CONTRAST_INIT 17
#endif
#ifdef _LCD_CONTRAST_INIT
#define HAS_LCD_CONTRAST 1
#endif
#if HAS_LCD_CONTRAST
#ifndef LCD_CONTRAST_MIN
#ifdef _LCD_CONTRAST_MIN
#define LCD_CONTRAST_MIN _LCD_CONTRAST_MIN
#else
#define LCD_CONTRAST_MIN 0
#endif
#endif
#ifndef LCD_CONTRAST_INIT
#define LCD_CONTRAST_INIT _LCD_CONTRAST_INIT
#endif
#ifndef LCD_CONTRAST_MAX
#ifdef _LCD_CONTRAST_MAX
#define LCD_CONTRAST_MAX _LCD_CONTRAST_MAX
#elif _LCD_CONTRAST_INIT > 63
#define LCD_CONTRAST_MAX 255
#else
#define LCD_CONTRAST_MAX 63 // ST7567 6-bits contrast
#endif
#endif
#ifndef DEFAULT_LCD_CONTRAST
#define DEFAULT_LCD_CONTRAST LCD_CONTRAST_INIT
#endif
#endif
/**
* Override the SD_DETECT_STATE set in Configuration_adv.h
*/
#if ENABLED(SDSUPPORT)
#if HAS_LCD_MENU && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION))
#undef SD_DETECT_STATE
#if ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define SD_DETECT_STATE HIGH
#endif
#endif
#ifndef SD_DETECT_STATE
#define SD_DETECT_STATE LOW
#endif
#endif
/**
* Set defaults for missing (newer) options
*/
#ifndef DISABLE_INACTIVE_X
#define DISABLE_INACTIVE_X DISABLE_X
#endif
#ifndef DISABLE_INACTIVE_Y
#define DISABLE_INACTIVE_Y DISABLE_Y
#endif
#ifndef DISABLE_INACTIVE_Z
#define DISABLE_INACTIVE_Z DISABLE_Z
#endif
#ifndef DISABLE_INACTIVE_E
#define DISABLE_INACTIVE_E DISABLE_E
#endif
/**
* Power Supply
*/
#ifndef PSU_NAME
#if DISABLED(PSU_CONTROL)
#define PSU_NAME "Generic" // No control
#elif PSU_ACTIVE_HIGH
#define PSU_NAME "XBox" // X-Box 360 (203W)
#else
#define PSU_NAME "ATX" // ATX style
#endif
#endif
#if !defined(PSU_POWERUP_DELAY) && ENABLED(PSU_CONTROL)
#define PSU_POWERUP_DELAY 100
#endif
/**
* Temp Sensor defines
*/
#define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_6 == (n) || TEMP_SENSOR_7 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_PROBE == (n) || TEMP_SENSOR_CHAMBER == (n))
#define HAS_USER_THERMISTORS ANY_TEMP_SENSOR_IS(1000)
#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2
#define HEATER_0_USES_MAX6675
#if TEMP_SENSOR_0 == -3
#define HEATER_0_MAX6675_TMIN -270
#define HEATER_0_MAX6675_TMAX 1800
#else
#define HEATER_0_MAX6675_TMIN 0
#define HEATER_0_MAX6675_TMAX 1024
#endif
#if TEMP_SENSOR_0 == -5
#define MAX6675_IS_MAX31865
#elif TEMP_SENSOR_0 == -3
#define MAX6675_IS_MAX31855
#endif
#elif TEMP_SENSOR_0 == -4
#define HEATER_0_USES_AD8495
#elif TEMP_SENSOR_0 == -1
#define HEATER_0_USES_AD595
#elif TEMP_SENSOR_0 > 0
#define THERMISTOR_HEATER_0 TEMP_SENSOR_0
#define HEATER_0_USES_THERMISTOR
#if TEMP_SENSOR_0 == 1000
#define HEATER_0_USER_THERMISTOR
#endif
#else
#undef HEATER_0_MINTEMP
#undef HEATER_0_MAXTEMP
#endif
#if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2
#define HEATER_1_USES_MAX6675
#if TEMP_SENSOR_1 == -3
#define HEATER_1_MAX6675_TMIN -270
#define HEATER_1_MAX6675_TMAX 1800
#else
#define HEATER_1_MAX6675_TMIN 0
#define HEATER_1_MAX6675_TMAX 1024
#endif
#if TEMP_SENSOR_1 != TEMP_SENSOR_0
#if TEMP_SENSOR_1 == -5
#error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match."
#elif TEMP_SENSOR_1 == -3
#error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match."
#elif TEMP_SENSOR_1 == -2
#error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_1 then TEMP_SENSOR_0 must match."
#endif
#endif
#elif TEMP_SENSOR_1 == -4
#define HEATER_1_USES_AD8495
#elif TEMP_SENSOR_1 == -1
#define HEATER_1_USES_AD595
#elif TEMP_SENSOR_1 > 0
#define THERMISTOR_HEATER_1 TEMP_SENSOR_1
#define HEATER_1_USES_THERMISTOR
#if TEMP_SENSOR_1 == 1000
#define HEATER_1_USER_THERMISTOR
#endif
#else
#undef HEATER_1_MINTEMP
#undef HEATER_1_MAXTEMP
#endif
#if TEMP_SENSOR_2 == -4
#define HEATER_2_USES_AD8495
#elif TEMP_SENSOR_2 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == -1
#define HEATER_2_USES_AD595
#elif TEMP_SENSOR_2 > 0
#define THERMISTOR_HEATER_2 TEMP_SENSOR_2
#define HEATER_2_USES_THERMISTOR
#if TEMP_SENSOR_2 == 1000
#define HEATER_2_USER_THERMISTOR
#endif
#else
#undef HEATER_2_MINTEMP
#undef HEATER_2_MAXTEMP
#endif
#if TEMP_SENSOR_3 == -4
#define HEATER_3_USES_AD8495
#elif TEMP_SENSOR_3 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3."
#elif TEMP_SENSOR_3 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3."
#elif TEMP_SENSOR_3 == -1
#define HEATER_3_USES_AD595
#elif TEMP_SENSOR_3 > 0
#define THERMISTOR_HEATER_3 TEMP_SENSOR_3
#define HEATER_3_USES_THERMISTOR
#if TEMP_SENSOR_3 == 1000
#define HEATER_3_USER_THERMISTOR
#endif
#else
#undef HEATER_3_MINTEMP
#undef HEATER_3_MAXTEMP
#endif
#if TEMP_SENSOR_4 == -4
#define HEATER_4_USES_AD8495
#elif TEMP_SENSOR_4 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4."
#elif TEMP_SENSOR_4 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4."
#elif TEMP_SENSOR_4 == -1
#define HEATER_4_USES_AD595
#elif TEMP_SENSOR_4 > 0
#define THERMISTOR_HEATER_4 TEMP_SENSOR_4
#define HEATER_4_USES_THERMISTOR
#if TEMP_SENSOR_4 == 1000
#define HEATER_4_USER_THERMISTOR
#endif
#else
#undef HEATER_4_MINTEMP
#undef HEATER_4_MAXTEMP
#endif
#if TEMP_SENSOR_5 == -4
#define HEATER_5_USES_AD8495
#elif TEMP_SENSOR_5 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5."
#elif TEMP_SENSOR_5 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5."
#elif TEMP_SENSOR_5 == -1
#define HEATER_5_USES_AD595
#elif TEMP_SENSOR_5 > 0
#define THERMISTOR_HEATER_5 TEMP_SENSOR_5
#define HEATER_5_USES_THERMISTOR
#if TEMP_SENSOR_5 == 1000
#define HEATER_5_USER_THERMISTOR
#endif
#else
#undef HEATER_5_MINTEMP
#undef HEATER_5_MAXTEMP
#endif
#if TEMP_SENSOR_6 == -4
#define HEATER_6_USES_AD8495
#elif TEMP_SENSOR_6 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6."
#elif TEMP_SENSOR_6 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_6."
#elif TEMP_SENSOR_6 == -1
#define HEATER_6_USES_AD595
#elif TEMP_SENSOR_6 > 0
#define THERMISTOR_HEATER_6 TEMP_SENSOR_6
#define HEATER_6_USES_THERMISTOR
#if TEMP_SENSOR_6 == 1000
#define HEATER_6_USER_THERMISTOR
#endif
#else
#undef HEATER_6_MINTEMP
#undef HEATER_6_MAXTEMP
#endif
#if TEMP_SENSOR_7 == -4
#define HEATER_7_USES_AD8495
#elif TEMP_SENSOR_7 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7."
#elif TEMP_SENSOR_7 == -2
#error "MAX7775 Thermocouples (-2) not supported for TEMP_SENSOR_7."
#elif TEMP_SENSOR_7 == -1
#define HEATER_7_USES_AD595
#elif TEMP_SENSOR_7 > 0
#define THERMISTOR_HEATER_7 TEMP_SENSOR_7
#define HEATER_7_USES_THERMISTOR
#if TEMP_SENSOR_7 == 1000
#define HEATER_7_USER_THERMISTOR
#endif
#else
#undef HEATER_7_MINTEMP
#undef HEATER_7_MAXTEMP
#endif
#if TEMP_SENSOR_BED == -4
#define HEATER_BED_USES_AD8495
#elif TEMP_SENSOR_BED == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -1
#define HEATER_BED_USES_AD595
#elif TEMP_SENSOR_BED > 0
#define THERMISTORBED TEMP_SENSOR_BED
#define HEATER_BED_USES_THERMISTOR
#if TEMP_SENSOR_BED == 1000
#define HEATER_BED_USER_THERMISTOR
#endif
#else
#undef BED_MINTEMP
#undef BED_MAXTEMP
#endif
#if TEMP_SENSOR_CHAMBER == -4
#define HEATER_CHAMBER_USES_AD8495
#elif TEMP_SENSOR_CHAMBER == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER."
#elif TEMP_SENSOR_CHAMBER == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER."
#elif TEMP_SENSOR_CHAMBER == -1
#define HEATER_CHAMBER_USES_AD595
#elif TEMP_SENSOR_CHAMBER > 0
#define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER
#define HEATER_CHAMBER_USES_THERMISTOR
#if TEMP_SENSOR_CHAMBER == 1000
#define HEATER_CHAMBER_USER_THERMISTOR
#endif
#else
#undef CHAMBER_MINTEMP
#undef CHAMBER_MAXTEMP
#endif
#if TEMP_SENSOR_PROBE == -4
#define HEATER_PROBE_USES_AD8495
#elif TEMP_SENSOR_PROBE == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE."
#elif TEMP_SENSOR_PROBE == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_PROBE."
#elif TEMP_SENSOR_PROBE == -1
#define HEATER_PROBE_USES_AD595
#elif TEMP_SENSOR_PROBE > 0
#define THERMISTORPROBE TEMP_SENSOR_PROBE
#define PROBE_USES_THERMISTOR
#if TEMP_SENSOR_PROBE == 1000
#define PROBE_USER_THERMISTOR
#endif
#endif
#define HOTEND_USES_THERMISTOR ANY( \
HEATER_0_USES_THERMISTOR, HEATER_1_USES_THERMISTOR, HEATER_2_USES_THERMISTOR, HEATER_3_USES_THERMISTOR, \
HEATER_4_USES_THERMISTOR, HEATER_5_USES_THERMISTOR, HEATER_6_USES_THERMISTOR, HEATER_7_USES_THERMISTOR )
/**
* X_DUAL_ENDSTOPS endstop reassignment
*/
#if ENABLED(X_DUAL_ENDSTOPS)
#if X_HOME_DIR > 0
#if X2_USE_ENDSTOP == _XMIN_
#define X2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _XMAX_
#define X2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _YMIN_
#define X2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _YMAX_
#define X2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _ZMIN_
#define X2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _ZMAX_
#define X2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define X2_MAX_ENDSTOP_INVERTING false
#endif
#ifndef X2_MAX_PIN
#if X2_USE_ENDSTOP == _XMIN_
#define X2_MAX_PIN X_MIN_PIN
#elif X2_USE_ENDSTOP == _XMAX_
#define X2_MAX_PIN X_MAX_PIN
#elif X2_USE_ENDSTOP == _YMIN_
#define X2_MAX_PIN Y_MIN_PIN
#elif X2_USE_ENDSTOP == _YMAX_
#define X2_MAX_PIN Y_MAX_PIN
#elif X2_USE_ENDSTOP == _ZMIN_
#define X2_MAX_PIN Z_MIN_PIN
#elif X2_USE_ENDSTOP == _ZMAX_
#define X2_MAX_PIN Z_MAX_PIN
#elif X2_USE_ENDSTOP == _XDIAG_
#define X2_MAX_PIN X_DIAG_PIN
#elif X2_USE_ENDSTOP == _YDIAG_
#define X2_MAX_PIN Y_DIAG_PIN
#elif X2_USE_ENDSTOP == _ZDIAG_
#define X2_MAX_PIN Z_DIAG_PIN
#elif X2_USE_ENDSTOP == _E0DIAG_
#define X2_MAX_PIN E0_DIAG_PIN
#elif X2_USE_ENDSTOP == _E1DIAG_
#define X2_MAX_PIN E1_DIAG_PIN
#elif X2_USE_ENDSTOP == _E2DIAG_
#define X2_MAX_PIN E2_DIAG_PIN
#elif X2_USE_ENDSTOP == _E3DIAG_
#define X2_MAX_PIN E3_DIAG_PIN
#elif X2_USE_ENDSTOP == _E4DIAG_
#define X2_MAX_PIN E4_DIAG_PIN
#elif X2_USE_ENDSTOP == _E5DIAG_
#define X2_MAX_PIN E5_DIAG_PIN
#elif X2_USE_ENDSTOP == _E6DIAG_
#define X2_MAX_PIN E6_DIAG_PIN
#elif X2_USE_ENDSTOP == _E7DIAG_
#define X2_MAX_PIN E7_DIAG_PIN
#endif
#endif
#define X2_MIN_ENDSTOP_INVERTING false
#else
#if X2_USE_ENDSTOP == _XMIN_
#define X2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _XMAX_
#define X2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _YMIN_
#define X2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _YMAX_
#define X2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _ZMIN_
#define X2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif X2_USE_ENDSTOP == _ZMAX_
#define X2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define X2_MIN_ENDSTOP_INVERTING false
#endif
#ifndef X2_MIN_PIN
#if X2_USE_ENDSTOP == _XMIN_
#define X2_MIN_PIN X_MIN_PIN
#elif X2_USE_ENDSTOP == _XMAX_
#define X2_MIN_PIN X_MAX_PIN
#elif X2_USE_ENDSTOP == _YMIN_
#define X2_MIN_PIN Y_MIN_PIN
#elif X2_USE_ENDSTOP == _YMAX_
#define X2_MIN_PIN Y_MAX_PIN
#elif X2_USE_ENDSTOP == _ZMIN_
#define X2_MIN_PIN Z_MIN_PIN
#elif X2_USE_ENDSTOP == _ZMAX_
#define X2_MIN_PIN Z_MAX_PIN
#elif X2_USE_ENDSTOP == _XDIAG_
#define X2_MIN_PIN X_DIAG_PIN
#elif X2_USE_ENDSTOP == _YDIAG_
#define X2_MIN_PIN Y_DIAG_PIN
#elif X2_USE_ENDSTOP == _ZDIAG_
#define X2_MIN_PIN Z_DIAG_PIN
#elif X2_USE_ENDSTOP == _E0DIAG_
#define X2_MIN_PIN E0_DIAG_PIN
#elif X2_USE_ENDSTOP == _E1DIAG_
#define X2_MIN_PIN E1_DIAG_PIN
#elif X2_USE_ENDSTOP == _E2DIAG_
#define X2_MIN_PIN E2_DIAG_PIN
#elif X2_USE_ENDSTOP == _E3DIAG_
#define X2_MIN_PIN E3_DIAG_PIN
#elif X2_USE_ENDSTOP == _E4DIAG_
#define X2_MIN_PIN E4_DIAG_PIN
#elif X2_USE_ENDSTOP == _E5DIAG_
#define X2_MIN_PIN E5_DIAG_PIN
#elif X2_USE_ENDSTOP == _E6DIAG_
#define X2_MIN_PIN E6_DIAG_PIN
#elif X2_USE_ENDSTOP == _E7DIAG_
#define X2_MIN_PIN E7_DIAG_PIN
#endif
#endif
#define X2_MAX_ENDSTOP_INVERTING false
#endif
#endif
/**
* Y_DUAL_ENDSTOPS endstop reassignment
*/
#if ENABLED(Y_DUAL_ENDSTOPS)
#if Y_HOME_DIR > 0
#if Y2_USE_ENDSTOP == _XMIN_
#define Y2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _XMAX_
#define Y2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _YMIN_
#define Y2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _YMAX_
#define Y2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _ZMIN_
#define Y2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _ZMAX_
#define Y2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define Y2_MAX_ENDSTOP_INVERTING false
#endif
#ifndef Y2_MAX_PIN
#if Y2_USE_ENDSTOP == _XMIN_
#define Y2_MAX_PIN X_MIN_PIN
#elif Y2_USE_ENDSTOP == _XMAX_
#define Y2_MAX_PIN X_MAX_PIN
#elif Y2_USE_ENDSTOP == _YMIN_
#define Y2_MAX_PIN Y_MIN_PIN
#elif Y2_USE_ENDSTOP == _YMAX_
#define Y2_MAX_PIN Y_MAX_PIN
#elif Y2_USE_ENDSTOP == _ZMIN_
#define Y2_MAX_PIN Z_MIN_PIN
#elif Y2_USE_ENDSTOP == _ZMAX_
#define Y2_MAX_PIN Z_MAX_PIN
#elif Y2_USE_ENDSTOP == _XDIAG_
#define Y2_MAX_PIN X_DIAG_PIN
#elif Y2_USE_ENDSTOP == _YDIAG_
#define Y2_MAX_PIN Y_DIAG_PIN
#elif Y2_USE_ENDSTOP == _ZDIAG_
#define Y2_MAX_PIN Z_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E0DIAG_
#define Y2_MAX_PIN E0_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E1DIAG_
#define Y2_MAX_PIN E1_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E2DIAG_
#define Y2_MAX_PIN E2_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E3DIAG_
#define Y2_MAX_PIN E3_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E4DIAG_
#define Y2_MAX_PIN E4_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E5DIAG_
#define Y2_MAX_PIN E5_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E6DIAG_
#define Y2_MAX_PIN E6_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E7DIAG_
#define Y2_MAX_PIN E7_DIAG_PIN
#endif
#endif
#define Y2_MIN_ENDSTOP_INVERTING false
#else
#if Y2_USE_ENDSTOP == _XMIN_
#define Y2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _XMAX_
#define Y2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _YMIN_
#define Y2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _YMAX_
#define Y2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _ZMIN_
#define Y2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif Y2_USE_ENDSTOP == _ZMAX_
#define Y2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define Y2_MIN_ENDSTOP_INVERTING false
#endif
#ifndef Y2_MIN_PIN
#if Y2_USE_ENDSTOP == _XMIN_
#define Y2_MIN_PIN X_MIN_PIN
#elif Y2_USE_ENDSTOP == _XMAX_
#define Y2_MIN_PIN X_MAX_PIN
#elif Y2_USE_ENDSTOP == _YMIN_
#define Y2_MIN_PIN Y_MIN_PIN
#elif Y2_USE_ENDSTOP == _YMAX_
#define Y2_MIN_PIN Y_MAX_PIN
#elif Y2_USE_ENDSTOP == _ZMIN_
#define Y2_MIN_PIN Z_MIN_PIN
#elif Y2_USE_ENDSTOP == _ZMAX_
#define Y2_MIN_PIN Z_MAX_PIN
#elif Y2_USE_ENDSTOP == _XDIAG_
#define Y2_MIN_PIN X_DIAG_PIN
#elif Y2_USE_ENDSTOP == _YDIAG_
#define Y2_MIN_PIN Y_DIAG_PIN
#elif Y2_USE_ENDSTOP == _ZDIAG_
#define Y2_MIN_PIN Z_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E0DIAG_
#define Y2_MIN_PIN E0_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E1DIAG_
#define Y2_MIN_PIN E1_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E2DIAG_
#define Y2_MIN_PIN E2_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E3DIAG_
#define Y2_MIN_PIN E3_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E4DIAG_
#define Y2_MIN_PIN E4_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E5DIAG_
#define Y2_MIN_PIN E5_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E6DIAG_
#define Y2_MIN_PIN E6_DIAG_PIN
#elif Y2_USE_ENDSTOP == _E7DIAG_
#define Y2_MIN_PIN E7_DIAG_PIN
#endif
#endif
#define Y2_MAX_ENDSTOP_INVERTING false
#endif
#endif
/**
* Z_MULTI_ENDSTOPS endstop reassignment
*/
#if ENABLED(Z_MULTI_ENDSTOPS)
#if Z_HOME_DIR > 0
#if Z2_USE_ENDSTOP == _XMIN_
#define Z2_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _XMAX_
#define Z2_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _YMIN_
#define Z2_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _YMAX_
#define Z2_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _ZMIN_
#define Z2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _ZMAX_
#define Z2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define Z2_MAX_ENDSTOP_INVERTING false
#endif
#ifndef Z2_MAX_PIN
#if Z2_USE_ENDSTOP == _XMIN_
#define Z2_MAX_PIN X_MIN_PIN
#elif Z2_USE_ENDSTOP == _XMAX_
#define Z2_MAX_PIN X_MAX_PIN
#elif Z2_USE_ENDSTOP == _YMIN_
#define Z2_MAX_PIN Y_MIN_PIN
#elif Z2_USE_ENDSTOP == _YMAX_
#define Z2_MAX_PIN Y_MAX_PIN
#elif Z2_USE_ENDSTOP == _ZMIN_
#define Z2_MAX_PIN Z_MIN_PIN
#elif Z2_USE_ENDSTOP == _ZMAX_
#define Z2_MAX_PIN Z_MAX_PIN
#elif Z2_USE_ENDSTOP == _XDIAG_
#define Z2_MAX_PIN X_DIAG_PIN
#elif Z2_USE_ENDSTOP == _YDIAG_
#define Z2_MAX_PIN Y_DIAG_PIN
#elif Z2_USE_ENDSTOP == _ZDIAG_
#define Z2_MAX_PIN Z_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E0DIAG_
#define Z2_MAX_PIN E0_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E1DIAG_
#define Z2_MAX_PIN E1_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E2DIAG_
#define Z2_MAX_PIN E2_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E3DIAG_
#define Z2_MAX_PIN E3_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E4DIAG_
#define Z2_MAX_PIN E4_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E5DIAG_
#define Z2_MAX_PIN E5_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E6DIAG_
#define Z2_MAX_PIN E6_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E7DIAG_
#define Z2_MAX_PIN E7_DIAG_PIN
#endif
#endif
#define Z2_MIN_ENDSTOP_INVERTING false
#else
#if Z2_USE_ENDSTOP == _XMIN_
#define Z2_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _XMAX_
#define Z2_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _YMIN_
#define Z2_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _YMAX_
#define Z2_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _ZMIN_
#define Z2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif Z2_USE_ENDSTOP == _ZMAX_
#define Z2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define Z2_MIN_ENDSTOP_INVERTING false
#endif
#ifndef Z2_MIN_PIN
#if Z2_USE_ENDSTOP == _XMIN_
#define Z2_MIN_PIN X_MIN_PIN
#elif Z2_USE_ENDSTOP == _XMAX_
#define Z2_MIN_PIN X_MAX_PIN
#elif Z2_USE_ENDSTOP == _YMIN_
#define Z2_MIN_PIN Y_MIN_PIN
#elif Z2_USE_ENDSTOP == _YMAX_
#define Z2_MIN_PIN Y_MAX_PIN
#elif Z2_USE_ENDSTOP == _ZMIN_
#define Z2_MIN_PIN Z_MIN_PIN
#elif Z2_USE_ENDSTOP == _ZMAX_
#define Z2_MIN_PIN Z_MAX_PIN
#elif Z2_USE_ENDSTOP == _XDIAG_
#define Z2_MIN_PIN X_DIAG_PIN
#elif Z2_USE_ENDSTOP == _YDIAG_
#define Z2_MIN_PIN Y_DIAG_PIN
#elif Z2_USE_ENDSTOP == _ZDIAG_
#define Z2_MIN_PIN Z_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E0DIAG_
#define Z2_MIN_PIN E0_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E1DIAG_
#define Z2_MIN_PIN E1_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E2DIAG_
#define Z2_MIN_PIN E2_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E3DIAG_
#define Z2_MIN_PIN E3_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E4DIAG_
#define Z2_MIN_PIN E4_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E5DIAG_
#define Z2_MIN_PIN E5_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E6DIAG_
#define Z2_MIN_PIN E6_DIAG_PIN
#elif Z2_USE_ENDSTOP == _E7DIAG_
#define Z2_MIN_PIN E7_DIAG_PIN
#endif
#endif
#define Z2_MAX_ENDSTOP_INVERTING false
#endif
#if NUM_Z_STEPPER_DRIVERS >= 3
#if Z_HOME_DIR > 0
#if Z3_USE_ENDSTOP == _XMIN_
#define Z3_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _XMAX_
#define Z3_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _YMIN_
#define Z3_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _YMAX_
#define Z3_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _ZMIN_
#define Z3_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _ZMAX_
#define Z3_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define Z3_MAX_ENDSTOP_INVERTING false
#endif
#ifndef Z3_MAX_PIN
#if Z3_USE_ENDSTOP == _XMIN_
#define Z3_MAX_PIN X_MIN_PIN
#elif Z3_USE_ENDSTOP == _XMAX_
#define Z3_MAX_PIN X_MAX_PIN
#elif Z3_USE_ENDSTOP == _YMIN_
#define Z3_MAX_PIN Y_MIN_PIN
#elif Z3_USE_ENDSTOP == _YMAX_
#define Z3_MAX_PIN Y_MAX_PIN
#elif Z3_USE_ENDSTOP == _ZMIN_
#define Z3_MAX_PIN Z_MIN_PIN
#elif Z3_USE_ENDSTOP == _ZMAX_
#define Z3_MAX_PIN Z_MAX_PIN
#elif Z3_USE_ENDSTOP == _XDIAG_
#define Z3_MAX_PIN X_DIAG_PIN
#elif Z3_USE_ENDSTOP == _YDIAG_
#define Z3_MAX_PIN Y_DIAG_PIN
#elif Z3_USE_ENDSTOP == _ZDIAG_
#define Z3_MAX_PIN Z_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E0DIAG_
#define Z3_MAX_PIN E0_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E1DIAG_
#define Z3_MAX_PIN E1_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E2DIAG_
#define Z3_MAX_PIN E2_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E3DIAG_
#define Z3_MAX_PIN E3_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E4DIAG_
#define Z3_MAX_PIN E4_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E5DIAG_
#define Z3_MAX_PIN E5_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E6DIAG_
#define Z3_MAX_PIN E6_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E7DIAG_
#define Z3_MAX_PIN E7_DIAG_PIN
#endif
#endif
#define Z3_MIN_ENDSTOP_INVERTING false
#else
#if Z3_USE_ENDSTOP == _XMIN_
#define Z3_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _XMAX_
#define Z3_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _YMIN_
#define Z3_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _YMAX_
#define Z3_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _ZMIN_
#define Z3_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif Z3_USE_ENDSTOP == _ZMAX_
#define Z3_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define Z3_MIN_ENDSTOP_INVERTING false
#endif
#ifndef Z3_MIN_PIN
#if Z3_USE_ENDSTOP == _XMIN_
#define Z3_MIN_PIN X_MIN_PIN
#elif Z3_USE_ENDSTOP == _XMAX_
#define Z3_MIN_PIN X_MAX_PIN
#elif Z3_USE_ENDSTOP == _YMIN_
#define Z3_MIN_PIN Y_MIN_PIN
#elif Z3_USE_ENDSTOP == _YMAX_
#define Z3_MIN_PIN Y_MAX_PIN
#elif Z3_USE_ENDSTOP == _ZMIN_
#define Z3_MIN_PIN Z_MIN_PIN
#elif Z3_USE_ENDSTOP == _ZMAX_
#define Z3_MIN_PIN Z_MAX_PIN
#elif Z3_USE_ENDSTOP == _XDIAG_
#define Z3_MIN_PIN X_DIAG_PIN
#elif Z3_USE_ENDSTOP == _YDIAG_
#define Z3_MIN_PIN Y_DIAG_PIN
#elif Z3_USE_ENDSTOP == _ZDIAG_
#define Z3_MIN_PIN Z_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E0DIAG_
#define Z3_MIN_PIN E0_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E1DIAG_
#define Z3_MIN_PIN E1_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E2DIAG_
#define Z3_MIN_PIN E2_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E3DIAG_
#define Z3_MIN_PIN E3_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E4DIAG_
#define Z3_MIN_PIN E4_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E5DIAG_
#define Z3_MIN_PIN E5_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E6DIAG_
#define Z3_MIN_PIN E6_DIAG_PIN
#elif Z3_USE_ENDSTOP == _E7DIAG_
#define Z3_MIN_PIN E7_DIAG_PIN
#endif
#endif
#define Z3_MAX_ENDSTOP_INVERTING false
#endif
#endif
#if NUM_Z_STEPPER_DRIVERS >= 4
#if Z_HOME_DIR > 0
#if Z4_USE_ENDSTOP == _XMIN_
#define Z4_MAX_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _XMAX_
#define Z4_MAX_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _YMIN_
#define Z4_MAX_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _YMAX_
#define Z4_MAX_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _ZMIN_
#define Z4_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _ZMAX_
#define Z4_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define Z4_MAX_ENDSTOP_INVERTING false
#endif
#ifndef Z4_MAX_PIN
#if Z4_USE_ENDSTOP == _XMIN_
#define Z4_MAX_PIN X_MIN_PIN
#elif Z4_USE_ENDSTOP == _XMAX_
#define Z4_MAX_PIN X_MAX_PIN
#elif Z4_USE_ENDSTOP == _YMIN_
#define Z4_MAX_PIN Y_MIN_PIN
#elif Z4_USE_ENDSTOP == _YMAX_
#define Z4_MAX_PIN Y_MAX_PIN
#elif Z4_USE_ENDSTOP == _ZMIN_
#define Z4_MAX_PIN Z_MIN_PIN
#elif Z4_USE_ENDSTOP == _ZMAX_
#define Z4_MAX_PIN Z_MAX_PIN
#elif Z4_USE_ENDSTOP == _XDIAG_
#define Z4_MAX_PIN X_DIAG_PIN
#elif Z4_USE_ENDSTOP == _YDIAG_
#define Z4_MAX_PIN Y_DIAG_PIN
#elif Z4_USE_ENDSTOP == _ZDIAG_
#define Z4_MAX_PIN Z_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E0DIAG_
#define Z4_MAX_PIN E0_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E1DIAG_
#define Z4_MAX_PIN E1_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E2DIAG_
#define Z4_MAX_PIN E2_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E3DIAG_
#define Z4_MAX_PIN E3_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E4DIAG_
#define Z4_MAX_PIN E4_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E5DIAG_
#define Z4_MAX_PIN E5_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E6DIAG_
#define Z4_MAX_PIN E6_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E7DIAG_
#define Z4_MAX_PIN E7_DIAG_PIN
#endif
#endif
#define Z4_MIN_ENDSTOP_INVERTING false
#else
#if Z4_USE_ENDSTOP == _XMIN_
#define Z4_MIN_ENDSTOP_INVERTING X_MIN_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _XMAX_
#define Z4_MIN_ENDSTOP_INVERTING X_MAX_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _YMIN_
#define Z4_MIN_ENDSTOP_INVERTING Y_MIN_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _YMAX_
#define Z4_MIN_ENDSTOP_INVERTING Y_MAX_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _ZMIN_
#define Z4_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING
#elif Z4_USE_ENDSTOP == _ZMAX_
#define Z4_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING
#else
#define Z4_MIN_ENDSTOP_INVERTING false
#endif
#ifndef Z4_MIN_PIN
#if Z4_USE_ENDSTOP == _XMIN_
#define Z4_MIN_PIN X_MIN_PIN
#elif Z4_USE_ENDSTOP == _XMAX_
#define Z4_MIN_PIN X_MAX_PIN
#elif Z4_USE_ENDSTOP == _YMIN_
#define Z4_MIN_PIN Y_MIN_PIN
#elif Z4_USE_ENDSTOP == _YMAX_
#define Z4_MIN_PIN Y_MAX_PIN
#elif Z4_USE_ENDSTOP == _ZMIN_
#define Z4_MIN_PIN Z_MIN_PIN
#elif Z4_USE_ENDSTOP == _ZMAX_
#define Z4_MIN_PIN Z_MAX_PIN
#elif Z4_USE_ENDSTOP == _XDIAG_
#define Z4_MIN_PIN X_DIAG_PIN
#elif Z4_USE_ENDSTOP == _YDIAG_
#define Z4_MIN_PIN Y_DIAG_PIN
#elif Z4_USE_ENDSTOP == _ZDIAG_
#define Z4_MIN_PIN Z_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E0DIAG_
#define Z4_MIN_PIN E0_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E1DIAG_
#define Z4_MIN_PIN E1_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E2DIAG_
#define Z4_MIN_PIN E2_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E3DIAG_
#define Z4_MIN_PIN E3_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E4DIAG_
#define Z4_MIN_PIN E4_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E5DIAG_
#define Z4_MIN_PIN E5_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E6DIAG_
#define Z4_MIN_PIN E6_DIAG_PIN
#elif Z4_USE_ENDSTOP == _E7DIAG_
#define Z4_MIN_PIN E7_DIAG_PIN
#endif
#endif
#define Z4_MAX_ENDSTOP_INVERTING false
#endif
#endif
#endif // Z_MULTI_ENDSTOPS
/**
* Set ENDSTOPPULLUPS for active endstop switches
*/
#if ENABLED(ENDSTOPPULLUPS)
#if ENABLED(USE_XMAX_PLUG)
#define ENDSTOPPULLUP_XMAX
#endif
#if ENABLED(USE_YMAX_PLUG)
#define ENDSTOPPULLUP_YMAX
#endif
#if ENABLED(USE_ZMAX_PLUG)
#define ENDSTOPPULLUP_ZMAX
#endif
#if ENABLED(USE_XMIN_PLUG)
#define ENDSTOPPULLUP_XMIN
#endif
#if ENABLED(USE_YMIN_PLUG)
#define ENDSTOPPULLUP_YMIN
#endif
#if ENABLED(USE_ZMIN_PLUG)
#define ENDSTOPPULLUP_ZMIN
#endif
#endif
/**
* Set ENDSTOPPULLDOWNS for active endstop switches
*/
#if ENABLED(ENDSTOPPULLDOWNS)
#if ENABLED(USE_XMAX_PLUG)
#define ENDSTOPPULLDOWN_XMAX
#endif
#if ENABLED(USE_YMAX_PLUG)
#define ENDSTOPPULLDOWN_YMAX
#endif
#if ENABLED(USE_ZMAX_PLUG)
#define ENDSTOPPULLDOWN_ZMAX
#endif
#if ENABLED(USE_XMIN_PLUG)
#define ENDSTOPPULLDOWN_XMIN
#endif
#if ENABLED(USE_YMIN_PLUG)
#define ENDSTOPPULLDOWN_YMIN
#endif
#if ENABLED(USE_ZMIN_PLUG)
#define ENDSTOPPULLDOWN_ZMIN
#endif
#endif
/**
* Shorthand for pin tests, used wherever needed
*/
// Steppers
#define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X)))
#define HAS_X_DIR (PIN_EXISTS(X_DIR))
#define HAS_X_STEP (PIN_EXISTS(X_STEP))
#define HAS_X_MICROSTEPS (PIN_EXISTS(X_MS1))
#define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)))
#define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
#define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
#define HAS_X2_MICROSTEPS (PIN_EXISTS(X2_MS1))
#define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)))
#define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
#define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
#define HAS_Y_MICROSTEPS (PIN_EXISTS(Y_MS1))
#define HAS_Y2_ENABLE (PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)))
#define HAS_Y2_DIR (PIN_EXISTS(Y2_DIR))
#define HAS_Y2_STEP (PIN_EXISTS(Y2_STEP))
#define HAS_Y2_MICROSTEPS (PIN_EXISTS(Y2_MS1))
#define HAS_Z_ENABLE (PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)))
#define HAS_Z_DIR (PIN_EXISTS(Z_DIR))
#define HAS_Z_STEP (PIN_EXISTS(Z_STEP))
#define HAS_Z_MICROSTEPS (PIN_EXISTS(Z_MS1))
#define HAS_Z2_ENABLE (PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)))
#define HAS_Z2_DIR (PIN_EXISTS(Z2_DIR))
#define HAS_Z2_STEP (PIN_EXISTS(Z2_STEP))
#define HAS_Z2_MICROSTEPS (PIN_EXISTS(Z2_MS1))
#define HAS_Z3_ENABLE (PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)))
#define HAS_Z3_DIR (PIN_EXISTS(Z3_DIR))
#define HAS_Z3_STEP (PIN_EXISTS(Z3_STEP))
#define HAS_Z3_MICROSTEPS (PIN_EXISTS(Z3_MS1))
#define HAS_Z4_ENABLE (PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)))
#define HAS_Z4_DIR (PIN_EXISTS(Z4_DIR))
#define HAS_Z4_STEP (PIN_EXISTS(Z4_STEP))
#define HAS_Z4_MICROSTEPS (PIN_EXISTS(Z4_MS1))
// Extruder steppers and solenoids
#define HAS_E0_ENABLE (PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)))
#define HAS_E0_DIR (PIN_EXISTS(E0_DIR))
#define HAS_E0_STEP (PIN_EXISTS(E0_STEP))
#define HAS_E0_MICROSTEPS (PIN_EXISTS(E0_MS1))
#define HAS_SOLENOID_0 (PIN_EXISTS(SOL0))
#define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)))
#define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
#define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
#define HAS_E1_MICROSTEPS (PIN_EXISTS(E1_MS1))
#define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
#define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)))
#define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
#define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
#define HAS_E2_MICROSTEPS (PIN_EXISTS(E2_MS1))
#define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
#define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)))
#define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
#define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
#define HAS_E3_MICROSTEPS (PIN_EXISTS(E3_MS1))
#define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
#define HAS_E4_ENABLE (PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)))
#define HAS_E4_DIR (PIN_EXISTS(E4_DIR))
#define HAS_E4_STEP (PIN_EXISTS(E4_STEP))
#define HAS_E4_MICROSTEPS (PIN_EXISTS(E4_MS1))
#define HAS_SOLENOID_4 (PIN_EXISTS(SOL4))
#define HAS_E5_ENABLE (PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)))
#define HAS_E5_DIR (PIN_EXISTS(E5_DIR))
#define HAS_E5_STEP (PIN_EXISTS(E5_STEP))
#define HAS_E5_MICROSTEPS (PIN_EXISTS(E5_MS1))
#define HAS_SOLENOID_5 (PIN_EXISTS(SOL5))
#define HAS_E6_ENABLE (PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)))
#define HAS_E6_DIR (PIN_EXISTS(E6_DIR))
#define HAS_E6_STEP (PIN_EXISTS(E6_STEP))
#define HAS_E6_MICROSTEPS (PIN_EXISTS(E6_MS1))
#define HAS_SOLENOID_6 (PIN_EXISTS(SOL6))
#define HAS_E7_ENABLE (PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)))
#define HAS_E7_DIR (PIN_EXISTS(E7_DIR))
#define HAS_E7_STEP (PIN_EXISTS(E7_STEP))
#define HAS_E7_MICROSTEPS (PIN_EXISTS(E7_MS1))
#define HAS_SOLENOID_7 (PIN_EXISTS(SOL7))
// Trinamic Stepper Drivers
#if HAS_TRINAMIC_CONFIG
#if ANY(STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_E)
#define STEALTHCHOP_ENABLED 1
#endif
#if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING)
#define USE_SENSORLESS 1
#endif
// Disable Z axis sensorless homing if a probe is used to home the Z axis
#if HOMING_Z_WITH_PROBE
#undef Z_STALL_SENSITIVITY
#endif
#if defined(X_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X)
#define X_SENSORLESS 1
#endif
#if defined(X2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2)
#define X2_SENSORLESS 1
#endif
#if defined(Y_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y)
#define Y_SENSORLESS 1
#endif
#if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2)
#define Y2_SENSORLESS 1
#endif
#if defined(Z_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z)
#define Z_SENSORLESS 1
#endif
#if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2)
#define Z2_SENSORLESS 1
#endif
#if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3)
#define Z3_SENSORLESS 1
#endif
#if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4)
#define Z4_SENSORLESS 1
#endif
#if ENABLED(SPI_ENDSTOPS)
#define X_SPI_SENSORLESS X_SENSORLESS
#define Y_SPI_SENSORLESS Y_SENSORLESS
#define Z_SPI_SENSORLESS Z_SENSORLESS
#endif
#endif
#define HAS_E_STEPPER_ENABLE (HAS_E_DRIVER(TMC2660) \
|| ( E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != X_ENABLE_PIN \
&& E0_ENABLE_PIN != Y_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN ) \
)
//
// Endstops and bed probe
//
// Is an endstop plug used for extra Z endstops or the probe?
#define IS_PROBE_PIN(A,M) (HAS_CUSTOM_PROBE_PIN && Z_MIN_PROBE_PIN == P)
#define IS_X2_ENDSTOP(A,M) (ENABLED(X_DUAL_ENDSTOPS) && X2_USE_ENDSTOP == _##A##M##_)
#define IS_Y2_ENDSTOP(A,M) (ENABLED(Y_DUAL_ENDSTOPS) && Y2_USE_ENDSTOP == _##A##M##_)
#define IS_Z2_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_)
#define IS_Z3_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && Z3_USE_ENDSTOP == _##A##M##_)
#define IS_Z4_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && Z4_USE_ENDSTOP == _##A##M##_)
#define _HAS_STOP(A,M) (PIN_EXISTS(A##_##M) && !IS_PROBE_PIN(A,M) && !IS_X2_ENDSTOP(A,M) && !IS_Y2_ENDSTOP(A,M) && !IS_Z2_ENDSTOP(A,M) && !IS_Z3_ENDSTOP(A,M) && !IS_Z4_ENDSTOP(A,M))
#define HAS_X_MIN _HAS_STOP(X,MIN)
#define HAS_X_MAX _HAS_STOP(X,MAX)
#define HAS_Y_MIN _HAS_STOP(Y,MIN)
#define HAS_Y_MAX _HAS_STOP(Y,MAX)
#define HAS_Z_MIN _HAS_STOP(Z,MIN)
#define HAS_Z_MAX _HAS_STOP(Z,MAX)
#define HAS_X2_MIN (PIN_EXISTS(X2_MIN))
#define HAS_X2_MAX (PIN_EXISTS(X2_MAX))
#define HAS_Y2_MIN (PIN_EXISTS(Y2_MIN))
#define HAS_Y2_MAX (PIN_EXISTS(Y2_MAX))
#define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
#define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
#define HAS_Z3_MIN (PIN_EXISTS(Z3_MIN))
#define HAS_Z3_MAX (PIN_EXISTS(Z3_MAX))
#define HAS_Z4_MIN (PIN_EXISTS(Z4_MIN))
#define HAS_Z4_MAX (PIN_EXISTS(Z4_MAX))
#define HAS_Z_MIN_PROBE_PIN (HAS_CUSTOM_PROBE_PIN && PIN_EXISTS(Z_MIN_PROBE))
//
// ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
//
#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && DISABLED(HEATER_##P##_USES_MAX6675))
#define HAS_TEMP_ADC_0 HAS_ADC_TEST(0)
#define HAS_TEMP_ADC_1 HAS_ADC_TEST(1)
#define HAS_TEMP_ADC_2 HAS_ADC_TEST(2)
#define HAS_TEMP_ADC_3 HAS_ADC_TEST(3)
#define HAS_TEMP_ADC_4 HAS_ADC_TEST(4)
#define HAS_TEMP_ADC_5 HAS_ADC_TEST(5)
#define HAS_TEMP_ADC_6 HAS_ADC_TEST(6)
#define HAS_TEMP_ADC_7 HAS_ADC_TEST(7)
#define HAS_TEMP_ADC_BED HAS_ADC_TEST(BED)
#define HAS_TEMP_ADC_PROBE HAS_ADC_TEST(PROBE)
#define HAS_TEMP_ADC_CHAMBER HAS_ADC_TEST(CHAMBER)
#define HAS_TEMP_HOTEND ((HAS_TEMP_ADC_0 || ENABLED(HEATER_0_USES_MAX6675)) && HOTENDS)
#define HAS_TEMP_BED HAS_TEMP_ADC_BED
#define HAS_TEMP_PROBE HAS_TEMP_ADC_PROBE
#define HAS_TEMP_CHAMBER HAS_TEMP_ADC_CHAMBER
#if ENABLED(JOYSTICK)
#define HAS_JOY_ADC_X PIN_EXISTS(JOY_X)
#define HAS_JOY_ADC_Y PIN_EXISTS(JOY_Y)
#define HAS_JOY_ADC_Z PIN_EXISTS(JOY_Z)
#define HAS_JOY_ADC_EN PIN_EXISTS(JOY_EN)
#endif
// Heaters
#define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
#define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
#define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
#define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
#define HAS_HEATER_4 (PIN_EXISTS(HEATER_4))
#define HAS_HEATER_5 (PIN_EXISTS(HEATER_5))
#define HAS_HEATER_6 (PIN_EXISTS(HEATER_6))
#define HAS_HEATER_7 (PIN_EXISTS(HEATER_7))
#define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
// Shorthand for common combinations
#if HAS_TEMP_BED && HAS_HEATER_BED
#define HAS_HEATED_BED 1
#endif
#if HAS_HEATED_BED || HAS_TEMP_CHAMBER
#define BED_OR_CHAMBER 1
#endif
#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE
#define HAS_TEMP_SENSOR 1
#endif
#if HAS_TEMP_CHAMBER && PIN_EXISTS(HEATER_CHAMBER)
#define HAS_HEATED_CHAMBER 1
#endif
// PID heating
#if !HAS_HEATED_BED
#undef PIDTEMPBED
#endif
#if EITHER(PIDTEMP, PIDTEMPBED)
#define HAS_PID_HEATING 1
#endif
#if BOTH(PIDTEMP, PIDTEMPBED)
#define HAS_PID_FOR_BOTH 1
#endif
// Thermal protection
#if HAS_HEATED_BED && ENABLED(THERMAL_PROTECTION_BED)
#define HAS_THERMALLY_PROTECTED_BED 1
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
#define WATCH_HOTENDS 1
#endif
#if HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0
#define WATCH_BED 1
#endif
#if HAS_HEATED_CHAMBER && ENABLED(THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0
#define WATCH_CHAMBER 1
#endif
#if (ENABLED(THERMAL_PROTECTION_HOTENDS) || !EXTRUDERS) \
&& (ENABLED(THERMAL_PROTECTION_BED) || !HAS_HEATED_BED) \
&& (ENABLED(THERMAL_PROTECTION_CHAMBER) || !HAS_HEATED_CHAMBER)
#define THERMALLY_SAFE 1
#endif
// Auto fans
#define HAS_AUTO_FAN_0 (HOTENDS > 0 && PIN_EXISTS(E0_AUTO_FAN))
#define HAS_AUTO_FAN_1 (HOTENDS > 1 && PIN_EXISTS(E1_AUTO_FAN))
#define HAS_AUTO_FAN_2 (HOTENDS > 2 && PIN_EXISTS(E2_AUTO_FAN))
#define HAS_AUTO_FAN_3 (HOTENDS > 3 && PIN_EXISTS(E3_AUTO_FAN))
#define HAS_AUTO_FAN_4 (HOTENDS > 4 && PIN_EXISTS(E4_AUTO_FAN))
#define HAS_AUTO_FAN_5 (HOTENDS > 5 && PIN_EXISTS(E5_AUTO_FAN))
#define HAS_AUTO_FAN_6 (HOTENDS > 6 && PIN_EXISTS(E6_AUTO_FAN))
#define HAS_AUTO_FAN_7 (HOTENDS > 7 && PIN_EXISTS(E7_AUTO_FAN))
#define HAS_AUTO_CHAMBER_FAN (HAS_TEMP_CHAMBER && PIN_EXISTS(CHAMBER_AUTO_FAN))
#define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3 || HAS_AUTO_FAN_4 || HAS_AUTO_FAN_5 || HAS_AUTO_FAN_6 || HAS_AUTO_FAN_7 || HAS_AUTO_CHAMBER_FAN)
#define _FANOVERLAP(A,B) (A##_AUTO_FAN_PIN == E##B##_AUTO_FAN_PIN)
#if HAS_AUTO_FAN
#define AUTO_CHAMBER_IS_E (_FANOVERLAP(CHAMBER,0) || _FANOVERLAP(CHAMBER,1) || _FANOVERLAP(CHAMBER,2) || _FANOVERLAP(CHAMBER,3) || _FANOVERLAP(CHAMBER,4) || _FANOVERLAP(CHAMBER,5) || _FANOVERLAP(CHAMBER,6) || _FANOVERLAP(CHAMBER,7))
#endif
#if !HAS_TEMP_SENSOR
#undef AUTO_REPORT_TEMPERATURES
#endif
#define HAS_AUTO_REPORTING EITHER(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS)
#if !HAS_AUTO_CHAMBER_FAN || AUTO_CHAMBER_IS_E
#undef AUTO_POWER_CHAMBER_FAN
#endif
// Other fans
#define HAS_FAN0 (PIN_EXISTS(FAN))
#define _HAS_FAN(P) (PIN_EXISTS(FAN##P) && CONTROLLER_FAN_PIN != FAN##P##_PIN && E0_AUTO_FAN_PIN != FAN##P##_PIN && E1_AUTO_FAN_PIN != FAN##P##_PIN && E2_AUTO_FAN_PIN != FAN##P##_PIN && E3_AUTO_FAN_PIN != FAN##P##_PIN && E4_AUTO_FAN_PIN != FAN##P##_PIN && E5_AUTO_FAN_PIN != FAN##P##_PIN && E6_AUTO_FAN_PIN != FAN##P##_PIN && E7_AUTO_FAN_PIN != FAN##P##_PIN)
#define HAS_FAN1 _HAS_FAN(1)
#define HAS_FAN2 _HAS_FAN(2)
#define HAS_FAN3 _HAS_FAN(3)
#define HAS_FAN4 _HAS_FAN(4)
#define HAS_FAN5 _HAS_FAN(5)
#define HAS_FAN6 _HAS_FAN(6)
#define HAS_FAN7 _HAS_FAN(7)
#define HAS_CONTROLLER_FAN (PIN_EXISTS(CONTROLLER_FAN))
// Servos
#define HAS_SERVO_0 (PIN_EXISTS(SERVO0) && NUM_SERVOS > 0)
#define HAS_SERVO_1 (PIN_EXISTS(SERVO1) && NUM_SERVOS > 1)
#define HAS_SERVO_2 (PIN_EXISTS(SERVO2) && NUM_SERVOS > 2)
#define HAS_SERVO_3 (PIN_EXISTS(SERVO3) && NUM_SERVOS > 3)
#define HAS_SERVOS (NUM_SERVOS > 0)
// Sensors
#define HAS_FILAMENT_WIDTH_SENSOR (PIN_EXISTS(FILWIDTH))
// User Interface
#if PIN_EXISTS(HOME)
#define HAS_HOME 1
#endif
#if PIN_EXISTS(KILL)
#define HAS_KILL 1
#endif
#if PIN_EXISTS(SUICIDE)
#define HAS_SUICIDE 1
#endif
#if PIN_EXISTS(PHOTOGRAPH)
#define HAS_PHOTOGRAPH 1
#endif
#if PIN_EXISTS(BEEPER) || EITHER(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
#define HAS_BUZZER 1
#endif
#if HAS_BUZZER && DISABLED(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
#define USE_BEEPER 1
#endif
#if PIN_EXISTS(CASE_LIGHT) && ENABLED(CASE_LIGHT_ENABLE)
#define HAS_CASE_LIGHT 1
#endif
// Digital control
#if PIN_EXISTS(STEPPER_RESET)
#define HAS_STEPPER_RESET 1
#endif
#if PIN_EXISTS(DIGIPOTSS)
#define HAS_DIGIPOTSS 1
#endif
#if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_E)
#define HAS_MOTOR_CURRENT_PWM 1
#endif
#if HAS_Z_MICROSTEPS || HAS_Z2_MICROSTEPS || HAS_Z3_MICROSTEPS || HAS_Z4_MICROSTEPS
#define HAS_SOME_Z_MICROSTEPS 1
#endif
#if HAS_E0_MICROSTEPS || HAS_E1_MICROSTEPS || HAS_E2_MICROSTEPS || HAS_E3_MICROSTEPS || HAS_E4_MICROSTEPS || HAS_E5_MICROSTEPS || HAS_E6_MICROSTEPS || HAS_E7_MICROSTEPS
#define HAS_SOME_E_MICROSTEPS 1
#endif
#if HAS_X_MICROSTEPS || HAS_X2_MICROSTEPS || HAS_Y_MICROSTEPS || HAS_Y2_MICROSTEPS || HAS_SOME_Z_MICROSTEPS || HAS_SOME_E_MICROSTEPS
#define HAS_MICROSTEPS 1
#endif
#if HAS_MICROSTEPS
// MS1 MS2 MS3 Stepper Driver Microstepping mode table
#ifndef MICROSTEP1
#define MICROSTEP1 LOW,LOW,LOW
#endif
#if ENABLED(HEROIC_STEPPER_DRIVERS)
#ifndef MICROSTEP128
#define MICROSTEP128 LOW,HIGH,LOW
#endif
#else
#ifndef MICROSTEP2
#define MICROSTEP2 HIGH,LOW,LOW
#endif
#ifndef MICROSTEP4
#define MICROSTEP4 LOW,HIGH,LOW
#endif
#endif
#ifndef MICROSTEP8
#define MICROSTEP8 HIGH,HIGH,LOW
#endif
#ifdef __SAM3X8E__
#if MB(ALLIGATOR)
#ifndef MICROSTEP16
#define MICROSTEP16 LOW,LOW,LOW
#endif
#ifndef MICROSTEP32
#define MICROSTEP32 HIGH,HIGH,LOW
#endif
#else
#ifndef MICROSTEP16
#define MICROSTEP16 HIGH,HIGH,LOW
#endif
#endif
#else
#ifndef MICROSTEP16
#define MICROSTEP16 HIGH,HIGH,LOW
#endif
#endif
#define HAS_MICROSTEP1 defined(MICROSTEP1)
#define HAS_MICROSTEP2 defined(MICROSTEP2)
#define HAS_MICROSTEP4 defined(MICROSTEP4)
#define HAS_MICROSTEP8 defined(MICROSTEP8)
#define HAS_MICROSTEP16 defined(MICROSTEP16)
#define HAS_MICROSTEP32 defined(MICROSTEP32)
#define HAS_MICROSTEP64 defined(MICROSTEP64)
#define HAS_MICROSTEP128 defined(MICROSTEP128)
#endif // HAS_MICROSTEPS
/**
* Heater signal inversion defaults
*/
#if HAS_HEATER_0 && !defined(HEATER_0_INVERTING)
#define HEATER_0_INVERTING false
#endif
#if HAS_HEATER_1 && !defined(HEATER_1_INVERTING)
#define HEATER_1_INVERTING false
#endif
#if HAS_HEATER_2 && !defined(HEATER_2_INVERTING)
#define HEATER_2_INVERTING false
#endif
#if HAS_HEATER_3 && !defined(HEATER_3_INVERTING)
#define HEATER_3_INVERTING false
#endif
#if HAS_HEATER_4 && !defined(HEATER_4_INVERTING)
#define HEATER_4_INVERTING false
#endif
#if HAS_HEATER_5 && !defined(HEATER_5_INVERTING)
#define HEATER_5_INVERTING false
#endif
#if HAS_HEATER_6 && !defined(HEATER_6_INVERTING)
#define HEATER_6_INVERTING false
#endif
#if HAS_HEATER_7 && !defined(HEATER_7_INVERTING)
#define HEATER_7_INVERTING false
#endif
/**
* Helper Macros for heaters and extruder fan
*/
#define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, (v) ^ HEATER_0_INVERTING)
#if HOTENDS > 1 || ENABLED(HEATERS_PARALLEL)
#define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, (v) ^ HEATER_1_INVERTING)
#if HOTENDS > 2
#define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, (v) ^ HEATER_2_INVERTING)
#if HOTENDS > 3
#define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, (v) ^ HEATER_3_INVERTING)
#if HOTENDS > 4
#define WRITE_HEATER_4(v) WRITE(HEATER_4_PIN, (v) ^ HEATER_4_INVERTING)
#if HOTENDS > 5
#define WRITE_HEATER_5(v) WRITE(HEATER_5_PIN, (v) ^ HEATER_5_INVERTING)
#if HOTENDS > 6
#define WRITE_HEATER_6(v) WRITE(HEATER_6_PIN, (v) ^ HEATER_6_INVERTING)
#if HOTENDS > 7
#define WRITE_HEATER_7(v) WRITE(HEATER_7_PIN, (v) ^ HEATER_7_INVERTING)
#endif // HOTENDS > 7
#endif // HOTENDS > 6
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#if ENABLED(HEATERS_PARALLEL)
#define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
#else
#define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
#endif
#ifndef MIN_POWER
#define MIN_POWER 0
#endif
/**
* Heated bed requires settings
*/
#if HAS_HEATED_BED
#ifndef MIN_BED_POWER
#define MIN_BED_POWER 0
#endif
#ifndef MAX_BED_POWER
#define MAX_BED_POWER 255
#endif
#ifndef HEATER_BED_INVERTING
#define HEATER_BED_INVERTING false
#endif
#define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, (v) ^ HEATER_BED_INVERTING)
#endif
/**
* Heated chamber requires settings
*/
#if HAS_HEATED_CHAMBER
#ifndef MAX_CHAMBER_POWER
#define MAX_CHAMBER_POWER 255
#endif
#ifndef HEATER_CHAMBER_INVERTING
#define HEATER_CHAMBER_INVERTING false
#endif
#define WRITE_HEATER_CHAMBER(v) WRITE(HEATER_CHAMBER_PIN, (v) ^ HEATER_CHAMBER_INVERTING)
#endif
/**
* Up to 3 PWM fans
*/
#ifndef FAN_INVERTING
#define FAN_INVERTING false
#endif
#if HAS_FAN7
#define FAN_COUNT 8
#elif HAS_FAN6
#define FAN_COUNT 7
#elif HAS_FAN5
#define FAN_COUNT 6
#elif HAS_FAN4
#define FAN_COUNT 5
#elif HAS_FAN3
#define FAN_COUNT 4
#elif HAS_FAN2
#define FAN_COUNT 3
#elif HAS_FAN1
#define FAN_COUNT 2
#elif HAS_FAN0
#define FAN_COUNT 1
#else
#define FAN_COUNT 0
#endif
#if FAN_COUNT > 0
#define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ FAN_INVERTING)
#endif
/**
* Part Cooling fan multipliexer
*/
#define HAS_FANMUX PIN_EXISTS(FANMUX0)
/**
* MIN/MAX fan PWM scaling
*/
#ifndef FAN_OFF_PWM
#define FAN_OFF_PWM 0
#endif
#ifndef FAN_MIN_PWM
#if FAN_OFF_PWM > 0
#define FAN_MIN_PWM (FAN_OFF_PWM + 1)
#else
#define FAN_MIN_PWM 0
#endif
#endif
#ifndef FAN_MAX_PWM
#define FAN_MAX_PWM 255
#endif
#if FAN_MIN_PWM < 0 || FAN_MIN_PWM > 255
#error "FAN_MIN_PWM must be a value from 0 to 255."
#elif FAN_MAX_PWM < 0 || FAN_MAX_PWM > 255
#error "FAN_MAX_PWM must be a value from 0 to 255."
#elif FAN_MIN_PWM > FAN_MAX_PWM
#error "FAN_MIN_PWM must be less than or equal to FAN_MAX_PWM."
#elif FAN_OFF_PWM > FAN_MIN_PWM
#error "FAN_OFF_PWM must be less than or equal to FAN_MIN_PWM."
#endif
/**
* FAST PWM FAN Settings
*/
#if ENABLED(FAST_PWM_FAN) && !defined(FAST_PWM_FAN_FREQUENCY)
#define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) // Fan frequency default
#endif
/**
* MIN/MAX case light PWM scaling
*/
#if HAS_CASE_LIGHT
#ifndef CASE_LIGHT_MAX_PWM
#define CASE_LIGHT_MAX_PWM 255
#elif !WITHIN(CASE_LIGHT_MAX_PWM, 1, 255)
#error "CASE_LIGHT_MAX_PWM must be a value from 1 to 255."
#endif
#endif
/**
* Bed Probe dependencies
*/
#if HAS_BED_PROBE
#if ENABLED(ENDSTOPPULLUPS) && HAS_Z_MIN_PROBE_PIN
#define ENDSTOPPULLUP_ZMIN_PROBE
#endif
#ifndef Z_PROBE_OFFSET_RANGE_MIN
#define Z_PROBE_OFFSET_RANGE_MIN -20
#endif
#ifndef Z_PROBE_OFFSET_RANGE_MAX
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
#ifndef XY_PROBE_SPEED
#ifdef HOMING_FEEDRATE_XY
#define XY_PROBE_SPEED HOMING_FEEDRATE_XY
#else
#define XY_PROBE_SPEED 4000
#endif
#endif
#ifndef NOZZLE_TO_PROBE_OFFSET
#define NOZZLE_TO_PROBE_OFFSET { 0, 0, 0 }
#endif
#else
#undef NOZZLE_TO_PROBE_OFFSET
#endif
/**
* XYZ Bed Skew Correction
*/
#if ENABLED(SKEW_CORRECTION)
#define SKEW_FACTOR_MIN -1
#define SKEW_FACTOR_MAX 1
#define _GET_SIDE(a,b,c) (SQRT(2*sq(a)+2*sq(b)-4*sq(c))*0.5)
#define _SKEW_SIDE(a,b,c) tan(M_PI*0.5-acos((sq(a)-sq(b)-sq(c))/(2*c*b)))
#define _SKEW_FACTOR(a,b,c) _SKEW_SIDE(float(a),_GET_SIDE(float(a),float(b),float(c)),float(c))
#ifndef XY_SKEW_FACTOR
#if defined(XY_DIAG_AC) && defined(XY_DIAG_BD) && defined(XY_SIDE_AD)
#define XY_SKEW_FACTOR _SKEW_FACTOR(XY_DIAG_AC, XY_DIAG_BD, XY_SIDE_AD)
#else
#define XY_SKEW_FACTOR 0.0
#endif
#endif
#ifndef XZ_SKEW_FACTOR
#if defined(XY_SIDE_AD) && !defined(XZ_SIDE_AD)
#define XZ_SIDE_AD XY_SIDE_AD
#endif
#if defined(XZ_DIAG_AC) && defined(XZ_DIAG_BD) && defined(XZ_SIDE_AD)
#define XZ_SKEW_FACTOR _SKEW_FACTOR(XZ_DIAG_AC, XZ_DIAG_BD, XZ_SIDE_AD)
#else
#define XZ_SKEW_FACTOR 0.0
#endif
#endif
#ifndef YZ_SKEW_FACTOR
#if defined(YZ_DIAG_AC) && defined(YZ_DIAG_BD) && defined(YZ_SIDE_AD)
#define YZ_SKEW_FACTOR _SKEW_FACTOR(YZ_DIAG_AC, YZ_DIAG_BD, YZ_SIDE_AD)
#else
#define YZ_SKEW_FACTOR 0.0
#endif
#endif
#endif // SKEW_CORRECTION
/**
* Heater, Fan, and Probe interactions
*/
#if FAN_COUNT == 0
#undef PROBING_FANS_OFF
#undef ADAPTIVE_FAN_SLOWING
#undef NO_FAN_SLOWING_IN_PID_TUNING
#endif
#define QUIET_PROBING (HAS_BED_PROBE && (EITHER(PROBING_HEATERS_OFF, PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0))
#define HEATER_IDLE_HANDLER EITHER(ADVANCED_PAUSE_FEATURE, PROBING_HEATERS_OFF)
#if ENABLED(ADVANCED_PAUSE_FEATURE) && !defined(FILAMENT_CHANGE_SLOW_LOAD_LENGTH)
#define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0
#endif
#if EXTRUDERS > 1 && !defined(TOOLCHANGE_FIL_EXTRA_PRIME)
#define TOOLCHANGE_FIL_EXTRA_PRIME 0
#endif
/**
* Only constrain Z on DELTA / SCARA machines
*/
#if IS_KINEMATIC
#undef MIN_SOFTWARE_ENDSTOP_X
#undef MIN_SOFTWARE_ENDSTOP_Y
#undef MAX_SOFTWARE_ENDSTOP_X
#undef MAX_SOFTWARE_ENDSTOP_Y
#endif
/**
* Bed Probing bounds
*/
#ifndef MIN_PROBE_EDGE
#define MIN_PROBE_EDGE 0
#endif
#if IS_KINEMATIC
#undef MIN_PROBE_EDGE_LEFT
#undef MIN_PROBE_EDGE_RIGHT
#undef MIN_PROBE_EDGE_FRONT
#undef MIN_PROBE_EDGE_BACK
#define MIN_PROBE_EDGE_LEFT 0
#define MIN_PROBE_EDGE_RIGHT 0
#define MIN_PROBE_EDGE_FRONT 0
#define MIN_PROBE_EDGE_BACK 0
#else
#ifndef MIN_PROBE_EDGE_LEFT
#define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
#endif
#ifndef MIN_PROBE_EDGE_RIGHT
#define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
#endif
#ifndef MIN_PROBE_EDGE_FRONT
#define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
#endif
#ifndef MIN_PROBE_EDGE_BACK
#define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
#endif
#endif
#if ENABLED(DELTA)
/**
* Delta radius/rod trimmers/angle trimmers
*/
#ifndef DELTA_ENDSTOP_ADJ
#define DELTA_ENDSTOP_ADJ { 0, 0, 0 }
#endif
#ifndef DELTA_TOWER_ANGLE_TRIM
#define DELTA_TOWER_ANGLE_TRIM { 0, 0, 0 }
#endif
#ifndef DELTA_RADIUS_TRIM_TOWER
#define DELTA_RADIUS_TRIM_TOWER { 0, 0, 0 }
#endif
#ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER
#define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0, 0, 0 }
#endif
#endif
#if ENABLED(SEGMENT_LEVELED_MOVES) && !defined(LEVELED_SEGMENT_LENGTH)
#define LEVELED_SEGMENT_LENGTH 5
#endif
/**
* Default mesh area is an area with an inset margin on the print area.
*/
#if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
#if IS_KINEMATIC
// Probing points may be verified at compile time within the radius
// using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(DELTA_PRINTABLE_RADIUS),"bad probe point!")
// so that may be added to SanityCheck.h in the future.
#define _MESH_MIN_X (X_MIN_BED + MESH_INSET)
#define _MESH_MIN_Y (Y_MIN_BED + MESH_INSET)
#define _MESH_MAX_X (X_MAX_BED - (MESH_INSET))
#define _MESH_MAX_Y (Y_MAX_BED - (MESH_INSET))
#else
// Boundaries for Cartesian probing based on set limits
#define _MESH_MIN_X (_MAX(X_MIN_BED + MESH_INSET, X_MIN_POS)) // UBL is careful not to probe off the bed. It does not
#define _MESH_MIN_Y (_MAX(Y_MIN_BED + MESH_INSET, Y_MIN_POS)) // need NOZZLE_TO_PROBE_OFFSET in the mesh dimensions
#define _MESH_MAX_X (_MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS))
#define _MESH_MAX_Y (_MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS))
#endif
// These may be overridden in Configuration.h if a smaller area is desired
#ifndef MESH_MIN_X
#define MESH_MIN_X _MESH_MIN_X
#endif
#ifndef MESH_MIN_Y
#define MESH_MIN_Y _MESH_MIN_Y
#endif
#ifndef MESH_MAX_X
#define MESH_MAX_X _MESH_MAX_X
#endif
#ifndef MESH_MAX_Y
#define MESH_MAX_Y _MESH_MAX_Y
#endif
#else
#undef MESH_MIN_X
#undef MESH_MIN_Y
#undef MESH_MAX_X
#undef MESH_MAX_Y
#endif
#if defined(PROBE_PT_1_X) && defined(PROBE_PT_2_X) && defined(PROBE_PT_3_X) && defined(PROBE_PT_1_Y) && defined(PROBE_PT_2_Y) && defined(PROBE_PT_3_Y)
#define HAS_FIXED_3POINT 1
#endif
/**
* Buzzer/Speaker
*/
#if ENABLED(LCD_USE_I2C_BUZZER)
#ifndef LCD_FEEDBACK_FREQUENCY_HZ
#define LCD_FEEDBACK_FREQUENCY_HZ 1000
#endif
#ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
#endif
#elif HAS_BUZZER
#ifndef LCD_FEEDBACK_FREQUENCY_HZ
#define LCD_FEEDBACK_FREQUENCY_HZ 5000
#endif
#ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
#endif
#endif
/**
* Make sure DOGLCD_SCK and DOGLCD_MOSI are defined.
*/
#if HAS_GRAPHICAL_LCD
#ifndef DOGLCD_SCK
#define DOGLCD_SCK SCK_PIN
#endif
#ifndef DOGLCD_MOSI
#define DOGLCD_MOSI MOSI_PIN
#endif
#endif
/**
* Z_HOMING_HEIGHT / Z_CLEARANCE_BETWEEN_PROBES
*/
#ifndef Z_HOMING_HEIGHT
#ifdef Z_CLEARANCE_BETWEEN_PROBES
#define Z_HOMING_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
#else
#define Z_HOMING_HEIGHT 0
#endif
#endif
#if PROBE_SELECTED
#ifndef Z_CLEARANCE_BETWEEN_PROBES
#define Z_CLEARANCE_BETWEEN_PROBES Z_HOMING_HEIGHT
#endif
#if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT
#define MANUAL_PROBE_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
#else
#define MANUAL_PROBE_HEIGHT Z_HOMING_HEIGHT
#endif
#ifndef Z_CLEARANCE_MULTI_PROBE
#define Z_CLEARANCE_MULTI_PROBE Z_CLEARANCE_BETWEEN_PROBES
#endif
#if ENABLED(BLTOUCH) && !defined(BLTOUCH_DELAY)
#define BLTOUCH_DELAY 500
#endif
#endif
#ifndef __SAM3X8E__ //todo: hal: broken hal encapsulation
#undef UI_VOLTAGE_LEVEL
#undef RADDS_DISPLAY
#undef MOTOR_CURRENT
#endif
// Updated G92 behavior shifts the workspace
#if DISABLED(NO_WORKSPACE_OFFSETS)
#define HAS_POSITION_SHIFT 1
#if IS_CARTESIAN
#define HAS_HOME_OFFSET 1 // The home offset also shifts the coordinate space
#define HAS_WORKSPACE_OFFSET 1 // Cumulative offset to workspace to save some calculation
#define HAS_M206_COMMAND 1 // M206 sets the home offset for Cartesian machines
#elif IS_SCARA
#define HAS_SCARA_OFFSET 1 // The SCARA home offset applies only on G28
#endif
#endif
// LCD timeout to status screen default is 15s
#ifndef LCD_TIMEOUT_TO_STATUS
#define LCD_TIMEOUT_TO_STATUS 15000
#endif
// Add commands that need sub-codes to this list
#if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY)
#define USE_GCODE_SUBCODES
#endif
// Parking Extruder
#if ENABLED(PARKING_EXTRUDER)
#ifndef PARKING_EXTRUDER_GRAB_DISTANCE
#define PARKING_EXTRUDER_GRAB_DISTANCE 0
#endif
#ifndef PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
#define PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE HIGH
#endif
#endif
// Number of VFAT entries used. Each entry has 13 UTF-16 characters
#define MAX_VFAT_ENTRIES TERN(SCROLL_LONG_FILENAMES, 5, 2)
// Nozzle park for Delta
#if BOTH(NOZZLE_PARK_FEATURE, DELTA)
#undef NOZZLE_PARK_Z_FEEDRATE
#define NOZZLE_PARK_Z_FEEDRATE NOZZLE_PARK_XY_FEEDRATE
#endif
// Force SDCARD_SORT_ALPHA to be enabled for Graphical LCD on LPC1768
// on boards where SD card and LCD display share the same SPI bus
// because of a bug in the shared SPI implementation. (See #8122)
#if defined(TARGET_LPC1768) && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && (SCK_PIN == LCD_PINS_D4)
#define SDCARD_SORT_ALPHA // Keep one directory level in RAM. Changing directory levels
// may still glitch the screen, but LCD updates clean it up.
#undef SDSORT_LIMIT
#undef SDSORT_USES_RAM
#undef SDSORT_USES_STACK
#undef SDSORT_CACHE_NAMES
#define SDSORT_LIMIT 64
#define SDSORT_USES_RAM true
#define SDSORT_USES_STACK false
#define SDSORT_CACHE_NAMES true
#ifndef FOLDER_SORTING
#define FOLDER_SORTING -1
#endif
#ifndef SDSORT_GCODE
#define SDSORT_GCODE false
#endif
#ifndef SDSORT_DYNAMIC_RAM
#define SDSORT_DYNAMIC_RAM false
#endif
#ifndef SDSORT_CACHE_VFATS
#define SDSORT_CACHE_VFATS 2
#endif
#endif
// Defined here to catch the above defines
#if ENABLED(SDCARD_SORT_ALPHA) && (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
#define HAS_FOLDER_SORTING 1
#endif
#if HAS_SPI_LCD
// Get LCD character width/height, which may be overridden by pins, configs, etc.
#ifndef LCD_WIDTH
#if HAS_GRAPHICAL_LCD
#define LCD_WIDTH 21
#else
#define LCD_WIDTH TERN(ULTIPANEL, 20, 16)
#endif
#endif
#ifndef LCD_HEIGHT
#if HAS_GRAPHICAL_LCD
#define LCD_HEIGHT 5
#else
#define LCD_HEIGHT TERN(ULTIPANEL, 4, 2)
#endif
#endif
#endif
#if ENABLED(SDSUPPORT)
#if SD_CONNECTION_IS(ONBOARD) && DISABLED(NO_SD_HOST_DRIVE) && !defined(ARDUINO_GRAND_CENTRAL_M4)
//
// The external SD card is not used. Hardware SPI is used to access the card.
// When sharing the SD card with a PC we want the menu options to
// mount/unmount the card and refresh it. So we disable card detect.
//
#undef SD_DETECT_PIN
#define SHARED_SD_CARD
#endif
#if DISABLED(SHARED_SD_CARD)
#define INIT_SDCARD_ON_BOOT
#endif
#endif
#if !NUM_SERIAL
#undef BAUD_RATE_GCODE
#endif
| 69,204
|
C++
|
.h
| 2,011
| 30.320736
| 358
| 0.678047
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,921
|
MarlinConfig.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/inc/MarlinConfig.h
|
/**
* 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
//
// Prefix header for all Marlin sources
//
#include "MarlinConfigPre.h"
#include "../HAL/HAL.h"
#include "../pins/pins.h"
#include HAL_PATH(../HAL, spi_pins.h)
#include "Conditionals_post.h"
#include HAL_PATH(../HAL, inc/Conditionals_post.h)
#include "SanityCheck.h"
#include HAL_PATH(../HAL, inc/SanityCheck.h)
// Include all core headers
#include "../core/types.h"
#include "../core/language.h"
#include "../core/utility.h"
#include "../core/serial.h"
| 1,338
|
C++
|
.h
| 38
| 33.5
| 79
| 0.742459
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
1,537,923
|
Version.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/inc/Version.h
|
/**
* 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
/**
* Release version. Leave the Marlin version or apply a custom scheme.
*/
#ifndef SHORT_BUILD_VERSION
#define SHORT_BUILD_VERSION "2.0.5.2"
#endif
/**
* Verbose version identifier containing a unique identifier, such as the
* vendor name, download location, GitHub account, etc.
*/
#ifndef DETAILED_BUILD_VERSION
#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (GitHub)"
#endif
/**
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
* here we define this default string as the date where the latest release
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2020-03-24"
#endif
/**
* Minimum Configuration.h and Configuration_adv.h file versions.
* Set based on the release version number. Used to catch an attempt to use
* older configurations. Override these if using a custom versioning scheme
* to alert users to major changes.
*/
#define MARLIN_HEX_VERSION 020005
#ifndef REQUIRED_CONFIGURATION_H_VERSION
#define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION
#endif
#ifndef REQUIRED_CONFIGURATION_ADV_H_VERSION
#define REQUIRED_CONFIGURATION_ADV_H_VERSION MARLIN_HEX_VERSION
#endif
/**
* The protocol for communication to the host. Protocol indicates communication
* standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc.
* (Other behaviors are given by the firmware version and capabilities report.)
*/
#ifndef PROTOCOL_VERSION
#define PROTOCOL_VERSION "1.0"
#endif
/**
* Define a generic printer name to be output to the LCD after booting Marlin.
*/
#ifndef MACHINE_NAME
#define MACHINE_NAME "3D Printer"
#endif
/**
* Website where users can find Marlin source code for the binary installed on the
* device. Override this if you provide public source code download. (GPLv3 requires
* providing the source code to your customers.)
*/
#ifndef SOURCE_CODE_URL
#define SOURCE_CODE_URL "https://github.com/MarlinFirmware/Marlin"
#endif
/**
* Default generic printer UUID.
*/
#ifndef DEFAULT_MACHINE_UUID
#define DEFAULT_MACHINE_UUID "cede2a2f-41a2-4748-9b12-c55c62f367ff"
#endif
/**
* The WEBSITE_URL is the location where users can get more information such as
* documentation about a specific Marlin release. Displayed in the Info Menu.
*/
#ifndef WEBSITE_URL
#define WEBSITE_URL "http://marlinfw.org"
#endif
/**
* Set the vendor info the serial USB interface, if changable
* Currently only supported by DUE platform
*/
#ifndef USB_DEVICE_VENDOR_ID
#define USB_DEVICE_VENDOR_ID 0x03EB /* ATMEL VID */
#endif
#ifndef USB_DEVICE_PRODUCT_ID
#define USB_DEVICE_PRODUCT_ID 0x2424 /* MSC / CDC */
#endif
//! USB Device string definitions (Optional)
#ifndef USB_DEVICE_MANUFACTURE_NAME
#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL
#endif
#ifdef CUSTOM_MACHINE_NAME
#define USB_DEVICE_PRODUCT_NAME CUSTOM_MACHINE_NAME
#else
#define USB_DEVICE_PRODUCT_NAME MACHINE_NAME
#endif
#define USB_DEVICE_SERIAL_NAME "123985739853"
| 3,927
|
C++
|
.h
| 111
| 33.468468
| 84
| 0.762418
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,924
|
Conditionals_adv.h
|
LONGER3D_Marlin2_0-lgt/Marlin/src/inc/Conditionals_adv.h
|
/**
* 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
/**
* Conditionals_adv.h
* Defines that depend on advanced configuration.
*/
#if EXTRUDERS == 0
#define NO_VOLUMETRICS
#undef TEMP_SENSOR_0
#undef TEMP_SENSOR_1
#undef TEMP_SENSOR_2
#undef TEMP_SENSOR_3
#undef TEMP_SENSOR_4
#undef TEMP_SENSOR_5
#undef TEMP_SENSOR_6
#undef TEMP_SENSOR_7
#undef FWRETRACT
#undef PIDTEMP
#undef AUTOTEMP
#undef PID_EXTRUSION_SCALING
#undef LIN_ADVANCE
#undef FILAMENT_RUNOUT_SENSOR
#undef ADVANCED_PAUSE_FEATURE
#undef FILAMENT_RUNOUT_DISTANCE_MM
#undef FILAMENT_LOAD_UNLOAD_GCODES
#undef DISABLE_INACTIVE_EXTRUDER
#undef FILAMENT_LOAD_UNLOAD_GCODES
#undef EXTRUDER_RUNOUT_PREVENT
#undef PREVENT_COLD_EXTRUSION
#undef PREVENT_LENGTHY_EXTRUDE
#undef THERMAL_PROTECTION_HOTENDS
#undef THERMAL_PROTECTION_PERIOD
#undef WATCH_TEMP_PERIOD
#undef SHOW_TEMP_ADC_VALUES
#endif
#if EITHER(DUAL_X_CARRIAGE, MULTI_NOZZLE_DUPLICATION)
#define HAS_DUPLICATION_MODE 1
#endif
#if ENABLED(PRINTCOUNTER) && (SERVICE_INTERVAL_1 > 0 || SERVICE_INTERVAL_2 > 0 || SERVICE_INTERVAL_3 > 0)
#define HAS_SERVICE_INTERVALS 1
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#define HAS_FILAMENT_SENSOR 1
#endif
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
#define HAS_PRINT_PROGRESS 1
#endif
#if HAS_PRINT_PROGRESS && EITHER(PRINT_PROGRESS_SHOW_DECIMALS, SHOW_REMAINING_TIME)
#define HAS_PRINT_PROGRESS_PERMYRIAD 1
#endif
#if ANY(MARLIN_BRICKOUT, MARLIN_INVADERS, MARLIN_SNAKE, MARLIN_MAZE)
#define HAS_GAMES 1
#if (1 < ENABLED(MARLIN_BRICKOUT) + ENABLED(MARLIN_INVADERS) + ENABLED(MARLIN_SNAKE) + ENABLED(MARLIN_MAZE))
#define HAS_GAME_MENU 1
#endif
#endif
#if ANY(FWRETRACT, HAS_LEVELING, SKEW_CORRECTION)
#define HAS_POSITION_MODIFIERS 1
#endif
#if ANY(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS, Z_MULTI_ENDSTOPS)
#define HAS_EXTRA_ENDSTOPS 1
#endif
#if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
#define HAS_SOFTWARE_ENDSTOPS 1
#endif
#if ANY(EXTENSIBLE_UI, NEWPANEL, EMERGENCY_PARSER)
#define HAS_RESUME_CONTINUE 1
#endif
#if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED)
#define HAS_COLOR_LEDS 1
#endif
#if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT)
#define HAS_LEDS_OFF_FLAG 1
#endif
// Multiple Z steppers
#ifndef NUM_Z_STEPPER_DRIVERS
#define NUM_Z_STEPPER_DRIVERS 1
#endif
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
#undef Z_STEPPER_ALIGN_AMP
#endif
#ifndef Z_STEPPER_ALIGN_AMP
#define Z_STEPPER_ALIGN_AMP 1.0
#endif
#define HAS_CUTTER EITHER(SPINDLE_FEATURE, LASER_FEATURE)
#if !defined(__AVR__) || !defined(USBCON)
// Define constants and variables for buffering serial data.
// Use only 0 or powers of 2 greater than 1
// : [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, ...]
#ifndef RX_BUFFER_SIZE
#define RX_BUFFER_SIZE 128
#endif
// 256 is the max TX buffer limit due to uint8_t head and tail
// : [0, 4, 8, 16, 32, 64, 128, 256]
#ifndef TX_BUFFER_SIZE
#define TX_BUFFER_SIZE 32
#endif
#else
// SERIAL_XON_XOFF not supported on USB-native devices
#undef SERIAL_XON_XOFF
#endif
#if ENABLED(HOST_ACTION_COMMANDS)
#ifndef ACTION_ON_PAUSE
#define ACTION_ON_PAUSE "pause"
#endif
#ifndef ACTION_ON_PAUSED
#define ACTION_ON_PAUSED "paused"
#endif
#ifndef ACTION_ON_RESUME
#define ACTION_ON_RESUME "resume"
#endif
#ifndef ACTION_ON_RESUMED
#define ACTION_ON_RESUMED "resumed"
#endif
#ifndef ACTION_ON_CANCEL
#define ACTION_ON_CANCEL "cancel"
#endif
#ifndef ACTION_ON_KILL
#define ACTION_ON_KILL "poweroff"
#endif
#if HAS_FILAMENT_SENSOR
#ifndef ACTION_ON_FILAMENT_RUNOUT
#define ACTION_ON_FILAMENT_RUNOUT "filament_runout"
#endif
#ifndef ACTION_REASON_ON_FILAMENT_RUNOUT
#define ACTION_REASON_ON_FILAMENT_RUNOUT "filament_runout"
#endif
#endif
#if ENABLED(G29_RETRY_AND_RECOVER)
#ifndef ACTION_ON_G29_RECOVER
#define ACTION_ON_G29_RECOVER "probe_rewipe"
#endif
#ifndef ACTION_ON_G29_FAILURE
#define ACTION_ON_G29_FAILURE "probe_failed"
#endif
#endif
#endif
#if ENABLED(FYSETC_MINI_12864_2_1)
#define LED_CONTROL_MENU
#define LED_USER_PRESET_STARTUP
#define LED_COLOR_PRESETS
#ifndef LED_USER_PRESET_GREEN
#define LED_USER_PRESET_GREEN 128
#endif
#ifndef LED_USER_PRESET_BLUE
#define LED_USER_PRESET_BLUE 0
#endif
#ifndef LED_USER_PRESET_BRIGHTNESS
#define LED_USER_PRESET_BRIGHTNESS 255
#endif
#endif
// Set defaults for unspecified LED user colors
#if ENABLED(LED_CONTROL_MENU)
#ifndef LED_USER_PRESET_RED
#define LED_USER_PRESET_RED 255
#endif
#ifndef LED_USER_PRESET_GREEN
#define LED_USER_PRESET_GREEN 255
#endif
#ifndef LED_USER_PRESET_BLUE
#define LED_USER_PRESET_BLUE 255
#endif
#ifndef LED_USER_PRESET_WHITE
#define LED_USER_PRESET_WHITE 0
#endif
#ifndef LED_USER_PRESET_BRIGHTNESS
#ifdef NEOPIXEL_BRIGHTNESS
#define LED_USER_PRESET_BRIGHTNESS NEOPIXEL_BRIGHTNESS
#else
#define LED_USER_PRESET_BRIGHTNESS 255
#endif
#endif
#endif
// If platform requires early initialization of watchdog to properly boot
#if ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM)
#define EARLY_WATCHDOG 1
#endif
// Extensible UI pin mapping for RepRapDiscount
#if ENABLED(TOUCH_UI_FTDI_EVE) && ANY(AO_EXP1_PINMAP, AO_EXP2_PINMAP, CR10_TFT_PINMAP)
#define TOUCH_UI_ULTIPANEL 1
#endif
// Poll-based jogging for joystick and other devices
#if ENABLED(JOYSTICK)
#define POLL_JOG
#endif
/**
* Driver Timings
* NOTE: Driver timing order is longest-to-shortest duration.
* Preserve this ordering when adding new drivers.
*/
#ifndef MINIMUM_STEPPER_POST_DIR_DELAY
#if HAS_DRIVER(TB6560)
#define MINIMUM_STEPPER_POST_DIR_DELAY 15000
#elif HAS_DRIVER(TB6600)
#define MINIMUM_STEPPER_POST_DIR_DELAY 1500
#elif HAS_DRIVER(DRV8825)
#define MINIMUM_STEPPER_POST_DIR_DELAY 650
#elif HAS_DRIVER(LV8729)
#define MINIMUM_STEPPER_POST_DIR_DELAY 500
#elif HAS_DRIVER(A5984)
#define MINIMUM_STEPPER_POST_DIR_DELAY 400
#elif HAS_DRIVER(A4988)
#define MINIMUM_STEPPER_POST_DIR_DELAY 200
#elif HAS_TRINAMIC_CONFIG || HAS_TRINAMIC_STANDALONE
#define MINIMUM_STEPPER_POST_DIR_DELAY 20
#else
#define MINIMUM_STEPPER_POST_DIR_DELAY 0 // Expect at least 10µS since one Stepper ISR must transpire
#endif
#endif
#ifndef MINIMUM_STEPPER_PRE_DIR_DELAY
#define MINIMUM_STEPPER_PRE_DIR_DELAY MINIMUM_STEPPER_POST_DIR_DELAY
#endif
#ifndef MINIMUM_STEPPER_PULSE
#if HAS_DRIVER(TB6560)
#define MINIMUM_STEPPER_PULSE 30
#elif HAS_DRIVER(TB6600)
#define MINIMUM_STEPPER_PULSE 3
#elif HAS_DRIVER(DRV8825)
#define MINIMUM_STEPPER_PULSE 2
#elif HAS_DRIVER(A4988) || HAS_DRIVER(A5984)
#define MINIMUM_STEPPER_PULSE 1
#elif HAS_TRINAMIC_CONFIG || HAS_TRINAMIC_STANDALONE
#define MINIMUM_STEPPER_PULSE 0
#elif HAS_DRIVER(LV8729)
#define MINIMUM_STEPPER_PULSE 0
#else
#define MINIMUM_STEPPER_PULSE 2
#endif
#endif
#ifndef MAXIMUM_STEPPER_RATE
#if HAS_DRIVER(TB6560)
#define MAXIMUM_STEPPER_RATE 15000
#elif HAS_DRIVER(TB6600)
#define MAXIMUM_STEPPER_RATE 150000
#elif HAS_DRIVER(DRV8825)
#define MAXIMUM_STEPPER_RATE 250000
#elif HAS_DRIVER(A4988)
#define MAXIMUM_STEPPER_RATE 500000
#elif HAS_DRIVER(LV8729)
#define MAXIMUM_STEPPER_RATE 1000000
#elif HAS_TRINAMIC_CONFIG || HAS_TRINAMIC_STANDALONE
#define MAXIMUM_STEPPER_RATE 5000000
#else
#define MAXIMUM_STEPPER_RATE 250000
#endif
#endif
| 8,412
|
C++
|
.h
| 266
| 28.657895
| 110
| 0.748645
|
LONGER3D/Marlin2.0-lgt
| 30
| 20
| 15
|
GPL-3.0
|
9/20/2024, 10:44:51 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,929
|
cigar.cpp
|
rcedgar_urmap/src/cigar.cpp
|
#include "myutils.h"
#include "cigar.h"
void PathToCIGAR(const char *Path, string &CIGAR)
{
char LastC = *Path;
unsigned n = 1;
char Tmp[32];
for (unsigned i = 1; ; ++i)
{
char c = Path[i];
if (c == 0)
break;
if (c == LastC)
{
++n;
continue;
}
else
{
assert(n > 0);
if (LastC == 'D')
LastC = 'I';
else if (LastC == 'I')
LastC = 'D';
sprintf(Tmp, "%u%c", n, LastC);
CIGAR += string(Tmp);
LastC = c;
n = 1;
}
}
if (n > 0)
{
if (LastC == 'D')
LastC = 'I';
else if (LastC == 'I')
LastC = 'D';
sprintf(Tmp, "%u%c", n, LastC);
CIGAR += string(Tmp);
}
}
void CIGARGetOps(const string &CIGAR, vector<char> &Ops,
vector<unsigned> &Lengths)
{
Ops.clear();
Lengths.clear();
if (CIGAR.empty())
return;
unsigned L = SIZE(CIGAR);
unsigned n = 0;
for (unsigned i = 0; i < L; ++i)
{
char c = CIGAR[i];
if (isdigit(c))
n = n*10 + (c - '0');
else if (isupper(c) || c == '=')
{
if (n == 0)
Die("Operation '%c' has zero length in CIGAR '%s'", c, CIGAR.c_str());
Ops.push_back(c);
Lengths.push_back(n);
n = 0;
}
else
Die("Invalid char '%c' in CIGAR '%s'", c, CIGAR.c_str());
}
if (n > 0)
Die("Missing operation at end of CIGAR '%s'", CIGAR.c_str());
}
unsigned CIGARToQL(const string &CIGAR)
{
vector<char> Ops;
vector<unsigned> Lengths;
CIGARGetOps(CIGAR, Ops, Lengths);
const unsigned N = SIZE(Ops);
asserta(SIZE(Lengths) == N);
unsigned QL = 0;
for (unsigned i = 0; i < N; ++i)
{
char Op = Ops[i];
switch (Op)
{
case 'M':
case 'I':
QL += Lengths[i];
break;
case 'D':
break;
default:
Die("Unsupported op '%c' in CIGAR '%s'", Op, CIGAR.c_str());
}
}
return QL;
}
void CIGAROpsToLs(const vector<char> &Ops, const vector<unsigned> &Lengths,
unsigned &QL, unsigned &TL)
{
QL = 0;
TL = 0;
const unsigned N = SIZE(Ops);
asserta(SIZE(Lengths) == N);
for (unsigned i = 0; i < N; ++i)
{
char Op = Ops[i];
switch (Op)
{
case 'M':
QL += Lengths[i];
TL += Lengths[i];
break;
// CIGAR D&I reverse of my usual convention
case 'I':
QL += Lengths[i];
break;
case 'D':
TL += Lengths[i];
break;
default:
Die("Unsupported op '%c' in CIGAR", Op);
}
}
}
void CIGARToLs(const string &CIGAR, unsigned &QL, unsigned &TL)
{
vector<char> Ops;
vector<unsigned> Lengths;
CIGARGetOps(CIGAR, Ops, Lengths);
CIGAROpsToLs(Ops, Lengths, QL, TL);
}
void CIGAROpsFixDanglingMs(vector<char> &Ops, vector<unsigned> &Lengths)
{
const unsigned N = SIZE(Ops);
asserta(SIZE(Lengths) == N);
if (N < 3)
return;
// 1M 6I 100M
if (Ops[0] == 'M' && Lengths[0] <= 2 && Lengths[1] > 4 && Ops[2] == 'M')
{
unsigned OldQL;
unsigned OldTL;
CIGAROpsToLs(Ops, Lengths, OldQL, OldTL);
vector<char> NewOps;
vector<unsigned> NewLengths;
for (unsigned i = 1; i < N; ++i)
{
NewOps.push_back(Ops[i]);
NewLengths.push_back(Lengths[i]);
}
NewLengths[1] += Lengths[0];
unsigned NewQL;
unsigned NewTL;
CIGAROpsToLs(NewOps, NewLengths, NewQL, NewTL);
asserta(NewQL == OldQL);
asserta(NewTL == OldTL);
Ops = NewOps;
Lengths = NewLengths;
}
// 100M 6D M1
if (Ops[N-1] == 'M' && Lengths[N-1] <= 2 && Lengths[N-2] > 4 && Ops[N-3] == 'M')
{
unsigned OldQL;
unsigned OldTL;
CIGAROpsToLs(Ops, Lengths, OldQL, OldTL);
vector<char> NewOps;
vector<unsigned> NewLengths;
for (unsigned i = 0; i < N-1; ++i)
{
NewOps.push_back(Ops[i]);
NewLengths.push_back(Lengths[i]);
}
NewLengths[N-3] += Lengths[N-1];
unsigned NewQL;
unsigned NewTL;
CIGAROpsToLs(NewOps, NewLengths, NewQL, NewTL);
asserta(NewQL == OldQL);
asserta(NewTL == OldTL);
Ops = NewOps;
Lengths = NewLengths;
}
}
void OpsToCIGAR(const vector<char> &Ops, const vector<unsigned> &Lengths,
string &CIGAR)
{
CIGAR.clear();
const unsigned N = SIZE(Ops);
asserta(SIZE(Lengths) == N);
for (unsigned i = 0; i < N; ++i)
Psa(CIGAR, "%u%c", Lengths[i], Ops[i]);
}
| 3,995
|
C++
|
.cpp
| 188
| 18.25
| 81
| 0.606445
|
rcedgar/urmap
| 39
| 11
| 5
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,930
|
evalue.cpp
|
rcedgar_urmap/src/evalue.cpp
|
#include "myutils.h"
/***
NCBI BLAST parameters.
Method Lambda K H
--------------- ------ ------ -----
BLASTP gapped 0.267 0.0410 0.140
BLASTP ungapped 0.311 0.128 0.407
BLASTN gapped 1.280 0.460 0.850
BLASTN ungapped 1.330 0.621 1.120
***/
static const double Log2 = log(2.0);
static double g_GappedLambda;
static double g_UngappedLambda;
static double g_GappedK;
static double g_UngappedK;
static double g_LogGappedK;
static double g_LogUngappedK;
static double g_DBLength;
double GetKarlinDBLength()
{
return g_DBLength;
}
void SetKarlinDBLength(double DBLength)
{
g_DBLength = DBLength;
}
void LogKarlin()
{
Log("\n");
Log("Evalue parameters:\n");
Log(" Lambda %.3f gapped, %.3f ungapped\n", g_GappedLambda, g_UngappedLambda);
Log(" K %.3f gapped, %.3f ungapped\n", g_GappedK, g_UngappedK);
Log(" Effective DB size %s letters\n", FloatToStr(g_DBLength));
}
void SetKarlin(double GappedLambda, double UngappedLambda,
double GappedK, double UngappedK, double DBLength)
{
if (optset_ka_gapped_lambda)
g_GappedLambda = opt(ka_gapped_lambda);
else
g_GappedLambda = GappedLambda;
if (optset_ka_ungapped_lambda)
g_UngappedLambda = opt(ka_ungapped_lambda);
else
g_UngappedLambda = UngappedLambda;
if (optset_ka_gapped_k)
g_GappedK = opt(ka_gapped_k);
else
g_GappedK = GappedK;
if (optset_ka_ungapped_k)
g_UngappedK = opt(ka_ungapped_k);
else
g_UngappedK = UngappedK;
if (optset_ka_dbsize)
g_DBLength = opt(ka_dbsize);
else
g_DBLength = DBLength;
g_LogGappedK = log(g_GappedK);
g_LogUngappedK = log(g_UngappedK);
}
void SetKarlinAmino(double DBLength)
{
SetKarlin(0.267, 0.311, 0.0410, 0.128, DBLength);
}
void SetKarlinNucleo(double DBLength)
{
//SetKarlin(0.625, 0.634, 0.410, 0.408, DBLength);
SetKarlin(1.28, 1.33, 0.460, 0.621, DBLength);
}
void SetKarlin(double DBLength, bool Nucleo)
{
if (Nucleo)
SetKarlinNucleo(DBLength);
else
SetKarlinAmino(DBLength);
}
double ComputeBitScoreGapped(double Score)
{
double BitScore = (Score*g_GappedLambda - g_LogGappedK)/Log2;
return BitScore;
}
double ComputeBitScoreUngapped(double Score)
{
double BitScore = (Score*g_UngappedLambda - g_LogUngappedK)/Log2;
return BitScore;
}
// Evalue = (NM)/2^BitScore
double ComputeEvalueGappedFromBitScore(double BitScore, unsigned QueryLength)
{
asserta(g_DBLength > 0);
double NM = double(QueryLength)*double(g_DBLength);
double Evalue = NM/pow(2, BitScore);
return Evalue;
}
// Evalue = NM/2^BitScore
double ComputeEvalueGapped(double Score, unsigned QueryLength)
{
asserta(g_DBLength > 0);
double NM = double(QueryLength)*double(g_DBLength);
double BitScore = ComputeBitScoreGapped(Score);
double Evalue = NM/pow(2, BitScore);
return Evalue;
}
double ComputeEvalueUngapped(double Score, unsigned QueryLength)
{
asserta(g_DBLength > 0);
double NM = double(QueryLength)*double(g_DBLength);
double BitScore = ComputeBitScoreUngapped(Score);
double Evalue = NM/pow(2, BitScore);
return Evalue;
}
double ComputeMinScoreGivenEvalueAGapped(double Evalue, unsigned Area)
{
double BitScore = (log(double(Area)) - log(Evalue))/Log2;
double Score = (BitScore*Log2 + g_LogGappedK)/g_GappedLambda;
return Score;
}
double ComputeMinScoreGivenEvalueAUngapped(double Evalue, unsigned Area)
{
double BitScore = (log(double(Area)) - log(Evalue))/Log2;
double Score = (BitScore*Log2 + g_LogUngappedK)/g_UngappedLambda;
return Score;
}
double ComputeMinScoreGivenEvalueQGapped(double Evalue, unsigned QueryLength)
{
double BitScore = (log(double(g_DBLength*QueryLength)) - log(Evalue))/Log2;
double Score = (BitScore*Log2 + g_LogGappedK)/g_GappedLambda;
return Score;
}
double ComputeMinScoreGivenEvalueQUngapped(double Evalue, unsigned QueryLength)
{
double BitScore = (log(double(g_DBLength*QueryLength)) - log(Evalue))/Log2;
double Score = (BitScore*Log2 + g_LogUngappedK)/g_UngappedLambda;
return Score;
}
| 3,933
|
C++
|
.cpp
| 135
| 27.081481
| 80
| 0.755107
|
rcedgar/urmap
| 39
| 11
| 5
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,931
|
ufindex.cpp
|
rcedgar_urmap/src/ufindex.cpp
|
#include "myutils.h"
#include "ufindex.h"
#include "alpha.h"
#include <inttypes.h>
void UFIndex::LogSeqDict() const
{
unsigned n = SIZE(m_Labels);
Log("%u seqs\n", n);
for (unsigned i = 0; i < n; ++i)
{
Log("[%3u]", i);
Log(" %10u", m_SeqLengths[i]);
Log(" %10u", m_Offsets[i]);
Log(" %s", m_Labels[i].c_str());
Log("\n");
}
}
void UFIndex::SetShiftMask()
{
m_ShiftMask = 0;
for (unsigned i = 0; i < 2u*m_WordLength; ++i)
m_ShiftMask |= (uint64(1) << i);
for (unsigned i = 0; i < m_WordLength; ++i)
m_LowerCaseShiftMask |= (uint64(1) << i);
}
const char *UFIndex::GetStr(uint32 Pos, unsigned n, string &s) const
{
s.clear();
for (unsigned i = 0; i < n; ++i)
{
byte c = m_SeqData[Pos+i];
s += c;
}
return s.c_str();
}
const char *UFIndex::WordToStr(uint64 Word, string &s) const
{
s.clear();
for (unsigned i = 0; i < m_WordLength; ++i)
{
byte Letter = Word & 3;
byte c = g_LetterToCharNucleo[Letter];
s = char(c) + s;
Word >>= 2;
}
return s.c_str();
}
uint64 UFIndex::SeqToWord(const byte *Seq) const
{
uint64 Word = 0;
for (unsigned i = 0; i < m_WordLength; ++i)
{
byte c = Seq[i];
byte Letter = g_CharToLetterNucleo[c];
if (Letter > 3)
return UINT64_MAX;
Word = (Word << uint64(2)) | Letter;
}
return Word;
}
uint64 UFIndex::GetWord(uint32 Pos) const
{
asserta(Pos < m_SeqDataSize);
uint64 Word = 0;
for (unsigned i = 0; i < m_WordLength; ++i)
{
byte c = m_SeqData[Pos+i];
byte Letter = g_CharToLetterNucleo[c];
if (Letter > 3)
return UINT64_MAX;
Word = (Word << uint64(2)) | Letter;
}
return Word;
}
void UFIndex::MakeIndex()
{
if (m_StartPos == UINT_MAX)
{
m_StartPos = 0;
m_EndPos = m_SeqDataSize;
}
m_TruncatedCount = 0;
ProgressOne("Init vectors");
uint64 Size = 5*m_SlotCount;
m_Blob = myalloc64(byte, Size);
memset_zero(m_Blob, Size);
for (uint64 Slot = 0; Slot < m_SlotCount; ++Slot)
{
SetPos(Slot, UINT32_MAX);
SetTally(Slot, TALLY_FREE);
}
ProgressDone();
CountSlots();
CountSlots_Minus();
// LogCountHist();
uint64 Word = 0;
byte K = 0;
uint32 SeqPos;
ProgressOne("Index");
for (SeqPos = m_StartPos; SeqPos < m_EndPos; ++SeqPos)
{
ProgressLoopTick(SeqPos);
byte c = m_SeqData[SeqPos];
byte Letter = g_CharToLetterNucleo[c];
if (Letter == INVALID_LETTER)
{
K = 0;
Word = 0;
continue;
}
if (K < m_WordLength)
++K;
Word = (Word << uint64(2)) | Letter;
if (K == m_WordLength)
{
uint32 StartPos = SeqPos - (m_WordLength-1);
uint64 Slot = WordToSlot(Word & m_ShiftMask, m_SlotCount);
#if TSLOT
if (Slot == TSLOT)
{
uint64 Word2 = GetWord(StartPos);
asserta(Word2 == (Word & m_ShiftMask));
string s;
GetStr(StartPos, m_WordLength, s);
Log("\n");
Log("============================================\n");
Log("Update\n");
Log("Slot %" PRIx64 "\n", Slot);
Log("Word %" PRIx64 "\n", Word & m_ShiftMask);
Log("Word2 %" PRIx64 "\n", Word2);
Log("Seq %s\n", s.c_str());
LogList(Slot);
}
#endif
UpdateSlot(Slot, StartPos);
}
}
ProgressDone();
Progress("%u slots truncated\n", m_TruncatedCount);
}
void UFIndex::TruncateSlot(uint64 Slot)
{
++m_TruncatedCount;
byte T = GetTally(Slot);
asserta(!TallyOther(T));
uint32 Pos = GetPos(Slot);
uint64 Slot2 = Slot;
unsigned K = 0;
for (;;)
{
byte T = GetTally(Slot2);
uint32 Pos = GetPos(Slot2);
SetTally(Slot2, TALLY_FREE);
SetPos(Slot2, UINT32_MAX);
if (T == TALLY_PLUS1 || T == TALLY_BOTH1)
{
assert(Slot2 == Slot);
return;
}
if (T == TALLY_END)
return;
if (T == TALLY_NEXT_LONG_MINE || T == TALLY_NEXT_LONG_OTHER)
{
uint32 StepA = Pos & 0xffff;
uint32 StepB = (Pos >> 16);
uint64 SlotA = (Slot2 + StepA)%m_SlotCount;
Slot2 = (SlotA + StepB)%m_SlotCount;
}
else
{
byte Next = GetTallyNext(T);
assert(Next > 0 && Next <= TALLY_MAX_NEXT);
Slot2 = (Slot2 + Next)%m_SlotCount;
}
}
Die("TruncateSlot(%" PRIx64 ")", Slot);
}
void UFIndex::UpdateSlot(uint64 Slot, uint32 Pos)
{
byte n = m_SlotCounts[Slot];
byte n_minus = m_SlotCounts_Minus[Slot];
#if TSLOT
if (Slot == TSLOT)
{
Log("\n");
Log("_______________________________________\n");
Log("\nUpdateSlot(%" PRIx64 ", %u) nplus %u, nminus %u\n", Slot, Pos, n, n_minus);
Log("Before update... ");
LogList(Slot);
}
#endif
if (n > m_MaxIx || n_minus > m_MaxIx)
{
#if TSLOT
if (Slot == TSLOT)
Log("n=%u, n_minus=%u > m_MaxIx=%u\n", n, n_minus, m_MaxIx);
#endif
return;
}
byte T = GetTally(Slot);
if (T == TALLY_FREE)
{
assert(GetPos(Slot) == UINT32_MAX);
SetPos(Slot, Pos);
if (n == 1 && n_minus == 0)
SetTally(Slot, TALLY_BOTH1);
else
SetTally(Slot, TALLY_PLUS1);
#if TSLOT
if (Slot == TSLOT)
{
Log("TALLY_FREE (n=%u): ", n);
LogRow(Slot);
Log("\n");
}
#endif
return;
}
uint64 EOLSlot = FindEndOfList(Slot);
#if TSLOT
if (Slot == TSLOT)
Log("EOLSlot=%" PRIx64 "\n", EOLSlot);
#endif
unsigned Step = FindFreeSlot(EOLSlot);
#if TSLOT
if (Slot == TSLOT)
Log("Step=%u\n", Step);
#endif
if (Step == UINT_MAX)
{
TruncateSlot(Slot);
return;
}
uint64 FreeSlot = (EOLSlot + Step)%m_SlotCount;
#if TSLOT
if (Slot == TSLOT)
Log("FreeSlot=%" PRIx64 "\n", FreeSlot);
#endif
if (Step > TALLY_MAX_NEXT)
{
unsigned Step2 = FindFreeSlot(FreeSlot);
#if TSLOT
if (Slot == TSLOT)
Log("Step2=%u\n", Step2);
#endif
if (Step2 == UINT_MAX)
{
TruncateSlot(Slot);
return;
}
uint32 EOLPos = GetPos(EOLSlot);
#if TSLOT
if (Slot == TSLOT)
Log("EOLPos=%" PRIu64 "\n", EOLPos);
#endif
uint64 FreeSlot2 = (FreeSlot + Step2)%m_SlotCount;
#if TSLOT
if (Slot == TSLOT)
Log("FreeSlot2=%" PRIx64 "\n", FreeSlot2);
#endif
if (EOLSlot == Slot)
SetTallyNext(EOLSlot, TALLY_NEXT_LONG_MINE);
else
SetTallyNext(EOLSlot, TALLY_NEXT_LONG_OTHER);
SetPos(EOLSlot, Step | (Step2 << 16));
SetTally(FreeSlot, TALLY_NEXT_LONG_OTHER);
SetPos(FreeSlot, EOLPos);
SetTally(FreeSlot2, TALLY_END);
SetPos(FreeSlot2, Pos);
#if TSLOT
if (Slot == TSLOT)
{
Log("After update long...");
LogList(Slot);
}
#endif
return;
}
#if TSLOT
if (Slot == TSLOT)
Log("FreeSlot=%" PRIx64 "\n");
#endif
// EOL slot
byte Next = byte(Step);
SetTallyNext(EOLSlot, Next);
assert(GetTally(FreeSlot) == TALLY_FREE);
SetTally(FreeSlot, TALLY_END);
SetPos(FreeSlot, Pos);
#if TSLOT
if (Slot == TSLOT)
{
Log(" After update, row: ");
LogRow(Slot);
Log("\n");
}
#endif
}
void UFIndex::FreeTempBuildData()
{
if (m_SlotCounts != 0)
{
myfree(m_SlotCounts);
m_SlotCounts = 0;
}
if (m_SlotCounts_Minus != 0)
{
myfree(m_SlotCounts_Minus);
m_SlotCounts_Minus = 0;
}
}
void UFIndex::CountSlots()
{
ProgressOne("Init slot counts");
m_SlotCounts = myalloc64(byte, m_SlotCount);
memset_zero(m_SlotCounts, m_SlotCount);
ProgressDone();
uint64 Word = 0;
byte K = 0;
uint32 SeqPos;
ProgressOne("Count slots");
for (SeqPos = m_StartPos; SeqPos < m_EndPos; ++SeqPos)
{
ProgressLoopTick(SeqPos);
byte c = m_SeqData[SeqPos];
byte Letter = g_CharToLetterNucleo[c];
if (Letter == INVALID_LETTER)
{
K = 0;
Word = 0;
continue;
}
if (K < m_WordLength)
++K;
Word = (Word << uint64(2)) | Letter;
if (K == m_WordLength)
{
uint64 Slot = WordToSlot(Word & m_ShiftMask, m_SlotCount);
if (m_SlotCounts[Slot] < 255)
++(m_SlotCounts[Slot]);
}
}
ProgressDone();
}
void UFIndex::CountSlots_Minus()
{
ProgressOne("Init minus slot counts");
m_SlotCounts_Minus = myalloc64(byte, m_SlotCount);
memset_zero(m_SlotCounts_Minus, m_SlotCount);
ProgressDone();
uint64 Word = 0;
byte K = 0;
uint32 nnn;
uint32 SeqPos = m_EndPos;
ProgressOne("Count slots minus");
for (nnn = m_StartPos; nnn < m_EndPos; ++nnn)
{
ProgressLoopTick(nnn);
byte c = m_SeqData[--SeqPos];
byte Letter = g_CharToCompLetter[c];
if (Letter == INVALID_LETTER)
{
K = 0;
Word = 0;
continue;
}
if (K < m_WordLength)
++K;
Word = (Word << uint64(2)) | Letter;
if (K == m_WordLength)
{
uint64 Slot = WordToSlot(Word & m_ShiftMask, m_SlotCount);
if (m_SlotCounts_Minus[Slot] < 255)
++(m_SlotCounts_Minus[Slot]);
}
}
asserta(SeqPos == m_StartPos);
ProgressDone();
}
void UFIndex::CountIndexedWords(unsigned &IndexedCount,
unsigned &NotIndexedCount, unsigned &WildcardCount)
{
IndexedCount = 0;
NotIndexedCount = 0;
WildcardCount = 0;
uint64 Word = 0;
byte K = 0;
uint32 *PosVec = myalloc(uint32, m_MaxIx);
ProgressOne("Count indexed words");
for (uint32 SeqPos = m_StartPos; SeqPos < m_EndPos; ++SeqPos)
{
byte c = m_SeqData[SeqPos];
byte Letter = g_CharToLetterNucleo[c];
if (Letter == INVALID_LETTER)
{
K = 0;
Word = 0;
++WildcardCount;
continue;
}
if (K < m_WordLength)
++K;
Word = (Word << uint64(2)) | Letter;
if (K == m_WordLength)
{
uint64 Slot = WordToSlot(Word & m_ShiftMask, m_SlotCount);
unsigned RowLen = GetRow(Slot, PosVec);
bool Found = false;
uint32 StartPos = SeqPos - (m_WordLength-1);
for (unsigned k = 0; k < RowLen; ++k)
{
uint32 Pos_k = PosVec[k];
if (Pos_k == StartPos)
{
Found = true;
break;
}
}
if (Found)
++IndexedCount;
else
++NotIndexedCount;
}
else
++WildcardCount;
}
ProgressDone();
myfree(PosVec);
}
void UFIndex::ReadSeqData(const string &FastaFileName)
{
SeqDB DB;
DB.FromFasta(FastaFileName);
DB.ToUpper();
const unsigned SeqCount = DB.GetSeqCount();
ProgressOne("Initialize seqs");
m_SeqDataSize = 0;
bool AltWarningDone = false;
for (unsigned SeqIndex = 0; SeqIndex < SeqCount; ++SeqIndex)
{
const char *Label = DB.GetLabel(SeqIndex);
if (EndsWith(string(Label), "_alt"))
{
Warning("\nURMAP is not alt-aware, recommend removing alt chromosomes\n");
AltWarningDone = true;
}
unsigned L = DB.GetSeqLength(SeqIndex);
m_Labels.push_back(string(Label));
m_SeqLengths.push_back(L);
m_Offsets.push_back(m_SeqDataSize);
m_SeqDataSize += L;
m_GenomeSize += L;
if (SeqIndex + 1 != SeqCount)
m_SeqDataSize += PADGAP;
}
m_SeqData = myalloc(byte, m_SeqDataSize);
unsigned Offset = 0;
for (unsigned SeqIndex = 0; SeqIndex < SeqCount; ++SeqIndex)
{
const char *Label = DB.GetLabel(SeqIndex);
const byte *Seq = DB.GetSeq(SeqIndex);
unsigned L = DB.GetSeqLength(SeqIndex);
memcpy(m_SeqData + Offset, Seq, L);
Offset += L;
if (SeqIndex + 1 != SeqCount)
{
for (unsigned i = 0; i < PADGAP; ++i)
m_SeqData[Offset+i] = '-';
Offset += PADGAP;
}
}
asserta(Offset == m_SeqDataSize);
DB.Free();
ProgressDone();
}
void UFIndex::LogMe() const
{
Log("\n");
Log("Word %u\n", m_WordLength);
Log("m_MaxIx %u\n", m_MaxIx);
LogSlots(0, 100);
Log("\n\n");
LogSlots(1000, 2000);
Log("\n\n");
LogSlots(m_SlotCount - 101, 100);
}
void UFIndex::LogSlots(uint64 SlotLo, uint64 N) const
{
for (uint64 i = 0; i < N; ++i)
{
uint64 Slot = SlotLo + i;
byte T = GetTally(Slot);
bool Mine = TallyMine(T);
uint32 Pos = GetPos(Slot);
Log("%10" PRIx64, Slot);
if (m_SlotCounts != 0)
Log(" %3u", m_SlotCounts[Slot]);
Log(" %02x", T);
if (Pos == UINT32_MAX)
Log(" ..........");
else if (T == TALLY_NEXT_LONG_MINE || T == TALLY_NEXT_LONG_OTHER)
Log(" steps %u, %u", (Pos & 0xffff), Pos >> 16);
else
Log(" %10u", Pos);
Log(" ");
LogTally(T);
if (TallyMine(T))
LogRow(Slot);
Log("\n");
}
}
void UFIndex::GetCollisionCount(uint64 &CollisionCount, uint64 &IndexedCount) const
{
CollisionCount = 0;
IndexedCount = 0;
string s;
uint32 *PosVec = myalloc(uint32, m_MaxIx);
uint64 Slot = 0;
ProgressLoop64(m_SlotCount, &Slot, "Collisions");
for (Slot = 0; Slot < m_SlotCount; ++Slot)
{
unsigned K = GetRow(Slot, PosVec);
asserta(K < 256);
IndexedCount += K;
const byte *Str0 = m_SeqData + PosVec[0];
for (unsigned k = 1; k < K; ++k)
{
uint32 Pos = PosVec[k];
asserta(Pos < m_SeqDataSize);
const byte *Str = m_SeqData + PosVec[k];
if (memcmp(Str, Str0, m_WordLength) != 0)
++CollisionCount;
}
}
ProgressDone();
myfree(PosVec);
}
void UFIndex::LogSlot(uint64 Slot) const
{
Log("\n");
Log("LogSlot(%" PRIx64 ")\n", Slot);
uint32 *PosVec = myalloc(uint32, m_MaxIx);
unsigned K = GetRow(Slot, PosVec);
Log(" K=%u\n", K);
asserta(K <= m_MaxIx);
for (unsigned k = 0; k < K; ++k)
{
uint32 Pos = PosVec[k];
asserta(Pos < m_SeqDataSize);
Log("\n");
Log(" k %u\n", k);
Log(" Pos %u\n", Pos);
uint64 Word = GetWord(Pos);
uint64 Slot2 = WordToSlot(Word, m_SlotCount);
string s;
GetStr(Pos, 24, s);
uint64 Word2 = SeqToWord((const byte *) s.c_str());
Log(" Str %s\n", s.c_str());
Log(" Word %" PRIx64 "\n", Word);
Log(" Word2 %" PRIx64 "\n", Word2);
Log(" Slot %" PRIx64 "\n", Slot);
Log(" Slot2 %" PRIx64 "\n", Slot2);
}
myfree(PosVec);
}
void UFIndex::ValidateSlot(uint64 Slot) const
{
uint32 *PosVec = myalloc(uint32, m_MaxIx);
unsigned K = GetRow_Validate(Slot, PosVec);
asserta(K <= m_MaxIx);
for (unsigned k = 0; k < K; ++k)
{
uint32 Pos = PosVec[k];
asserta(Pos < m_SeqDataSize);
uint64 Word = GetWord(Pos);
uint64 Slot2 = WordToSlot(Word, m_SlotCount);
if (Slot2 != Slot)
{
Log("\n");
Log("============== validate fail 0x%" PRIx64 "===============\n", Slot);
if (Slot >= 2)
LogSlots(Slot-2, 256);
string s;
GetStr(Pos, 24, s);
uint64 Word2 = SeqToWord((const byte *) s.c_str());
Log("\n");
Log(" k %u\n", k);
Log(" K %u\n", K);
Log(" Pos %u\n", Pos);
Log(" Str %s\n", s.c_str());
Log(" Word %" PRIx64 "\n", Word);
Log(" Word2 %" PRIx64 "\n", Word2);
Log(" Slot %" PRIx64 "\n", Slot);
Log(" Slot2 %" PRIx64 "\n", Slot2);
Log(" SlotCount %" PRIx64 "\n", m_SlotCount);
Die("WordToSlot != Slot");
}
}
myfree(PosVec);
}
void UFIndex::Validate() const
{
uint64 Slot;
ProgressLoop64(m_SlotCount, &Slot, "Validate");
for (Slot = 0; Slot < m_SlotCount; ++Slot)
{
ProgressLoopTick(Slot);
ValidateSlot(Slot);
}
ProgressDone();
}
const byte *UFIndex::GetSeq(unsigned SeqIndex) const
{
asserta(SeqIndex < SIZE(m_Offsets));
unsigned Offset = m_Offsets[SeqIndex];
return m_SeqData + Offset;
}
unsigned UFIndex::GetSeqIndex(const string &Label) const
{
for (unsigned i = 0; i < SIZE(m_Labels); ++i)
if (m_Labels[i] == Label)
return i;
Die("Label not found >%s", Label.c_str());
return UINT_MAX;
}
uint32 UFIndex::CoordToPos(const string &Label, uint32 Coord) const
{
unsigned SeqIndex = GetSeqIndex(Label);
uint32 Offset = m_Offsets[SeqIndex];
uint32 Pos = Offset + Coord;
return Pos;
}
void UFIndex::GetUserPosStr(uint32 Pos, string &s) const
{
string Label;
unsigned Coord = PosToCoord(Pos, Label);
if (Coord == UINT32_MAX)
{
s = "*";
return;
}
if (Label[0] == 'c' && Label[1] == 'h' && Label[2] == 'r')
s = Label.substr(3, string::npos);
else
s = Label;
Psa(s, ":%u", Coord + 1);
}
uint32 UFIndex::PosToCoord(uint32 Pos, string &Label) const
{
const unsigned SeqCount = SIZE(m_Labels);
unsigned Lo = 0;
unsigned Hi = SeqCount - 1;
while (Lo <= Hi)
{
unsigned SeqIndex = (Lo + Hi)/2;
uint32 Offset = m_Offsets[SeqIndex];
uint32 SeqLength = m_SeqLengths[SeqIndex];
if (Pos >= Offset && Pos < Offset + SeqLength)
{
Label = m_Labels[SeqIndex];
uint32 Coord = Pos - Offset;
return Coord;
}
else if (Pos > Offset)
Lo = SeqIndex + 1;
else
Hi = SeqIndex - 1;
}
// Anomaly -- this point reached (rarely)
// when alignment extends into inter-chr padding
return UINT32_MAX;
}
uint32 UFIndex::PosToCoordL(uint32 Pos, string &Label, unsigned &L) const
{
const unsigned SeqCount = SIZE(m_Labels);
unsigned Lo = 0;
unsigned Hi = SeqCount - 1;
while (Lo <= Hi)
{
unsigned SeqIndex = (Lo + Hi)/2;
uint32 Offset = m_Offsets[SeqIndex];
uint32 SeqLength = m_SeqLengths[SeqIndex];
if (Pos >= Offset && Pos < Offset + SeqLength)
{
Label = m_Labels[SeqIndex];
uint32 Coord = Pos - Offset;
L = m_SeqLengths[SeqIndex];
return Coord;
}
else if (Pos > Offset)
Lo = SeqIndex + 1;
else
Hi = SeqIndex - 1;
}
// Anomaly -- this point is reached (rarely)
// when alignment extends into inter-chr padding
return UINT32_MAX;
}
unsigned UFIndex::GetSeqLength(unsigned SeqIndex) const
{
asserta(SeqIndex < SIZE(m_SeqLengths));
unsigned L = m_SeqLengths[SeqIndex];
return L;
}
unsigned UFIndex::GetSeqLength(const string &Label) const
{
const unsigned SeqCount = SIZE(m_Labels);
for (unsigned SeqIndex = 0; SeqIndex < SeqCount; ++SeqIndex)
{
if (Label == m_Labels[SeqIndex])
return m_SeqLengths[SeqIndex];
}
Die("GetSeqLength(%s)", Label.c_str());
return 0;
}
unsigned UFIndex::GetRow(uint64 Slot, uint32 *PosVec) const
{
byte T = GetTally(Slot);
if (TallyOther(T))
return 0;
uint32 Pos = GetPos(Slot);
uint64 Slot2 = Slot;
unsigned K = 0;
for (;;)
{
byte T = GetTally(Slot2);
uint32 Pos = GetPos(Slot2);
PosVec[K++] = Pos;
if (T == TALLY_PLUS1 || T == TALLY_BOTH1)
{
assert(Slot2 == Slot);
return K;
}
if (K == m_MaxIx)
return K;
#if DEBUG
{
if (Slot2 == Slot)
assert(TallyMine(T));
else
assert(TallyOther(T));
}
#endif
if (T == TALLY_END)
return K;
if (T == TALLY_NEXT_LONG_MINE || T == TALLY_NEXT_LONG_OTHER)
{
uint32 StepA = Pos & 0xffff;
uint32 StepB = (Pos >> 16);
uint64 SlotA = (Slot2 + StepA)%m_SlotCount;
Slot2 = (SlotA + StepB)%m_SlotCount;
uint32 PosA = GetPos(SlotA);
PosVec[K-1] = PosA;
#if DEBUG
{
byte TA = GetTally(SlotA);
assert(TA == TALLY_NEXT_LONG_OTHER);
}
#endif
}
else
{
byte Next = GetTallyNext(T);
assert(Next > 0 && Next <= TALLY_MAX_NEXT);
Slot2 = (Slot2 + Next)%m_SlotCount;
}
}
Die("GetRow(%" PRIx64 ")", Slot);
return 0;
}
unsigned UFIndex::GetRow_Validate(uint64 Slot, uint32 *PosVec) const
{
byte T = GetTally(Slot);
if (TallyOther(T))
return 0;
uint32 Pos = GetPos(Slot);
uint64 Slot2 = Slot;
unsigned K = 0;
for (;;)
{
byte T = GetTally(Slot2);
uint32 Pos = GetPos(Slot2);
PosVec[K++] = Pos;
if (T == TALLY_PLUS1 || T == TALLY_BOTH1)
{
assert(Slot2 == Slot);
return K;
}
if (K == m_MaxIx)
return K;
if (Slot2 == Slot)
asserta(TallyMine(T));
else
asserta(TallyOther(T));
if (T == TALLY_END)
return K;
if (T == TALLY_NEXT_LONG_MINE || T == TALLY_NEXT_LONG_OTHER)
{
uint32 StepA = Pos & 0xffff;
uint32 StepB = (Pos >> 16);
uint64 SlotA = (Slot2 + StepA)%m_SlotCount;
Slot2 = (SlotA + StepB)%m_SlotCount;
uint32 PosA = GetPos(SlotA);
PosVec[K-1] = PosA;
byte TA = GetTally(SlotA);
asserta(TA == TALLY_NEXT_LONG_OTHER);
}
else
{
byte Next = GetTallyNext(T);
assert(Next > 0 && Next <= TALLY_MAX_NEXT);
Slot2 = (Slot2 + Next)%m_SlotCount;
}
}
Die("GetRow(%" PRIx64 ")", Slot);
return 0;
}
unsigned UFIndex::GetRow_Blob(uint64 Slot, const byte *ptrBlob,
uint32 *PosVec) const
{
byte T = *ptrBlob;
if (TallyOther(T))
return 0;
uint64 Slot2 = Slot;
uint32 Pos = *(uint32 *) (ptrBlob + 1);
unsigned K = 0;
for (;;)
{
if (K > 0)
{
T = GetTally(Slot2);
Pos = GetPos(Slot2);
}
assert(Pos < m_SeqDataSize);
PosVec[K++] = Pos;
if (K == m_MaxIx)
return K;
if (T == TALLY_PLUS1 || T == TALLY_BOTH1)
{
return 1;
}
#if DEBUG
{
if (K == 1)
assert(TallyMine(T));
else
assert(TallyOther(T));
}
#endif
if (T == TALLY_END)
return K;
if (T == TALLY_NEXT_LONG_MINE || T == TALLY_NEXT_LONG_OTHER)
{
uint32 StepA = Pos & 0xffff;
uint32 StepB = (Pos >> 16);
uint64 SlotA = (Slot2 + StepA)%m_SlotCount;
Slot2 = (SlotA + StepB)%m_SlotCount;
uint32 PosA = GetPos(SlotA);
PosVec[K-1] = PosA;
#if DEBUG
{
byte TA = GetTally(SlotA);
assert(TA == TALLY_NEXT_LONG_OTHER);
}
#endif
}
else
{
byte Next = GetTallyNext(T);
assert(Next > 0 && Next <= TALLY_MAX_NEXT);
Slot2 = (Slot2 + Next)%m_SlotCount;
}
}
Die("GetRow_Blob(%" PRIx64 ")", Slot);
return 0;
}
uint64 UFIndex::FindEndOfList(uint64 Slot) const
{
byte T = GetTally(Slot);
uint32 Pos = GetPos(Slot);
assert(TallyMine(T));
uint64 Slot2 = Slot;
unsigned PosCount = 0;
for (;;)
{
byte T = GetTally(Slot2);
uint32 Pos = GetPos(Slot2);
if (T == TALLY_PLUS1 || T == TALLY_BOTH1)
{
assert(Slot2 == Slot);
return Slot2;
}
if (Slot2 == Slot)
assert(TallyMine(T));
else
assert(TallyOther(T));
if (T == TALLY_END)
return Slot2;
if (T == TALLY_NEXT_LONG_MINE || T == TALLY_NEXT_LONG_OTHER)
{
uint32 StepA = Pos & 0xffff;
uint32 StepB = (Pos >> 16);
uint64 SlotA = (Slot2 + StepA)%m_SlotCount;
Slot2 = (SlotA + StepB)%m_SlotCount;
}
else
{
byte Next = GetTallyNext(T);
assert(Next > 0 && Next <= TALLY_MAX_NEXT);
Slot2 = (Slot2 + Next)%m_SlotCount;
}
}
Die("FindEndOfList failed");
return UINT64_MAX;
}
unsigned UFIndex::FindFreeSlot(uint64 Slot)
{
for (unsigned i = 1; i < MAX_LINK_STEP; ++i)
{
uint64 Slot2 = (Slot + i)%m_SlotCount;
byte n = m_SlotCounts[Slot2];
if (n > 0 && n <= m_MaxIx)
continue;
byte T = GetTally(Slot2);
if (T == TALLY_FREE)
return i;
}
return UINT_MAX;
}
void UFIndex::LogRow(uint64 Slot) const
{
uint32 PosVec[128];
unsigned K = GetRow(Slot, PosVec);
for (unsigned k = 0; k < K; ++k)
{
uint32 Pos = PosVec[k];
string s;
GetStr(Pos, m_WordLength, s);
string Label;
unsigned Coord = PosToCoord(Pos, Label);
Log(" %s(%u=%s:%u)", s.c_str(), Pos, Label.c_str(), Coord+1);
}
}
void UFIndex::LogCountHist() const
{
asserta(m_SlotCounts != 0);
Log("\n");
Log("CountHist\n");
vector<unsigned> CountHist(256);
unsigned Total = 0;
for (uint64 Slot = 0; Slot < m_SlotCount; ++Slot)
{
unsigned n = m_SlotCounts[Slot];
Total += n;
++(CountHist[n]);
}
unsigned Maxi = 0;
for (unsigned i = 0; i < 256; ++i)
if (CountHist[i] > 0)
Maxi = i;
for (unsigned i = 0; i <= Maxi; ++i)
{
unsigned CH = CountHist[i];
Log("[%3u] %10u", i, CH);
if (i > 0)
Log(" %7.2f%%", GetPct(CH, Total));
Log("\n");
}
Log("Total %u\n", Total);
}
void UFIndex::LogTally(byte T) const
{
Log("T=%02x/", T);
if (T == TALLY_FREE)
Log("Free");
else if (T == TALLY_END)
Log("End");
else if (T == TALLY_BOTH1)
Log("Both1");
else if (T == TALLY_PLUS1)
Log("Plus1");
else if (T == TALLY_NEXT_LONG_MINE)
Log("LongM");
else if (T == TALLY_NEXT_LONG_OTHER)
Log("LongO");
else
Log("%u", GetTallyNext(T));
}
void UFIndex::LogList(uint64 Slot) const
{
Log("\n");
Log("LogList(%x)\n", Slot);
byte T = GetTally(Slot);
uint32 Pos = GetPos(Slot);
if (TallyOther(T))
{
Log("%10" PRIx64, Slot);
Log(" %10u", Pos);
Log(" %02X", T);
LogTally(T);
Log("\n");
return;
}
uint64 Slot2 = Slot;
unsigned PosCount = 0;
for (;;)
{
byte T = GetTally(Slot2);
uint32 Pos = GetPos(Slot2);
Log("%10" PRIx64, Slot2);
Log(" %10u", Pos);
Log(" %02X ", T);
LogTally(T);
if (T != TALLY_NEXT_LONG_MINE && T != TALLY_NEXT_LONG_OTHER)
{
assert(Pos < m_SeqDataSize);
string s;
GetStr(Pos, m_WordLength, s);
Log(" [%08" PRIx64 "]%u=%s", Slot, Pos, s.c_str());
Log("\n");
}
if (T == TALLY_PLUS1 || T == TALLY_BOTH1)
{
assert(Slot2 == Slot);
return;
}
if (Slot2 == Slot)
assert(TallyMine(T));
else
assert(TallyOther(T));
if (T == TALLY_END)
return;
if (T == TALLY_NEXT_LONG_MINE || T == TALLY_NEXT_LONG_OTHER)
{
uint32 StepA = Pos & 0xffff;
uint32 StepB = (Pos >> 16);
uint64 SlotA = (Slot2 + StepA)%m_SlotCount;
Slot2 = (SlotA + StepB)%m_SlotCount;
Log(" ...StepA=%u, StepB=%u, SlotA %" PRIx64 ", Slot2 -> %" PRIx64 "\n", StepA, StepB, SlotA, Slot2);
Log("SlotA:\n");
uint32 PosA = GetPos(SlotA);
byte TA = GetTally(SlotA);
Log("%10" PRIx64, SlotA);
Log(" %10u", PosA);
Log(" %02X ", TA);
LogTally(TA);
string s;
GetStr(PosA, m_WordLength, s);
Log(" [%08" PRIx64 "]%u=%s", SlotA, PosA, s.c_str());
Log("\n");
}
else
{
byte Next = GetTallyNext(T);
assert(Next > 0 && Next <= TALLY_MAX_NEXT);
Slot2 = (Slot2 + Next)%m_SlotCount;
}
}
}
| 24,337
|
C++
|
.cpp
| 1,058
| 20.060491
| 104
| 0.621827
|
rcedgar/urmap
| 39
| 11
| 5
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,932
|
seqdbio.cpp
|
rcedgar_urmap/src/seqdbio.cpp
|
#include "myutils.h"
#include "seqdb.h"
#define TRACE 0
uint32 SeqDB::GetLabelBytes() const
{
uint64 Bytes = 0;
for (unsigned i = 0; i < m_SeqCount; ++i)
Bytes += (uint64) strlen(m_Labels[i]) + 1;
if (Bytes > UINT_MAX)
Die("Label data too big");
return (uint32) Bytes;
}
void SeqDB::ToFile(FILE *f) const
{
#if TRACE
Log("\n");
Log("SeqDB::ToFile, pos %u\n", GetStdioFilePos64(f));
Log("SeqCount %u\n", m_SeqCount);
#endif
Progress("Buffers (%u seqs)\n", m_SeqCount);
// padding for safety
const unsigned MAX_SIZE = UINT_MAX - 1024;
off_t HdrPos = GetStdioFilePos64(f);
// Placeholder header, invalid in case of crash.
SeqDBFileHdr Hdr;
memset(&Hdr, 0, sizeof(Hdr));
WriteStdioFile(f, &Hdr, sizeof(Hdr));
uint64 SeqBytes = GetLetterCount();
uint32 LabelBytes = GetLabelBytes();
#if TRACE
Log("SeqBytes %s\n", IntToStr2(SeqBytes));
Log("LabelBytes %s\n", IntToStr2(LabelBytes));
#endif
if (double(m_SeqCount)*4 > double(MAX_SIZE))
Die("Too many seqs for 32-bit vector");
char *LabelBuffer = myalloc(char, LabelBytes);//1
uint32 *LabelOffsets = myalloc(uint32, m_SeqCount);//2
uint32 Offset = 0;
for (unsigned i = 0; i < m_SeqCount; ++i)
{
LabelOffsets[i] = Offset;
const char *Label = m_Labels[i];
unsigned n = (unsigned) strlen(Label) + 1;
memcpy(LabelBuffer + Offset, Label, n);
if (double(Offset)+n > double(MAX_SIZE))
Die("Label data too big");
Offset += n;
}
#if TRACE
Log("Pos %u LabelOffsets\n", GetStdioFilePos64(f));
#endif
WriteStdioFile(f, LabelOffsets, m_SeqCount*sizeof(uint32));
#if TRACE
Log("Pos %u LabelBuffer\n", GetStdioFilePos64(f));
#endif
WriteStdioFile(f, LabelBuffer, LabelBytes);
myfree(LabelBuffer);//1
myfree(LabelOffsets);//2
LabelBuffer = 0;
LabelOffsets = 0;
#if TRACE
Log("Pos %u SeqLengths\n", GetStdioFilePos64(f));
#endif
asserta(sizeof(unsigned) == sizeof(uint32));
WriteStdioFile(f, m_SeqLengths, m_SeqCount*sizeof(uint32));
#if TRACE
Log("Pos %u Seqs\n", GetStdioFilePos64(f));
#endif
const unsigned BUFFER_SIZE = 16*1024*1024;
byte *Buffer = myalloc(byte, BUFFER_SIZE);
unsigned BufferPos = 0;
uint64 TotalSeqBytes = 0;
unsigned i;
ProgressLoop(m_SeqCount, &i, "Seqs");
for (i = 0; i < m_SeqCount; ++i)
{
const byte *Seq = m_Seqs[i];
unsigned L = m_SeqLengths[i];
TotalSeqBytes += L;
if (BufferPos + L < BUFFER_SIZE)
{
memcpy(Buffer + BufferPos, Seq, L);
BufferPos += L;
}
else
{
WriteStdioFile(f, Buffer, BufferPos);
BufferPos = 0;
WriteStdioFile(f, Seq, L);
}
}
ProgressDone();
asserta(TotalSeqBytes == SeqBytes);
if (BufferPos > 0)
WriteStdioFile(f, Buffer, BufferPos);
myfree(Buffer);
// Correct file header
Hdr.Magic1 = SeqDBFileHdr_Magic1;
Hdr.SeqCount= m_SeqCount;
Hdr.SeqBytes = SeqBytes;
Hdr.LabelBytes = LabelBytes;
Hdr.Magic2 = SeqDBFileHdr_Magic2;
uint64 EndPos = GetStdioFilePos64(f);
SetStdioFilePos64(f, HdrPos);
WriteStdioFile(f, &Hdr, sizeof(Hdr));
SetStdioFilePos64(f, EndPos);
}
static void SeqLengthsToBufferInfo(const uint32 *SeqLengths, unsigned SeqCount,
vector<unsigned> &BufferSeqCounts, vector<unsigned> &BufferSizes)
{
BufferSeqCounts.clear();
BufferSizes.clear();
if (SeqCount == 0)
return;
const uint64 MAX_BUFFER_SIZE = 1024*1024*1024;
unsigned BufferSeqCount = 0;
uint64 BufferSize = 0;
for (unsigned i = 0; i < SeqCount; ++i)
{
unsigned L = SeqLengths[i];
if (BufferSize + L > MAX_BUFFER_SIZE)
{
asserta(BufferSeqCount > 0);
BufferSeqCounts.push_back(BufferSeqCount);
BufferSizes.push_back((unsigned) BufferSize);
BufferSize = 0;
BufferSeqCount = 0;
}
++BufferSeqCount;
BufferSize += L;
}
asserta(BufferSeqCount > 0);
BufferSeqCounts.push_back(BufferSeqCount);
BufferSizes.push_back((unsigned) BufferSize);
}
| 3,778
|
C++
|
.cpp
| 135
| 25.503704
| 79
| 0.712825
|
rcedgar/urmap
| 39
| 11
| 5
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,933
|
ufigetboth1s.cpp
|
rcedgar_urmap/src/ufigetboth1s.cpp
|
#include "myutils.h"
#include "ufindex.h"
#include "seqinfo.h"
#include "alpha.h"
#include "state1.h"
#include "omplock.h"
#include <inttypes.h>
void State1::GetBoth1s(SeqInfo *Query, vector<uint32> &PosVec)
{
PosVec.clear();
m_Query = Query;
const byte *Q = m_Query->m_Seq;
const unsigned QL = m_Query->m_L;
unsigned QWordCount = QL - (m_WordLength - 1);
m_AllocBuffOffset = 0;
uint64 *SlotsVec_Plus = alloc_buff(uint64, QL);
uint64 *SlotsVec_Minus = alloc_buff(uint64, QL);
byte *BlobVec_Plus = alloc_buff(byte, 5*QL);
byte *BlobVec_Minus = alloc_buff(byte, 5*QL);
// Plus
SetSlotsVec(Q, QL, SlotsVec_Plus);
for (uint32 QPos = 0; QPos < QWordCount; ++QPos)
{
uint64 Slot = SlotsVec_Plus[QPos];
if (Slot == UINT64_MAX)
continue;
m_UFI->GetBlob(Slot, BlobVec_Plus + 5*QPos);
byte T = BlobVec_Plus[5*QPos];
if (T == TALLY_BOTH1)
{
uint32 Pos = *(uint32 *) (BlobVec_Plus + 5*QPos + 1);
PosVec.push_back(Pos);
}
}
// Minus
m_RevCompQuerySeq.Alloc(QL);
RevCompSeq(Q, QL, m_RevCompQuerySeq.Data);
const byte *QRC = m_RevCompQuerySeq.Data;
SetSlotsVec(QRC, QL, SlotsVec_Minus);
for (uint32 QPos = 0; QPos < QWordCount; ++QPos)
{
uint64 Slot = SlotsVec_Minus[QPos];
if (Slot == UINT64_MAX)
continue;
m_UFI->GetBlob(Slot, BlobVec_Minus + 5*QPos);
byte T = BlobVec_Minus[5*QPos];
if (T == TALLY_BOTH1)
{
uint32 Pos = *(uint32 *) (BlobVec_Minus + 5*QPos + 1);
PosVec.push_back(Pos);
}
}
}
| 1,464
|
C++
|
.cpp
| 53
| 25.018868
| 62
| 0.674269
|
rcedgar/urmap
| 39
| 11
| 5
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,934
|
test.cpp
|
rcedgar_urmap/src/test.cpp
|
#include "myutils.h"
#include "tenx.h"
void cmd_test()
{
unsigned n = count_t(~1);
ProgressLog("count_t(~1) = %u\n", n);
}
| 128
|
C++
|
.cpp
| 7
| 16.571429
| 38
| 0.625
|
rcedgar/urmap
| 39
| 11
| 5
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,935
|
gethsps.cpp
|
rcedgar_urmap/src/gethsps.cpp
|
#include "myutils.h"
#include "hspfinder.h"
#include "diagbox.h"
#include "alnheuristics.h"
#include <algorithm>
#define TRACE 0
unsigned HSPFinder::GetGlobalHSPs(unsigned MinLength, float MinFractId,
bool StaggerOk, float &HSPFractId)
{
IncCounter(GetGlobalHSPs);
const byte *A = m_SA->m_Seq;
const byte *B = m_SB->m_Seq;
const unsigned LA = m_SA->m_L;
const unsigned LB = m_SB->m_L;
float X = m_AH->XDropGlobalHSP;
UngappedBlast(X, StaggerOk, MinLength, m_AH->MinGlobalHSPScore);
Chain();
StartTimer(GetHSPs2);
unsigned TotalLength = 0;
unsigned TotalSameCount = 0;
unsigned N = m_ChainedHSPCount;
#if TRACE
Log("\n");
Log("After chain, %u HSPs:\n", m_ChainedHSPCount);
#endif
for (unsigned i = 0; i < m_ChainedHSPCount; ++i)
{
const HSPData &HSP = *m_ChainedHSPs[i];
#if TRACE
HSP.LogMe();
#endif
if (HSP.Leni != HSP.Lenj)
{
Warning("HSPFinder::GetHSPs, bad HSP");
HSP.LogMe();
m_UngappedHSPCount = 0;
m_ChainedHSPCount = 0;
EndTimer(GetHSPs2);
return 0;
}
TotalLength += HSP.GetLength();
TotalSameCount += GetHSPIdCount(HSP);
}
HSPFractId = TotalLength == 0 ? 0.0f :
float(TotalSameCount)/float(TotalLength);
EndTimer(GetHSPs2);
return m_ChainedHSPCount;
}
| 1,233
|
C++
|
.cpp
| 48
| 23.1875
| 71
| 0.715136
|
rcedgar/urmap
| 39
| 11
| 5
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,537,936
|
pathinfo.cpp
|
rcedgar_urmap/src/pathinfo.cpp
|
#include "myutils.h"
#include "pathinfo.h"
#define TRACE 0
void PathInfo::FreeIfBig()
{
if (m_BufferBytes < 4*g_MaxL)
return;
#if TRACE
Log("PathInfo::FreeIfBig(this=0x%lx) m_BufferBytes=%u\n",
(long) this, m_BufferBytes);
#endif
IncCounter(PathInfo_FreeIfBig);
myfree(m_Buffer);
m_Buffer = 0;
m_BufferBytes = 0;
}
void PathInfo::Alloc(unsigned Bytes)
{
FreeIfBig();
if (Bytes < m_BufferBytes)
return;
#if TRACE
Log("PathInfo::Alloc(this=0x%lx, Bytes=%u) m_BufferBytes=%u\n",
(long) this, Bytes, m_BufferBytes);
#endif
IncCounter(PathInfo_Realloc);
myfree(m_Buffer);
m_BufferBytes = Bytes + 128;
m_Buffer = myalloc(char, m_BufferBytes);
}
void PathInfo::Realloc(unsigned Bytes)
{
asserta(Bytes > m_BufferBytes);
char *NewBuffer = myalloc(char, Bytes);
if (m_ColCount > 0)
{
asserta(m_ColCount < m_BufferBytes);
memcpy(NewBuffer, m_Buffer, m_ColCount + 1);
}
myfree(m_Buffer);
m_Buffer = NewBuffer;
m_BufferBytes = Bytes;
}
void PathInfo::Alloc2(unsigned LA, unsigned LB)
{
FreeIfBig();
unsigned Bytes = LA + LB + 1;
if (Bytes > m_BufferBytes)
Alloc(Bytes);
}
void PathInfo::SetEmpty()
{
FreeIfBig();
// Prevent crash if never alloc'd
if (m_Buffer == 0)
Alloc(g_MaxL);
m_Buffer[0] = 0;
m_ColCount = 0;
}
unsigned PathInfo::GetCounts(unsigned &M, unsigned &D, unsigned &I) const
{
M = 0;
D = 0;
I = 0;
const char *Path = GetPath();
for (const char *p = Path; *p; ++p)
{
char c = *p;
if (c == 'M')
++M;
else if (c == 'D')
++D;
else if (c == 'I')
++I;
else
asserta(false);
}
return M + D + I;
}
void PathInfo::Reverse()
{
unsigned L = GetColCount();
for (unsigned i = 0; i < L/2; ++i)
swap(m_Buffer[i], m_Buffer[L-i-1]);
}
void PathInfo::AppendPath(const PathInfo &PI)
{
unsigned n = PI.GetColCount();
if (n == 0)
return;
Grow(n);
const char *Path = PI.GetPath();
memcpy(m_Buffer + m_ColCount, Path, n);
m_ColCount += n;
m_Buffer[m_ColCount] = 0;
}
void PathInfo::PrependPath(const PathInfo &PI)
{
unsigned n = PI.GetColCount();
Grow(n);
unsigned ColCount = PI.GetColCount();
if (m_ColCount > 0)
memmove(m_Buffer + ColCount, m_Buffer, m_ColCount);
if (ColCount > 0)
{
const char *Path = PI.GetPath();
memcpy(m_Buffer, Path, ColCount);
m_ColCount += ColCount;
asserta(m_ColCount < m_BufferBytes);
m_Buffer[m_ColCount] = 0;
assert(strlen(m_Buffer) == m_ColCount);
}
}
void PathInfo::AppendChar(char c)
{
Grow(1);
m_Buffer[m_ColCount++] = c;
m_Buffer[m_ColCount] = 0;
}
void PathInfo::AppendMs(unsigned Count)
{
Grow(Count);
for (unsigned i = 0; i < Count; ++i)
m_Buffer[m_ColCount++] = 'M';
m_Buffer[m_ColCount] = 0;
}
void PathInfo::AppendDs(unsigned Count)
{
for (unsigned i = 0; i < Count; ++i)
m_Buffer[m_ColCount++] = 'D';
m_Buffer[m_ColCount] = 0;
}
void PathInfo::AppendIs(unsigned Count)
{
for (unsigned i = 0; i < Count; ++i)
m_Buffer[m_ColCount++] = 'I';
m_Buffer[m_ColCount] = 0;
}
unsigned PathInfo::GetLeftICount()
{
for (unsigned i = 0; i < m_ColCount; ++i)
if (m_Buffer[i] != 'I')
return i;
asserta(false);
return UINT_MAX;
}
unsigned PathInfo::TrimLeftIs()
{
unsigned LeftICount = GetLeftICount();
m_ColCount -= LeftICount;
memmove(m_Buffer, m_Buffer+LeftICount, m_ColCount);
m_Buffer[m_ColCount] = 0;
return LeftICount;
}
void PathInfo::TrimRightIs()
{
for (unsigned i = m_ColCount - 1; i > 0; --i)
{
if (m_Buffer[i] == 'I')
{
m_Buffer[i] = 0;
--m_ColCount;
}
else
{
assert(strlen(m_Buffer) == m_ColCount);
return;
}
}
}
unsigned PathInfo::GetQL() const
{
unsigned n = 0;
for (unsigned i = 0; i < m_ColCount; ++i)
if (m_Buffer[i] == 'M' || m_Buffer[i] == 'D')
++n;
return n;
}
unsigned PathInfo::GetTL() const
{
unsigned n = 0;
for (unsigned i = 0; i < m_ColCount; ++i)
if (m_Buffer[i] == 'M' || m_Buffer[i] == 'I')
++n;
return n;
}
| 3,898
|
C++
|
.cpp
| 186
| 18.591398
| 73
| 0.649675
|
rcedgar/urmap
| 39
| 11
| 5
|
GPL-2.0
|
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.