Skip to content

Commit

Permalink
Merge branch 'master' into ntp_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bkerler authored Jan 21, 2024
2 parents 3bec243 + 0ba6a80 commit 0aebd3c
Show file tree
Hide file tree
Showing 16 changed files with 286 additions and 59 deletions.
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
This repository includes source code and firmware releases for the Original Prusa 3D printers based on the 32-bit ARM microcontrollers.

The currently supported models are:
- Original Prusa MINI
- Original Prusa MINI/MINI+
- Original Prusa MK3.9
- Original Prusa MK4
- Original Prusa XL

Expand Down Expand Up @@ -59,15 +60,9 @@ The build process of this project is driven by CMake and `build.py` is just a hi
- [Eclipse, STM32CubeIDE](doc/editor/stm32cubeide.md)
- [Other LSP-based IDEs (Atom, Sublime Text, ...)](doc/editor/lsp-based-ides.md)

#### Formatting
#### Contributing

All the source code in this repository is automatically formatted:

- C/C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html),
- Python files using [yapf](https://github.com/google/yapf),
- and CMake files using [cmake-format](https://github.com/cheshirekow/cmake_format).

If you want to contribute, make sure to install [pre-commit](https://pre-commit.com) and then run `pre-commit install` within the repository. This makes sure that all your future commits will be formatted appropriately. Our build server automatically rejects improperly formatted pull requests.
If you want to contribute to the codebase, please read the [Contribution Guidelines](doc/contributing.md).

#### XL and Puppies

Expand Down
64 changes: 64 additions & 0 deletions doc/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Contribution Guidelines

## Git

### Merging: Use rebase whenever possible

The goal is to have a simple and linear git history.
It is not always possible; for example when merging master into private.
In such cases, it is ok to use git-merge.

### Commit: Atomicity

A commit should be a single complete unit of work.
Every commit should be buildable and follow the rules in this document.

### Commit: Message

- Commit message comprises a subject and a body (separated by an empty line).
- Commit message is written in English.
- Subject uses the imperative mood.
- Subject starts with a capital letter and does not end with a period.
- When a commit is relevant to some subset/module of the project (most of the time), use it as a prefix of the subject as follows:
```
metrics: Add support for syslog
```
or
```
gui: Add touch support
```
- Write the module in lowercase
- Limit the subject to 72 letters.
- Wrap the body to 72 letters per line.
- Put an issue tracker reference (BFW-xxxx) at the end of the body if you have one. Do not put it in the subject line.

## Formatting & Code Organization

### Formatting

All the source code in this repository is automatically formatted:

- C/C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html),
- Python files using [yapf](https://github.com/google/yapf),
- and CMake files using [cmake-format](https://github.com/cheshirekow/cmake_format).

If you want to contribute, make sure to install [pre-commit](https://pre-commit.com) and then run `pre-commit install` within the repository. This makes sure that all your future commits will be formatted appropriately. Our build server automatically rejects improperly formatted pull requests.

### Files: Include Guards
Use the `#pragma once` as a file guard.
Do not use the `#ifdef FILE_X`, `#define FILE_X`, `#endif` pattern.

### Files: Author & Copyright

Do not add file headers with author/creation time/copyright, etc.
Those data are already stored in the commit, and we don't want to duplicate them.

This does not apply to 3rd party code in our repository.

### Code Style: C/C++ Naming Conventions

- Types & Classes are in `PascalCase`.
- Global constants in `SCREAMING_CASE`
- Variables (local, class, etc), class-level constants, `enum class` items, methods and namespaces are in `snake_case`.
- File names are in `snake_case.cpp` (even if the only thing the file contains is a class named in `PascalCase`).
- Types never end with a `'_t'`.
2 changes: 1 addition & 1 deletion include/marlin/Configuration_MINI.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@
// 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 290
#define HEATER_0_MAXTEMP 295
#define HEATER_1_MAXTEMP 275
#define HEATER_2_MAXTEMP 275
#define HEATER_3_MAXTEMP 275
Expand Down
4 changes: 2 additions & 2 deletions lib/Marlin/Marlin/src/gcode/feature/input_shaper/M74.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ void GcodeSuite::M74() {

if (parser.seen('W')) {
const float m = parser.value_float();
if (m > 0) {
if (m >= 0.f) {
params.mass = m;
} else {
SERIAL_ECHO_MSG("?Mass (W) must be greater than 0");
SERIAL_ECHO_MSG("?Mass (W) must be greater or equal 0");
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/WUI/link_content/basic_gets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ JsonResult get_printer(size_t resume_point, JsonOutput &output) {
JsonResult get_version(size_t resume_point, JsonOutput &output) {
char hostname[ETH_HOSTNAME_LEN + 1];
netdev_get_hostname(netdev_get_active_id(), hostname, sizeof hostname);
auto nozzle_diameter = config_store().get_nozzle_diameter(0);
float nozzle_diameter = config_store().get_nozzle_diameter(0);

// Keep the indentation of the JSON in here!
// clang-format off
Expand All @@ -210,7 +210,7 @@ JsonResult get_version(size_t resume_point, JsonOutput &output) {
JsonResult get_info(size_t resume_point, JsonOutput &output) {
char hostname[ETH_HOSTNAME_LEN + 1];
netdev_get_hostname(netdev_get_active_id(), hostname, sizeof hostname);
auto nozzle_diameter = config_store().get_nozzle_diameter(0);
float nozzle_diameter = config_store().get_nozzle_diameter(0);
auto mmu2_enabled =
#if HAS_MMU2()
config_store().mmu2_enabled.get();
Expand Down
6 changes: 4 additions & 2 deletions lib/WUI/nhttp/req_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ ExecutionControl RequestParser::event(Event event) {
error_code = Status::RequestHeaderFieldsTooLarge;
return ExecutionControl::Continue;
}
case Names::Nonce: {
case Names::Nonce:
case Names::NonceUnquoted: {
if (!holds_alternative<DigestAuthParams>(auth_status)) {
auth_status = DigestAuthParams {};
}
Expand All @@ -126,7 +127,8 @@ ExecutionControl RequestParser::event(Event event) {
digest_params.recieved_nonce += static_cast<uint64_t>(value);
return ExecutionControl::Continue;
}
case Names::Response: {
case Names::Response:
case Names::ResponseUnquoted: {
if (!holds_alternative<DigestAuthParams>(auth_status)) {
auth_status = DigestAuthParams {};
}
Expand Down
55 changes: 55 additions & 0 deletions src/common/filament.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,50 @@ enum class Type : uint8_t {
_last = PA
};

struct ColorIndex {
const char *name;
uint32_t color;
};

enum class ColorName : uint32_t {
NONE = 0,
BLACK,
BLUE,
GREEN,
BROWN,
PURPLE,
GRAY,
TERRACOTTA,
SILVER,
GOLD,
RED,
PINK,
ORANGE,
TRANSPARENT,
YELLOW,
WHITE,
_last = WHITE
};

const ColorIndex colortable[size_t(filament::ColorName::_last) + 1] = {
{ "NONE", 0 },
{ "BLACK", 0x000000 },
{ "BLUE", 0x0000FF },
{ "GREEN", 0x00FF00 },
{ "BROWN", 0x800000 },
{ "PURPLE", 0x800080 },
{ "GRAY", 0x999999 },
{ "TERRACOTTA", 0xB87F6A },
{ "SILVER", 0xC0C0C0 },
{ "GOLD", 0xD4AF37 },
{ "RED", 0xFF0000 },
{ "PINK", 0xFF007F },
{ "ORANGE", 0xFF8000 },
{ "TRANSPARENT", 0xF0F0F0 },
{ "YELLOW", 0xFFFF00 },
{ "WHITE", 0xFFFFFF }
};

constexpr Type default_type = Type::PLA;
constexpr float cold_nozzle = 50.f;
constexpr float cold_bed = 45.f;
Expand All @@ -53,6 +97,17 @@ struct Colour {
return red << 16 | green << 8 | blue;
}

static Colour from_string(char *name) {
// first name is not valid ("---")
size_t name_len = strlen(name);
for (size_t i = size_t(ColorName::NONE) + 1; i <= size_t(ColorName::_last); ++i) {
if ((strlen(colortable[i].name) == name_len) && (!strncmp(name, colortable[i].name, name_len))) {
return from_int(colortable[i].color);
}
}
return from_int(atoi(name));
}

static Colour from_int(int value) {
return Colour {
.red = static_cast<uint8_t>((value >> 16) & 0xFF),
Expand Down
4 changes: 2 additions & 2 deletions src/common/gcode/gcode_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ void GCodeInfo::EvaluateToolsValid() {
if (per_extruder_info[e].nozzle_diameter.has_value()) {
auto do_nozzle_check = [&](uint8_t hotend) {
assert(hotend < HOTENDS);
float nozzle_diameter_distance = per_extruder_info[e].nozzle_diameter.value() - config_store().get_nozzle_diameter(hotend);
if (nozzle_diameter_distance > 0.001f || nozzle_diameter_distance < -0.001f) {
float nozzle_diameter_distance = std::abs(per_extruder_info[e].nozzle_diameter.value() - config_store().get_nozzle_diameter(hotend));
if (nozzle_diameter_distance > 0.001f) {
valid_printer_settings.wrong_nozzle_diameter.fail();
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/common/marlin_print_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ auto PrintPreview::check_tools_mapping_validity(const ToolMapper &mapper, const
return true;
}

float nozzle_diameter_distance = gcode.get_extruder_info(gcode_tool).nozzle_diameter.value() - get_nozzle_diameter(physical_extruder);
if (nozzle_diameter_distance > 0.001f || nozzle_diameter_distance < -0.001f) {
float nozzle_diameter_distance = std::abs(static_cast<float>(gcode.get_extruder_info(gcode_tool).nozzle_diameter.value()) - static_cast<float>(get_nozzle_diameter(physical_extruder)));
if (nozzle_diameter_distance > 0.001f) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/DialogConnectReg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DialogConnectRegister : public AddSuperWindow<IDialog> {
private:
char attempt_buffer[30];
char detail_buffer[70];
char error_buffer[88];
char error_buffer[90];

// TODO: Doesn't fit
constexpr static const char *const headerLabel = N_("PRUSA CONNECT");
Expand Down
12 changes: 6 additions & 6 deletions src/gui/screen_tools_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ void disable_radio(RadioButton &radio) {
radio.Invalidate();
}

double get_nozzle_diameter([[maybe_unused]] size_t idx) {
float get_nozzle_diameter([[maybe_unused]] size_t idx) {
#if HAS_TOOLCHANGER()
return static_cast<double>(config_store().get_nozzle_diameter(idx));
return static_cast<float>(config_store().get_nozzle_diameter(idx));
#elif HAS_MMU2()
return static_cast<double>(config_store().get_nozzle_diameter(0));
return static_cast<float>(config_store().get_nozzle_diameter(0));
#endif
}

Expand All @@ -162,7 +162,7 @@ void print_right_tool_into_buffer(size_t idx, std::array<std::array<char, ToolsM

if (drawing_nozzles) {
const auto cur_strlen = strlen(text_buffers[idx].data());
snprintf(text_buffers[idx].data() + cur_strlen, ToolsMappingBody::max_item_text_width - cur_strlen, " %-4.2f", get_nozzle_diameter(idx));
snprintf(text_buffers[idx].data() + cur_strlen, ToolsMappingBody::max_item_text_width - cur_strlen, " %-4.2f", static_cast<double>(get_nozzle_diameter(idx)));
}
}

Expand Down Expand Up @@ -268,8 +268,8 @@ bool all_nozzles_same(GCodeInfo &gcode_info) {
bool initialized { false };

auto nozzles_are_matching = [](float lhs, float rhs) {
float nozzle_diameter_distance = lhs - rhs;
return !(nozzle_diameter_distance > 0.001f || nozzle_diameter_distance < -0.001f);
float nozzle_diameter_distance = std::abs(lhs - rhs);
return nozzle_diameter_distance <= 0.001f;
};
// check gcodes
EXTRUDER_LOOP() {
Expand Down
7 changes: 4 additions & 3 deletions src/marlin_stubs/host/M46.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ void GcodeSuite::M46() {
netdev_get_ipv4_addresses(netdev_get_active_id(), &ethconfig);
uint8_t *ipp = (uint8_t *)&ethconfig.addr_ip4;
char ip4[17] = { 0 };
sprintf(ip4, "%u.%u.%u.%u\n", ipp[0], ipp[1], ipp[2], ipp[3]);
snprintf(ip4, sizeof(ip4), "%u.%u.%u.%u\n", ipp[0], ipp[1], ipp[2], ipp[3]);
serialprintPGM(ip4);

if (parser.seen('M')) {
mac_address_t mac;
char mac_buffer[19] = { 0 };
get_MAC_address(&mac, netdev_get_active_id());
serialprintPGM(mac);
snprintf(mac_buffer, sizeof(mac_buffer), "%s\n", mac);
serialprintPGM(mac_buffer);
}
}
Loading

0 comments on commit 0aebd3c

Please sign in to comment.