| 3179 | } |
| 3180 | |
| 3181 | void MarlinSettings::load_mesh(const int8_t slot, void * const into/*=nullptr*/) { |
| 3182 | |
| 3183 | #if ENABLED(AUTO_BED_LEVELING_UBL) |
| 3184 | |
| 3185 | const int16_t a = settings.calc_num_meshes(); |
| 3186 | |
| 3187 | if (!WITHIN(slot, 0, a - 1)) { |
| 3188 | ubl_invalid_slot(a); |
| 3189 | return; |
| 3190 | } |
| 3191 | |
| 3192 | int pos = mesh_slot_offset(slot); |
| 3193 | uint16_t crc = 0; |
| 3194 | #if ENABLED(OPTIMIZED_MESH_STORAGE) |
| 3195 | int16_t z_mesh_store[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; |
| 3196 | uint8_t * const dest = (uint8_t*)&z_mesh_store; |
| 3197 | #else |
| 3198 | uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&bedlevel.z_values; |
| 3199 | #endif |
| 3200 | |
| 3201 | persistentStore.access_start(); |
| 3202 | uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); |
| 3203 | persistentStore.access_finish(); |
| 3204 | |
| 3205 | #if ENABLED(OPTIMIZED_MESH_STORAGE) |
| 3206 | if (into) { |
| 3207 | float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; |
| 3208 | bedlevel.set_mesh_from_store(z_mesh_store, z_values); |
| 3209 | memcpy(into, z_values, sizeof(z_values)); |
| 3210 | } |
| 3211 | else |
| 3212 | bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values); |
| 3213 | #endif |
| 3214 | |
| 3215 | #if ENABLED(DWIN_LCD_PROUI) |
| 3216 | status = !bedLevelTools.meshValidate(); |
| 3217 | if (status) { |
| 3218 | bedlevel.invalidate(); |
| 3219 | LCD_MESSAGE(MSG_UBL_MESH_INVALID); |
| 3220 | } |
| 3221 | else |
| 3222 | ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); |
| 3223 | #endif |
| 3224 | |
| 3225 | if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); |
| 3226 | else DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot); |
| 3227 | |
| 3228 | EEPROM_FINISH(); |
| 3229 | |
| 3230 | #else |
| 3231 | |
| 3232 | // Other mesh types |
| 3233 | |
| 3234 | #endif |
| 3235 | } |
| 3236 | |
| 3237 | //void MarlinSettings::delete_mesh() { return; } |
| 3238 | //void MarlinSettings::defrag_meshes() { return; } |
no test coverage detected