mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2026-01-03 05:12:36 -07:00
🎨 Standard logical FLIP(X)
This commit is contained in:
parent
cd3997f045
commit
99c3a7136d
26 changed files with 41 additions and 38 deletions
|
|
@ -80,6 +80,7 @@
|
|||
#define CBI32(n,b) (n &= ~_BV32(b))
|
||||
#define TBI32(N,B) (N ^= _BV32(B))
|
||||
|
||||
// Macros for common maths operations
|
||||
#define cu(x) ({__typeof__(x) _x = (x); (_x)*(_x)*(_x);})
|
||||
#define RADIANS(d) ((d)*float(M_PI)/180.0f)
|
||||
#define DEGREES(r) ((r)*180.0f/float(M_PI))
|
||||
|
|
@ -93,6 +94,8 @@
|
|||
#define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
|
||||
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
|
||||
|
||||
#define FLIP(X) (X = !(X))
|
||||
|
||||
// Macros to constrain values
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
|
|||
|
||||
// Get the corrected leveled / unleveled position
|
||||
planner.apply_modifiers(current_position, true); // Physical position with all modifiers
|
||||
planner.leveling_active ^= true; // Toggle leveling between apply and unapply
|
||||
FLIP(planner.leveling_active); // Toggle leveling between apply and unapply
|
||||
planner.unapply_modifiers(current_position, true); // Logical position with modifiers removed
|
||||
|
||||
sync_plan_position();
|
||||
|
|
|
|||
|
|
@ -1607,7 +1607,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||
}
|
||||
|
||||
if (abort_flag) break;
|
||||
zig_zag ^= true;
|
||||
FLIP(zig_zag);
|
||||
}
|
||||
}
|
||||
probe.stow();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
static bool enabled;
|
||||
static void enable() { enabled = true; }
|
||||
static void disable() { enabled = false; }
|
||||
static void toggle() { enabled = !enabled; }
|
||||
static void toggle() { FLIP(enabled); }
|
||||
|
||||
static uint8_t mode; // 0 = CO2 Liquid cooling, 1 = Laser Diode TEC Heatsink Cooling
|
||||
static void set_mode(const uint8_t m) { mode = m; }
|
||||
|
|
@ -96,7 +96,7 @@ public:
|
|||
#if ENABLED(FLOWMETER_SAFETY)
|
||||
static bool flowfault; // Flag that the cooler is in a fault state
|
||||
static bool flowsafety_enabled; // Flag to disable the cutter if flow rate is too low
|
||||
static void flowsafety_toggle() { flowsafety_enabled = !flowsafety_enabled; }
|
||||
static void flowsafety_toggle() { FLIP(flowsafety_enabled); }
|
||||
static bool check_flow_too_low() {
|
||||
const bool too_low = flowsafety_enabled && flowrate < (FLOWMETER_MIN_LITERS_PER_MINUTE);
|
||||
flowfault = too_low;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class FanCheck {
|
|||
static void compute_speed(uint16_t elapsedTime);
|
||||
static void print_fan_states();
|
||||
#if HAS_PWMFANCHECK
|
||||
static void toggle_measuring() { measuring = !measuring; }
|
||||
static void toggle_measuring() { FLIP(measuring); }
|
||||
static bool is_measuring() { return measuring; }
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@ void Max7219::register_setup() {
|
|||
}
|
||||
else
|
||||
sweepx -= MAX7219_X_LEDS * sweep_dir;
|
||||
patt_on ^= true;
|
||||
FLIP(patt_on);
|
||||
next_patt_ms += 100;
|
||||
if (++test_mode > 4) test_mode = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void SpoolJoin::initStatus() {
|
|||
|
||||
void SpoolJoin::toggle() {
|
||||
// Toggle enabled value.
|
||||
enabled = !enabled;
|
||||
FLIP(enabled);
|
||||
|
||||
// Following Prusa's implementation let's save the value to the EEPROM
|
||||
// TODO: Move to settings.cpp
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ G29_TYPE GcodeSuite::G29() {
|
|||
inInc = -1; // Zag left
|
||||
}
|
||||
|
||||
zig ^= true; // zag
|
||||
FLIP(zig); // zag
|
||||
|
||||
// An index to print current state
|
||||
grid_count_t pt_index = (PR_OUTER_VAR) * (PR_INNER_SIZE) + 1;
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi
|
|||
z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
||||
z_pt[uint8_t(LROUND(rad - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
||||
}
|
||||
zig_zag = !zig_zag;
|
||||
FLIP(zig_zag);
|
||||
}
|
||||
if (_7p_intermed_points)
|
||||
LOOP_CAL_RAD(rad)
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ void GcodeSuite::G34() {
|
|||
if (decreasing_accuracy(last_z_align_move[zstepper], z_align_abs)) {
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Z", zstepper + 1, " last_z_align_move = ", last_z_align_move[zstepper]);
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Z", zstepper + 1, " z_align_abs = ", z_align_abs);
|
||||
adjustment_reverse = !adjustment_reverse;
|
||||
FLIP(adjustment_reverse);
|
||||
}
|
||||
|
||||
// Remember the alignment for the next iteration, but only if steppers move,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void GcodeSuite::M303() {
|
|||
|
||||
#if HAS_PID_DEBUG
|
||||
if (parser.seen_test('D')) {
|
||||
thermalManager.pid_debug_flag ^= true;
|
||||
FLIP(thermalManager.pid_debug_flag);
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPGM("PID Debug ");
|
||||
serialprintln_onoff(thermalManager.pid_debug_flag);
|
||||
|
|
|
|||
|
|
@ -1342,7 +1342,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, probe_deployed);
|
||||
}
|
||||
else {
|
||||
probe_deployed ^= true;
|
||||
FLIP(probe_deployed);
|
||||
probe.set_deployed(probe_deployed);
|
||||
drawCheckbox(row, probe_deployed);
|
||||
}
|
||||
|
|
@ -1355,7 +1355,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, livemove);
|
||||
}
|
||||
else {
|
||||
livemove ^= true;
|
||||
FLIP(livemove);
|
||||
drawCheckbox(row, livemove);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1400,7 +1400,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, use_probe);
|
||||
}
|
||||
else {
|
||||
use_probe ^= true;
|
||||
FLIP(use_probe);
|
||||
drawCheckbox(row, use_probe);
|
||||
if (use_probe) {
|
||||
popupHandler(Popup_Level);
|
||||
|
|
@ -1616,7 +1616,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
planner.synchronize();
|
||||
redrawMenu();
|
||||
}
|
||||
liveadjust ^= true;
|
||||
FLIP(liveadjust);
|
||||
drawCheckbox(row, liveadjust);
|
||||
}
|
||||
break;
|
||||
|
|
@ -2719,7 +2719,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, eeprom_settings.time_format_textual);
|
||||
}
|
||||
else {
|
||||
eeprom_settings.time_format_textual ^= true;
|
||||
FLIP(eeprom_settings.time_format_textual);
|
||||
drawCheckbox(row, eeprom_settings.time_format_textual);
|
||||
}
|
||||
break;
|
||||
|
|
@ -2877,7 +2877,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, ui.sound_on);
|
||||
}
|
||||
else {
|
||||
ui.sound_on ^= true;
|
||||
FLIP(ui.sound_on);
|
||||
drawCheckbox(row, ui.sound_on);
|
||||
}
|
||||
break;
|
||||
|
|
@ -2960,7 +2960,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, runout.enabled);
|
||||
}
|
||||
else {
|
||||
runout.enabled ^= true;
|
||||
FLIP(runout.enabled);
|
||||
drawCheckbox(row, runout.enabled);
|
||||
}
|
||||
break;
|
||||
|
|
@ -3403,7 +3403,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, mesh_conf.viewer_print_value);
|
||||
}
|
||||
else {
|
||||
mesh_conf.viewer_print_value ^= true;
|
||||
FLIP(mesh_conf.viewer_print_value);
|
||||
drawCheckbox(row, mesh_conf.viewer_print_value);
|
||||
}
|
||||
break;
|
||||
|
|
@ -3413,7 +3413,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, mesh_conf.viewer_asymmetric_range);
|
||||
}
|
||||
else {
|
||||
mesh_conf.viewer_asymmetric_range ^= true;
|
||||
FLIP(mesh_conf.viewer_asymmetric_range);
|
||||
drawCheckbox(row, mesh_conf.viewer_asymmetric_range);
|
||||
}
|
||||
break;
|
||||
|
|
@ -3596,7 +3596,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, mesh_conf.goto_mesh_value);
|
||||
}
|
||||
else {
|
||||
mesh_conf.goto_mesh_value ^= true;
|
||||
FLIP(mesh_conf.goto_mesh_value);
|
||||
current_position.z = 0;
|
||||
mesh_conf.manual_mesh_move(true);
|
||||
drawCheckbox(row, mesh_conf.goto_mesh_value);
|
||||
|
|
@ -3957,7 +3957,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
|||
drawCheckbox(row, runout.enabled);
|
||||
}
|
||||
else {
|
||||
runout.enabled ^= true;
|
||||
FLIP(runout.enabled);
|
||||
drawCheckbox(row, runout.enabled);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1297,7 +1297,7 @@ void eachMomentUpdate() {
|
|||
|
||||
if (ELAPSED(ms, next_var_update_ms)) {
|
||||
next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL;
|
||||
blink = !blink;
|
||||
FLIP(blink);
|
||||
updateVariable();
|
||||
#if HAS_ESDIAG
|
||||
if (checkkey == ID_ESDiagProcess) esDiag.update();
|
||||
|
|
@ -2232,7 +2232,7 @@ void setMoveZ() { hmiValue.axis = Z_AXIS; setPFloatOnClick(Z_MIN_POS, Z_MAX_POS,
|
|||
#if ENABLED(BAUD_RATE_GCODE)
|
||||
void hmiSetBaudRate() { hmiData.baud115K ? setBaud115K() : setBaud250K(); }
|
||||
void setBaudRate() {
|
||||
hmiData.baud115K ^= true;
|
||||
FLIP(hmiData.baud115K);
|
||||
hmiSetBaudRate();
|
||||
drawCheckboxLine(currentMenu->line(), hmiData.baud115K);
|
||||
dwinUpdateLCD();
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ void showCheckboxLine(const bool checked) {
|
|||
}
|
||||
|
||||
void toggleCheckboxLine(bool &checked) {
|
||||
checked = !checked;
|
||||
FLIP(checked);
|
||||
showCheckboxLine(checked);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1134,7 +1134,7 @@ namespace Anycubic {
|
|||
}
|
||||
|
||||
void DgusTFT::toggle_audio() {
|
||||
lcd_info.audio_on = !lcd_info.audio_on;
|
||||
FLIP(lcd_info.audio_on);
|
||||
goto_system_page();
|
||||
lcdAudioSet(lcd_info.audio_on);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) {
|
|||
case 13: GOTO_SCREEN(BioConfirmHomeE); break;
|
||||
case 14: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break;
|
||||
case 15: GOTO_SCREEN(TemperatureScreen); break;
|
||||
case 16: fine_motion = !fine_motion; break;
|
||||
case 16: FLIP(fine_motion); break;
|
||||
default: return false;
|
||||
}
|
||||
// If a passcode is enabled, the LockScreen will prevent the
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ bool LoadChocolateScreen::onTouchEnd(uint8_t tag) {
|
|||
switch (tag) {
|
||||
case 2: mydata.repeat_tag = 5; break;
|
||||
case 3: mydata.repeat_tag = 6; break;
|
||||
case 4: mydata.repeating = !mydata.repeating; break;
|
||||
case 4: FLIP(mydata.repeating); break;
|
||||
case 1: GOTO_PREVIOUS(); break;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ bool NudgeNozzleScreen::onTouchHeld(uint8_t tag) {
|
|||
#if HAS_MULTI_EXTRUDER
|
||||
case 8: mydata.link_nozzles = !link; break;
|
||||
#endif
|
||||
case 9: mydata.show_offsets = !mydata.show_offsets; break;
|
||||
case 9: FLIP(mydata.show_offsets); break;
|
||||
case 10: GOTO_SCREEN(SaveSettingsDialogBox); break;
|
||||
default: return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ bool WidgetsScreen::onTouchStart(uint8_t tag) {
|
|||
case 5: cmd.track_linear (BTN_POS(3,4), BTN_SIZE(2,1), 5).execute(); break;
|
||||
case 6: cmd.track_linear (BTN_POS(3,5), BTN_SIZE(2,1), 6).execute(); break;
|
||||
#endif
|
||||
case 7: show_grid = !show_grid; break;
|
||||
case 7: FLIP(show_grid); break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1252,7 +1252,7 @@ void RTS::handleData() {
|
|||
setTouchScreenConfiguration();
|
||||
break;
|
||||
case 21:
|
||||
dwin_settings.display_standby ^= true;
|
||||
FLIP(dwin_settings.display_standby);
|
||||
setTouchScreenConfiguration();
|
||||
break;
|
||||
case 22:
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
|||
draw_return_ui();
|
||||
break;
|
||||
case ID_ENCODER_STATE:
|
||||
gCfgItems.encoder_enable ^= true;
|
||||
FLIP(gCfgItems.encoder_enable);
|
||||
lv_screen_menu_item_onoff_update(buttonEncoderState, gCfgItems.encoder_enable);
|
||||
update_spi_flash();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
|||
break;
|
||||
case ID_FILAMNT_TYPE:
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
uiCfg.extruderIndex = !uiCfg.extruderIndex;
|
||||
FLIP(uiCfg.extruderIndex);
|
||||
#endif
|
||||
disp_filament_type();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ void InvadersGame::game_screen() {
|
|||
|
||||
const bool did_blink = (++idat.blink_count > idat.count >> 1);
|
||||
if (did_blink) {
|
||||
idat.game_blink = !idat.game_blink;
|
||||
FLIP(idat.game_blink);
|
||||
idat.blink_count = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class MenuItem_bool : public MenuEditItemBase {
|
|||
draw(sel, row, fstr, pget());
|
||||
}
|
||||
static void action(FSTR_P const fstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr) {
|
||||
*ptr ^= true; ui.refresh();
|
||||
FLIP(*ptr); ui.refresh();
|
||||
if (callbackFunc) (*callbackFunc)();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ void menu_move() {
|
|||
|
||||
bool show_state = c.active;
|
||||
EDIT_ITEM(bool, MSG_FIXED_TIME_MOTION, &show_state, []{
|
||||
ftMotion.cfg.active ^= true;
|
||||
FLIP(ftMotion.cfg.active);
|
||||
ftMotion.update_shaping_params();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ void RTS::init() {
|
|||
inStop = -1;
|
||||
inInc = -1;
|
||||
}
|
||||
zig ^= true;
|
||||
FLIP(zig);
|
||||
for (int8_t x = inStart; x != inStop; x += inInc) {
|
||||
sendData(bedlevel.z_values[x][y] * 100, AUTO_BED_LEVEL_1POINT_VP + showcount * 2);
|
||||
showcount++;
|
||||
|
|
@ -1207,7 +1207,7 @@ void RTS::handleData() {
|
|||
inStop = -1;
|
||||
inInc = -1;
|
||||
}
|
||||
zig ^= true;
|
||||
FLIP(zig);
|
||||
for (int8_t x = inStart; x != inStop; x += inInc) {
|
||||
sendData(bedlevel.z_values[x][y] * 100, AUTO_BED_LEVEL_1POINT_VP + showcount * 2);
|
||||
showcount++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue