From e8b7dff62defdeecdd29eab2c7683d1e0c70ded0 Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Tue, 25 Feb 2025 14:53:49 -0500 Subject: [PATCH] fix more errors, update comment syntax / spacing --- Marlin/src/core/types.h | 2 +- Marlin/src/sd/Sd2Card.cpp | 2 +- Marlin/src/sd/SdBaseFile.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 5 ++- Marlin/src/sd/cardreader.h | 3 +- .../lib-uhs3/UHS_host/UHS_host_INLINE.h | 13 +++--- buildroot/share/fonts/buildhzk.py | 40 +++++++++++-------- 7 files changed, 38 insertions(+), 29 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 68adadc95d..14b3776cdc 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -225,7 +225,7 @@ struct Flags { // Flag bits for more than 64 states template struct Flags { - uint8_t bitmask[(N+7)>>3]; + uint8_t bitmask[(N + 7) >> 3]; // Proxy class for handling bit assignment class BitProxy { public: diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index 25fc35e6ab..e36395ca91 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -97,7 +97,7 @@ static uint8_t CRC7(const uint8_t *data, uint8_t n) { uint8_t crc = 0; while (n > 0) { - crc = pgm_read_byte(&crctab7[ (crc << 1) ^ *data++ ]); + crc = pgm_read_byte(&crctab7[(crc << 1) ^ *data++ ]); n--; } return (crc << 1) | 1; diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 3963043ca6..27437355ba 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -643,9 +643,9 @@ bool SdBaseFile::open(SdBaseFile * const dirFile, const uint8_t dname[11] emptyIndex = 0, reqEntriesNum = useLFN ? getLFNEntriesNum((char*)dlname) + 1 : 1, lfnNameLength = useLFN ? strlen((char*)dlname) : 0, - lfnName[LONG_FILENAME_LENGTH], lfnSequenceNumber = 0, lfnChecksum = 0; + uint8_t lfnName[LONG_FILENAME_LENGTH]; #endif // Rewind this dir diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 68b5846c2f..a20635feff 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -87,7 +87,8 @@ IF_DISABLED(NO_SD_AUTOSTART, uint8_t CardReader::autofile_index); // = 0 // private: -MediaFile CardReader::root, CardReader::workDir, CardReader::workDirParents[MAX_DIR_DEPTH]; +MediaFile CardReader::root, CardReader::workDir; +MediaFile CardReader::workDirParents[MAX_DIR_DEPTH]; uint8_t CardReader::workDirDepth; int16_t CardReader::nrItems = -1; @@ -123,7 +124,7 @@ int16_t CardReader::nrItems = -1; #if ENABLED(SDSORT_DYNAMIC_RAM) uint8_t *CardReader::isDir; #elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK) - uint8_t CardReader::isDir[(SDSORT_LIMIT+7)>>3]; + uint8_t CardReader::isDir[(SDSORT_LIMIT + 7) >> 3]; #endif #define IS_DIR(n) TEST(isDir[(n) >> 3], (n) & 0x07) #endif diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index eeead4e490..e00b2cdaed 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -271,7 +271,8 @@ private: // // Working directory and parents // - static MediaFile root, workDir, workDirParents[MAX_DIR_DEPTH]; + static MediaFile root, workDir; + static MediaFile workDirParents[MAX_DIR_DEPTH]; static uint8_t workDirDepth; static int16_t nrItems; // Cache the total count diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h index d87b40fea2..a75eb77761 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h @@ -160,7 +160,7 @@ uint8_t UHS_USB_HOST_BASE::doSoftReset(uint8_t parent, uint8_t port, uint8_t add return rcode; } -/* +/** * Pseudo code so you may understand the code flow. * * reset; (happens at the lower level) @@ -168,7 +168,7 @@ uint8_t UHS_USB_HOST_BASE::doSoftReset(uint8_t parent, uint8_t port, uint8_t add * reset; * If there are no configuration descriptors { * // - * // Note: I know of no device that does this. + * // NOTE: I know of no device that does this. * // I suppose there could be one though. * // * try to enumerate. @@ -1003,7 +1003,7 @@ uint8_t UHS_USB_HOST_BASE::ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbyt rcode = ctrlReqRead(pep, &left, &read, nbytes, dataptr); #if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE - HOST_DEBUG("RESULT: 0x%2.2x 0x%2.2x 0x%2.2x 0x%8.8lx%8.8lx\r\n", rcode, addr, read, (uint32_t)((Request>>32)&0xFFFFFFFFLU), (uint32_t)(Request&0xFFFFFFFFLU)); + HOST_DEBUG("RESULT: 0x%2.2x 0x%2.2x 0x%2.2x 0x%8.8lx%8.8lx\r\n", rcode, addr, read, (uint32_t)((Request >> 32) & 0xFFFFFFFFLU), (uint32_t)(Request & 0xFFFFFFFFLU)); // Should only be used for GET_DESCRIPTOR USB_DESCRIPTOR_DEVICE constexpr uint32_t req_match = ((uint32_t)USB_DESCRIPTOR_DEVICE << 24) | ((uint32_t)USB_REQUEST_GET_DESCRIPTOR << 8); @@ -1167,10 +1167,11 @@ uint8_t UHS_NI UHS_VSI::SetInterface(ENUMERATION_INFO *ei) { #if 0 -/* TO-DO: Move this silliness to a NONE driver. +/** + * TODO: Move this silliness to a NONE driver. * When we have a generic NONE driver we can: - * o Extract ALL device information to help users with a new device. - * o Use an unknown device from a sketch, kind of like usblib does. + * - Extract ALL device information to help users with a new device. + * - Use an unknown device from a sketch, kind of like usblib does. * This will aid in making more drivers in a faster way. */ uint8_t UHS_USB_HOST_BASE::DefaultAddressing(uint8_t parent, uint8_t port, uint8_t speed) { diff --git a/buildroot/share/fonts/buildhzk.py b/buildroot/share/fonts/buildhzk.py index 2b59980f66..dc4707b59c 100644 --- a/buildroot/share/fonts/buildhzk.py +++ b/buildroot/share/fonts/buildhzk.py @@ -18,7 +18,7 @@ def glyph_bits(size_x, size_y, font, glyph_ord): v = row rpad = size_x - glyph.bbW if rpad < 0: rpad = 0 - if glyph.bbW > size_x: v = v >> (glyph.bbW - size_x) # some glyphs are actually too wide to fit! + if glyph.bbW > size_x: v = v >> (glyph.bbW - size_x) # some glyphs are actually too wide to fit! v = v << (glyph_bytes * 8) - size_x + rpad v = v >> glyph.bbX bits[y + desc + glyph.bbY] |= v @@ -30,23 +30,28 @@ def glyph_bits(size_x, size_y, font, glyph_ord): def marlin_font_hzk(): fonts = [ - [6,12,'marlin-6x12-3.bdf'], - [8,16,'marlin-8x16.bdf'], - [10,20,'marlin-10x20.bdf'], - [12,24,'marlin-12x24.bdf'], - [14,28,'marlin-14x28.bdf'], - [16,32,'marlin-16x32.bdf'], - [20,40,'marlin-20x40.bdf'], - [24,48,'marlin-24x48.bdf'], - [28,56,'marlin-28x56.bdf'], - [32,64,'marlin-32x64.bdf'] + [ 6, 12, 'marlin-6x12-3.bdf'], + [ 8, 16, 'marlin-8x16.bdf'], + [10, 20, 'marlin-10x20.bdf'], + [12, 24, 'marlin-12x24.bdf'], + [14, 28, 'marlin-14x28.bdf'], + [16, 32, 'marlin-16x32.bdf'], + [20, 40, 'marlin-20x40.bdf'], + [24, 48, 'marlin-24x48.bdf'], + [28, 56, 'marlin-28x56.bdf'], + [32, 64, 'marlin-32x64.bdf'] ] - with open('marlin_fixed.hzk','wb') as output: + with open('marlin_fixed.hzk', 'wb') as output: for f in fonts: with open(f[2], 'rb') as file: - print(f'{f[0]}x{f[1]}') + print(f"{f[0]}x{f[1]}") font = bdflib.reader.read_bdf(file) + + if font is None: + print(f"Failed to read font from {f[2]}") + continue # Skip this font and move to the next one + for glyph in range(128): bits = glyph_bits(f[0], f[1], font, glyph) glyph_bytes = math.ceil(f[0]/8) @@ -56,8 +61,9 @@ def marlin_font_hzk(): z = b.to_bytes(glyph_bytes, 'big') output.write(z) except OverflowError: - print('Overflow') - print(f'{glyph}') - print(font[glyph]) - for b in bits: print(f'{b:0{f[0]}b}') + print("Overflow") + print(f"{glyph}") + if font and glyph in font: print(font[glyph]) + else: print(f"Glyph {glyph} not found in the font or font is None") + for b in bits: print(f"{b:0{f[0]}b}") return