Skip to content

m0clockless_c.h apply_scale() is broken, always resulting in 0 value output #3504

Closed

Description

@phatpaul

FL_FORCE_INLINE fl::u8 apply_scale(fl::u8 pixel, fl::u32 scale_factor) FL_NO_EXCEPT {
fl::u32 result = (fl::u32)pixel * scale_factor;
// Extract high byte (bits 23:16) as the scaled result
return (fl::u8)(result >> 16);
}

This function always outputs 0. That caused my sketch's pixel values to be ignored and always outputs all black.

BTW, Was arm/common/m0clockless_c.h ever validated on actual hardware? It looks like this function (actually this whole file) was generated to try to match the asm version from src/platforms/arm/common/m0clockless_asm.h. Why reverse engineer the asm version to a C++ version anyway?
I spent some hours debugging this file and finding this and other bugs. Now I see there there are several other C++ implementations that are more clearly written and use common library functions:

  • src/platforms/arm/k66/clockless_arm_k66.h
  • src/platforms/arm/teensy/teensy36/clockless_arm_k66.h
  • etc.

Any reason to prefer this ASM -> generated C++ version vs. adapting something like those other versions which were at-least validated on other hardware?

Sorry, not trying to be negative, but I'm not used to working with this much AI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions