Browse Source

🎨 Misc. shorthand operators

Scott Lahteine 3 years ago
parent
commit
76d784f75f

+ 1
- 1
Marlin/src/HAL/DUE/usb/compiler.h View File

@@ -1059,7 +1059,7 @@ static inline void convert_64_bit_to_byte_array(uint64_t value, uint8_t *data)
1059 1059
     while (val_index < 8)
1060 1060
     {
1061 1061
         data[val_index++] = value & 0xFF;
1062
-        value = value >> 8;
1062
+        value >>= 8;
1063 1063
     }
1064 1064
 }
1065 1065
 

+ 8
- 8
Marlin/src/HAL/LINUX/eeprom.cpp View File

@@ -69,12 +69,12 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
69 69
   std::size_t bytes_written = 0;
70 70
 
71 71
   for (std::size_t i = 0; i < size; i++) {
72
-    buffer[pos+i] = value[i];
73
-    bytes_written ++;
72
+    buffer[pos + i] = value[i];
73
+    bytes_written++;
74 74
   }
75 75
 
76 76
   crc16(crc, value, size);
77
-  pos = pos + size;
77
+  pos += size;
78 78
   return (bytes_written != size);  // return true for any error
79 79
 }
80 80
 
@@ -82,21 +82,21 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uin
82 82
   std::size_t bytes_read = 0;
83 83
   if (writing) {
84 84
     for (std::size_t i = 0; i < size; i++) {
85
-      value[i] = buffer[pos+i];
86
-      bytes_read ++;
85
+      value[i] = buffer[pos + i];
86
+      bytes_read++;
87 87
     }
88 88
     crc16(crc, value, size);
89 89
   }
90 90
   else {
91 91
     uint8_t temp[size];
92 92
     for (std::size_t i = 0; i < size; i++) {
93
-      temp[i] = buffer[pos+i];
94
-      bytes_read ++;
93
+      temp[i] = buffer[pos + i];
94
+      bytes_read++;
95 95
     }
96 96
     crc16(crc, temp, size);
97 97
   }
98 98
 
99
-  pos = pos + size;
99
+  pos += size;
100 100
   return bytes_read != size;  // return true for any error
101 101
 }
102 102
 

+ 2
- 2
Marlin/src/HAL/LINUX/hardware/Heater.h View File

@@ -26,8 +26,8 @@
26 26
 struct LowpassFilter {
27 27
   uint64_t data_delay = 0;
28 28
   uint16_t update(uint16_t value) {
29
-    data_delay = data_delay - (data_delay >> 6) + value;
30
-    return (uint16_t)(data_delay >> 6);
29
+    data_delay += value - (data_delay >> 6);
30
+    return uint16_t(data_delay >> 6);
31 31
   }
32 32
 };
33 33
 

+ 2
- 2
Marlin/src/HAL/shared/backtrace/unwarmbytab.cpp View File

@@ -135,11 +135,11 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
135 135
   while ((instruction = UnwTabGetNextInstruction(cb, ucb)) != -1) {
136 136
 
137 137
     if ((instruction & 0xC0) == 0x00) { // ARM_EXIDX_CMD_DATA_POP
138
-      /* vsp = vsp + (xxxxxx << 2) + 4 */
138
+      /* vsp += (xxxxxx << 2) + 4 */
139 139
       ucb->vrs[13] += ((instruction & 0x3F) << 2) + 4;
140 140
     }
141 141
     else if ((instruction & 0xC0) == 0x40) { // ARM_EXIDX_CMD_DATA_PUSH
142
-      /* vsp = vsp - (xxxxxx << 2) - 4 */
142
+      /* vsp -= (xxxxxx << 2) - 4 */
143 143
       ucb->vrs[13] -= ((instruction & 0x3F) << 2) - 4;
144 144
     }
145 145
     else if ((instruction & 0xF0) == 0x80) {

+ 1
- 1
Marlin/src/feature/power_monitor.h View File

@@ -32,7 +32,7 @@ struct pm_lpf_t {
32 32
   uint32_t filter_buf;
33 33
   float value;
34 34
   void add_sample(const uint16_t sample) {
35
-    filter_buf = filter_buf - (filter_buf >> K_VALUE) + (uint32_t(sample) << K_SCALE);
35
+    filter_buf += (uint32_t(sample) << K_SCALE) - (filter_buf >> K_VALUE);
36 36
   }
37 37
   void capture() {
38 38
     value = filter_buf * (SCALE * (1.0f / (1UL << (PM_K_VALUE + PM_K_SCALE))));

+ 2
- 2
Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp View File

@@ -1141,7 +1141,7 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr)
1141 1141
         else
1142 1142
           queue.inject(F("M290 Z-0.01"));
1143 1143
 
1144
-        z_offset_add = z_offset_add - ZOffset_distance;
1144
+        z_offset_add -= ZOffset_distance;
1145 1145
         break;
1146 1146
 
1147 1147
       case 1:
@@ -1156,7 +1156,7 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr)
1156 1156
         else
1157 1157
           queue.inject(F("M290 Z-0.01"));
1158 1158
 
1159
-        z_offset_add = z_offset_add + ZOffset_distance;
1159
+        z_offset_add += ZOffset_distance;
1160 1160
         break;
1161 1161
 
1162 1162
       default:

+ 1
- 1
Marlin/src/lcd/extui/mks_ui/wifi_module.cpp View File

@@ -1638,7 +1638,7 @@ void esp_data_parser(char *cmdRxBuf, int len) {
1638 1638
 
1639 1639
       esp_msg_index += cpyLen;
1640 1640
 
1641
-      leftLen = leftLen - cpyLen;
1641
+      leftLen -= cpyLen;
1642 1642
       tail_pos = charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL);
1643 1643
 
1644 1644
       if (tail_pos == -1) {

+ 1
- 1
Marlin/src/lcd/tft/touch.cpp View File

@@ -175,7 +175,7 @@ void Touch::touch(touch_control_t *control) {
175 175
       ui.refresh();
176 176
       break;
177 177
     case PAGE_DOWN:
178
-      encoderTopLine = encoderTopLine + 2 * LCD_HEIGHT < screen_items ? encoderTopLine + LCD_HEIGHT : screen_items - LCD_HEIGHT;
178
+      encoderTopLine = (encoderTopLine + 2 * LCD_HEIGHT < screen_items) ? encoderTopLine + LCD_HEIGHT : screen_items - LCD_HEIGHT;
179 179
       ui.encoderPosition = ui.encoderPosition + LCD_HEIGHT < (uint32_t)screen_items ? ui.encoderPosition + LCD_HEIGHT : screen_items;
180 180
       ui.refresh();
181 181
       break;

Loading…
Cancel
Save